LCOV - code coverage report
Current view: top level - flamenco/runtime - fd_bpf_frames.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 1 2 50.0 %
Date: 2026-11-11 12:40:43 Functions: 0 0 -

          Line data    Source code
       1             : #ifndef HEADER_fd_src_flamenco_runtime_fd_bpf_frames_h
       2             : #define HEADER_fd_src_flamenco_runtime_fd_bpf_frames_h
       3             : 
       4             : /* fd_bpf_frames holds the BPF loader input serialization frames for the
       5             :    exec{rp,le} tiles.  A BPF instruction serializes its input into a
       6             :    frame and holds it until it returns, and a CPI takes another frame
       7             :    while its caller keeps its own, so a tile holds up to one frame per
       8             :    instruction stack level.  This object allows for shared and
       9             :    tile-local frames for both tiles.  Each tile can keep some number of
      10             :    frames local to itself for performance reasons.  The last shared
      11             :    frames are held back so the pool cannot deadlock.  This is sized so
      12             :    that contending transactions cannot starve each other for bpf frames.
      13             : 
      14             :    fd_bpf_frames_shmem_t is the pool and fd_bpf_frames_t is one user's
      15             :    local join to it. */
      16             : 
      17             : #include "fd_runtime_const.h"
      18             : 
      19             : /* FD_BPF_FRAMES_HELD_CNT is the number of shared frames held back when
      20             :    each join has local_cnt local frames, and so the fewest shared frames
      21             :    a pool can have. */
      22             : 
      23          12 : #define FD_BPF_FRAMES_HELD_CNT( local_cnt ) (2UL*(FD_MAX_INSTRUCTION_STACK_DEPTH-(local_cnt)))
      24           0 : #define FD_BPF_FRAMES_CNT_MAX               (1UL<<16)
      25             : 
      26             : /* FD_BPF_FRAMES_ALIGN is the alignment of every frame. */
      27             : 
      28             : #define FD_BPF_FRAMES_ALIGN (4096UL)
      29             : 
      30             : struct fd_bpf_frames_shmem;
      31             : typedef struct fd_bpf_frames_shmem fd_bpf_frames_shmem_t;
      32             : 
      33             : struct fd_bpf_frames;
      34             : typedef struct fd_bpf_frames fd_bpf_frames_t;
      35             : 
      36             : FD_PROTOTYPES_BEGIN
      37             : 
      38             : /* fd_bpf_frames_shmem_{align,footprint,new} size and format a pool of
      39             :    frame_cnt shared frames, plus local_cnt local frames reserved for
      40             :    each of up to joiner_cnt_max joins.  footprint returns 0 if local_cnt
      41             :    is more than FD_MAX_INSTRUCTION_STACK_DEPTH, frame_cnt is less than
      42             :    FD_BPF_FRAMES_HELD_CNT( local_cnt ), or the pool would have more than
      43             :    FD_BPF_FRAMES_CNT_MAX frames.  new returns shmem on success, NULL on
      44             :    failure (logs details). */
      45             : 
      46             : FD_FN_CONST ulong
      47             : fd_bpf_frames_shmem_align( void );
      48             : 
      49             : FD_FN_CONST ulong
      50             : fd_bpf_frames_shmem_footprint( ulong frame_cnt,
      51             :                                ulong joiner_cnt_max,
      52             :                                ulong local_cnt );
      53             : 
      54             : void *
      55             : fd_bpf_frames_shmem_new( void * shmem,
      56             :                          ulong  frame_cnt,
      57             :                          ulong  joiner_cnt_max,
      58             :                          ulong  local_cnt );
      59             : 
      60             : /* fd_bpf_frames_{align,footprint,join} size and create a local join to
      61             :    the pool at shframes in the memory at ljoin, taking the next joiner's
      62             :    local frames.  Each user needs its own join.  join returns NULL (logs
      63             :    details) if joiner_cnt_max users already joined. */
      64             : 
      65             : FD_FN_CONST ulong
      66             : fd_bpf_frames_align( void );
      67             : 
      68             : FD_FN_CONST ulong
      69             : fd_bpf_frames_footprint( void );
      70             : 
      71             : fd_bpf_frames_t *
      72             : fd_bpf_frames_join( void * ljoin,
      73             :                     void * shframes );
      74             : 
      75             : /* fd_bpf_frames_acquire takes a frame, spinning until one is
      76             :    available.  priority is whether the caller is the priority caller. */
      77             : 
      78             : uchar *
      79             : fd_bpf_frames_acquire( fd_bpf_frames_t * join,
      80             :                        int               priority );
      81             : 
      82             : /* fd_bpf_frames_release returns a frame acquired through join.  A
      83             :    join's frames must be released in the reverse order they were
      84             :    acquired. */
      85             : 
      86             : void
      87             : fd_bpf_frames_release( fd_bpf_frames_t * join,
      88             :                        uchar *           frame );
      89             : 
      90             : FD_PROTOTYPES_END
      91             : 
      92             : #endif /* HEADER_fd_src_flamenco_runtime_fd_bpf_frames_h */

Generated by: LCOV version 1.14