Skip to content

Commit b371910

Browse files
Leo Yanacmel
authored andcommitted
perf kmem: Support legacy tracepoints
Commit 11e9734 ("mm/slab_common: unify NUMA and UMA version of tracepoints") removed tracepoints 'kmalloc_node' and 'kmem_cache_alloc_node', we need to consider the tool should be backward compatible. If it detect the tracepoint "kmem:kmalloc_node", this patch enables the legacy tracepoints, otherwise, it will ignore them. Fixes: 11e9734 ("mm/slab_common: unify NUMA and UMA version of tracepoints") Reported-by: Ravi Bangoria <[email protected]> Reviewed-by: James Clark <[email protected]> Signed-off-by: Leo Yan <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Hyeonggon Yoo <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Vlastimil Babka <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent d891f2b commit b371910

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

tools/perf/builtin-kmem.c

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1824,29 +1824,48 @@ static int parse_line_opt(const struct option *opt __maybe_unused,
18241824
return 0;
18251825
}
18261826

1827+
static bool slab_legacy_tp_is_exposed(void)
1828+
{
1829+
/*
1830+
* The tracepoints "kmem:kmalloc_node" and
1831+
* "kmem:kmem_cache_alloc_node" have been removed on the latest
1832+
* kernel, if the tracepoint "kmem:kmalloc_node" is existed it
1833+
* means the tool is running on an old kernel, we need to
1834+
* rollback to support these legacy tracepoints.
1835+
*/
1836+
return IS_ERR(trace_event__tp_format("kmem", "kmalloc_node")) ?
1837+
false : true;
1838+
}
1839+
18271840
static int __cmd_record(int argc, const char **argv)
18281841
{
18291842
const char * const record_args[] = {
18301843
"record", "-a", "-R", "-c", "1",
18311844
};
18321845
const char * const slab_events[] = {
18331846
"-e", "kmem:kmalloc",
1834-
"-e", "kmem:kmalloc_node",
18351847
"-e", "kmem:kfree",
18361848
"-e", "kmem:kmem_cache_alloc",
1837-
"-e", "kmem:kmem_cache_alloc_node",
18381849
"-e", "kmem:kmem_cache_free",
18391850
};
1851+
const char * const slab_legacy_events[] = {
1852+
"-e", "kmem:kmalloc_node",
1853+
"-e", "kmem:kmem_cache_alloc_node",
1854+
};
18401855
const char * const page_events[] = {
18411856
"-e", "kmem:mm_page_alloc",
18421857
"-e", "kmem:mm_page_free",
18431858
};
18441859
unsigned int rec_argc, i, j;
18451860
const char **rec_argv;
1861+
unsigned int slab_legacy_tp_exposed = slab_legacy_tp_is_exposed();
18461862

18471863
rec_argc = ARRAY_SIZE(record_args) + argc - 1;
1848-
if (kmem_slab)
1864+
if (kmem_slab) {
18491865
rec_argc += ARRAY_SIZE(slab_events);
1866+
if (slab_legacy_tp_exposed)
1867+
rec_argc += ARRAY_SIZE(slab_legacy_events);
1868+
}
18501869
if (kmem_page)
18511870
rec_argc += ARRAY_SIZE(page_events) + 1; /* for -g */
18521871

@@ -1861,6 +1880,10 @@ static int __cmd_record(int argc, const char **argv)
18611880
if (kmem_slab) {
18621881
for (j = 0; j < ARRAY_SIZE(slab_events); j++, i++)
18631882
rec_argv[i] = strdup(slab_events[j]);
1883+
if (slab_legacy_tp_exposed) {
1884+
for (j = 0; j < ARRAY_SIZE(slab_legacy_events); j++, i++)
1885+
rec_argv[i] = strdup(slab_legacy_events[j]);
1886+
}
18641887
}
18651888
if (kmem_page) {
18661889
rec_argv[i++] = strdup("-g");

0 commit comments

Comments
 (0)