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 E81D6C433EF for ; Mon, 28 Mar 2022 20:47:57 +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:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=raBxnbNpp+H9A9Nyp7BlRtkjTXmm976yFGcNKiuc6Bo=; b=wQXN3bSBxIeXu7 Ur19cF4UKrmPIJUBUSYeSPRB3SdCW49yuap8pK6cd1+oP5PL80WjDHYVPg9uev9SQuKbTQ9SwU2Ra 6H8ahpYpgBheAYtiDtQ9/xf0WO1RY2udPHN74LBV36SikPoKxKdK5tinFAw82cKOx1O2/n11YqU2Y rZS4sg660NUdr1qNnpbGMEZwGqGQJf6ct0etCWz9MxLjLS6uGjLJTR0bmywNAq7GlwHviAbAUPZO6 zEli/0FHtKINPAQntrvw8hCDgH/zOywIpwaPqloGrz+bSeaAkj3otrEFRXRnXWlEz4ps11Tjuud1t /Gq8yZnmqzgGB/h0ki+g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nYwGG-00A8bH-V9; Mon, 28 Mar 2022 20:46:49 +0000 Received: from mail-vs1-xe30.google.com ([2607:f8b0:4864:20::e30]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nYwGE-00A8YI-4d for linux-arm-kernel@lists.infradead.org; Mon, 28 Mar 2022 20:46:47 +0000 Received: by mail-vs1-xe30.google.com with SMTP id t123so17015504vst.13 for ; Mon, 28 Mar 2022 13:46:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=XsQUCW+gJbF0u5yR61fkU3TsOCnzNiiW+Vxpx9INrJc=; b=MNDWq16FFczuLNyJYyOX7vHHTdWA2Wu9kBX8qv46n3K741rT37IeIbD5nIaONQCbZw ykDGIGbG84boAlB7ETuwBxvrdxO+W+mgFtJ62oabT7/6qxVREQR3w7OLi7valopAvXDs AV7VBcy2wlN3N6BksJRwTutIU587j9Y07p2fp50UjdbZoG4WdtCzvC30Y8HTOdESgA+w 0VVUlhmtXEPzAgba0s1aNVkRTMFb72tQDKquGKo/uMscY8thjFyOoFsVZ/92RXSwejP0 1RumF0DEYGBBRUsTdmmR9HLRx5PFijQywtx0AE7xJFZqYlsuJfLcyUGEm8N36jj/I/uo 1OyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=XsQUCW+gJbF0u5yR61fkU3TsOCnzNiiW+Vxpx9INrJc=; b=ODQLrFr/aVbAnSo2ccUfvJjyQd9MwvB4sgate+ZTAQiUp2BVIkOKMJvPNNUhy3Vaoo BUeZvQxBlqBnl/FqsWIiAX07D5tkfA2O7l+zBbpsaNMfflb2QSfrXDTjURjEGfP3xBpk GhmvReIlvBw4t+9ZySZwcu+1rDHMtBUS5YsGebtKv0mT6s55vX+sGqwcWMytdOgnEJFd RKmN/sm5cVttU6+pKsCFsDYmJJNA8qprbYRTB9BjzZXF5QwkTWJdmAbUi1bexQrtEZgV AZf7PIWc558eS+e4n+T4tOlxwb6n8Y/vMZnZo3jAIxzOsnsE6apC3LaAR2jXwc5xfqkN yh2g== X-Gm-Message-State: AOAM532hQiN3mKzO6Kml74dLM7R6dd+cnPpRs9MUu/qWUiT1vqY75RIP UegLEbocQ6HRhZ/hCKNFit3jl6pR53YCsQic/R8Gtg== X-Google-Smtp-Source: ABdhPJzzdXoVPaMj6oTX3qrkIGyEHAVu69MNP7vNBnLGNfBJAsNqF3ReaFVP6i9HdVRszInntBnpHH+cIw0gdA37t+k= X-Received: by 2002:a05:6102:c8b:b0:325:983f:9862 with SMTP id f11-20020a0561020c8b00b00325983f9862mr5858756vst.74.1648500401268; Mon, 28 Mar 2022 13:46:41 -0700 (PDT) MIME-Version: 1.0 References: <20220328062414.1893550-1-irogers@google.com> <20220328062414.1893550-5-irogers@google.com> In-Reply-To: From: Ian Rogers Date: Mon, 28 Mar 2022 13:46:29 -0700 Message-ID: Subject: Re: [PATCH 4/5] perf stat: Avoid segv if core.user_cpus isn't set. To: Arnaldo Carvalho de Melo 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220328_134646_188302_10B5E7F5 X-CRM114-Status: GOOD ( 26.89 ) 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 On Mon, Mar 28, 2022 at 1:32 PM Arnaldo Carvalho de Melo wrote: > > 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. Ack. The problem is best exhibited when the intersect happens, without it getting a reproducer wasn't something I was able to do. Thanks, Ian > - 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 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 28EFFC433EF for ; Mon, 28 Mar 2022 20:49:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345729AbiC1Uuz (ORCPT ); Mon, 28 Mar 2022 16:50:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346396AbiC1Usg (ORCPT ); Mon, 28 Mar 2022 16:48:36 -0400 Received: from mail-vs1-xe33.google.com (mail-vs1-xe33.google.com [IPv6:2607:f8b0:4864:20::e33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E6EF4D621 for ; Mon, 28 Mar 2022 13:46:42 -0700 (PDT) Received: by mail-vs1-xe33.google.com with SMTP id o67so17072412vsc.0 for ; Mon, 28 Mar 2022 13:46:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=XsQUCW+gJbF0u5yR61fkU3TsOCnzNiiW+Vxpx9INrJc=; b=MNDWq16FFczuLNyJYyOX7vHHTdWA2Wu9kBX8qv46n3K741rT37IeIbD5nIaONQCbZw ykDGIGbG84boAlB7ETuwBxvrdxO+W+mgFtJ62oabT7/6qxVREQR3w7OLi7valopAvXDs AV7VBcy2wlN3N6BksJRwTutIU587j9Y07p2fp50UjdbZoG4WdtCzvC30Y8HTOdESgA+w 0VVUlhmtXEPzAgba0s1aNVkRTMFb72tQDKquGKo/uMscY8thjFyOoFsVZ/92RXSwejP0 1RumF0DEYGBBRUsTdmmR9HLRx5PFijQywtx0AE7xJFZqYlsuJfLcyUGEm8N36jj/I/uo 1OyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=XsQUCW+gJbF0u5yR61fkU3TsOCnzNiiW+Vxpx9INrJc=; b=b6QJyZ335RkJtjhubY7t44jF6CTto+sKCTTPESkWOkPfsqFjO4cfpQDfDUa/4GKGEk Lx/kg7M8CEq/kGmqYKmj0+qtJ+Gw3IUczOfoD635Of8g3EKdgKnz7tpInd5m6xKThX0o YW8np/7M61qjoC42/N39nNJGvUgwgSAlRsuTO3v1GSyLKqL3UubCXwBYr1FrQjU1DcsK Y4gGrjymIIovXxHBtoyV+wqQlDEZNIDRsvi1do8n8Cpzv8UzKFTODXw8W9oTUzSgdoBS 2AMlEXgmdCP7dVmD8EJD1+EMvYasn9ftEQwB3Ai1PRYcEvix+gVmH2xklA0d/ml0BSog cY3g== X-Gm-Message-State: AOAM530UopKmJHVeBJz6kXibT3fg8hIUYZENAlBr+IIhTeqNuMn7loLS +KW6USPpy0LgNw+XwjvAhlAuDqMdzui9+RXc00B9+w== X-Google-Smtp-Source: ABdhPJzzdXoVPaMj6oTX3qrkIGyEHAVu69MNP7vNBnLGNfBJAsNqF3ReaFVP6i9HdVRszInntBnpHH+cIw0gdA37t+k= X-Received: by 2002:a05:6102:c8b:b0:325:983f:9862 with SMTP id f11-20020a0561020c8b00b00325983f9862mr5858756vst.74.1648500401268; Mon, 28 Mar 2022 13:46:41 -0700 (PDT) MIME-Version: 1.0 References: <20220328062414.1893550-1-irogers@google.com> <20220328062414.1893550-5-irogers@google.com> In-Reply-To: From: Ian Rogers Date: Mon, 28 Mar 2022 13:46:29 -0700 Message-ID: Subject: Re: [PATCH 4/5] perf stat: Avoid segv if core.user_cpus isn't set. To: Arnaldo Carvalho de Melo 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 Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 28, 2022 at 1:32 PM Arnaldo Carvalho de Melo wrote: > > 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. Ack. The problem is best exhibited when the intersect happens, without it getting a reproducer wasn't something I was able to do. Thanks, Ian > - 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