Line data Source code
1 : #ifndef _GNU_SOURCE /* GCC seems to do this this is on the command line somehow when using g++ */
2 : #define _GNU_SOURCE
3 : #endif
4 :
5 : #include <ctype.h>
6 : #include <errno.h>
7 : #include <pthread.h>
8 : #include <unistd.h>
9 : #include <sched.h>
10 : #include <syscall.h>
11 : #include <sys/resource.h>
12 : #include <sys/mman.h>
13 : #include <sys/prctl.h>
14 :
15 : #include "../sanitize/fd_sanitize.h"
16 : #include "fd_tile_private.h"
17 :
18 : /* Operating system shims ********************************************/
19 :
20 : struct fd_tile_private_cpu_config {
21 : int prio;
22 : };
23 :
24 : typedef struct fd_tile_private_cpu_config fd_tile_private_cpu_config_t;
25 :
26 : /* Configure the CPU optimally */
27 :
28 : static inline void
29 : fd_tile_private_cpu_config( fd_tile_private_cpu_config_t * save,
30 2561 : ulong cpu_idx ) {
31 :
32 : /* If a floating tile, leave scheduler priority unchanged from however
33 : the thread group launcher configured it. */
34 :
35 2561 : if( cpu_idx==65535UL ) {
36 2414 : save->prio = INT_MIN;
37 2414 : return;
38 2414 : }
39 :
40 : /* Otherwise, configure high scheduler priority */
41 :
42 2561 : errno = 0;
43 147 : int prio = getpriority( PRIO_PROCESS, (id_t)0 );
44 147 : if( prio==-1 && errno ) {
45 0 : FD_LOG_WARNING(( "fd_tile: getpriority failed (%i-%s)\n\t"
46 0 : "Unable to determine initial tile priority so not configuring the tile\n\t"
47 0 : "for high scheduler priority. Attempting to continue but this thread\n\t"
48 0 : "group's performance and stability might be compromised. Probably should\n\t"
49 0 : "configure 'ulimit -e 39' (or 40 and this might require adjusting\n\t"
50 0 : "/etc/security/limits.conf as superuser to nice -19 or -20 for this user)\n\t"
51 0 : "to eliminate this warning. Also consider starting this thread group\n\t"
52 0 : "with 'nice --19'.",
53 0 : errno, fd_io_strerror( errno ) ));
54 0 : save->prio = INT_MIN;
55 0 : }
56 :
57 147 : if( FD_UNLIKELY( prio!=-19 ) && FD_UNLIKELY( setpriority( PRIO_PROCESS, (id_t)0, -19 ) ) ) {
58 0 : FD_LOG_WARNING(( "fd_tile: setpriority failed (%i-%s)\n\t"
59 0 : "Unable to configure this tile for high scheduler priority. Attempting\n\t"
60 0 : "to continue but this thread group's performance and stability might be\n\t"
61 0 : "compromised. Probably should configure 'ulimit -e 39' (or 40 and this\n\t"
62 0 : "might require adjusting /etc/security/limits.conf to nice -19 or -20\n\t"
63 0 : "for this user) to eliminate this warning. Also consider starting this\n\t"
64 0 : "thread group with 'nice --19'.",
65 0 : errno, fd_io_strerror( errno ) ));
66 0 : save->prio = INT_MIN;
67 0 : return;
68 0 : }
69 :
70 147 : save->prio = prio;
71 147 : }
72 :
73 : /* Restore the CPU to the given state */
74 :
75 : static inline void
76 1382 : fd_tile_private_cpu_restore( fd_tile_private_cpu_config_t * save ) {
77 1382 : int prio = save->prio;
78 1382 : if( FD_LIKELY( prio!=INT_MIN ) && FD_UNLIKELY( prio!=-19 ) && FD_UNLIKELY( setpriority( PRIO_PROCESS, (id_t)0, prio ) ) )
79 0 : FD_LOG_WARNING(( "fd_tile: setpriority failed (%i-%s); attempting to continue", errno, fd_io_strerror( errno ) ));
80 1382 : }
81 :
82 : void *
83 : fd_tile_private_stack_new( int optimize,
84 36 : ulong cpu_idx ) { /* Ignored if optimize is not requested */
85 :
86 36 : uchar * stack = NULL;
87 :
88 36 : if( optimize ) { /* Create a NUMA and TLB optimized stack for a tile running on cpu cpu_idx */
89 :
90 36 : stack = (uchar *)
91 36 : fd_shmem_acquire( FD_SHMEM_HUGE_PAGE_SZ, (FD_TILE_PRIVATE_STACK_SZ/FD_SHMEM_HUGE_PAGE_SZ)+2UL, cpu_idx ); /* logs details */
92 :
93 36 : if( FD_LIKELY( stack ) ) { /* Make space for guard lo and guard hi */
94 :
95 36 : fd_shmem_release( stack, FD_SHMEM_HUGE_PAGE_SZ, 1UL );
96 :
97 36 : stack += FD_SHMEM_HUGE_PAGE_SZ;
98 :
99 36 : fd_shmem_release( stack + FD_TILE_PRIVATE_STACK_SZ, FD_SHMEM_HUGE_PAGE_SZ, 1UL );
100 :
101 36 : } else {
102 :
103 0 : ulong numa_idx = fd_shmem_numa_idx( cpu_idx );
104 0 : static ulong warn = 0UL;
105 0 : if( FD_LIKELY( !(warn & (1UL<<numa_idx) ) ) ) {
106 0 : FD_LOG_WARNING(( "fd_tile: fd_shmem_acquire failed\n\t"
107 0 : "There are probably not enough huge pages allocated by the OS on numa\n\t"
108 0 : "node %lu. Falling back on normal page backed stack for tile on cpu %lu\n\t"
109 0 : "and attempting to continue. Run:\n\t"
110 0 : "\techo [CNT] > /sys/devices/system/node/node%lu/hugepages/hugepages-2048kB/nr_hugepages\n\t"
111 0 : "(probably as superuser) or equivalent where [CNT] is a sufficient number\n\t"
112 0 : "huge pages to reserve on this numa node system wide and/or adjust\n\t"
113 0 : "/etc/security/limits.conf to permit this user to lock a sufficient\n\t"
114 0 : "amount of memory to eliminate this warning.",
115 0 : numa_idx, cpu_idx, numa_idx ));
116 0 : warn |= 1UL<<numa_idx;
117 0 : }
118 :
119 0 : }
120 :
121 36 : }
122 :
123 36 : if( !stack ) { /* Request for a non-optimized stack (or optimized stack creation failed above and we are falling back) */
124 :
125 0 : ulong mmap_sz = FD_TILE_PRIVATE_STACK_SZ + 2UL*FD_SHMEM_NORMAL_PAGE_SZ;
126 0 : stack = (uchar *)mmap( NULL, mmap_sz, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, (off_t)0 );
127 :
128 0 : if( FD_LIKELY( ((void *)stack)!=MAP_FAILED ) ) { /* Make space for guard lo and guard hi */
129 :
130 0 : if( FD_UNLIKELY( munmap( stack, FD_SHMEM_NORMAL_PAGE_SZ ) ) )
131 0 : FD_LOG_WARNING(( "fd_tile: munmap failed (%i-%s); attempting to continue", errno, fd_io_strerror( errno ) ));
132 :
133 0 : stack += FD_SHMEM_NORMAL_PAGE_SZ;
134 :
135 0 : if( FD_UNLIKELY( munmap( stack + FD_TILE_PRIVATE_STACK_SZ, FD_SHMEM_NORMAL_PAGE_SZ ) ) )
136 0 : FD_LOG_WARNING(( "fd_tile: munmap failed (%i-%s); attempting to continue", errno, fd_io_strerror( errno ) ));
137 :
138 0 : } else {
139 :
140 0 : FD_LOG_WARNING(( "fd_tile: mmap(NULL,%lu KiB,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANONYMOUS,-1,0) failed (%i-%s)\n\t"
141 0 : "Falling back on pthreads created stack and attempting to continue.",
142 0 : mmap_sz >> 10, errno, fd_io_strerror( errno ) ));
143 0 : return NULL;
144 :
145 0 : }
146 :
147 0 : }
148 :
149 : /* Create the guard regions in the extra space */
150 :
151 36 : void * guard_lo = (void *)(stack - FD_SHMEM_NORMAL_PAGE_SZ );
152 36 : if( FD_UNLIKELY( mmap( guard_lo, FD_SHMEM_NORMAL_PAGE_SZ, PROT_NONE,
153 36 : MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, (off_t)0 )!=guard_lo ) )
154 0 : FD_LOG_WARNING(( "fd_tile: mmap failed (%i-%s)\n\tAttempting to continue without stack guard lo.",
155 36 : errno, fd_io_strerror( errno ) ));
156 :
157 36 : void * guard_hi = (void *)(stack + FD_TILE_PRIVATE_STACK_SZ);
158 36 : if( FD_UNLIKELY( mmap( guard_hi, FD_SHMEM_NORMAL_PAGE_SZ, PROT_NONE,
159 36 : MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, (off_t)0 )!=guard_hi ) )
160 0 : FD_LOG_WARNING(( "fd_tile: mmap failed (%i-%s)\n\tAttempting to continue without stack guard hi.",
161 36 : errno, fd_io_strerror( errno ) ));
162 :
163 36 : return stack;
164 36 : }
165 :
166 : static void
167 36 : fd_tile_private_stack_delete( void * _stack ) {
168 36 : if( FD_UNLIKELY( !_stack ) ) return;
169 :
170 36 : uchar * stack = (uchar *)_stack;
171 36 : uchar * guard_lo = stack - FD_SHMEM_NORMAL_PAGE_SZ;
172 36 : uchar * guard_hi = stack + FD_TILE_PRIVATE_STACK_SZ;
173 :
174 36 : if( FD_UNLIKELY( munmap( guard_hi, FD_SHMEM_NORMAL_PAGE_SZ ) ) )
175 0 : FD_LOG_WARNING(( "fd_tile: munmap failed (%i-%s); attempting to continue", errno, fd_io_strerror( errno ) ));
176 :
177 36 : if( FD_UNLIKELY( munmap( guard_lo, FD_SHMEM_NORMAL_PAGE_SZ ) ) )
178 0 : FD_LOG_WARNING(( "fd_tile: munmap failed (%i-%s); attempting to continue", errno, fd_io_strerror( errno ) ));
179 :
180 : /* Note that fd_shmem_release is just a wrapper around munmap such
181 : that this covers both the optimized and non-optimized cases */
182 :
183 36 : if( FD_UNLIKELY( munmap( stack, FD_TILE_PRIVATE_STACK_SZ ) ) )
184 0 : FD_LOG_WARNING(( "fd_tile: munmap failed (%i-%s); attempting to continue", errno, fd_io_strerror( errno ) ));
185 36 : }
186 :
187 : /* Tile side APIs ****************************************************/
188 :
189 : static ulong fd_tile_private_id0; /* Zeroed at app start, initialized by the boot manager */
190 : static ulong fd_tile_private_id1; /* " */
191 : static ulong fd_tile_private_cnt; /* " */
192 :
193 78 : ulong fd_tile_id0( void ) { return fd_tile_private_id0; }
194 36 : ulong fd_tile_id1( void ) { return fd_tile_private_id1; }
195 234 : ulong fd_tile_cnt( void ) { return fd_tile_private_cnt; }
196 :
197 : static FD_TL ulong fd_tile_private_id; /* Zeroed at app/thread start, initialized by the boot / tile manager */
198 : static FD_TL ulong fd_tile_private_idx; /* " */
199 : /**/ FD_TL ulong fd_tile_private_stack0; /* " */
200 : /**/ FD_TL ulong fd_tile_private_stack1; /* " */
201 :
202 54 : ulong fd_tile_id ( void ) { return fd_tile_private_id; }
203 639 : ulong fd_tile_idx( void ) { return fd_tile_private_idx; }
204 :
205 : static ushort fd_tile_private_cpu_id[ FD_TILE_MAX ]; /* Zeroed at app start, initialized by boot */
206 :
207 : ulong
208 78 : fd_tile_cpu_id( ulong tile_idx ) {
209 78 : if( FD_UNLIKELY( tile_idx>=fd_tile_private_cnt ) ) return ULONG_MAX;
210 78 : ulong cpu_idx = (ulong)fd_tile_private_cpu_id[ tile_idx ];
211 78 : return fd_ulong_if( cpu_idx<65535UL, cpu_idx, ULONG_MAX-1UL );
212 78 : }
213 :
214 : /* This is used for the OS services to communicate information with the
215 : tile managers */
216 :
217 5 : #define FD_TILE_PRIVATE_STATE_BOOT (0) /* Tile is booting */
218 189 : #define FD_TILE_PRIVATE_STATE_IDLE (1) /* Tile is idle */
219 105 : #define FD_TILE_PRIVATE_STATE_EXEC (2) /* Tile is executing a task */
220 36 : #define FD_TILE_PRIVATE_STATE_HALT (3) /* Tile is halting */
221 :
222 : struct __attribute__((aligned(128))) fd_tile_private { /* Double cache line aligned to avoid aclpf false sharing */
223 : ulong id;
224 : ulong idx;
225 : int state; /* FD_TILE_PRIVATE_STATE_* */
226 : int argc;
227 : char ** argv;
228 : fd_tile_task_t task;
229 : char const * fail;
230 : int ret;
231 : };
232 :
233 : typedef struct fd_tile_private fd_tile_private_t;
234 :
235 : struct fd_tile_private_manager_args {
236 : ulong id;
237 : ulong idx;
238 : ulong cpu_idx;
239 : void * stack; /* NULL if pthread created, non-NULL if user created */
240 : ulong stack_sz;
241 : fd_tile_private_t * tile;
242 : };
243 :
244 : typedef struct fd_tile_private_manager_args fd_tile_private_manager_args_t;
245 :
246 : static void *
247 36 : fd_tile_private_manager( void * _args ) {
248 36 : fd_tile_private_manager_args_t * args = (fd_tile_private_manager_args_t *)_args;
249 :
250 : # if !__GLIBC__
251 : if( args->cpu_idx<65535UL ) {
252 : FD_CPUSET_DECL( cpu_set );
253 : fd_cpuset_insert( cpu_set, args->cpu_idx );
254 : int err = fd_cpuset_setaffinity( (pid_t)0, cpu_set );
255 : if( FD_UNLIKELY( err ) )
256 : FD_LOG_WARNING(( "fd_tile: fd_cpuset_setaffinity_failed (%i-%s)\n\t"
257 : "Unable to set the thread affinity for tile %lu to cpu %lu. Attempting to\n\t"
258 : "continue without explicitly specifying this tile's cpu affinity but it\n\t"
259 : "is likely this thread group's performance and stability are compromised\n\t"
260 : "(possibly catastrophically so). Update --tile-cpus to specify a set of\n\t"
261 : "allowed cpus that have been reserved for this thread group on this host\n\t"
262 : "to eliminate this warning.", err, fd_io_strerror( err ), args->idx, args->cpu_idx ));
263 : }
264 : # endif /* !__GLIBC__ */
265 :
266 36 : ulong id = args->id;
267 36 : ulong idx = args->idx;
268 36 : void * stack = args->stack;
269 36 : ulong stack_sz = args->stack_sz;
270 :
271 36 : char thread_name[ 20 ];
272 36 : FD_TEST( fd_cstr_printf_check( thread_name, sizeof( thread_name ), NULL, "tile:%lu", idx ) );
273 36 : if( FD_UNLIKELY( prctl( PR_SET_NAME, thread_name, 0, 0, 0 ) ) ) FD_LOG_ERR(( "prctl(PR_SET_NAME) failed (%i-%s)", errno, fd_io_strerror( errno ) ));
274 :
275 36 : if( FD_UNLIKELY( !( (id ==fd_log_thread_id() ) &
276 36 : (idx==(id-fd_tile_private_id0) ) &
277 36 : ((fd_tile_private_id0<id) & (id<fd_tile_private_id1) ) &
278 36 : (fd_tile_private_cnt==(fd_tile_private_id1-fd_tile_private_id0)) ) ) )
279 0 : FD_LOG_ERR(( "fd_tile: internal error (unexpected thread identifiers)" ));
280 :
281 36 : fd_tile_private_t tile[1];
282 36 : FD_VOLATILE( tile->id ) = id;
283 36 : FD_VOLATILE( tile->idx ) = idx;
284 36 : FD_VOLATILE( tile->state ) = FD_TILE_PRIVATE_STATE_BOOT;
285 36 : FD_VOLATILE( tile->argc ) = 0;
286 36 : FD_VOLATILE( tile->argv ) = NULL;
287 36 : FD_VOLATILE( tile->task ) = NULL;
288 36 : FD_VOLATILE( tile->fail ) = NULL;
289 36 : FD_VOLATILE( tile->ret ) = 0;
290 :
291 : /* state is BOOT ... configure the tile, transition to IDLE and then
292 : start polling for tasks */
293 :
294 36 : fd_tile_private_id = id;
295 36 : fd_tile_private_idx = idx;
296 :
297 36 : if( FD_LIKELY( stack ) ) { /* User provided stack */
298 36 : fd_tile_private_stack0 = (ulong)stack;
299 36 : fd_tile_private_stack1 = (ulong)stack + stack_sz;
300 :
301 : /* Prevent another fork() from smashing the stack */
302 36 : if( FD_UNLIKELY( madvise( stack, FD_TILE_PRIVATE_STACK_SZ, MADV_DONTFORK ) ) ) {
303 0 : FD_LOG_ERR(( "madvise(stack,MADV_DONTFORK) failed (%i-%s)", errno, fd_io_strerror( errno ) ));
304 0 : }
305 :
306 36 : } else { /* Pthread provided stack */
307 0 : fd_log_private_stack_discover( stack_sz, &fd_tile_private_stack0, &fd_tile_private_stack1 ); /* logs details */
308 0 : if( FD_UNLIKELY( !fd_tile_private_stack0 ) )
309 0 : FD_LOG_WARNING(( "stack diagnostics not available on this tile; attempting to continue" ));
310 0 : }
311 :
312 36 : fd_tile_private_cpu_config_t dummy[1];
313 36 : fd_tile_private_cpu_config( dummy, args->cpu_idx );
314 :
315 36 : ulong app_id = fd_log_app_id();
316 36 : FD_LOG_INFO(( "fd_tile: boot tile %lu success (thread %lu:%lu in thread group %lu:%lu/%lu)",
317 36 : idx, app_id, id, app_id, fd_tile_private_id0, fd_tile_private_cnt ));
318 :
319 36 : FD_COMPILER_MFENCE();
320 36 : FD_VOLATILE( tile->state ) = FD_TILE_PRIVATE_STATE_IDLE;
321 36 : FD_VOLATILE( args->tile ) = tile;
322 :
323 282622579 : for(;;) {
324 :
325 : /* We are awake ... see what we should do next */
326 :
327 282622579 : int state = FD_VOLATILE_CONST( tile->state );
328 282622579 : if( FD_UNLIKELY( state!=FD_TILE_PRIVATE_STATE_EXEC ) ) {
329 117227076 : if( FD_UNLIKELY( state!=FD_TILE_PRIVATE_STATE_IDLE ) ) break;
330 : /* state is IDLE ... try again */
331 117227043 : FD_SPIN_PAUSE();
332 117227043 : continue;
333 117227076 : }
334 :
335 : /* state is EXEC ... the run assigned task and then
336 : transition to IDLE when done */
337 : /* FIXME: MORE SOPHISTICATED HANDLING OF EXCEPTIONS */
338 :
339 165395503 : int argc = FD_VOLATILE_CONST( tile->argc );
340 165395503 : char ** argv = FD_VOLATILE_CONST( tile->argv );
341 165395503 : fd_tile_task_t task = FD_VOLATILE_CONST( tile->task );
342 165395503 : try {
343 165395503 : FD_VOLATILE( tile->ret ) = task( argc, argv );
344 165395503 : FD_VOLATILE( tile->fail ) = NULL;
345 165395503 : } catch( ... ) {
346 0 : FD_VOLATILE( tile->fail ) = "uncaught exception";
347 0 : }
348 :
349 165395503 : FD_COMPILER_MFENCE();
350 105 : FD_VOLATILE( tile->state ) = FD_TILE_PRIVATE_STATE_IDLE;
351 105 : }
352 :
353 : /* state is HALT, clean up and then reset back to BOOT */
354 :
355 5 : FD_LOG_INFO(( "fd_tile: halting tile %lu", idx ));
356 :
357 5 : FD_COMPILER_MFENCE();
358 5 : FD_VOLATILE( tile->state ) = FD_TILE_PRIVATE_STATE_BOOT;
359 5 : return stack;
360 36 : }
361 :
362 : /* Dispatch side APIs ************************************************/
363 :
364 : static struct __attribute__((aligned(128))) { /* Each on its own cache line pair to limit false sharing in parallel dispatch */
365 : fd_tile_private_t * lock; /* Non-NULL if tile idx is available for dispatch, ==tile otherwise */
366 : fd_tile_private_t * tile;
367 : pthread_t pthread;
368 : } fd_tile_private[ FD_TILE_MAX ];
369 :
370 : /* FIXME: ATOMIC_XCHG BASED INSTEAD? */
371 : static inline fd_tile_private_t *
372 108 : fd_tile_private_trylock( ulong tile_idx ) {
373 108 : fd_tile_private_t * volatile * vtile = (fd_tile_private_t * volatile *)&fd_tile_private[ tile_idx ].lock;
374 108 : fd_tile_private_t * tile = *vtile;
375 108 : if( FD_LIKELY( tile ) && FD_LIKELY( FD_ATOMIC_CAS( vtile, tile, NULL )==tile ) ) return tile;
376 3 : return NULL;
377 108 : }
378 :
379 : static inline fd_tile_private_t *
380 36 : fd_tile_private_lock( ulong tile_idx ) {
381 36 : fd_tile_private_t * volatile * vtile = (fd_tile_private_t * volatile *)&fd_tile_private[ tile_idx ].lock;
382 36 : fd_tile_private_t * tile;
383 36 : for(;;) {
384 36 : tile = *vtile;
385 36 : if( FD_LIKELY( tile ) && FD_LIKELY( FD_ATOMIC_CAS( vtile, tile, NULL )==tile ) ) break;
386 0 : FD_SPIN_PAUSE();
387 0 : }
388 36 : return tile;
389 36 : }
390 :
391 : static inline void
392 : fd_tile_private_unlock( ulong tile_idx,
393 141 : fd_tile_private_t * tile ) {
394 141 : FD_VOLATILE( fd_tile_private[ tile_idx ].lock ) = tile;
395 141 : }
396 :
397 : fd_tile_exec_t *
398 : fd_tile_exec_new( ulong idx,
399 : fd_tile_task_t task,
400 : int argc,
401 141 : char ** argv ) {
402 141 : if( FD_UNLIKELY( (idx==fd_tile_private_idx) | (!idx) ) ) return NULL; /* Can't dispatch to self or to tile 0 */
403 :
404 108 : fd_tile_private_t * tile = fd_tile_private_trylock( idx );
405 108 : if( FD_UNLIKELY( !tile ) ) return NULL;
406 :
407 : /* Exec holds the lock and tile state is idle here */
408 105 : FD_VOLATILE( tile->argc ) = argc;
409 105 : FD_VOLATILE( tile->argv ) = argv;
410 105 : FD_VOLATILE( tile->task ) = task;
411 105 : FD_COMPILER_MFENCE();
412 105 : FD_VOLATILE( tile->state ) = FD_TILE_PRIVATE_STATE_EXEC;
413 105 : return (fd_tile_exec_t *)tile;
414 108 : }
415 :
416 : char const *
417 : fd_tile_exec_delete( fd_tile_exec_t * exec,
418 105 : int * opt_ret ) {
419 105 : fd_tile_private_t * tile = (fd_tile_private_t *)exec;
420 105 : ulong tile_idx = tile->idx;
421 :
422 105 : int state;
423 1371609 : for(;;) {
424 1371609 : state = FD_VOLATILE_CONST( tile->state );
425 1371609 : if( FD_LIKELY( state==FD_TILE_PRIVATE_STATE_IDLE ) ) break;
426 1371504 : FD_SPIN_PAUSE();
427 1371504 : }
428 : /* state is IDLE at this point */
429 105 : char const * fail = FD_VOLATILE_CONST( tile->fail );
430 105 : if( FD_LIKELY( (!fail) & (!!opt_ret) ) ) *opt_ret = FD_VOLATILE_CONST( tile->ret );
431 105 : fd_tile_private_unlock( tile_idx, tile );
432 105 : return fail;
433 105 : }
434 :
435 108 : fd_tile_exec_t * fd_tile_exec( ulong tile_idx ) { return (fd_tile_exec_t *)fd_tile_private[ tile_idx ].tile; }
436 :
437 0 : ulong fd_tile_exec_id ( fd_tile_exec_t const * exec ) { return ((fd_tile_private_t const *)exec)->id; }
438 12 : ulong fd_tile_exec_idx ( fd_tile_exec_t const * exec ) { return ((fd_tile_private_t const *)exec)->idx; }
439 12 : fd_tile_task_t fd_tile_exec_task( fd_tile_exec_t const * exec ) { return ((fd_tile_private_t const *)exec)->task; }
440 12 : int fd_tile_exec_argc( fd_tile_exec_t const * exec ) { return ((fd_tile_private_t const *)exec)->argc; }
441 12 : char ** fd_tile_exec_argv( fd_tile_exec_t const * exec ) { return ((fd_tile_private_t const *)exec)->argv; }
442 :
443 : int
444 12 : fd_tile_exec_done( fd_tile_exec_t const * exec ) {
445 12 : fd_tile_private_t const * tile = (fd_tile_private_t const *)exec;
446 12 : return FD_VOLATILE_CONST( tile->state )==FD_TILE_PRIVATE_STATE_IDLE;
447 12 : }
448 :
449 : /* Boot/halt APIs ****************************************************/
450 :
451 : /* Parse a list of cpu tiles */
452 :
453 : FD_STATIC_ASSERT( FD_TILE_MAX<65535, update_tile_to_cpu_type );
454 :
455 : ulong
456 : fd_tile_private_cpus_parse( char const * cstr,
457 2525 : ushort * tile_to_cpu ) {
458 2525 : if( !cstr ) return 0UL;
459 111 : ulong cnt = 0UL;
460 :
461 111 : FD_CPUSET_DECL( assigned_set );
462 :
463 111 : char const * p = cstr;
464 225 : for(;;) {
465 :
466 225 : while( fd_isspace( (int)p[0] ) ) p++; /* Munch whitespace */
467 :
468 225 : if( p[0]=='f' ) { /* These tiles have been requested to float on the original core set */
469 0 : p++;
470 :
471 0 : ulong float_cnt;
472 :
473 0 : while( fd_isspace( (int)p[0] ) ) p++; /* Munch whitespace */
474 0 : if ( p[0]==',' ) float_cnt = 1UL, p++;
475 0 : else if( p[0]=='\0' ) float_cnt = 1UL;
476 0 : else if( !fd_isdigit( (int)p[0] ) ) FD_LOG_ERR(( "fd_tile: malformed --tile-cpus (malformed count)" ));
477 0 : else {
478 0 : float_cnt = fd_cstr_to_ulong( p );
479 0 : if( FD_UNLIKELY( !float_cnt ) ) FD_LOG_ERR(( "fd_tile: malformed --tile-cpus (bad count)" ));
480 0 : p++; while( fd_isdigit( (int)p[0] ) ) p++; /* FIXME: USE STRTOUL ENDPTR FOR CORRECT HANDLING OF NON-BASE-10 */
481 0 : while( fd_isspace( (int)p[0] ) ) p++; /* Munch whitespace */
482 0 : if( FD_UNLIKELY( !( p[0]==',' || p[0]=='\0' ) ) ) FD_LOG_ERR(( "fd_tile: malformed --tile-cpus (bad count delimiter)" ));
483 0 : if( p[0]==',' ) p++;
484 0 : }
485 :
486 : /* float_cnt is at least 1 at this point */
487 0 : do {
488 0 : if( FD_UNLIKELY( cnt>=FD_TILE_MAX ) ) FD_LOG_ERR(( "fd_tile: too many --tile-cpus" ));
489 0 : tile_to_cpu[ cnt++ ] = (ushort)65535;
490 0 : } while( --float_cnt );
491 :
492 0 : continue;
493 0 : }
494 :
495 225 : if( !fd_isdigit( (int)p[0] ) ) {
496 111 : if( FD_UNLIKELY( p[0]!='\0' ) ) FD_LOG_ERR(( "fd_tile: malformed --tile-cpus (range lo not a cpu)" ));
497 111 : break;
498 111 : }
499 114 : ulong cpu0 = fd_cstr_to_ulong( p );
500 114 : ulong cpu1 = cpu0;
501 114 : ulong stride = 1UL;
502 156 : p++; while( fd_isdigit( (int)p[0] ) ) p++; /* FIXME: USE STRTOUL ENDPTR FOR CORRECT HANDLING OF NON-BASE-10 */
503 114 : while( fd_isspace( (int)p[0] ) ) p++;
504 114 : if( p[0]=='-' ) {
505 6 : p++;
506 6 : while( fd_isspace( (int)p[0] ) ) p++;
507 6 : if( FD_UNLIKELY( !fd_isdigit( (int)p[0] ) ) ) FD_LOG_ERR(( "fd_tile: malformed --tile-cpus (range hi not a cpu)" ));
508 6 : cpu1 = fd_cstr_to_ulong( p );
509 6 : p++; while( fd_isdigit( (int)p[0] ) ) p++; /* FIXME: USE STRTOUL ENDPTR FOR CORRECT HANDLING OF NON-BASE-10 */
510 6 : while( fd_isspace( (int)p[0] ) ) p++;
511 6 : if( p[0]=='/' || p[0]==':' ) {
512 3 : p++;
513 3 : while( fd_isspace( (int)p[0] ) ) p++;
514 3 : if( FD_UNLIKELY( !fd_isdigit( (int)p[0] ) ) ) FD_LOG_ERR(( "fd_tile: malformed --tile-cpus (stride not an int)" ));
515 3 : stride = fd_cstr_to_ulong( p );
516 3 : p++; while( fd_isdigit( (int)p[0] ) ) p++; /* FIXME: USE STRTOUL ENDPTR FOR CORRECT HANDLING OF NON-BASE-10 */
517 3 : }
518 6 : }
519 108 : else if( p[0]=='h' ) {
520 : /* `Nh` is a shorthand for "core N and its hyperthread sibling".
521 : If M is the sibling id and S = N-M, it translates as "N,M" or
522 : equivalently "N-M/S", i.e. a range from N to M with stride S.
523 : If core N doesn't have a sibling, the `h` suffix is ignored.
524 : This way an expression like "0h" also works on systems where
525 : hyperthread is not available. */
526 0 : p++;
527 0 : ulong sibling = fd_tile_private_sibling_idx( cpu0 );
528 0 : cpu1 = fd_ulong_if( sibling==ULONG_MAX, cpu0, sibling );
529 0 : stride = fd_ulong_if( sibling==ULONG_MAX, 1, sibling-cpu0 );
530 0 : }
531 114 : while( fd_isspace( (int)p[0] ) ) p++;
532 114 : if( FD_UNLIKELY( !( p[0]==',' || p[0]=='\0' ) ) ) FD_LOG_ERR(( "fd_tile: malformed --tile-cpus (bad range delimiter)" ));
533 114 : if( p[0]==',' ) p++;
534 114 : cpu1++;
535 114 : if( FD_UNLIKELY( cpu1<=cpu0 ) ) FD_LOG_ERR(( "fd_tile: malformed --tile-cpus (invalid range)" ));
536 114 : if( FD_UNLIKELY( !stride ) ) FD_LOG_ERR(( "fd_tile: malformed --tile-cpus (invalid stride)" ));
537 :
538 261 : for( ulong cpu=cpu0; cpu<cpu1; cpu+=stride ) {
539 147 : if( FD_UNLIKELY( cnt>=FD_TILE_MAX ) ) FD_LOG_ERR(( "fd_tile: too many --tile-cpus" ));
540 147 : if( FD_UNLIKELY( fd_cpuset_test( assigned_set, cpu ) ) ) FD_LOG_ERR(( "fd_tile: malformed --tile-cpus (repeated cpu)" ));
541 147 : tile_to_cpu[ cnt++ ] = (ushort)cpu;
542 147 : fd_cpuset_insert( assigned_set, cpu );
543 147 : }
544 114 : }
545 :
546 111 : return cnt;
547 111 : }
548 :
549 : static fd_tile_private_cpu_config_t fd_tile_private_cpu_config_save[1];
550 :
551 : void
552 : fd_tile_private_map_boot( ushort * tile_to_cpu,
553 2525 : ulong tile_cnt ) {
554 2525 : fd_tile_private_id0 = fd_log_thread_id();
555 2525 : fd_tile_private_id1 = fd_tile_private_id0 + tile_cnt;
556 2525 : fd_tile_private_cnt = tile_cnt;
557 :
558 2525 : ulong app_id = fd_log_app_id();
559 2525 : ulong host_id = fd_log_host_id();
560 2525 : FD_LOG_INFO(( "fd_tile: booting thread group %lu:%lu/%lu", app_id, fd_tile_private_id0, fd_tile_private_cnt ));
561 :
562 : /* We create the tiles [1,tile_cnt) first so that any floating tiles
563 : in this inherit the appropriate scheduler priorities and affinities
564 : from the thread group launcher. */
565 :
566 2561 : for( ulong tile_idx=1UL; tile_idx<tile_cnt; tile_idx++ ) {
567 :
568 36 : ulong cpu_idx = (ulong)tile_to_cpu[ tile_idx ];
569 36 : int fixed = (cpu_idx<65535UL);
570 :
571 36 : if( fixed ) FD_LOG_INFO(( "fd tile: booting tile %lu on cpu %lu:%lu", tile_idx, host_id, cpu_idx ));
572 0 : else FD_LOG_INFO(( "fd tile: booting tile %lu on cpu %lu:float", tile_idx, host_id ));
573 :
574 36 : pthread_attr_t attr[1];
575 36 : int err = pthread_attr_init( attr );
576 36 : if( FD_UNLIKELY( err ) ) FD_LOG_ERR(( "fd_tile: pthread_attr_init failed (%i-%s) for tile %lu.\n\t",
577 36 : err, fd_io_strerror( err ), tile_idx ));
578 :
579 : /* Set affinity ahead of time. This is a GNU-specific extension
580 : that is not available on musl. On musl, we just skip this
581 : step as we call sched_setaffinity(2) later on regardless. */
582 :
583 36 : # if __GLIBC__
584 36 : if( fixed ) {
585 36 : FD_CPUSET_DECL( cpu_set );
586 36 : fd_cpuset_insert( cpu_set, cpu_idx );
587 36 : err = pthread_attr_setaffinity_np( attr, fd_cpuset_footprint(), (cpu_set_t const *)fd_type_pun_const( cpu_set ) );
588 36 : if( FD_UNLIKELY( err ) ) FD_LOG_WARNING(( "fd_tile: pthread_attr_setaffinity_failed (%i-%s)\n\t"
589 36 : "Unable to set the thread affinity for tile %lu on cpu %lu. Attempting to\n\t"
590 36 : "continue without explicitly specifying this cpu's thread affinity but it\n\t"
591 36 : "is likely this thread group's performance and stability are compromised\n\t"
592 36 : "(possibly catastrophically so). Update --tile-cpus to specify a set of\n\t"
593 36 : "allowed cpus that have been reserved for this thread group on this host\n\t"
594 36 : "to eliminate this warning.",
595 36 : err, fd_io_strerror( err ), tile_idx, cpu_idx ));
596 36 : }
597 36 : # endif /* __GLIBC__ */
598 :
599 : /* Create an optimized stack with guard regions if the build target
600 : is x86 (e.g. supports huge pages necessary to optimize TLB usage)
601 : and the tile is assigned to a particular CPU (e.g. bind the stack
602 : memory to the NUMA node closest to the cpu).
603 :
604 : Otherwise (or if an optimized stack could not be created), create
605 : vanilla pthread-style stack with guard regions. We DIY here
606 : because pthreads seems to be missing an API to determine the
607 : extents of the stacks it creates and we need to know the stack
608 : extents for run-time stack diagnostics. Though we can use
609 : fd_log_private_stack_discover to determine stack extents after
610 : the thread is started, it is faster, more flexible, more reliable
611 : and more portable to use a user specified stack when possible.
612 :
613 : If neither can be done, we will let pthreads create the tile's
614 : stack and try to discover the stack extents after the thread is
615 : started. */
616 :
617 36 : int optimize = FD_HAS_X86 & fixed;
618 :
619 36 : void * stack = fd_tile_private_stack_new( optimize, cpu_idx );
620 36 : if( FD_LIKELY( stack ) ) {
621 36 : err = pthread_attr_setstack( attr, stack, FD_TILE_PRIVATE_STACK_SZ );
622 36 : if( FD_UNLIKELY( err ) ) {
623 0 : FD_LOG_WARNING(( "fd_tile: pthread_attr_setstack failed (%i-%s)\n\t", err, fd_io_strerror( err ) ));
624 0 : fd_tile_private_stack_delete( stack );
625 0 : stack = NULL;
626 0 : }
627 36 : }
628 :
629 36 : if( FD_UNLIKELY( !stack ) ) FD_LOG_WARNING(( "fd_tile: Unable to create a stack for tile %lu.\n\t"
630 36 : "Attempting to continue with the default stack but it is likely this\n\t"
631 36 : "thread group's performance and stability is compromised (possibly\n\t"
632 36 : "catastrophically so).",
633 36 : tile_idx ));
634 :
635 36 : ulong stack_sz;
636 36 : err = pthread_attr_getstacksize( attr, &stack_sz );
637 36 : if( FD_UNLIKELY( err ) ) FD_LOG_ERR(( "fd_tile: pthread_attr_getstacksize failed (%i-%s) for tile %lu.\n\t",
638 36 : err, fd_io_strerror( err ), tile_idx ));
639 :
640 36 : FD_VOLATILE( fd_tile_private[ tile_idx ].lock ) = NULL;
641 :
642 36 : fd_tile_private_manager_args_t args[1];
643 :
644 36 : FD_VOLATILE( args->id ) = fd_tile_private_id0 + tile_idx;
645 36 : FD_VOLATILE( args->idx ) = tile_idx;
646 36 : FD_VOLATILE( args->cpu_idx ) = cpu_idx;
647 36 : FD_VOLATILE( args->stack ) = stack;
648 36 : FD_VOLATILE( args->stack_sz ) = stack_sz;
649 36 : FD_VOLATILE( args->tile ) = NULL;
650 :
651 36 : FD_COMPILER_MFENCE();
652 :
653 36 : err = pthread_create( &fd_tile_private[tile_idx].pthread, attr, fd_tile_private_manager, args );
654 36 : if( FD_UNLIKELY( err ) ) {
655 0 : if( fixed ) FD_LOG_ERR(( "fd_tile: pthread_create failed (%i-%s)\n\t"
656 0 : "Unable to start up the tile %lu on cpu %lu. Likely causes for this include\n\t"
657 0 : "this cpu is restricted from the user or does not exist on this host.\n\t"
658 0 : "Update --tile-cpus to specify a set of allowed cpus that have been reserved\n\t"
659 0 : "for this thread group on this host.",
660 0 : err, fd_io_strerror( err ), tile_idx, cpu_idx ));
661 0 : FD_LOG_ERR(( "fd_tile: pthread_create failed (%i-%s)\n\tUnable to start up the tile %lu (floating).",
662 0 : err, fd_io_strerror( err ), tile_idx ));
663 0 : }
664 :
665 : /* Wait for the tile to be ready to exec */
666 :
667 36 : fd_tile_private_t * tile;
668 7705 : for(;;) {
669 7705 : tile = FD_VOLATILE_CONST( args->tile );
670 7705 : if( FD_LIKELY( tile ) ) break;
671 7669 : FD_YIELD();
672 7669 : }
673 36 : FD_VOLATILE( fd_tile_private[ tile_idx ].tile ) = tile;
674 36 : FD_VOLATILE( fd_tile_private[ tile_idx ].lock ) = tile;
675 :
676 : /* Tile is running, args is safe to reuse */
677 :
678 36 : err = pthread_attr_destroy( attr );
679 36 : if( FD_UNLIKELY( err ) )
680 0 : FD_LOG_WARNING(( "fd_tile: pthread_attr_destroy failed (%i-%s) for tile %lu; attempting to continue",
681 36 : err, fd_io_strerror( err ), tile_idx ));
682 36 : }
683 :
684 : /* And now we "boot" tile 0 */
685 :
686 2525 : ulong cpu_idx = (ulong)tile_to_cpu[ 0UL ];
687 2525 : int fixed = (cpu_idx<65535UL);
688 2525 : if( fixed ) FD_LOG_INFO(( "fd tile: booting tile %lu on cpu %lu:%lu", 0UL, host_id, cpu_idx ));
689 2414 : else FD_LOG_INFO(( "fd tile: booting tile %lu on cpu %lu:float", 0UL, host_id ));
690 :
691 2525 : if( fixed ) {
692 :
693 111 : int good_taskset;
694 111 : FD_CPUSET_DECL( cpu_set );
695 111 : if( FD_UNLIKELY( fd_cpuset_getaffinity( (pid_t)0, cpu_set ) ) ) {
696 0 : FD_LOG_WARNING(( "fd_tile: fd_cpuset_getaffinity failed (%i-%s) for tile 0 on cpu %lu",
697 0 : errno, fd_io_strerror( errno ), cpu_idx ));
698 0 : good_taskset = 0;
699 111 : } else {
700 111 : ulong cnt = fd_cpuset_cnt( cpu_set );
701 111 : ulong idx = fd_cpuset_first( cpu_set );
702 111 : good_taskset = (cnt==1UL) & (idx==cpu_idx);
703 111 : }
704 :
705 111 : if( FD_UNLIKELY( !good_taskset ) ) {
706 9 : FD_LOG_WARNING(( "fd_tile: --tile-cpus for tile 0 may not match initial kernel affinity\n\t"
707 9 : "Tile 0 might not be fully optimized because of kernel first touch.\n\t"
708 9 : "Overriding fd_log_cpu_id(), fd_log_cpu(), fd_log_thread() on tile 0 to\n\t"
709 9 : "match --tile-cpus and attempting to continue. Launch this thread\n\t"
710 9 : "group via 'taskset -c %lu' or equivalent to eliminate this warning.", cpu_idx ));
711 9 : fd_cpuset_null( cpu_set );
712 9 : fd_cpuset_insert( cpu_set, cpu_idx );
713 9 : if( FD_UNLIKELY( fd_cpuset_setaffinity( (pid_t)0, cpu_set ) ) )
714 0 : FD_LOG_WARNING(( "fd_tile: fd_cpuset_setaffinity_failed (%i-%s)\n\t"
715 9 : "Unable to set the thread affinity for tile 0 on cpu %lu. Attempting to\n\t"
716 9 : "continue without explicitly specifying this cpu's thread affinity but it\n\t"
717 9 : "is likely this thread group's performance and stability are compromised\n\t"
718 9 : "(possibly catastrophically so). Update --tile-cpus to specify a set of\n\t"
719 9 : "allowed cpus that have been reserved for this thread group on this host\n\t"
720 9 : "to eliminate this warning.",
721 9 : errno, fd_io_strerror( errno ), cpu_idx ));
722 9 : fd_log_private_cpu_id_set( cpu_idx );
723 9 : fd_log_cpu_set ( NULL );
724 9 : fd_log_thread_set( NULL );
725 9 : }
726 111 : }
727 :
728 : /* Tile 0 "pthread_create" */
729 2525 : fd_tile_private[0].pthread = pthread_self();
730 : /* FIXME: ON X86, DETECT IF TILE 0 STACK ISN'T HUGE PAGE AND WARN AS NECESSARY? */
731 :
732 : /* Tile 0 "thread manager init" */
733 2525 : fd_tile_private_id = fd_tile_private_id0;
734 2525 : fd_tile_private_idx = 0UL;
735 :
736 2525 : # if !FD_HAS_ASAN
737 2525 : fd_log_private_stack_discover( fd_log_private_main_stack_sz(),
738 2525 : &fd_tile_private_stack0, &fd_tile_private_stack1 ); /* logs details */
739 2525 : if( FD_UNLIKELY( !fd_tile_private_stack0 ) )
740 0 : FD_LOG_WARNING(( "stack diagnostics not available on this tile; attempting to continue" ));
741 2525 : # endif /* FD_HAS_ASAN */
742 :
743 2525 : fd_tile_private_cpu_config( fd_tile_private_cpu_config_save, cpu_idx );
744 2525 : fd_tile_private[0].lock = NULL; /* Can't dispatch to tile 0 */
745 2525 : fd_tile_private[0].tile = NULL; /* " */
746 :
747 2525 : FD_LOG_INFO(( "fd_tile: boot tile %lu success (thread %lu:%lu in thread group %lu:%lu/%lu)",
748 2525 : fd_tile_private_idx, app_id, fd_tile_private_id, app_id, fd_tile_private_id0, fd_tile_private_cnt ));
749 :
750 2525 : fd_memcpy( fd_tile_private_cpu_id, tile_to_cpu, fd_tile_private_cnt*sizeof(ushort) );
751 :
752 2525 : FD_LOG_INFO(( "fd_tile: boot success" ));
753 2525 : }
754 :
755 : void
756 2525 : fd_tile_private_boot_str( char const * cpus ) {
757 2525 : ushort tile_to_cpu[ FD_TILE_MAX ];
758 2525 : ulong tile_cnt = fd_tile_private_cpus_parse( cpus, tile_to_cpu );
759 :
760 2525 : if( FD_UNLIKELY( !tile_cnt ) ) {
761 2414 : FD_LOG_INFO(( "fd_tile: no cpus specified; treating thread group as single tile running on O/S assigned cpu(s)" ));
762 2414 : tile_to_cpu[0] = (ushort)65535;
763 2414 : tile_cnt = 1UL;
764 2414 : }
765 :
766 2525 : fd_tile_private_map_boot( tile_to_cpu, tile_cnt );
767 2525 : }
768 :
769 : void
770 : fd_tile_private_boot( int * pargc,
771 2525 : char *** pargv ) {
772 : /* Extract the tile configuration from the command line */
773 :
774 2525 : char const * cpus = fd_env_strip_cmdline_cstr( pargc, pargv, "--tile-cpus", "FD_TILE_CPUS", NULL );
775 :
776 2525 : if( !cpus ) FD_LOG_INFO(( "fd_tile: --tile-cpus not specified" ));
777 111 : else FD_LOG_INFO(( "fd_tile: --tile-cpus \"%s\"", cpus ));
778 :
779 2525 : fd_tile_private_boot_str( cpus );
780 2525 : }
781 :
782 : void
783 1382 : fd_tile_private_halt( void ) {
784 1382 : FD_LOG_INFO(( "fd_tile: halt" ));
785 :
786 1382 : fd_memset( fd_tile_private_cpu_id, 0, fd_tile_private_cnt*sizeof(ushort) );
787 :
788 1382 : ulong tile_cnt = fd_tile_private_cnt;
789 :
790 1382 : fd_tile_private_t * tile[ FD_TILE_MAX ]; /* FIXME: ALLOCA TO TILE_CNT? */
791 :
792 1382 : FD_LOG_INFO(( "fd_tile: disabling dispatch" ));
793 1418 : for( ulong tile_idx=1UL; tile_idx<tile_cnt; tile_idx++ ) tile[ tile_idx ] = fd_tile_private_lock( tile_idx );
794 : /* All tile to tile dispatches will fail at this point */
795 :
796 1382 : FD_LOG_INFO(( "fd_tile: waiting for all tasks to complete" ));
797 1418 : for( ulong tile_idx=1UL; tile_idx<tile_cnt; tile_idx++ )
798 36 : while( FD_VOLATILE_CONST( tile[ tile_idx ]->state )!=FD_TILE_PRIVATE_STATE_IDLE ) FD_YIELD();
799 : /* All halt transitions will be valid at this point */
800 :
801 1382 : FD_LOG_INFO(( "fd_tile: signaling all tiles to halt" ));
802 1418 : for( ulong tile_idx=1UL; tile_idx<tile_cnt; tile_idx++ ) FD_VOLATILE( tile[ tile_idx ]->state ) = FD_TILE_PRIVATE_STATE_HALT;
803 : /* All tiles are halting at this point. tile[*] is no longer safe */
804 :
805 1382 : FD_LOG_INFO(( "fd_tile: waiting for all tiles to halt" ));
806 1418 : for( ulong tile_idx=1UL; tile_idx<tile_cnt; tile_idx++ ) {
807 36 : void * stack;
808 36 : int err = pthread_join( fd_tile_private[ tile_idx ].pthread, &stack );
809 36 : if( FD_UNLIKELY( err ) ) FD_LOG_ERR(( "fd_tile: pthread_join failed (%i-%s)", err, fd_io_strerror( err ) ));
810 36 : fd_tile_private_stack_delete( stack );
811 36 : FD_LOG_INFO(( "fd_tile: halt tile %lu success", tile_idx ));
812 36 : }
813 :
814 : /* All tiles but this one are halted at this point */
815 :
816 1382 : fd_tile_private_cpu_restore( fd_tile_private_cpu_config_save );
817 :
818 1382 : FD_LOG_INFO(( "fd_tile: halt tile 0 success" ));
819 :
820 1382 : FD_LOG_INFO(( "fd_tile: cleaning up" ));
821 :
822 1418 : for( ulong tile_idx=1UL; tile_idx<tile_cnt; tile_idx++ ) fd_tile_private_unlock( tile_idx, NULL );
823 :
824 1382 : fd_memset( fd_tile_private_cpu_config_save, 0, sizeof(fd_tile_private_cpu_config_t) );
825 :
826 1382 : fd_tile_private_stack1 = 0UL;
827 1382 : fd_tile_private_stack0 = 0UL;
828 1382 : fd_tile_private_idx = 0UL;
829 1382 : fd_tile_private_id = 0UL;
830 :
831 1382 : fd_tile_private_cnt = 0UL;
832 1382 : fd_tile_private_id1 = 0UL;
833 1382 : fd_tile_private_id0 = 0UL;
834 :
835 1382 : FD_LOG_INFO(( "fd_tile: halt success" ));
836 1382 : }
|