Line data Source code
1 : #ifndef HEADER_fd_src_disco_topo_fd_topo_h
2 : #define HEADER_fd_src_disco_topo_fd_topo_h
3 :
4 : #include "../stem/fd_stem.h"
5 : #include "../../tango/fd_tango.h"
6 : #include "../../waltz/xdp/fd_xdp1.h"
7 : #include "../../ballet/base58/fd_base58.h"
8 : #include "../../util/net/fd_net_headers.h"
9 :
10 : /* Maximum number of workspaces that may be present in a topology. */
11 : #define FD_TOPO_MAX_WKSPS (256UL)
12 : /* Maximum number of links that may be present in a topology. */
13 : #define FD_TOPO_MAX_LINKS (256UL)
14 : /* Maximum number of tiles that may be present in a topology. */
15 0 : #define FD_TOPO_MAX_TILES (256UL)
16 : /* Maximum number of objects that may be present in a topology. */
17 : #define FD_TOPO_MAX_OBJS (4096UL)
18 : /* Maximum number of links that may go into any one tile in the
19 : topology. */
20 : #define FD_TOPO_MAX_TILE_IN_LINKS ( 128UL)
21 : /* Maximum number of links that a tile may write to. */
22 : #define FD_TOPO_MAX_TILE_OUT_LINKS ( 32UL)
23 : /* Maximum number of objects that a tile can use. */
24 : #define FD_TOPO_MAX_TILE_OBJS ( 256UL)
25 :
26 : /* Maximum number of additional ip addresses */
27 : #define FD_NET_MAX_SRC_ADDR 4
28 :
29 : /* Maximum number of additional destinations for leader shreds and for retransmitted shreds */
30 : #define FD_TOPO_ADTL_DESTS_MAX ( 32UL)
31 :
32 0 : #define FD_TOPO_CORE_DUMP_LEVEL_DISABLED (0)
33 0 : #define FD_TOPO_CORE_DUMP_LEVEL_MINIMAL (1)
34 6 : #define FD_TOPO_CORE_DUMP_LEVEL_REGULAR (2)
35 0 : #define FD_TOPO_CORE_DUMP_LEVEL_FULL (3)
36 0 : #define FD_TOPO_CORE_DUMP_LEVEL_NEVER (4)
37 :
38 : /* A workspace is a Firedancer specific memory management structure that
39 : sits on top of 1 or more memory mapped gigantic or huge pages mounted
40 : to the hugetlbfs. */
41 : typedef struct {
42 : ulong id; /* The ID of this workspace. Indexed from [0, wksp_cnt). When placed in a topology, the ID must be the index of the workspace in the workspaces list. */
43 : char name[ 14UL ]; /* The name of this workspace, like "pack". There can be at most one of each workspace name in a topology. */
44 :
45 : ulong numa_idx; /* The index of the NUMA node on the system that this workspace should be allocated from. */
46 :
47 : ulong min_part_max; /* Artificially raise part_max */
48 : ulong min_loose_sz; /* Artificially raise loose footprint */
49 :
50 : /* Computed fields. These are not supplied as configuration but calculated as needed. */
51 : struct {
52 : ulong page_sz; /* The size of the pages that this workspace is backed by. One of FD_PAGE_SIZE_*. */
53 : ulong page_cnt; /* The number of pages that must be mapped to this workspace to store all the data needed by consumers. */
54 : ulong part_max; /* The maximum number of partitions in the underlying workspace. There can only be this many allocations made at any one time. */
55 :
56 : int core_dump_level; /* The core dump level required to be set in the application configuration to have this workspace appear in core dumps. */
57 :
58 : fd_wksp_t * wksp; /* The workspace memory in the local process. */
59 : ulong known_footprint; /* Total size in bytes of all data in Firedancer that will be stored in this workspace at startup. */
60 : ulong total_footprint; /* Total size in bytes of all data in Firedancer that could be stored in this workspace, includes known data and loose data. */
61 : };
62 : } fd_topo_wksp_t;
63 :
64 : /* A link is an mcache in a workspace that has one producer and one or
65 : more consumers. A link may optionally also have a dcache, that holds
66 : fragments referred to by the mcache entries.
67 :
68 : A link belongs to exactly one workspace. A link has exactly one
69 : producer, and 1 or more consumers. Each consumer is either reliable
70 : or not reliable. A link has a depth and a MTU, which correspond to
71 : the depth and MTU of the mcache and dcache respectively. A MTU of
72 : zero means no dcache is needed, as there is no data. */
73 : typedef struct {
74 : ulong id; /* The ID of this link. Indexed from [0, link_cnt). When placed in a topology, the ID must be the index of the link in the links list. */
75 : char name[ 14UL ]; /* The name of this link, like "pack_execle". There can be multiple of each link name in a topology. */
76 : ulong kind_id; /* The ID of this link within its name. If there are N links of a particular name, they have IDs [0, N). The pair (name, kind_id) uniquely identifies a link, as does "id" on its own. */
77 :
78 : ulong depth; /* The depth of the mcache representing the link. */
79 : ulong mtu; /* The MTU of data fragments in the mcache. A value of 0 means there is no dcache. */
80 : ulong burst; /* The max amount of MTU sized data fragments that might be bursted to the dcache. */
81 :
82 : ulong mcache_obj_id;
83 : ulong dcache_obj_id;
84 :
85 : /* Computed fields. These are not supplied as configuration but calculated as needed. */
86 : struct {
87 : fd_frag_meta_t * mcache; /* The mcache of this link. */
88 : void * dcache; /* The dcache of this link, if it has one. */
89 : };
90 :
91 : uint permit_no_consumers : 1; /* Permit a topology where this link has no consumers */
92 : uint permit_no_producers : 1; /* Permit a topology where this link has no producers */
93 : } fd_topo_link_t;
94 :
95 : /* Be careful: ip and host are in different byte order */
96 : typedef struct {
97 : uint ip; /* in network byte order */
98 : ushort port; /* in host byte order */
99 : } fd_topo_ip_port_t;
100 :
101 : struct fd_topo_net_tile {
102 : ulong umem_dcache_obj_id; /* dcache for XDP UMEM frames */
103 : uint bind_address;
104 :
105 : ushort shred_listen_port;
106 : ushort quic_transaction_listen_port;
107 : ushort legacy_transaction_listen_port;
108 : ushort gossip_listen_port;
109 : ushort repair_intake_listen_port;
110 : ushort repair_serve_listen_port;
111 : ushort txsend_src_port;
112 : };
113 : typedef struct fd_topo_net_tile fd_topo_net_tile_t;
114 :
115 : /* A tile is a unique process that is spawned by Firedancer to represent
116 : one thread of execution. Firedancer sandboxes all tiles to their own
117 : process for security reasons.
118 :
119 : A tile belongs to exactly one workspace. A tile is a consumer of 0
120 : or more links, it's inputs. A tile is a producer of 0 or more output
121 : links.
122 :
123 : All input links will be automatically polled by the tile
124 : infrastructure, and output links will automatically source and manage
125 : credits from consumers. */
126 : struct fd_topo_tile {
127 : ulong id; /* The ID of this tile. Indexed from [0, tile_cnt). When placed in a topology, the ID must be the index of the tile in the tiles list. */
128 : char name[ 7UL ]; /* The name of this tile. There can be multiple of each tile name in a topology. */
129 : ulong kind_id; /* The ID of this tile within its name. If there are n tile of a particular name, they have IDs [0, N). The pair (name, kind_id) uniquely identifies a tile, as does "id" on its own. */
130 : int is_agave; /* If the tile needs to run in the Agave (Anza) address space or not. */
131 : int allow_shutdown; /* If the tile is allowed to shutdown gracefully. If false, when the tile exits it will tear down the entire application. */
132 :
133 : ulong cpu_idx; /* The CPU index to pin the tile on. A value of ULONG_MAX or more indicates the tile should be floating and not pinned to a core. */
134 :
135 : ulong in_cnt; /* The number of links that this tile reads from. */
136 : ulong in_link_id[ FD_TOPO_MAX_TILE_IN_LINKS ]; /* The link_id of each link that this tile reads from, indexed in [0, in_cnt). */
137 : int in_link_reliable[ FD_TOPO_MAX_TILE_IN_LINKS ]; /* If each link that this tile reads from is a reliable or unreliable consumer, indexed in [0, in_cnt). */
138 : int in_link_poll[ FD_TOPO_MAX_TILE_IN_LINKS ]; /* If each link that this tile reads from should be polled by the tile infrastructure, indexed in [0, in_cnt).
139 : If the link is not polled, the tile will not receive frags for it and the tile writer is responsible for
140 : reading from the link. The link must be marked as unreliable as it is not flow controlled. */
141 :
142 : ulong out_cnt; /* The number of links that this tile writes to. */
143 : ulong out_link_id[ FD_TOPO_MAX_TILE_OUT_LINKS ]; /* The link_id of each link that this tile writes to, indexed in [0, link_cnt). */
144 :
145 : ulong tile_obj_id;
146 : ulong metrics_obj_id;
147 : ulong keyswitch_obj_id;
148 : ulong in_link_fseq_obj_id[ FD_TOPO_MAX_TILE_IN_LINKS ];
149 :
150 : ulong uses_obj_cnt;
151 : ulong uses_obj_id[ FD_TOPO_MAX_TILE_OBJS ];
152 : int uses_obj_mode[ FD_TOPO_MAX_TILE_OBJS ];
153 :
154 : /* Computed fields. These are not supplied as configuration but calculated as needed. */
155 : struct {
156 : ulong * metrics; /* The shared memory for metrics that this tile should write. Consumer by monitoring and metrics writing tiles. */
157 :
158 : /* The fseq of each link that this tile reads from. Multiple fseqs
159 : may point to the link, if there are multiple consumers. An fseq
160 : can be uniquely identified via (link_id, tile_id), or (link_kind,
161 : link_kind_id, tile_kind, tile_kind_id) */
162 : ulong * in_link_fseq[ FD_TOPO_MAX_TILE_IN_LINKS ];
163 : };
164 :
165 : /* Configuration fields. These are required to be known by the topology so it can determine the
166 : total size of Firedancer in memory. */
167 : union {
168 : fd_topo_net_tile_t net;
169 :
170 : struct {
171 : fd_topo_net_tile_t net;
172 :
173 : char if_virt[ 16 ]; /* device name (virtual, for routing) */
174 : char if_phys[ 16 ]; /* device name (physical, for RX/TX) */
175 : uint if_queue; /* device queue index */
176 :
177 : /* xdp specific options */
178 : ulong xdp_rx_queue_size;
179 : ulong xdp_tx_queue_size;
180 : ulong free_ring_depth;
181 : long tx_flush_timeout_ns;
182 : char xdp_mode[8];
183 : int zero_copy;
184 :
185 : ulong netdev_dbl_buf_obj_id; /* dbl_buf containing netdev_tbl */
186 : ulong fib4_main_obj_id; /* fib4 containing main route table */
187 : ulong fib4_local_obj_id; /* fib4 containing local route table */
188 : ulong neigh4_obj_id; /* neigh4 hash map */
189 :
190 : int xsk_core_dump;
191 : } xdp;
192 :
193 : struct {
194 : fd_topo_net_tile_t net;
195 : /* sock specific options */
196 : int so_sndbuf;
197 : int so_rcvbuf;
198 : } sock;
199 :
200 : struct {
201 : ulong netdev_dbl_buf_obj_id; /* dbl_buf containing netdev_tbl */
202 : ulong fib4_main_obj_id; /* fib4 containing main route table */
203 : ulong fib4_local_obj_id; /* fib4 containing local route table */
204 : char neigh_if[ 16 ]; /* neigh4 interface name */
205 : ulong neigh4_obj_id; /* neigh4 hash map */
206 : } netlink;
207 :
208 0 : #define FD_TOPO_GOSSIP_ENTRYPOINTS_MAX 16UL
209 :
210 : struct {
211 : char identity_key_path[ PATH_MAX ];
212 :
213 : ulong entrypoints_cnt;
214 : fd_ip4_port_t entrypoints[ FD_TOPO_GOSSIP_ENTRYPOINTS_MAX ];
215 :
216 : long boot_timestamp_nanos;
217 :
218 : ulong tcache_depth;
219 :
220 : ushort shred_version;
221 : int allow_private_address;
222 : } gossvf;
223 :
224 : struct {
225 : char identity_key_path[ PATH_MAX ];
226 :
227 : ulong entrypoints_cnt;
228 : fd_ip4_port_t entrypoints[ FD_TOPO_GOSSIP_ENTRYPOINTS_MAX ];
229 :
230 : long boot_timestamp_nanos;
231 :
232 : uint ip_addr;
233 : ushort shred_version;
234 :
235 : ulong max_entries;
236 : ulong max_purged;
237 : ulong max_failed;
238 :
239 : struct {
240 : ushort gossip;
241 : ushort tvu;
242 : ushort tvu_quic;
243 : ushort tpu;
244 : ushort tpu_quic;
245 : ushort repair;
246 : } ports;
247 : } gossip;
248 :
249 : struct {
250 : uint out_depth;
251 : uint reasm_cnt;
252 : ulong max_concurrent_connections;
253 : ulong max_concurrent_handshakes;
254 : ushort quic_transaction_listen_port;
255 : long idle_timeout_millis;
256 : uint ack_delay_millis;
257 : int retry;
258 : char key_log_path[ PATH_MAX ];
259 : } quic;
260 :
261 : struct {
262 : ulong tcache_depth;
263 : } verify;
264 :
265 : struct {
266 : ulong tcache_depth;
267 : } dedup;
268 :
269 : struct {
270 : char url[ 256 ];
271 : ulong url_len;
272 : char sni[ 256 ];
273 : ulong sni_len;
274 : char identity_key_path[ PATH_MAX ];
275 : char key_log_path[ PATH_MAX ];
276 : ulong buf_sz;
277 : ulong ssl_heap_sz;
278 : ulong keepalive_interval_nanos;
279 : uchar tls_cert_verify : 1;
280 : } bundle;
281 :
282 : struct {
283 : char url[ 256 ];
284 : char identity_key_path[ PATH_MAX ];
285 : } event;
286 :
287 : struct {
288 : ulong max_pending_transactions;
289 : ulong execle_tile_count;
290 : int larger_max_cost_per_block;
291 : int larger_shred_limits_per_block;
292 : int use_consumed_cus;
293 : int schedule_strategy;
294 : struct {
295 : int enabled;
296 : uchar tip_distribution_program_addr[ 32 ];
297 : uchar tip_payment_program_addr[ 32 ];
298 : uchar tip_distribution_authority[ 32 ];
299 : ulong commission_bps;
300 : char identity_key_path[ PATH_MAX ];
301 : char vote_account_path[ PATH_MAX ]; /* or pubkey is okay */
302 : } bundle;
303 : } pack;
304 :
305 : struct {
306 : int lagged_consecutive_leader_start;
307 : int plugins_enabled;
308 : ulong execle_cnt;
309 : char identity_key_path[ PATH_MAX ];
310 : struct {
311 : int enabled;
312 : uchar tip_payment_program_addr[ 32 ];
313 : uchar tip_distribution_program_addr[ 32 ];
314 : char vote_account_path[ PATH_MAX ];
315 : } bundle;
316 : } pohh;
317 :
318 : struct {
319 : ulong execle_cnt;
320 : char identity_key_path[ PATH_MAX ];
321 : } poh;
322 :
323 : struct {
324 : ulong depth;
325 : ulong fec_resolver_depth;
326 : char identity_key_path[ PATH_MAX ];
327 : ushort shred_listen_port;
328 : int larger_shred_limits_per_block;
329 : ushort expected_shred_version;
330 : ulong adtl_dests_retransmit_cnt;
331 : fd_topo_ip_port_t adtl_dests_retransmit[ FD_TOPO_ADTL_DESTS_MAX ];
332 : ulong adtl_dests_leader_cnt;
333 : fd_topo_ip_port_t adtl_dests_leader[ FD_TOPO_ADTL_DESTS_MAX ];
334 : } shred;
335 :
336 : struct {
337 : ulong disable_blockstore_from_slot;
338 : } store;
339 :
340 : struct {
341 : char identity_key_path[ PATH_MAX ];
342 : ulong authorized_voter_paths_cnt;
343 : char authorized_voter_paths[ 16 ][ PATH_MAX ];
344 : } sign;
345 :
346 : struct {
347 : uint listen_addr;
348 : ushort listen_port;
349 :
350 : int is_voting;
351 :
352 : char cluster[ 32 ];
353 : char identity_key_path[ PATH_MAX ];
354 : char vote_key_path[ PATH_MAX ];
355 :
356 : ulong max_http_connections;
357 : ulong max_websocket_connections;
358 : ulong max_http_request_length;
359 : ulong send_buffer_size_mb;
360 : int schedule_strategy;
361 :
362 : int websocket_compression;
363 : int frontend_release_channel;
364 : } gui;
365 :
366 : struct {
367 : uint listen_addr;
368 : ushort listen_port;
369 :
370 : ulong max_http_connections;
371 : ulong send_buffer_size_mb;
372 : ulong max_http_request_length;
373 :
374 : ulong max_live_slots;
375 :
376 : char identity_key_path[ PATH_MAX ];
377 : } rpc;
378 :
379 : struct {
380 : uint prometheus_listen_addr;
381 : ushort prometheus_listen_port;
382 : } metric;
383 :
384 : struct {
385 : ulong fec_max;
386 :
387 : ulong txncache_obj_id;
388 : ulong progcache_obj_id;
389 :
390 : char shred_cap[ PATH_MAX ];
391 :
392 : char identity_key_path[ PATH_MAX ];
393 : uint ip_addr;
394 : char vote_account_path[ PATH_MAX ];
395 :
396 : ushort expected_shred_version;
397 : int wait_for_vote_to_start_leader;
398 :
399 : ulong heap_size_gib;
400 : ulong max_live_slots;
401 : ulong write_delay_slots;
402 :
403 : /* not specified in TOML */
404 :
405 : ulong enable_features_cnt;
406 : char enable_features[ 16 ][ FD_BASE58_ENCODED_32_SZ ];
407 :
408 : char genesis_path[ PATH_MAX ];
409 :
410 : int larger_max_cost_per_block;
411 :
412 : ulong capture_start_slot;
413 : char solcap_capture[ PATH_MAX ];
414 : char dump_proto_dir[ PATH_MAX ];
415 : int dump_block_to_pb;
416 :
417 : struct {
418 : int enabled;
419 : uchar tip_payment_program_addr[ 32 ];
420 : uchar tip_distribution_program_addr[ 32 ];
421 : char vote_account_path[ PATH_MAX ];
422 : } bundle;
423 :
424 : } replay;
425 :
426 : struct {
427 : ulong txncache_obj_id;
428 : ulong progcache_obj_id;
429 : ulong acc_pool_obj_id;
430 :
431 : ulong max_live_slots;
432 :
433 : ulong capture_start_slot;
434 : char solcap_capture[ PATH_MAX ];
435 : char dump_proto_dir[ PATH_MAX ];
436 : char dump_syscall_name_filter[ PATH_MAX ];
437 : char dump_instr_program_id_filter[ FD_BASE58_ENCODED_32_SZ ];
438 : int dump_instr_to_pb;
439 : int dump_txn_to_pb;
440 : int dump_syscall_to_pb;
441 : int dump_elf_to_pb;
442 : } execrp;
443 :
444 : struct {
445 : ushort send_to_port;
446 : uint send_to_ip_addr;
447 : ulong conn_cnt;
448 : int no_quic;
449 : } benchs;
450 :
451 : struct {
452 : ushort rpc_port;
453 : uint rpc_ip_addr;
454 : } bencho;
455 :
456 : struct {
457 : ulong accounts_cnt;
458 : int mode;
459 : float contending_fraction;
460 : float cu_price_spread;
461 : } benchg;
462 :
463 : struct {
464 : ushort repair_intake_listen_port;
465 : ushort repair_serve_listen_port;
466 : char identity_key_path[ PATH_MAX ];
467 : ulong max_pending_shred_sets;
468 : ulong slot_max;
469 :
470 : /* non-config */
471 :
472 : ulong repair_sign_depth;
473 : ulong repair_sign_cnt;
474 :
475 : ulong end_slot; /* repair profiler mode only */
476 : } repair;
477 :
478 : struct {
479 : ushort txsend_src_port;
480 :
481 : /* non-config */
482 :
483 : uint ip_addr;
484 : char identity_key_path[ PATH_MAX ];
485 : } txsend;
486 :
487 : struct {
488 : uint fake_dst_ip;
489 : } pktgen;
490 :
491 : struct {
492 : ulong end_slot;
493 : char rocksdb_path[ PATH_MAX ];
494 : char ingest_mode[ 32 ];
495 :
496 : /* Set internally by the archiver tile */
497 : int archive_fd;
498 : } archiver;
499 :
500 : struct {
501 : int ingest_dead_slots;
502 : ulong root_distance;
503 : ulong end_slot;
504 : char rocksdb_path[ PATH_MAX ];
505 : char shredcap_path[ PATH_MAX ];
506 : } backtest;
507 :
508 : struct {
509 : ulong authorized_voter_paths_cnt;
510 : char authorized_voter_paths[ 16 ][ PATH_MAX ];
511 : int hard_fork_fatal;
512 : ulong max_live_slots;
513 : ulong max_vote_lookahead;
514 : int debug_logging;
515 : char identity_key[ PATH_MAX ];
516 : char vote_account[ PATH_MAX ];
517 : char base_path[PATH_MAX];
518 : } tower;
519 :
520 : struct {
521 : char folder_path[ PATH_MAX ];
522 : ushort repair_intake_listen_port;
523 : ulong write_buffer_size; /* Size of the write buffer for the capture tile */
524 : int enable_publish_stake_weights;
525 : char manifest_path[ PATH_MAX ];
526 :
527 : /* Set internally by the capture tile */
528 : int shreds_fd;
529 : int requests_fd;
530 : int fecs_fd;
531 : int peers_fd;
532 : int bank_hashes_fd;
533 : int slices_fd;
534 : } shredcap;
535 :
536 : #define FD_TOPO_SNAPSHOTS_GOSSIP_LIST_MAX (32UL)
537 0 : #define FD_TOPO_SNAPSHOTS_SERVERS_MAX (16UL)
538 0 : #define FD_TOPO_MAX_RESOLVED_ADDRS ( 4UL)
539 0 : #define FD_TOPO_SNAPSHOTS_SERVERS_MAX_RESOLVED (FD_TOPO_MAX_RESOLVED_ADDRS*FD_TOPO_SNAPSHOTS_SERVERS_MAX)
540 :
541 : struct fd_topo_tile_snapct {
542 : char snapshots_path[ PATH_MAX ];
543 :
544 : struct {
545 : uint max_local_full_effective_age;
546 : uint max_local_incremental_age;
547 :
548 : struct {
549 : int allow_any;
550 : ulong allow_list_cnt;
551 : fd_pubkey_t allow_list[ FD_TOPO_SNAPSHOTS_GOSSIP_LIST_MAX ];
552 : ulong block_list_cnt;
553 : fd_pubkey_t block_list[ FD_TOPO_SNAPSHOTS_GOSSIP_LIST_MAX ];
554 : } gossip;
555 :
556 : ulong servers_cnt;
557 : struct {
558 : fd_ip4_port_t addr;
559 : char hostname[ 256UL ];
560 : int is_https;
561 : } servers[ FD_TOPO_SNAPSHOTS_SERVERS_MAX_RESOLVED ];
562 : } sources;
563 :
564 : int incremental_snapshots;
565 : uint max_full_snapshots_to_keep;
566 : uint max_incremental_snapshots_to_keep;
567 : uint full_effective_age_cancel_threshold;
568 : uint max_retry_abort;
569 : } snapct;
570 :
571 : struct {
572 : char snapshots_path[ PATH_MAX ];
573 : uint min_download_speed_mibs;
574 : } snapld;
575 :
576 : struct {
577 : ulong max_live_slots;
578 : ulong funk_obj_id;
579 : ulong txncache_obj_id;
580 :
581 : uint lthash_disabled : 1;
582 : uint use_vinyl : 1;
583 : } snapin;
584 :
585 : struct {
586 : ulong vinyl_meta_map_obj_id;
587 : ulong vinyl_meta_pool_obj_id;
588 : ulong snapwr_depth;
589 : char vinyl_path[ PATH_MAX ];
590 : uint lthash_disabled : 1;
591 : } snapwm;
592 :
593 : struct {
594 : ulong dcache_obj_id;
595 : char vinyl_path[ PATH_MAX ];
596 : uint lthash_disabled : 1;
597 : } snapwr;
598 :
599 : struct {
600 : ulong dcache_obj_id;
601 : int io_uring_enabled;
602 : char vinyl_path[ PATH_MAX ];
603 : } snaplh;
604 :
605 : struct {
606 :
607 : uint bind_address;
608 : ushort bind_port;
609 :
610 : ushort expected_shred_version;
611 : ulong entrypoints_cnt;
612 : fd_ip4_port_t entrypoints[ FD_TOPO_GOSSIP_ENTRYPOINTS_MAX ];
613 : } ipecho;
614 :
615 : struct {
616 : ulong max_live_slots;
617 : ulong txncache_obj_id;
618 : ulong progcache_obj_id;
619 : ulong acc_pool_obj_id;
620 : } execle;
621 :
622 : struct {
623 : int allow_download;
624 :
625 : ushort expected_shred_version;
626 : ulong entrypoints_cnt;
627 : fd_ip4_port_t entrypoints[ FD_TOPO_GOSSIP_ENTRYPOINTS_MAX ];
628 :
629 : int has_expected_genesis_hash;
630 : uchar expected_genesis_hash[ 32UL ];
631 :
632 : char genesis_path[ PATH_MAX ];
633 :
634 : uint target_gid;
635 : uint target_uid;
636 : } genesi;
637 :
638 : struct {
639 : ulong meta_map_obj_id;
640 : ulong meta_pool_obj_id;
641 : ulong line_max;
642 : ulong data_obj_id;
643 : char bstream_path[ PATH_MAX ];
644 :
645 : int io_type; /* FD_VINYL_IO_TYPE_* */
646 : uint uring_depth;
647 : } accdb;
648 :
649 : struct {
650 : ulong capture_start_slot;
651 : char solcap_capture[ PATH_MAX ];
652 : int recent_only;
653 : ulong recent_slots_per_file;
654 : } solcap;
655 : };
656 : };
657 :
658 : typedef struct fd_topo_tile fd_topo_tile_t;
659 :
660 : typedef struct {
661 : ulong id;
662 : char name[ 13UL ]; /* object type */
663 : ulong wksp_id;
664 :
665 : /* Optional label for object */
666 : char label[ 13UL ]; /* object label */
667 : ulong label_idx; /* index of object for this label (ULONG_MAX if not labelled) */
668 :
669 : ulong offset;
670 : ulong footprint;
671 : } fd_topo_obj_t;
672 :
673 : /* An fd_topo_t represents the overall structure of a Firedancer
674 : configuration, describing all the workspaces, tiles, and links
675 : between them. */
676 : struct fd_topo {
677 : char app_name[ 256UL ];
678 : uchar props[ 16384UL ];
679 :
680 : ulong wksp_cnt;
681 : ulong link_cnt;
682 : ulong tile_cnt;
683 : ulong obj_cnt;
684 :
685 : fd_topo_wksp_t workspaces[ FD_TOPO_MAX_WKSPS ];
686 : fd_topo_link_t links[ FD_TOPO_MAX_LINKS ];
687 : fd_topo_tile_t tiles[ FD_TOPO_MAX_TILES ];
688 : fd_topo_obj_t objs[ FD_TOPO_MAX_OBJS ];
689 :
690 : ulong agave_affinity_cnt;
691 : ulong agave_affinity_cpu_idx[ FD_TILE_MAX ];
692 : ulong blocklist_cores_cnt;
693 : ulong blocklist_cores_cpu_idx[ FD_TILE_MAX ];
694 :
695 : ulong max_page_size; /* 2^21 or 2^30 */
696 : ulong gigantic_page_threshold; /* see [hugetlbfs.gigantic_page_threshold_mib]*/
697 : };
698 : typedef struct fd_topo fd_topo_t;
699 :
700 : typedef struct {
701 : char const * name;
702 :
703 : int keep_host_networking;
704 : int allow_connect;
705 : int allow_renameat;
706 : ulong rlimit_file_cnt;
707 : ulong rlimit_address_space;
708 : ulong rlimit_data;
709 : ulong rlimit_nproc;
710 : int for_tpool;
711 :
712 : ulong (*populate_allowed_seccomp)( fd_topo_t const * topo, fd_topo_tile_t const * tile, ulong out_cnt, struct sock_filter * out );
713 : ulong (*populate_allowed_fds )( fd_topo_t const * topo, fd_topo_tile_t const * tile, ulong out_fds_sz, int * out_fds );
714 : ulong (*scratch_align )( void );
715 : ulong (*scratch_footprint )( fd_topo_tile_t const * tile );
716 : ulong (*loose_footprint )( fd_topo_tile_t const * tile );
717 : void (*privileged_init )( fd_topo_t * topo, fd_topo_tile_t * tile );
718 : void (*unprivileged_init )( fd_topo_t * topo, fd_topo_tile_t * tile );
719 : void (*run )( fd_topo_t * topo, fd_topo_tile_t * tile );
720 : ulong (*rlimit_file_cnt_fn )( fd_topo_t const * topo, fd_topo_tile_t const * tile );
721 : } fd_topo_run_tile_t;
722 :
723 : struct fd_topo_obj_callbacks {
724 : char const * name;
725 : ulong (* footprint )( fd_topo_t const * topo, fd_topo_obj_t const * obj );
726 : ulong (* align )( fd_topo_t const * topo, fd_topo_obj_t const * obj );
727 : ulong (* loose )( fd_topo_t const * topo, fd_topo_obj_t const * obj );
728 : void (* new )( fd_topo_t const * topo, fd_topo_obj_t const * obj );
729 : };
730 :
731 : typedef struct fd_topo_obj_callbacks fd_topo_obj_callbacks_t;
732 :
733 : FD_PROTOTYPES_BEGIN
734 :
735 : FD_FN_CONST static inline ulong
736 0 : fd_topo_workspace_align( void ) {
737 : /* This needs to be the max( align ) of all the child members that
738 : could be aligned into this workspace, otherwise our footprint
739 : calculation will not be correct. For now just set to 4096 but this
740 : should probably be calculated dynamically, or we should reduce
741 : those child aligns if we can. */
742 0 : return 4096UL;
743 0 : }
744 :
745 : void *
746 : fd_topo_obj_laddr( fd_topo_t const * topo,
747 : ulong obj_id );
748 :
749 : /* Returns a pointer in the local address space to the base address of
750 : the workspace out of which the given object was allocated. */
751 :
752 : static inline void *
753 : fd_topo_obj_wksp_base( fd_topo_t const * topo,
754 0 : ulong obj_id ) {
755 0 : FD_TEST( obj_id<FD_TOPO_MAX_OBJS );
756 0 : fd_topo_obj_t const * obj = &topo->objs[ obj_id ];
757 0 : FD_TEST( obj->id == obj_id );
758 0 : ulong const wksp_id = obj->wksp_id;
759 :
760 0 : FD_TEST( wksp_id<FD_TOPO_MAX_WKSPS );
761 0 : fd_topo_wksp_t const * wksp = &topo->workspaces[ wksp_id ];
762 0 : FD_TEST( wksp->id == wksp_id );
763 0 : return wksp->wksp;
764 0 : }
765 :
766 : FD_FN_PURE static inline ulong
767 : fd_topo_tile_name_cnt( fd_topo_t const * topo,
768 3 : char const * name ) {
769 3 : ulong cnt = 0;
770 6 : for( ulong i=0; i<topo->tile_cnt; i++ ) {
771 3 : if( FD_UNLIKELY( !strcmp( topo->tiles[ i ].name, name ) ) ) cnt++;
772 3 : }
773 3 : return cnt;
774 3 : }
775 :
776 : /* Finds the workspace of a given name in the topology. Returns
777 : ULONG_MAX if there is no such workspace. There can be at most one
778 : workspace of a given name. */
779 :
780 : FD_FN_PURE static inline ulong
781 : fd_topo_find_wksp( fd_topo_t const * topo,
782 66 : char const * name ) {
783 66 : for( ulong i=0; i<topo->wksp_cnt; i++ ) {
784 66 : if( FD_UNLIKELY( !strcmp( topo->workspaces[ i ].name, name ) ) ) return i;
785 66 : }
786 0 : return ULONG_MAX;
787 66 : }
788 :
789 : /* Find the tile of a given name and kind_id in the topology, there will
790 : be at most one such tile, since kind_id is unique among the name.
791 : Returns ULONG_MAX if there is no such tile. */
792 :
793 : FD_FN_PURE static inline ulong
794 : fd_topo_find_tile( fd_topo_t const * topo,
795 : char const * name,
796 21 : ulong kind_id ) {
797 21 : for( ulong i=0; i<topo->tile_cnt; i++ ) {
798 21 : if( FD_UNLIKELY( !strcmp( topo->tiles[ i ].name, name ) ) && topo->tiles[ i ].kind_id == kind_id ) return i;
799 21 : }
800 0 : return ULONG_MAX;
801 21 : }
802 :
803 : /* Find the link of a given name and kind_id in the topology, there will
804 : be at most one such link, since kind_id is unique among the name.
805 : Returns ULONG_MAX if there is no such link. */
806 :
807 : FD_FN_PURE static inline ulong
808 : fd_topo_find_link( fd_topo_t const * topo,
809 : char const * name,
810 18 : ulong kind_id ) {
811 39 : for( ulong i=0; i<topo->link_cnt; i++ ) {
812 39 : if( FD_UNLIKELY( !strcmp( topo->links[ i ].name, name ) ) && topo->links[ i ].kind_id == kind_id ) return i;
813 39 : }
814 0 : return ULONG_MAX;
815 18 : }
816 :
817 : FD_FN_PURE static inline ulong
818 : fd_topo_find_tile_in_link( fd_topo_t const * topo,
819 : fd_topo_tile_t const * tile,
820 : char const * name,
821 0 : ulong kind_id ) {
822 0 : for( ulong i=0; i<tile->in_cnt; i++ ) {
823 0 : if( FD_UNLIKELY( !strcmp( topo->links[ tile->in_link_id[ i ] ].name, name ) )
824 0 : && topo->links[ tile->in_link_id[ i ] ].kind_id == kind_id ) return i;
825 0 : }
826 0 : return ULONG_MAX;
827 0 : }
828 :
829 : FD_FN_PURE static inline ulong
830 : fd_topo_find_tile_out_link( fd_topo_t const * topo,
831 : fd_topo_tile_t const * tile,
832 : char const * name,
833 0 : ulong kind_id ) {
834 0 : for( ulong i=0; i<tile->out_cnt; i++ ) {
835 0 : if( FD_UNLIKELY( !strcmp( topo->links[ tile->out_link_id[ i ] ].name, name ) )
836 0 : && topo->links[ tile->out_link_id[ i ] ].kind_id == kind_id ) return i;
837 0 : }
838 0 : return ULONG_MAX;
839 0 : }
840 :
841 : /* Find the id of the tile which is a producer for the given link. If
842 : no tile is a producer for the link, returns ULONG_MAX. This should
843 : not be possible for a well formed and validated topology. */
844 : FD_FN_PURE static inline ulong
845 : fd_topo_find_link_producer( fd_topo_t const * topo,
846 0 : fd_topo_link_t const * link ) {
847 0 : for( ulong i=0; i<topo->tile_cnt; i++ ) {
848 0 : fd_topo_tile_t const * tile = &topo->tiles[ i ];
849 :
850 0 : for( ulong j=0; j<tile->out_cnt; j++ ) {
851 0 : if( FD_UNLIKELY( tile->out_link_id[ j ] == link->id ) ) return i;
852 0 : }
853 0 : }
854 0 : return ULONG_MAX;
855 0 : }
856 :
857 : /* Given a link, count the number of consumers of that link among all
858 : the tiles in the topology. */
859 : FD_FN_PURE static inline ulong
860 : fd_topo_link_consumer_cnt( fd_topo_t const * topo,
861 0 : fd_topo_link_t const * link ) {
862 0 : ulong cnt = 0;
863 0 : for( ulong i=0; i<topo->tile_cnt; i++ ) {
864 0 : fd_topo_tile_t const * tile = &topo->tiles[ i ];
865 0 : for( ulong j=0; j<tile->in_cnt; j++ ) {
866 0 : if( FD_UNLIKELY( tile->in_link_id[ j ] == link->id ) ) cnt++;
867 0 : }
868 0 : }
869 :
870 0 : return cnt;
871 0 : }
872 :
873 : /* Given a link, count the number of reliable consumers of that link
874 : among all the tiles in the topology. */
875 : FD_FN_PURE static inline ulong
876 : fd_topo_link_reliable_consumer_cnt( fd_topo_t const * topo,
877 0 : fd_topo_link_t const * link ) {
878 0 : ulong cnt = 0;
879 0 : for( ulong i=0; i<topo->tile_cnt; i++ ) {
880 0 : fd_topo_tile_t const * tile = &topo->tiles[ i ];
881 0 : for( ulong j=0; j<tile->in_cnt; j++ ) {
882 0 : if( FD_UNLIKELY( tile->in_link_id[ j ] == link->id && tile->in_link_reliable[ j ] ) ) cnt++;
883 0 : }
884 0 : }
885 :
886 0 : return cnt;
887 0 : }
888 :
889 : FD_FN_PURE static inline ulong
890 : fd_topo_tile_consumer_cnt( fd_topo_t const * topo,
891 0 : fd_topo_tile_t const * tile ) {
892 0 : (void)topo;
893 0 : return tile->out_cnt;
894 0 : }
895 :
896 : FD_FN_PURE static inline ulong
897 : fd_topo_tile_reliable_consumer_cnt( fd_topo_t const * topo,
898 0 : fd_topo_tile_t const * tile ) {
899 0 : ulong reliable_cons_cnt = 0UL;
900 0 : for( ulong i=0UL; i<topo->tile_cnt; i++ ) {
901 0 : fd_topo_tile_t const * consumer_tile = &topo->tiles[ i ];
902 0 : for( ulong j=0UL; j<consumer_tile->in_cnt; j++ ) {
903 0 : for( ulong k=0UL; k<tile->out_cnt; k++ ) {
904 0 : if( FD_UNLIKELY( consumer_tile->in_link_id[ j ]==tile->out_link_id[ k ] && consumer_tile->in_link_reliable[ j ] ) ) {
905 0 : reliable_cons_cnt++;
906 0 : }
907 0 : }
908 0 : }
909 0 : }
910 0 : return reliable_cons_cnt;
911 0 : }
912 :
913 : FD_FN_PURE static inline ulong
914 : fd_topo_tile_producer_cnt( fd_topo_t const * topo,
915 0 : fd_topo_tile_t const * tile ) {
916 0 : (void)topo;
917 0 : ulong in_cnt = 0UL;
918 0 : for( ulong i=0UL; i<tile->in_cnt; i++ ) {
919 0 : if( FD_UNLIKELY( !tile->in_link_poll[ i ] ) ) continue;
920 0 : in_cnt++;
921 0 : }
922 0 : return in_cnt;
923 0 : }
924 :
925 : FD_FN_PURE FD_FN_UNUSED static ulong
926 : fd_topo_obj_cnt( fd_topo_t const * topo,
927 : char const * obj_type,
928 0 : char const * label ) {
929 0 : ulong cnt = 0UL;
930 0 : for( ulong i=0UL; i<topo->obj_cnt; i++ ) {
931 0 : fd_topo_obj_t const * obj = &topo->objs[ i ];
932 0 : if( strncmp( obj->name, obj_type, sizeof(obj->name) ) ) continue;
933 0 : if( label &&
934 0 : strncmp( obj->label, label, sizeof(obj->label) ) ) continue;
935 0 : cnt++;
936 0 : }
937 0 : return cnt;
938 0 : }
939 :
940 : FD_FN_PURE FD_FN_UNUSED static fd_topo_obj_t const *
941 : fd_topo_find_obj( fd_topo_t const * topo,
942 : char const * obj_type,
943 : char const * label,
944 0 : ulong label_idx ) {
945 0 : for( ulong i=0UL; i<topo->obj_cnt; i++ ) {
946 0 : fd_topo_obj_t const * obj = &topo->objs[ i ];
947 0 : if( strncmp( obj->name, obj_type, sizeof(obj->name) ) ) continue;
948 0 : if( label &&
949 0 : strncmp( obj->label, label, sizeof(obj->label) ) ) continue;
950 0 : if( label_idx != ULONG_MAX && obj->label_idx != label_idx ) continue;
951 0 : return obj;
952 0 : }
953 0 : return NULL;
954 0 : }
955 :
956 : FD_FN_PURE FD_FN_UNUSED static fd_topo_obj_t const *
957 : fd_topo_find_tile_obj( fd_topo_t const * topo,
958 : fd_topo_tile_t const * tile,
959 0 : char const * obj_type ) {
960 0 : for( ulong i=0UL; i<(tile->uses_obj_cnt); i++ ) {
961 0 : fd_topo_obj_t const * obj = &topo->objs[ tile->uses_obj_id[ i ] ];
962 0 : if( strncmp( obj->name, obj_type, sizeof(obj->name) ) ) continue;
963 0 : return obj;
964 0 : }
965 0 : return NULL;
966 0 : }
967 :
968 : /* Join (map into the process) all shared memory (huge/gigantic pages)
969 : needed by the tile, in the given topology. All memory associated
970 : with the tile (aka. used by links that the tile either produces to or
971 : consumes from, or used by the tile itself for its cnc) will be
972 : attached (mapped into the process).
973 :
974 : This is needed to play nicely with the sandbox. Once a process is
975 : sandboxed we can no longer map any memory. */
976 : void
977 : fd_topo_join_tile_workspaces( fd_topo_t * topo,
978 : fd_topo_tile_t * tile,
979 : int core_dump_level );
980 :
981 : /* Join (map into the process) the shared memory (huge/gigantic pages)
982 : for the given workspace. Mode is one of
983 : FD_SHMEM_JOIN_MODE_READ_WRITE or FD_SHMEM_JOIN_MODE_READ_ONLY and
984 : determines the prot argument that will be passed to mmap when mapping
985 : the pages in (PROT_WRITE or PROT_READ respectively).
986 :
987 : Dump should be set to 1 if the workspace memory should be dumpable
988 : when the process crashes, or 0 if not. */
989 : void
990 : fd_topo_join_workspace( fd_topo_t * topo,
991 : fd_topo_wksp_t * wksp,
992 : int mode,
993 : int dump );
994 :
995 : /* Join (map into the process) all shared memory (huge/gigantic pages)
996 : needed by all tiles in the topology. Mode is one of
997 : FD_SHMEM_JOIN_MODE_READ_WRITE or FD_SHMEM_JOIN_MODE_READ_ONLY and
998 : determines the prot argument that will be passed to mmap when
999 : mapping the pages in (PROT_WRITE or PROT_READ respectively). */
1000 : void
1001 : fd_topo_join_workspaces( fd_topo_t * topo,
1002 : int mode,
1003 : int core_dump_level );
1004 :
1005 : /* Leave (unmap from the process) the shared memory needed for the
1006 : given workspace in the topology, if it was previously mapped.
1007 :
1008 : topo and wksp are assumed non-NULL. It is OK if the workspace
1009 : has not been previously joined, in which case this is a no-op. */
1010 :
1011 : void
1012 : fd_topo_leave_workspace( fd_topo_t * topo,
1013 : fd_topo_wksp_t * wksp );
1014 :
1015 : /* Leave (unmap from the process) all shared memory needed by all
1016 : tiles in the topology, if each of them was mapped.
1017 :
1018 : topo is assumed non-NULL. Only workspaces which were previously
1019 : joined are unmapped. */
1020 :
1021 : void
1022 : fd_topo_leave_workspaces( fd_topo_t * topo );
1023 :
1024 : /* Create the given workspace needed by the topology on the system.
1025 : This does not "join" the workspaces (map their memory into the
1026 : process), but only creates the .wksp file and formats it correctly
1027 : as a workspace.
1028 :
1029 : Returns 0 on success and -1 on failure, with errno set to the error.
1030 : The only reason for failure currently that will be returned is
1031 : ENOMEM, as other unexpected errors will cause the program to exit.
1032 :
1033 : If update_existing is 1, the workspace will not be created from
1034 : scratch but it will be assumed that it already exists from a prior
1035 : run and needs to be maybe resized and then have the header
1036 : structures reinitialized. This can save a very expensive operation
1037 : of zeroing all of the workspace pages. This is dangerous in
1038 : production because it can leave stray memory from prior runs around,
1039 : and should only be used in development environments. */
1040 :
1041 : int
1042 : fd_topo_create_workspace( fd_topo_t * topo,
1043 : fd_topo_wksp_t * wksp,
1044 : int update_existing );
1045 :
1046 : /* Join the standard IPC objects needed by the topology of this particular
1047 : tile */
1048 :
1049 : void
1050 : fd_topo_fill_tile( fd_topo_t * topo,
1051 : fd_topo_tile_t * tile );
1052 :
1053 : /* Same as fd_topo_fill_tile but fills in all the objects for a
1054 : particular workspace with the given mode. */
1055 : void
1056 : fd_topo_workspace_fill( fd_topo_t * topo,
1057 : fd_topo_wksp_t * wksp );
1058 :
1059 : /* Apply a new function to every object that is resident in the given
1060 : workspace in the topology. */
1061 :
1062 : void
1063 : fd_topo_wksp_new( fd_topo_t const * topo,
1064 : fd_topo_wksp_t const * wksp,
1065 : fd_topo_obj_callbacks_t ** callbacks );
1066 :
1067 : /* Same as fd_topo_fill_tile but fills in all tiles in the topology. */
1068 :
1069 : void
1070 : fd_topo_fill( fd_topo_t * topo );
1071 :
1072 : /* fd_topo_tile_stack_join joins a huge page optimized stack for the
1073 : provided tile. The stack is assumed to already exist at a known
1074 : path in the hugetlbfs mount. */
1075 :
1076 : void *
1077 : fd_topo_tile_stack_join( char const * app_name,
1078 : char const * tile_name,
1079 : ulong tile_kind_id );
1080 :
1081 : /* fd_topo_run_single_process runs all the tiles in a single process
1082 : (the calling process). This spawns a thread for each tile, switches
1083 : that thread to the given UID and GID and then runs the tile in it.
1084 : Each thread will never exit, as tiles are expected to run forever.
1085 : An error is logged and the application will exit if a tile exits.
1086 : The function itself does return after spawning all the threads.
1087 :
1088 : The threads will not be sandboxed in any way, except switching to the
1089 : provided UID and GID, so they will share the same address space, and
1090 : not have any seccomp restrictions or use any Linux namespaces. The
1091 : calling thread will also switch to the provided UID and GID before
1092 : it returns.
1093 :
1094 : In production, when running with an Agave child process this is
1095 : used for spawning certain tiles inside the Agave address space.
1096 : It's also useful for tooling and debugging, but is not how the main
1097 : production Firedancer process runs. For production, each tile is run
1098 : in its own address space with a separate process and full security
1099 : sandbox.
1100 :
1101 : The agave argument determines which tiles are started. If the
1102 : argument is 0 or 1, only non-agave (or only agave) tiles are started.
1103 : If the argument is any other value, all tiles in the topology are
1104 : started regardless of if they are Agave tiles or not. */
1105 :
1106 : void
1107 : fd_topo_run_single_process( fd_topo_t * topo,
1108 : int agave,
1109 : uint uid,
1110 : uint gid,
1111 : fd_topo_run_tile_t (* tile_run )( fd_topo_tile_t const * tile ) );
1112 :
1113 : /* fd_topo_run_tile runs the given tile directly within the current
1114 : process (and thread). The function will never return, as tiles are
1115 : expected to run forever. An error is logged and the application will
1116 : exit if the tile exits.
1117 :
1118 : The sandbox argument determines if the current process will be
1119 : sandboxed fully before starting the tile. The thread will switch to
1120 : the UID and GID provided before starting the tile, even if the thread
1121 : is not being sandboxed. Although POSIX specifies that all threads in
1122 : a process must share a UID and GID, this is not the case on Linux.
1123 : The thread will switch to the provided UID and GID without switching
1124 : the other threads in the process.
1125 :
1126 : If keep_controlling_terminal is set to 0, and the sandbox is enabled
1127 : the controlling terminal will be detached as an additional sandbox
1128 : measure, but you will not be able to send Ctrl+C or other signals
1129 : from the terminal. See fd_sandbox.h for more information.
1130 :
1131 : The allow_fd argument is only used if sandbox is true, and is a file
1132 : descriptor which will be allowed to exist in the process. Normally
1133 : the sandbox code rejects and aborts if there is an unexpected file
1134 : descriptor present on boot. This is helpful to allow a parent
1135 : process to be notified on termination of the tile by waiting for a
1136 : pipe file descriptor to get closed.
1137 :
1138 : wait and debugger are both used in debugging. If wait is non-NULL,
1139 : the runner will wait until the value pointed to by wait is non-zero
1140 : before launching the tile. Likewise, if debugger is non-NULL, the
1141 : runner will wait until a debugger is attached before setting the
1142 : value pointed to by debugger to non-zero. These are intended to be
1143 : used as a pair, where many tiles share a waiting reference, and then
1144 : one of the tiles (a tile you want to attach the debugger to) has the
1145 : same reference provided as the debugger, so all tiles will stop and
1146 : wait for the debugger to attach to it before proceeding. */
1147 :
1148 : void
1149 : fd_topo_run_tile( fd_topo_t * topo,
1150 : fd_topo_tile_t * tile,
1151 : int sandbox,
1152 : int keep_controlling_terminal,
1153 : int dumpable,
1154 : uint uid,
1155 : uint gid,
1156 : int allow_fd,
1157 : volatile int * wait,
1158 : volatile int * debugger,
1159 : fd_topo_run_tile_t * tile_run );
1160 :
1161 : /* This is for determining the value of RLIMIT_MLOCK that we need to
1162 : successfully run all tiles in separate processes. The value returned
1163 : is the maximum amount of memory that will be locked with mlock() by
1164 : any individual process in the tree. Specifically, if we have three
1165 : tile processes, and they each need to lock 5, 9, and 2 MiB of memory
1166 : respectively, RLIMIT_MLOCK needs to be 9 MiB to allow all three
1167 : process mlock() calls to succeed.
1168 :
1169 : Tiles lock memory in three ways. Any workspace they are using, they
1170 : lock the entire workspace. Then each tile uses huge pages for the
1171 : stack which are also locked, and finally some tiles use private
1172 : locked mmaps outside the workspace for storing key material. The
1173 : results here include all of this memory together.
1174 :
1175 : The result is not necessarily the amount of memory used by the tile
1176 : process, although it will be quite close. Tiles could potentially
1177 : allocate memory (eg, with brk) without needing to lock it, which
1178 : would not need to included, and some kernel memory that tiles cause
1179 : to be allocated (for example XSK buffers) is also not included. The
1180 : actual amount of memory used will not be less than this value. */
1181 : FD_FN_PURE ulong
1182 : fd_topo_mlock_max_tile( fd_topo_t const * topo );
1183 :
1184 : /* Same as fd_topo_mlock_max_tile, but for loading the entire topology
1185 : into one process, rather than a separate process per tile. This is
1186 : used, for example, by the configuration code when it creates all the
1187 : workspaces, or the monitor that maps the entire system into one
1188 : address space. */
1189 : FD_FN_PURE ulong
1190 : fd_topo_mlock( fd_topo_t const * topo );
1191 :
1192 : /* This returns the number of gigantic pages needed by the topology on
1193 : the provided numa node. It includes pages needed by the workspaces,
1194 : as well as additional allocations like huge pages for process stacks
1195 : and private key storage. */
1196 :
1197 : FD_FN_PURE ulong
1198 : fd_topo_gigantic_page_cnt( fd_topo_t const * topo,
1199 : ulong numa_idx );
1200 :
1201 : /* This returns the number of huge pages in the application needed by
1202 : the topology on the provided numa node. It includes pages needed by
1203 : things placed in the hugetlbfs (workspaces, process stacks). If
1204 : include_anonymous is true, it also includes anonymous hugepages which
1205 : are needed but are not placed in the hugetlbfs. */
1206 :
1207 : FD_FN_PURE ulong
1208 : fd_topo_huge_page_cnt( fd_topo_t const * topo,
1209 : ulong numa_idx,
1210 : int include_anonymous );
1211 :
1212 : /* Prints a message describing the topology to an output stream. If
1213 : stdout is true, will be written to stdout, otherwise will be written
1214 : as a NOTICE log message to the log file. */
1215 : void
1216 : fd_topo_print_log( int stdout,
1217 : fd_topo_t * topo );
1218 :
1219 : FD_PROTOTYPES_END
1220 :
1221 : #endif /* HEADER_fd_src_disco_topo_fd_topo_h */
|