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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EE8D7C433FE for ; Mon, 28 Mar 2022 20:34:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244645AbiC1UgQ (ORCPT ); Mon, 28 Mar 2022 16:36:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346274AbiC1UeQ (ORCPT ); Mon, 28 Mar 2022 16:34:16 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BE6232EF8; Mon, 28 Mar 2022 13:32:35 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3A86D6149E; Mon, 28 Mar 2022 20:32:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 60CA1C340ED; Mon, 28 Mar 2022 20:32:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1648499554; bh=8+UTYWbVLgOBzCkQVECx2w9eUsJDkRhc8E5Y1Jz2ip0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=sPy/YTXkdJdSZVHLGbJfXwU8C0JLpFaTNvtev8+HV1HOtIxVNXr8isggfrPXodslo d5/r7Zn4lLeWOpZWcd6/rk9M00q9O4CdS79sdqlXOUUii20ZrQfqN71rPcBUHIPlXt /rEBLI07rQO8OI0qPBNmerM0KlAC0VQ41Z3LCJPahzAQtSjhlJAHJWqJ3PmGy4EGLn zoqohpSev54HbH7NZ3SaAfInKtZs3xSf7/XehKqj/XFM4yzbMcF4aWogKMRHdcrsdC 6Lwvr77bWO60aTj9DzWNDIyoBLUkno0z6EB7mdF7+Lxdk/b0X7KepLA0XELxwUDTAR twPi+mbwai4Mw== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 3A55E40407; Mon, 28 Mar 2022 17:32:31 -0300 (-03) Date: Mon, 28 Mar 2022 17:32:31 -0300 From: Arnaldo Carvalho de Melo To: Ian Rogers Cc: Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Mathieu Poirier , Suzuki K Poulose , Mike Leach , Leo Yan , John Garry , Will Deacon , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Kajol Jain , James Clark , German Gomez , Adrian Hunter , Riccardo Mancini , Andi Kleen , Alexey Bayduraev , Alexander Antonov , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, bpf@vger.kernel.org, Stephane Eranian Subject: Re: [PATCH 4/5] perf stat: Avoid segv if core.user_cpus isn't set. Message-ID: References: <20220328062414.1893550-1-irogers@google.com> <20220328062414.1893550-5-irogers@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220328062414.1893550-5-irogers@google.com> X-Url: http://acmel.wordpress.com Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org Em Sun, Mar 27, 2022 at 11:24:13PM -0700, Ian Rogers escreveu: > Passing null to perf_cpu_map__max doesn't make sense as there is no > valid max. Avoid this problem by null checking in > perf_stat_init_aggr_mode. Applying this one after changing user_cpus back to cpus as this is a fix independent of this patchset. In the future, please try to have such patches at the beginning of the series, so that they can get cherry-picked more easily. - Arnaldo > Signed-off-by: Ian Rogers > --- > tools/perf/builtin-stat.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c > index 5bee529f7656..ecd5cf4fd872 100644 > --- a/tools/perf/builtin-stat.c > +++ b/tools/perf/builtin-stat.c > @@ -1472,7 +1472,10 @@ static int perf_stat_init_aggr_mode(void) > * taking the highest cpu number to be the size of > * the aggregation translate cpumap. > */ > - nr = perf_cpu_map__max(evsel_list->core.user_cpus).cpu; > + if (evsel_list->core.user_cpus) > + nr = perf_cpu_map__max(evsel_list->core.user_cpus).cpu; > + else > + nr = 0; > stat_config.cpus_aggr_map = cpu_aggr_map__empty_new(nr + 1); > return stat_config.cpus_aggr_map ? 0 : -ENOMEM; > } > -- > 2.35.1.1021.g381101b075-goog -- - Arnaldo 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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8E317C433F5 for ; Mon, 28 Mar 2022 20:33:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=aGtB8BOFq4d0rh44FlZMvERP6R//3J441G0EC50ZMBA=; b=Hj5mmbKCzgk2gg dfgLdmbR/q8zyRg5TaaTtR9+2YL+skXIu2qG27cPD7UUW/nly424y92QAMgyV4dBcMbiYhKiCs64C WqHintNiWI+0nx3eV9MlXYbpghDIr0t1FetrXW+vElmax1kiv7Avgf6rArixRIgTeJEcHANnSDT21 P8fljKvVuRuiUj4QL7rS/8ph2ReN9na4nCqMC/jHxnK3LN38yf/Rny5mNgkzdE3ymLmvqDc33DbIl oRVNNnNr10WaewtY7x0rkGjeiGU5q8w33Km5zi8LPWr+ozSQ2WsiSEzPzHk0FPp2kAuBU3FCRPFqe aaYgKrIGhAnk3SikhuJw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nYw2W-00A5KU-QP; Mon, 28 Mar 2022 20:32:36 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nYw2V-00A5K5-5V for linux-arm-kernel@bombadil.infradead.org; Mon, 28 Mar 2022 20:32:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=5ayH9VdoRfyFRRCkwUFoqk1o0EvYeUpE6zCj/jfIqkc=; b=rhKKZv3/WF38YpfT5LnVFYC7o9 13yY1bpAQ0nXzUO7u1rWh06sOYSof8d5GfbYDRkw7PXmpo/YTuWyiTMY5xI260ZfPl+9FDPdTG+9z uSTF3X3IKZYBajk3lRT+NVIoIfKZoCqIhpjqMS52ao1XniqPO2iwVVdKneaJYj9BuK37SmH0zWm8s fA+PJGEvbgnvoBgoagysk77FAVVngLtdwjNhTm+byey3DwCgpY7KHEZvg2xGuhkS6kvnYqZaBmIwX 5CMleJq2M6Loj9CPJoa7AihsDmXO1VkQssDu0t/NCaYiSYM9R/LdlzMC9jJHWy/f8JmTKFn4Bc3WL t+04Sdaw==; Received: from [187.19.239.165] (helo=quaco.ghostprotocols.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nYw2T-00HFF7-Lw; Mon, 28 Mar 2022 20:32:33 +0000 Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 3A55E40407; Mon, 28 Mar 2022 17:32:31 -0300 (-03) Date: Mon, 28 Mar 2022 17:32:31 -0300 From: Arnaldo Carvalho de Melo To: Ian Rogers Cc: Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Mathieu Poirier , Suzuki K Poulose , Mike Leach , Leo Yan , John Garry , Will Deacon , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Kajol Jain , James Clark , German Gomez , Adrian Hunter , Riccardo Mancini , Andi Kleen , Alexey Bayduraev , Alexander Antonov , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, bpf@vger.kernel.org, Stephane Eranian Subject: Re: [PATCH 4/5] perf stat: Avoid segv if core.user_cpus isn't set. Message-ID: References: <20220328062414.1893550-1-irogers@google.com> <20220328062414.1893550-5-irogers@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220328062414.1893550-5-irogers@google.com> X-Url: http://acmel.wordpress.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Em Sun, Mar 27, 2022 at 11:24:13PM -0700, Ian Rogers escreveu: > Passing null to perf_cpu_map__max doesn't make sense as there is no > valid max. Avoid this problem by null checking in > perf_stat_init_aggr_mode. Applying this one after changing user_cpus back to cpus as this is a fix independent of this patchset. In the future, please try to have such patches at the beginning of the series, so that they can get cherry-picked more easily. - Arnaldo > Signed-off-by: Ian Rogers > --- > tools/perf/builtin-stat.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c > index 5bee529f7656..ecd5cf4fd872 100644 > --- a/tools/perf/builtin-stat.c > +++ b/tools/perf/builtin-stat.c > @@ -1472,7 +1472,10 @@ static int perf_stat_init_aggr_mode(void) > * taking the highest cpu number to be the size of > * the aggregation translate cpumap. > */ > - nr = perf_cpu_map__max(evsel_list->core.user_cpus).cpu; > + if (evsel_list->core.user_cpus) > + nr = perf_cpu_map__max(evsel_list->core.user_cpus).cpu; > + else > + nr = 0; > stat_config.cpus_aggr_map = cpu_aggr_map__empty_new(nr + 1); > return stat_config.cpus_aggr_map ? 0 : -ENOMEM; > } > -- > 2.35.1.1021.g381101b075-goog -- - Arnaldo _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel