mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-04 12:16:41 +00:00
perf kmem: Support field "node" in evsel__process_alloc_event() coping with recent tracepoint restructuring
[ Upstream commitdce088ab0d
] Commit11e9734bcb
("mm/slab_common: unify NUMA and UMA version of tracepoints") adds the field "node" into the tracepoints 'kmalloc' and 'kmem_cache_alloc', so this patch modifies the event process function to support the field "node". If field "node" is detected by checking function evsel__field(), it stats the cross allocation. When the "node" value is NUMA_NO_NODE (-1), it means the memory can be allocated from any memory node, in this case, we don't account it as a cross allocation. Fixes:11e9734bcb
("mm/slab_common: unify NUMA and UMA version of tracepoints") Reported-by: Ravi Bangoria <ravi.bangoria@amd.com> Reviewed-by: James Clark <james.clark@arm.com> Signed-off-by: Leo Yan <leo.yan@linaro.org> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Vlastimil Babka <vbabka@suse.cz> Link: https://lore.kernel.org/r/20230108062400.250690-2-leo.yan@linaro.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
4e81a8a47d
commit
8c3dc30061
@ -26,6 +26,7 @@
|
||||
#include "util/string2.h"
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/numa.h>
|
||||
#include <linux/rbtree.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/zalloc.h>
|
||||
@ -184,22 +185,33 @@ static int evsel__process_alloc_event(struct evsel *evsel, struct perf_sample *s
|
||||
total_allocated += bytes_alloc;
|
||||
|
||||
nr_allocs++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int evsel__process_alloc_node_event(struct evsel *evsel, struct perf_sample *sample)
|
||||
{
|
||||
int ret = evsel__process_alloc_event(evsel, sample);
|
||||
/*
|
||||
* Commit 11e9734bcb6a ("mm/slab_common: unify NUMA and UMA
|
||||
* version of tracepoints") adds the field "node" into the
|
||||
* tracepoints 'kmalloc' and 'kmem_cache_alloc'.
|
||||
*
|
||||
* The legacy tracepoints 'kmalloc_node' and 'kmem_cache_alloc_node'
|
||||
* also contain the field "node".
|
||||
*
|
||||
* If the tracepoint contains the field "node" the tool stats the
|
||||
* cross allocation.
|
||||
*/
|
||||
if (evsel__field(evsel, "node")) {
|
||||
int node1, node2;
|
||||
|
||||
if (!ret) {
|
||||
int node1 = cpu__get_node((struct perf_cpu){.cpu = sample->cpu}),
|
||||
node2 = evsel__intval(evsel, sample, "node");
|
||||
node1 = cpu__get_node((struct perf_cpu){.cpu = sample->cpu});
|
||||
node2 = evsel__intval(evsel, sample, "node");
|
||||
|
||||
if (node1 != node2)
|
||||
/*
|
||||
* If the field "node" is NUMA_NO_NODE (-1), we don't take it
|
||||
* as a cross allocation.
|
||||
*/
|
||||
if ((node2 != NUMA_NO_NODE) && (node1 != node2))
|
||||
nr_cross_allocs++;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ptr_cmp(void *, void *);
|
||||
@ -1368,8 +1380,8 @@ static int __cmd_kmem(struct perf_session *session)
|
||||
/* slab allocator */
|
||||
{ "kmem:kmalloc", evsel__process_alloc_event, },
|
||||
{ "kmem:kmem_cache_alloc", evsel__process_alloc_event, },
|
||||
{ "kmem:kmalloc_node", evsel__process_alloc_node_event, },
|
||||
{ "kmem:kmem_cache_alloc_node", evsel__process_alloc_node_event, },
|
||||
{ "kmem:kmalloc_node", evsel__process_alloc_event, },
|
||||
{ "kmem:kmem_cache_alloc_node", evsel__process_alloc_event, },
|
||||
{ "kmem:kfree", evsel__process_free_event, },
|
||||
{ "kmem:kmem_cache_free", evsel__process_free_event, },
|
||||
/* page allocator */
|
||||
|
Loading…
Reference in New Issue
Block a user