3 # Systemtap script to instrument the Samba gencache subsystem
7 # Instrument all smbd processes:
8 # # stap gencache.stp smbd
10 # Instrument all winbindd processes:
11 # # stap gencache.stp winbindd
13 # Instrument a specific smbd process:
14 # # stap -x PID gencache.stp smbd
16 # Instrument a specific winbindd process:
17 # # stap -x PID gencache.stp winbindd
20 global running, intervals
21 global cache_misses, cache_hits, neg_cache_hits
24 printf("Collecting data, press ctrl-C to stop... ")
27 probe process(@1).library("*").function("gencache_parse") {
28 running["gencache_parse", tid()] = gettimeofday_us()
31 probe process(@1).library("*").function("gencache_parse").return {
32 if (!(["gencache_parse", tid()] in running))
35 end = gettimeofday_us()
36 begin = running["gencache_parse", tid()]
37 delete running["gencache_parse", tid()]
39 duration = end - begin
40 intervals["gencache_parse"] <<< duration
49 probe process(@1).library("*").function("gencache_get_data_blob_parser") {
55 probe process(@1).library("*").function("gencache_get_data_blob") {
56 running["gencache_get_data_blob", tid()] = gettimeofday_us()
59 probe process(@1).library("*").function("gencache_get_data_blob").return {
60 if (!(["gencache_get_data_blob", tid()] in running))
63 end = gettimeofday_us()
64 begin = running["gencache_get_data_blob", tid()]
65 delete running["gencache_get_data_blob", tid()]
67 duration = end - begin
68 intervals["gencache_get_data_blob"] <<< duration
71 probe process(@1).library("*").function("gencache_set_data_blob") {
72 running["gencache_set_data_blob", tid()] = gettimeofday_us()
75 probe process(@1).library("*").function("gencache_set_data_blob").return {
76 if (!(["gencache_set_data_blob", tid()] in running))
79 end = gettimeofday_us()
80 begin = running["gencache_set_data_blob", tid()]
81 delete running["gencache_set_data_blob", tid()]
83 duration = end - begin
84 intervals["gencache_set_data_blob"] <<< duration
87 probe process(@1).library("*").function("gencache_del") {
88 running["gencache_del", tid()] = gettimeofday_us()
91 probe process(@1).library("*").function("gencache_del").return {
92 if (!(["gencache_del", tid()] in running))
95 end = gettimeofday_us()
96 begin = running["gencache_del", tid()]
97 delete running["gencache_del", tid()]
99 duration = end - begin
100 intervals["gencache_del"] <<< duration
103 probe process(@1).library("*").function("gencache_stabilize") {
104 running["gencache_stabilize", tid()] = gettimeofday_us()
107 probe process(@1).library("*").function("gencache_stabilize").return {
108 if (!(["gencache_stabilize", tid()] in running))
111 end = gettimeofday_us()
112 begin = running["gencache_stabilize", tid()]
113 delete running["gencache_stabilize", tid()]
115 duration = end - begin
116 intervals["gencache_stabilize"] <<< duration
122 printf("Summary of cache access stats\n")
123 printf("=============================\n\n")
124 printf("%-10s %-10s %-10s\n",
125 "Hits", "Misses", "Negative-Hits");
126 printf("--------------------------------------\n")
127 printf("%-10d %-10d %-10d\n",
128 cache_hits, cache_misses, neg_cache_hits);
132 foreach ([name] in intervals) {
133 printf("%-30s count: %d sum: %d us (min: %d us avg: %d us max: %d us)\n",
135 @count(intervals[name]),
136 @sum(intervals[name]),
137 @min(intervals[name]),
138 @avg(intervals[name]),
139 @max(intervals[name]))
143 foreach ([name] in intervals) {
144 printf("%s time distribution histogram:\n", name)
145 println(@hist_log(intervals[name]))