[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <156741218504.17280.8058375020426111095.tip-bot2@tip-bot2>
Date: Mon, 02 Sep 2019 08:16:25 -0000
From: "tip-bot2 for Kyle Meyer" <tip-bot2@...utronix.de>
To: linux-tip-commits@...r.kernel.org
Cc: Kyle Meyer <kyle.meyer@....com>, Jiri Olsa <jolsa@...hat.com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Namhyung Kim <namhyung@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
Russ Anderson <russ.anderson@....com>,
Arnaldo Carvalho de Melo <acme@...hat.com>,
Ingo Molnar <mingo@...nel.org>, Borislav Petkov <bp@...en8.de>,
linux-kernel@...r.kernel.org
Subject: [tip: perf/core] perf machine: Replace MAX_NR_CPUS with
perf_env::nr_cpus_online
The following commit has been merged into the perf/core branch of tip:
Commit-ID: 8c7274691f0de5fb56f3b9fe9208ce7e515a2d2c
Gitweb: https://git.kernel.org/tip/8c7274691f0de5fb56f3b9fe9208ce7e515a2d2c
Author: Kyle Meyer <meyerk@....com>
AuthorDate: Tue, 27 Aug 2019 16:43:50 -05:00
Committer: Arnaldo Carvalho de Melo <acme@...hat.com>
CommitterDate: Thu, 29 Aug 2019 17:38:32 -03:00
perf machine: Replace MAX_NR_CPUS with perf_env::nr_cpus_online
nr_cpus, the number of CPUs online during a record session bound by
MAX_NR_CPUS, can be used as a dynamic alternative for MAX_NR_CPUS in
__machine__synthesize_threads and machine__set_current_tid.
Signed-off-by: Kyle Meyer <kyle.meyer@....com>
Reviewed-by: Jiri Olsa <jolsa@...hat.com>
Cc: Alexander Shishkin <alexander.shishkin@...ux.intel.com>
Cc: Namhyung Kim <namhyung@...nel.org>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: Russ Anderson <russ.anderson@....com>
Link: http://lore.kernel.org/lkml/20190827214352.94272-6-meyerk@stormcage.eag.rdlabs.hpecorp.net
Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.com>
---
tools/perf/util/machine.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 93483f1..a1542b4 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -2619,7 +2619,9 @@ int __machine__synthesize_threads(struct machine *machine, struct perf_tool *too
pid_t machine__get_current_tid(struct machine *machine, int cpu)
{
- if (cpu < 0 || cpu >= MAX_NR_CPUS || !machine->current_tid)
+ int nr_cpus = min(machine->env->nr_cpus_online, MAX_NR_CPUS);
+
+ if (cpu < 0 || cpu >= nr_cpus || !machine->current_tid)
return -1;
return machine->current_tid[cpu];
@@ -2629,6 +2631,7 @@ int machine__set_current_tid(struct machine *machine, int cpu, pid_t pid,
pid_t tid)
{
struct thread *thread;
+ int nr_cpus = min(machine->env->nr_cpus_online, MAX_NR_CPUS);
if (cpu < 0)
return -EINVAL;
@@ -2636,14 +2639,14 @@ int machine__set_current_tid(struct machine *machine, int cpu, pid_t pid,
if (!machine->current_tid) {
int i;
- machine->current_tid = calloc(MAX_NR_CPUS, sizeof(pid_t));
+ machine->current_tid = calloc(nr_cpus, sizeof(pid_t));
if (!machine->current_tid)
return -ENOMEM;
- for (i = 0; i < MAX_NR_CPUS; i++)
+ for (i = 0; i < nr_cpus; i++)
machine->current_tid[i] = -1;
}
- if (cpu >= MAX_NR_CPUS) {
+ if (cpu >= nr_cpus) {
pr_err("Requested CPU %d too large. ", cpu);
pr_err("Consider raising MAX_NR_CPUS\n");
return -EINVAL;
Powered by blists - more mailing lists