File: pmap_agg_overflow.stp

package info (click to toggle)
systemtap 2.6-0.2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 21,220 kB
  • ctags: 10,944
  • sloc: cpp: 53,239; ansic: 50,615; exp: 33,694; sh: 9,906; xml: 7,665; perl: 2,089; python: 1,534; tcl: 1,236; makefile: 797; java: 148; lisp: 104; awk: 94; asm: 91; sed: 16
file content (44 lines) | stat: -rw-r--r-- 987 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# try to induce overflow of pmap aggregation
#   (this will only work on smp machines)

global stat, count, pcpu_count, max_count

probe begin {
    if (num_online_cpus() < 2) {
        warn("This test only applies to smp systems...")
        exit()
    }
    max_count = max_map_entries() + 1
}

probe kernel.function("scheduler_tick") {
    # Be sure not to overflow the percpu array
    if (++pcpu_count[cpu()] > max_map_entries())
        next

    i = ++count
    if (i <= max_count)
        stat[i] <<< i
    else
        exit()
}

probe end {
    # pmap aggregation should overflow here
    foreach (i in stat)
        printf("@count(stat[%d]) = %d\n", i, @count(stat[i]))
}

probe end {
    # sorted pmap aggregation should overflow here
    foreach (i+ in stat)
        printf("@count(stat[%d]) = %d\n", i, @count(stat[i]))
}

function max_map_entries:long() %{
    STAP_RETVALUE = MAXMAPENTRIES;
%}

function num_online_cpus:long() %{
    STAP_RETVALUE = num_online_cpus();
%}