From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.7 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A695BC3A5A3 for ; Tue, 27 Aug 2019 21:45:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 81DD6206E0 for ; Tue, 27 Aug 2019 21:45:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726566AbfH0Vpg (ORCPT ); Tue, 27 Aug 2019 17:45:36 -0400 Received: from mx0a-002e3701.pphosted.com ([148.163.147.86]:42884 "EHLO mx0a-002e3701.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725804AbfH0Vpg (ORCPT ); Tue, 27 Aug 2019 17:45:36 -0400 Received: from pps.filterd (m0150242.ppops.net [127.0.0.1]) by mx0a-002e3701.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x7RLavcB020692; Tue, 27 Aug 2019 21:44:27 GMT Received: from g9t5008.houston.hpe.com (g9t5008.houston.hpe.com [15.241.48.72]) by mx0a-002e3701.pphosted.com with ESMTP id 2un7hmj7nr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 27 Aug 2019 21:44:27 +0000 Received: from stormcage.eag.rdlabs.hpecorp.net (stormcage.eag.rdlabs.hpecorp.net [128.162.236.70]) by g9t5008.houston.hpe.com (Postfix) with ESMTP id 4A7B556; Tue, 27 Aug 2019 21:44:26 +0000 (UTC) Received: by stormcage.eag.rdlabs.hpecorp.net (Postfix, from userid 48777) id 14AC4201564D7; Tue, 27 Aug 2019 16:44:26 -0500 (CDT) From: Kyle Meyer Cc: Kyle Meyer , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-kernel@vger.kernel.org, Russ Anderson , Kyle Meyer Subject: [PATCH v4 5/7] perf/util/machine: Replace MAX_NR_CPUS with nr_cpus_online Date: Tue, 27 Aug 2019 16:43:50 -0500 Message-Id: <20190827214352.94272-6-meyerk@stormcage.eag.rdlabs.hpecorp.net> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20190827214352.94272-1-meyerk@stormcage.eag.rdlabs.hpecorp.net> References: <20190827214352.94272-1-meyerk@stormcage.eag.rdlabs.hpecorp.net> X-HPE-SCL: -1 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:5.22.84,1.0.8 definitions=2019-08-27_04:2019-08-27,2019-08-27 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 suspectscore=0 priorityscore=1501 malwarescore=0 adultscore=0 phishscore=0 impostorscore=0 bulkscore=0 mlxlogscore=999 mlxscore=0 spamscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1906280000 definitions=main-1908270202 To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Cc: Peter Zijlstra Cc: Ingo Molnar Cc: Arnaldo Carvalho de Melo Cc: Alexander Shishkin Cc: Jiri Olsa Cc: Namhyung Kim Cc: linux-kernel@vger.kernel.org Cc: Russ Anderson Signed-off-by: Kyle Meyer --- 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 5734460fc89e..194b9ec5f88b 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -2616,7 +2616,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]; @@ -2626,6 +2628,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; @@ -2633,14 +2636,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; -- 2.12.3