@@ -54,31 +54,6 @@ struct trace_entry {
5454 pid: i32,
5555}
5656
57- // Kprobe context struct (from BTF)
58- struct pt_regs {
59- r15: u64,
60- r14: u64,
61- r13: u64,
62- r12: u64,
63- rbp: u64,
64- rbx: u64,
65- r11: u64,
66- r10: u64,
67- r9: u64,
68- r8: u64,
69- rax: u64,
70- rcx: u64,
71- rdx: u64,
72- rsi: u64,
73- rdi: u64,
74- orig_rax: u64,
75- rip: u64,
76- cs: u64,
77- eflags: u64,
78- rsp: u64,
79- ss: u64,
80- }
81-
8257// This example demonstrates comprehensive map operations with multi-program analysis
8358// It shows various access patterns and concurrent access scenarios
8459
@@ -129,7 +104,7 @@ struct ArrayElement {
129104
130105 // Safe concurrent read access - multiple programs can read simultaneously
131106 var counter = global_counter[key]
132- if ( counter != null ) {
107+ if ( counter != none ) {
133108 // High-frequency lookup pattern - will generate optimization suggestions
134109 for ( i in 0 ..100 ) {
135110 var _ = global_counter[key + i]
@@ -142,7 +117,7 @@ struct ArrayElement {
142117 // Per-CPU access for maximum performance
143118 var cpu_id = 0
144119 var data = percpu_data[cpu_id]
145- if ( data != null ) {
120+ if ( data != none ) {
146121 data.local_counter = data.local_counter + 1
147122 percpu_data[cpu_id] = data
148123 } else {
@@ -162,7 +137,7 @@ struct ArrayElement {
162137
163138 // Potential write conflict with other programs
164139 var stats = shared_stats[ifindex]
165- if ( stats == null ) {
140+ if ( stats == none ) {
166141 stats = Statistics {
167142 packet_count: 0 ,
168143 byte_count: 0 ,
@@ -220,11 +195,11 @@ struct ArrayElement {
220195}
221196
222197// Program 4: Sequential access pattern demonstration
223- @kprobe fn data_processor( ctx : * pt_regs ) - > i32 {
198+ @kprobe fn data_processor( file : * file, buf: * u8, count: usize, pos: * i64 ) - > i32 {
224199 // Sequential access pattern - will be detected and optimized
225200 for ( i in 0 ..32 ) {
226201 var element = sequential_data[i]
227- if ( element != null ) {
202+ if ( element != none ) {
228203 if ( !element.processed) {
229204 element.value = element.value * 2
230205 element.processed = true
0 commit comments