|
26 | 26 | #include "util/string2.h" |
27 | 27 |
|
28 | 28 | #include <linux/kernel.h> |
| 29 | +#include <linux/numa.h> |
29 | 30 | #include <linux/rbtree.h> |
30 | 31 | #include <linux/string.h> |
31 | 32 | #include <linux/zalloc.h> |
@@ -185,22 +186,33 @@ static int evsel__process_alloc_event(struct evsel *evsel, struct perf_sample *s |
185 | 186 | total_allocated += bytes_alloc; |
186 | 187 |
|
187 | 188 | nr_allocs++; |
188 | | - return 0; |
189 | | -} |
190 | 189 |
|
191 | | -static int evsel__process_alloc_node_event(struct evsel *evsel, struct perf_sample *sample) |
192 | | -{ |
193 | | - int ret = evsel__process_alloc_event(evsel, sample); |
| 190 | + /* |
| 191 | + * Commit 11e9734bcb6a ("mm/slab_common: unify NUMA and UMA |
| 192 | + * version of tracepoints") adds the field "node" into the |
| 193 | + * tracepoints 'kmalloc' and 'kmem_cache_alloc'. |
| 194 | + * |
| 195 | + * The legacy tracepoints 'kmalloc_node' and 'kmem_cache_alloc_node' |
| 196 | + * also contain the field "node". |
| 197 | + * |
| 198 | + * If the tracepoint contains the field "node" the tool stats the |
| 199 | + * cross allocation. |
| 200 | + */ |
| 201 | + if (evsel__field(evsel, "node")) { |
| 202 | + int node1, node2; |
194 | 203 |
|
195 | | - if (!ret) { |
196 | | - int node1 = cpu__get_node((struct perf_cpu){.cpu = sample->cpu}), |
197 | | - node2 = evsel__intval(evsel, sample, "node"); |
| 204 | + node1 = cpu__get_node((struct perf_cpu){.cpu = sample->cpu}); |
| 205 | + node2 = evsel__intval(evsel, sample, "node"); |
198 | 206 |
|
199 | | - if (node1 != node2) |
| 207 | + /* |
| 208 | + * If the field "node" is NUMA_NO_NODE (-1), we don't take it |
| 209 | + * as a cross allocation. |
| 210 | + */ |
| 211 | + if ((node2 != NUMA_NO_NODE) && (node1 != node2)) |
200 | 212 | nr_cross_allocs++; |
201 | 213 | } |
202 | 214 |
|
203 | | - return ret; |
| 215 | + return 0; |
204 | 216 | } |
205 | 217 |
|
206 | 218 | static int ptr_cmp(void *, void *); |
@@ -1369,8 +1381,8 @@ static int __cmd_kmem(struct perf_session *session) |
1369 | 1381 | /* slab allocator */ |
1370 | 1382 | { "kmem:kmalloc", evsel__process_alloc_event, }, |
1371 | 1383 | { "kmem:kmem_cache_alloc", evsel__process_alloc_event, }, |
1372 | | - { "kmem:kmalloc_node", evsel__process_alloc_node_event, }, |
1373 | | - { "kmem:kmem_cache_alloc_node", evsel__process_alloc_node_event, }, |
| 1384 | + { "kmem:kmalloc_node", evsel__process_alloc_event, }, |
| 1385 | + { "kmem:kmem_cache_alloc_node", evsel__process_alloc_event, }, |
1374 | 1386 | { "kmem:kfree", evsel__process_free_event, }, |
1375 | 1387 | { "kmem:kmem_cache_free", evsel__process_free_event, }, |
1376 | 1388 | /* page allocator */ |
|
0 commit comments