@@ -44,8 +44,7 @@ bpf_map_def SEC("maps") dotnet_procs = {
4444// currently not Garbage Collected by the runtime. Though, we have submitted also an enhancement
4545// request to fix the nibble map format to something sane, and this might get implemented.
4646// see: https://github.com/dotnet/runtime/issues/93550
47- static EBPF_INLINE ErrorCode
48- dotnet_find_code_start (PerCPURecord * record , DotnetProcInfo * vi , u64 pc , u64 * code_start )
47+ static EBPF_INLINE ErrorCode dotnet_find_code_start (PerCPURecord * record , u64 pc , u64 * code_start )
4948{
5049 // This is an ebpf optimized implementation of EEJitManager::FindMethodCode()
5150 // https://github.com/dotnet/runtime/blob/v7.0.15/src/coreclr/vm/codeman.cpp#L4115
@@ -107,11 +106,12 @@ dotnet_find_code_start(PerCPURecord *record, DotnetProcInfo *vi, u64 pc, u64 *co
107106 // convert it from u32 to u64 offset
108107 int pos64 = (map_elements - 2 ) / 2 ;
109108 u64 val64 = scratch -> map64 [-- pos64 ];
110- #pragma unroll 256
109+
111110 // the loop iterations is number of u64 elements minus two:
112111 // - the last element special handled earlier
113112 // - the second last element which is preloaded immediately above
114- for (int i = 0 ; i < map_elements / 2 - 2 ; i ++ ) {
113+ UNROLL for (int i = 0 ; i < map_elements / 2 - 2 ; i ++ )
114+ {
115115 if (val64 != 0 ) {
116116 break ;
117117 }
@@ -146,8 +146,8 @@ dotnet_find_code_start(PerCPURecord *record, DotnetProcInfo *vi, u64 pc, u64 *co
146146 }
147147
148148 // Decode the code start info from the entry
149- #pragma unroll
150- for ( int i = 0 ; i < DOTNET_CODE_NIBBLES_PER_ENTRY ; i ++ ) {
149+ UNROLL for ( int i = 0 ; i < DOTNET_CODE_NIBBLES_PER_ENTRY ; i ++ )
150+ {
151151 u8 nybble = val & 0xf ;
152152 if (nybble != 0 ) {
153153 * code_start = pc_base + pc_delta + (nybble - 1 ) * DOTNET_CODE_ALIGN ;
@@ -177,8 +177,7 @@ push_dotnet(Trace *trace, u64 code_header_ptr, u64 pc_offset, bool return_addres
177177}
178178
179179// Unwind one dotnet frame
180- static EBPF_INLINE ErrorCode
181- unwind_one_dotnet_frame (PerCPURecord * record , DotnetProcInfo * vi , bool top )
180+ static EBPF_INLINE ErrorCode unwind_one_dotnet_frame (PerCPURecord * record )
182181{
183182 UnwindState * state = & record -> state ;
184183 Trace * trace = & record -> trace ;
@@ -241,7 +240,7 @@ unwind_one_dotnet_frame(PerCPURecord *record, DotnetProcInfo *vi, bool top)
241240 }
242241
243242 // JIT generated code, locate code start
244- ErrorCode error = dotnet_find_code_start (record , vi , pc , & code_start );
243+ ErrorCode error = dotnet_find_code_start (record , pc , & code_start );
245244 if (error != ERR_OK ) {
246245 DEBUG_PRINT ("dotnet: --> code_start failed with %d" , error );
247246 // dotnet_find_code_start incremented the metric already
@@ -305,11 +304,11 @@ static EBPF_INLINE int unwind_dotnet(struct pt_regs *ctx)
305304 record -> ratelimitAction = RATELIMIT_ACTION_FAST ;
306305 increment_metric (metricID_UnwindDotnetAttempts );
307306
308- #pragma unroll
309- for ( int i = 0 ; i < DOTNET_FRAMES_PER_PROGRAM ; i ++ ) {
307+ UNROLL for ( int i = 0 ; i < DOTNET_FRAMES_PER_PROGRAM ; i ++ )
308+ {
310309 unwinder = PROG_UNWIND_STOP ;
311310
312- error = unwind_one_dotnet_frame (record , vi , i == 0 );
311+ error = unwind_one_dotnet_frame (record );
313312 if (error ) {
314313 break ;
315314 }
0 commit comments