perf lock: Dynamically allocate lockhash_table
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@google.com> Link: https://lore.kernel.org/r/20230526183401.2326121-10-irogers@google.com Cc: K Prateek Nayak <kprateek.nayak@amd.com> Cc: Ravi Bangoria <ravi.bangoria@amd.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Ross Zwisler <zwisler@chromium.org> Cc: Steven Rostedt (Google) <rostedt@goodmis.org> Cc: Sean Christopherson <seanjc@google.com> Cc: Yang Jihong <yangjihong1@huawei.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Arnaldo Carvalho de Melo <acme@kernel.org> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Masami Hiramatsu (Google) <mhiramat@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Leo Yan <leo.yan@linaro.org> Cc: Andi Kleen <ak@linux.intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Kan Liang <kan.liang@linux.intel.com> Cc: Tiezhu Yang <yangtiezhu@loongson.cn> Cc: Ingo Molnar <mingo@redhat.com> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: linux-kernel@vger.kernel.org Cc: linux-perf-users@vger.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
92294b906e
commit
eef4fee5e5
1 changed files with 16 additions and 4 deletions
|
@ -48,7 +48,7 @@ static struct target target;
|
||||||
#define LOCKHASH_BITS 12
|
#define LOCKHASH_BITS 12
|
||||||
#define LOCKHASH_SIZE (1UL << LOCKHASH_BITS)
|
#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 __lockhashfn(key) hash_long((unsigned long)key, LOCKHASH_BITS)
|
||||||
#define lockhashentry(key) (lockhash_table + __lockhashfn((key)))
|
#define lockhashentry(key) (lockhash_table + __lockhashfn((key)))
|
||||||
|
@ -1871,7 +1871,6 @@ static int __cmd_contention(int argc, const char **argv)
|
||||||
};
|
};
|
||||||
struct lock_contention con = {
|
struct lock_contention con = {
|
||||||
.target = &target,
|
.target = &target,
|
||||||
.result = &lockhash_table[0],
|
|
||||||
.map_nr_entries = bpf_map_entries,
|
.map_nr_entries = bpf_map_entries,
|
||||||
.max_stack = max_stack_depth,
|
.max_stack = max_stack_depth,
|
||||||
.stack_skip = stack_skip,
|
.stack_skip = stack_skip,
|
||||||
|
@ -1880,10 +1879,17 @@ static int __cmd_contention(int argc, const char **argv)
|
||||||
.owner = show_lock_owner,
|
.owner = show_lock_owner,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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);
|
session = perf_session__new(use_bpf ? NULL : &data, &eops);
|
||||||
if (IS_ERR(session)) {
|
if (IS_ERR(session)) {
|
||||||
pr_err("Initializing perf session failed\n");
|
pr_err("Initializing perf session failed\n");
|
||||||
return PTR_ERR(session);
|
err = PTR_ERR(session);
|
||||||
|
goto out_delete;
|
||||||
}
|
}
|
||||||
|
|
||||||
con.machine = &session->machines.host;
|
con.machine = &session->machines.host;
|
||||||
|
@ -1983,6 +1989,7 @@ out_delete:
|
||||||
evlist__delete(con.evlist);
|
evlist__delete(con.evlist);
|
||||||
lock_contention_finish();
|
lock_contention_finish();
|
||||||
perf_session__delete(session);
|
perf_session__delete(session);
|
||||||
|
zfree(&lockhash_table);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2348,6 +2355,10 @@ int cmd_lock(int argc, const char **argv)
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
|
lockhash_table = calloc(LOCKHASH_SIZE, sizeof(*lockhash_table));
|
||||||
|
if (!lockhash_table)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
for (i = 0; i < LOCKHASH_SIZE; i++)
|
for (i = 0; i < LOCKHASH_SIZE; i++)
|
||||||
INIT_HLIST_HEAD(lockhash_table + i);
|
INIT_HLIST_HEAD(lockhash_table + i);
|
||||||
|
|
||||||
|
@ -2369,7 +2380,7 @@ int cmd_lock(int argc, const char **argv)
|
||||||
rc = __cmd_report(false);
|
rc = __cmd_report(false);
|
||||||
} else if (!strcmp(argv[0], "script")) {
|
} else if (!strcmp(argv[0], "script")) {
|
||||||
/* Aliased to 'perf script' */
|
/* Aliased to 'perf script' */
|
||||||
return cmd_script(argc, argv);
|
rc = cmd_script(argc, argv);
|
||||||
} else if (!strcmp(argv[0], "info")) {
|
} else if (!strcmp(argv[0], "info")) {
|
||||||
if (argc) {
|
if (argc) {
|
||||||
argc = parse_options(argc, argv,
|
argc = parse_options(argc, argv,
|
||||||
|
@ -2403,5 +2414,6 @@ int cmd_lock(int argc, const char **argv)
|
||||||
usage_with_options(lock_usage, lock_options);
|
usage_with_options(lock_usage, lock_options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
zfree(&lockhash_table);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue