[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241014141244.466609490@linuxfoundation.org>
Date: Mon, 14 Oct 2024 16:20:26 +0200
From: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To: stable@...r.kernel.org
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
patches@...ts.linux.dev,
Ian Rogers <irogers@...gle.com>,
K Prateek Nayak <kprateek.nayak@....com>,
Ravi Bangoria <ravi.bangoria@....com>,
Mark Rutland <mark.rutland@....com>,
Ross Zwisler <zwisler@...omium.org>,
"Steven Rostedt (Google)" <rostedt@...dmis.org>,
Sean Christopherson <seanjc@...gle.com>,
Yang Jihong <yangjihong1@...wei.com>,
Peter Zijlstra <peterz@...radead.org>,
Adrian Hunter <adrian.hunter@...el.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Jiri Olsa <jolsa@...nel.org>,
"Masami Hiramatsu (Google)" <mhiramat@...nel.org>,
Namhyung Kim <namhyung@...nel.org>,
Leo Yan <leo.yan@...aro.org>,
Andi Kleen <ak@...ux.intel.com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Kan Liang <kan.liang@...ux.intel.com>,
Tiezhu Yang <yangtiezhu@...ngson.cn>,
Ingo Molnar <mingo@...hat.com>,
Paolo Bonzini <pbonzini@...hat.com>,
linux-kernel@...r.kernel.org,
linux-perf-users@...r.kernel.org,
Arnaldo Carvalho de Melo <acme@...hat.com>,
Sasha Levin <sashal@...nel.org>
Subject: [PATCH 6.1 672/798] perf lock: Dynamically allocate lockhash_table
6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <irogers@...gle.com>
[ Upstream commit eef4fee5e52071d563d9a851df1c09869215ee15 ]
lockhash_table is 32,768 bytes in .bss, make it a memory allocation so
that the space is freed for non-lock perf commands.
Signed-off-by: Ian Rogers <irogers@...gle.com>
Link: https://lore.kernel.org/r/20230526183401.2326121-10-irogers@google.com
Cc: K Prateek Nayak <kprateek.nayak@....com>
Cc: Ravi Bangoria <ravi.bangoria@....com>
Cc: Mark Rutland <mark.rutland@....com>
Cc: Ross Zwisler <zwisler@...omium.org>
Cc: Steven Rostedt (Google) <rostedt@...dmis.org>
Cc: Sean Christopherson <seanjc@...gle.com>
Cc: Yang Jihong <yangjihong1@...wei.com>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: Adrian Hunter <adrian.hunter@...el.com>
Cc: Arnaldo Carvalho de Melo <acme@...nel.org>
Cc: Jiri Olsa <jolsa@...nel.org>
Cc: Masami Hiramatsu (Google) <mhiramat@...nel.org>
Cc: Namhyung Kim <namhyung@...nel.org>
Cc: Leo Yan <leo.yan@...aro.org>
Cc: Andi Kleen <ak@...ux.intel.com>
Cc: Alexander Shishkin <alexander.shishkin@...ux.intel.com>
Cc: Kan Liang <kan.liang@...ux.intel.com>
Cc: Tiezhu Yang <yangtiezhu@...ngson.cn>
Cc: Ingo Molnar <mingo@...hat.com>
Cc: Paolo Bonzini <pbonzini@...hat.com>
Cc: linux-kernel@...r.kernel.org
Cc: linux-perf-users@...r.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.com>
Stable-dep-of: 1a5efc9e13f3 ("libsubcmd: Don't free the usage string")
Signed-off-by: Sasha Levin <sashal@...nel.org>
---
tools/perf/builtin-lock.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c
index 470106643ed52..28fa76ecc0822 100644
--- a/tools/perf/builtin-lock.c
+++ b/tools/perf/builtin-lock.c
@@ -45,7 +45,7 @@ static struct target target;
#define LOCKHASH_BITS 12
#define LOCKHASH_SIZE (1UL << LOCKHASH_BITS)
-static struct hlist_head lockhash_table[LOCKHASH_SIZE];
+static struct hlist_head *lockhash_table;
#define __lockhashfn(key) hash_long((unsigned long)key, LOCKHASH_BITS)
#define lockhashentry(key) (lockhash_table + __lockhashfn((key)))
@@ -1645,16 +1645,22 @@ static int __cmd_contention(int argc, const char **argv)
};
struct lock_contention con = {
.target = &target,
- .result = &lockhash_table[0],
.map_nr_entries = bpf_map_entries,
.max_stack = max_stack_depth,
.stack_skip = stack_skip,
};
+ lockhash_table = calloc(LOCKHASH_SIZE, sizeof(*lockhash_table));
+ if (!lockhash_table)
+ return -ENOMEM;
+
+ con.result = &lockhash_table[0];
+
session = perf_session__new(use_bpf ? NULL : &data, &eops);
if (IS_ERR(session)) {
pr_err("Initializing perf session failed\n");
- return PTR_ERR(session);
+ err = PTR_ERR(session);
+ goto out_delete;
}
con.machine = &session->machines.host;
@@ -1755,6 +1761,7 @@ static int __cmd_contention(int argc, const char **argv)
evlist__delete(con.evlist);
lock_contention_finish();
perf_session__delete(session);
+ zfree(&lockhash_table);
return err;
}
@@ -1946,6 +1953,10 @@ int cmd_lock(int argc, const char **argv)
unsigned int i;
int rc = 0;
+ lockhash_table = calloc(LOCKHASH_SIZE, sizeof(*lockhash_table));
+ if (!lockhash_table)
+ return -ENOMEM;
+
for (i = 0; i < LOCKHASH_SIZE; i++)
INIT_HLIST_HEAD(lockhash_table + i);
@@ -1967,7 +1978,7 @@ int cmd_lock(int argc, const char **argv)
rc = __cmd_report(false);
} else if (!strcmp(argv[0], "script")) {
/* Aliased to 'perf script' */
- return cmd_script(argc, argv);
+ rc = cmd_script(argc, argv);
} else if (!strcmp(argv[0], "info")) {
if (argc) {
argc = parse_options(argc, argv,
@@ -1996,5 +2007,6 @@ int cmd_lock(int argc, const char **argv)
usage_with_options(lock_usage, lock_options);
}
+ zfree(&lockhash_table);
return rc;
}
--
2.43.0
Powered by blists - more mailing lists