Debian Codegraph @

doc/SystemTap_Beginners_Guide/testsuite/systemtap.maps/pmap_agg_overflow.stp

raw
1 # try to induce overflow of pmap aggregation
2 # (this will only work on smp machines)
3
4 global stat, count, pcpu_count, max_count
5
6 probe begin {
7 if (num_online_cpus() < 2) {
8 warn("This test only applies to smp systems...")
9 exit()
10 }
11 max_count = max_map_entries() + 1
12 }
13
14 probe kernel.function("sched_tick")!,
15 kernel.function("scheduler_tick") {
16 # Be sure not to overflow the percpu array
17 if (++pcpu_count[cpu()] > max_map_entries())
18 next
19
20 i = ++count
21 if (i <= max_count)
22 stat[i] <<< i
23 else
24 exit()
25 }
26
27 probe end {
28 # pmap aggregation should overflow here
29 foreach (i in stat)
30 printf("@count(stat[%d]) = %d\n", i, @count(stat[i]))
31 }
32
33 probe end {
34 # sorted pmap aggregation should overflow here
35 foreach (i+ in stat)
36 printf("@count(stat[%d]) = %d\n", i, @count(stat[i]))
37 }
38
39 function max_map_entries:long() %{
40 STAP_RETVALUE = MAXMAPENTRIES;
41 %}
42
43 function num_online_cpus:long() %{
44 STAP_RETVALUE = num_online_cpus();
45 %}