File: mmfilepage.stp

package info (click to toggle)
systemtap 5.1-5
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 47,964 kB
  • sloc: cpp: 80,838; ansic: 54,757; xml: 49,725; exp: 43,665; sh: 11,527; python: 5,003; perl: 2,252; tcl: 1,312; makefile: 1,006; javascript: 149; lisp: 105; awk: 101; asm: 91; java: 70; sed: 16
file content (101 lines) | stat: -rwxr-xr-x 2,711 bytes parent folder | download | duplicates (2)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#! /usr/bin/env stap
#
# filemap kernel tracepoints:
# mm_filemap_add_to_page_cache,
#   mm_filemap_delete_from_page_cache

global traced_pid, command
global allocation, free

global old_set_hits
global file_fault, file_cow, file_uunmap, file_kunmap
global file_page_cache_add, file_page_cache_delete

function log_event:long ()
{
  return (!traced_pid || traced_pid == pid())
}

probe kernel.{trace("mm_page_alloc")!, trace("mm_page_allocation")} {
  if (!log_event()) next
  allocation[pid()] <<< 1
  command[pid()] = execname()
}

probe kernel.{trace("mm_page_free")!, trace("mm_page_free_direct")} {
  if (!log_event()) next
  free[pid()] <<< 1
}

probe kernel.trace("mm_filemap_add_to_page_cache")? {
  if (!log_event()) next
  file_page_cache_add[pid()] <<< 1
}

probe kernel.trace("mm_filemap_delete_from_page_cache")? {
  if (!log_event()) next
  file_page_cache_delete[pid()] <<< 1
}

probe never {
  # Do a few initializations to let stap know what the global
  # variable types are. Note that since we're in a "never"
  # probe, these initializations will never actually happen.
  traced_pid = 0
  old_set_hits <<< 1
  file_fault[0] <<< 1
  file_cow[0] <<< 1
  file_uunmap[0] <<< 1
  file_kunmap[0] <<< 1
  file_page_cache_add[0] <<< 1
  file_page_cache_delete[0] <<< 1
}

probe begin {
  printf("Starting data collection\n")
  if (target())
    printf("mode Specific Pid, traced pid: %d\n\n", target())
  else
    printf("mode - All Pids\n\n")
}

function print_old_format:long ()
{
  printf("Command                 Pid     Alloc      Free  F_fault    F_cow F_kunmap F_uunmap\n")
  printf("-------                 ---     -----      ----  -------    ----- -------- --------\n")

  foreach (pid+ in allocation) {
      printf("%-16s %10d %9d %9d %8d %8d %8d %8d\n",
	     command[pid], pid,
	     @count(allocation[pid]), @count(free[pid]),
	     @count(file_fault[pid]), @count(file_cow[pid]),
	     @count(file_kunmap[pid]), @count(file_uunmap[pid]))
  }
}

function print_new_format:long ()
{
  printf("Command                 Pid     Alloc      Free CacheAdd CacheDel\n")
  printf("-------                 ---     -----      ---- -------- --------\n")

  foreach (pid+ in allocation) {
      printf("%-16s %10d %9d %9d %8d %8d\n",
	     command[pid], pid,
	     @count(allocation[pid]), @count(free[pid]),
	     @count(file_page_cache_add[pid]),
	     @count(file_page_cache_delete[pid]))
  }
}

probe end {
  printf("Terminating data collection\n")

  # We'll have hits from the filemap tracepoints
  # (mm_filemap_add_to_page_cache,
  # mm_filemap_delete_from_page_cache). Print out the set that got
  # hits.
  if (@count(old_set_hits))
    print_old_format()
  else
    print_new_format()
}