@@ -1894,6 +1894,11 @@ <h2 id="_functions">Functions</h2>
1894
1894
< td class ="tableblock halign-left valign-top "> < p class ="tableblock "> Sync</ p > </ td >
1895
1895
</ tr >
1896
1896
< tr >
1897
+ < td class ="tableblock halign-left valign-top "> < p class ="tableblock "> < a href ="#functions-percpu-kaddr "> < code > percpu_kaddr(const string name [, int cpu])</ code > </ a > </ p > </ td >
1898
+ < td class ="tableblock halign-left valign-top "> < p class ="tableblock "> Resolve percpu kernel symbol name</ p > </ td >
1899
+ < td class ="tableblock halign-left valign-top "> < p class ="tableblock "> Sync</ p > </ td >
1900
+ </ tr >
1901
+ < tr >
1897
1902
< td class ="tableblock halign-left valign-top "> < p class ="tableblock "> < a href ="#functions-print "> < code > print(…​)</ code > </ a > </ p > </ td >
1898
1903
< td class ="tableblock halign-left valign-top "> < p class ="tableblock "> Print a non-map value with default formatting</ p > </ td >
1899
1904
< td class ="tableblock halign-left valign-top "> < p class ="tableblock "> Async</ p > </ td >
@@ -2570,6 +2575,51 @@ <h3 id="functions-path">path</h3>
2570
2575
</ div >
2571
2576
</ div >
2572
2577
< div class ="sect2 ">
2578
+ < h3 id ="functions-percpu-kaddr "> percpu_kaddr</ h3 >
2579
+ < div class ="ulist ">
2580
+ < div class ="title "> variants</ div >
2581
+ < ul >
2582
+ < li >
2583
+ < p > < code > void *percpu_kaddr(const string name)</ code > </ p >
2584
+ </ li >
2585
+ < li >
2586
+ < p > < code > void *percpu_kaddr(const string name, int cpu)</ code > </ p >
2587
+ </ li >
2588
+ </ ul >
2589
+ </ div >
2590
+ < div class ="paragraph ">
2591
+ < p > < strong > sync</ strong > </ p >
2592
+ </ div >
2593
+ < div class ="paragraph ">
2594
+ < p > Get the address of the percpu kernel symbol < code > name</ code > for CPU < code > cpu</ code > . When < code > cpu</ code > is
2595
+ omitted, the current CPU is used.</ p >
2596
+ </ div >
2597
+ < div class ="listingblock ">
2598
+ < div class ="content ">
2599
+ < pre > interval:s:1 {
2600
+ $proc_cnt = percpu_kaddr("process_counts");
2601
+ printf("% processes are running on CPU %d\n", *$proc_cnt, cpu);
2602
+ }</ pre >
2603
+ </ div >
2604
+ </ div >
2605
+ < div class ="paragraph ">
2606
+ < p > The second variant may return NULL if < code > cpu</ code > is higher than the number of
2607
+ available CPUs. Therefore, it is necessary to perform a NULL-check on the result
2608
+ when accessing fields of the pointed structure, otherwise the BPF program will
2609
+ be rejected.</ p >
2610
+ </ div >
2611
+ < div class ="listingblock ">
2612
+ < div class ="content ">
2613
+ < pre > interval:s:1 {
2614
+ $runqueues = (struct rq *)percpu_kaddr("runqueues", 0);
2615
+ if ($runqueues != 0) { // The check is mandatory here
2616
+ print($runqueues->nr_running);
2617
+ }
2618
+ }</ pre >
2619
+ </ div >
2620
+ </ div >
2621
+ </ div >
2622
+ < div class ="sect2 ">
2573
2623
< h3 id ="functions-print "> print</ h3 >
2574
2624
< div class ="ulist ">
2575
2625
< div class ="title "> variants</ div >
0 commit comments