Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1588000rwr; Fri, 5 May 2023 17:09:15 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5XhhAuS1u8EfL42K3Zx4eUXd0Ezc7LiLOHCWFXqPuUL5KWsh7bu4dLGRdfpArEjp5SdqG3 X-Received: by 2002:aa7:8882:0:b0:643:5da1:d527 with SMTP id z2-20020aa78882000000b006435da1d527mr5081543pfe.27.1683331755327; Fri, 05 May 2023 17:09:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683331755; cv=none; d=google.com; s=arc-20160816; b=HtCN3sqyOwf+WzM20fGEtIqoWIpgvGh9/eanjfUeUwJ5qzudfCUlvf/lLnhzXqUbv8 0HJs6vszGYsGAwvjMKzvLILOoRhQv/MkLSBGt+0qDpl3KjWinn9pXzDUNFi2C0vWBXWi oGCJMPe9pWz2nwNl+WFOnF8onmSzXYsLeXCO/7huXyIY/ZO4K/rqx7QzJNnRe8FPMZrx r23KERciNR3sdg0FMLSAg6FqPgYBGBb85DNplnAsK3LkPtDzbkDmRnxVE+VmiO7ZanWm 6jf3prCWADutocCZglXuUXomYBZd8MZxTRUnYn8CF4ubzYW8rw0f53TC4fXxCWWmWnOr kstg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=jVtBfopYPkXyjpm4yer3i8+5DueYBfJXZm79nDr7Vb8=; b=XVZroevIwylyu5fPLA+S8mNGZjtakWWiRZYVWNu+nLwxBLQguJKfPfqNukV1lYM6UG dHqoxov53vVkWxeWWzCNaWbG+Qw9+NO/iyZ4bo75kKh5lTt2pwMJONvjuyIAWaJubgJE 6Xe4ahNf3cQQ4BKV40CqadWPATyhtq27V073Excx1QBVOcMkqFOTE7oTOMG4NgTemfZC fh7BClDVeN5kTTrLEVtO8q3fklltj5uaaGVacy3stKoL1f5HzHpvIB9Avw/2WPud3Khh PAfp//2nbB8PblG1HQAXt0RKHZQ8Cp8YGiUjo/t3CMTfCASm9ym82aE9fRl7hCa2097O PPng== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c198-20020a621ccf000000b0063d45a6d0e5si3341343pfc.17.2023.05.05.17.09.03; Fri, 05 May 2023 17:09:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232657AbjEEXne convert rfc822-to-8bit (ORCPT + 99 others); Fri, 5 May 2023 19:43:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229831AbjEEXnd (ORCPT ); Fri, 5 May 2023 19:43:33 -0400 Received: from mail-yw1-f170.google.com (mail-yw1-f170.google.com [209.85.128.170]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54E235FD9; Fri, 5 May 2023 16:43:32 -0700 (PDT) Received: by mail-yw1-f170.google.com with SMTP id 00721157ae682-55a8e9e2c53so22879967b3.1; Fri, 05 May 2023 16:43:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683330211; x=1685922211; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2x1tn4ecL7a7PZyU0NHPKD9PY3vOquBlEMbobtDzvuM=; b=A93/FvJv1FYbG/nolYa/F7ktpbKhtwrzy43ROIM2WvMNzNaYAbTSGlGuo+IMhn+fmu exlEo5f6cuWHuMuz6gXO5w90LPDUmdxnEofjFVlAIxYqOZrScKNlqbv3cO688X0UYbL3 SNbfcjxaIXq8CdThoe6qEoxHOch/WIebJt+7jeHfLveE5Vo6oJkXr6VUbsbgC1XT9tAa Zwjj/0tmQ3oMjw0yQ7w7HTIe7xf5/q+aRv+eaXbMxVlVQi6a2O6+xSdQliVR9k4QxQvk je7cgkzPi9FwnWQhiWH174rZ+CPCvmoOc/zKc+Yg2/keMEDsV5MBbeIMSjr3Rv0LZSMo wLrQ== X-Gm-Message-State: AC+VfDwodK3gldGpq2IMIGn7Hqkd2A+NlTIvpDhtxSscY3qXcMqamKWl 3us4X3V5slbPVfcjrJSdpfJ7VmBnD+SoU1yMjPg= X-Received: by 2002:a25:abe5:0:b0:ba1:b539:a39a with SMTP id v92-20020a25abe5000000b00ba1b539a39amr3430513ybi.6.1683330211398; Fri, 05 May 2023 16:43:31 -0700 (PDT) MIME-Version: 1.0 References: <83d6c6c05c54bf00c5a9df32ac160718efca0c7a.1683280603.git.sandipan.das@amd.com> In-Reply-To: <83d6c6c05c54bf00c5a9df32ac160718efca0c7a.1683280603.git.sandipan.das@amd.com> From: Namhyung Kim Date: Fri, 5 May 2023 16:43:20 -0700 Message-ID: Subject: Re: [PATCH 1/2] perf script: Skip aggregation for stat events To: Sandipan Das Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, acme@kernel.org, peterz@infradead.org, mingo@redhat.com, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@kernel.org, irogers@google.com, adrian.hunter@intel.com, terrelln@fb.com, ravi.bangoria@amd.com, ananth.narayan@amd.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On Fri, May 5, 2023 at 3:03 AM Sandipan Das wrote: > > The script command does not support aggregation modes by itself although > that can be achieved using post-processing scripts. Because of this, it > does not allocate memory for aggregated event values. > > Upon running perf stat record, the aggregation mode is set in the perf > data file. If the mode is AGGR_GLOBAL, the aggregated event values are > accessed and this leads to a segmentation fault since these were never > allocated to begin with. Set the mode to AGGR_NONE explicitly to avoid > this. > > E.g. > > $ perf stat record -e cycles true > $ perf script > > Before: > Segmentation fault (core dumped) > > After: > CPU THREAD VAL ENA RUN TIME EVENT > -1 231919 162831 362069 362069 935289 cycles:u > > Fixes: 8b76a3188b85 ("perf stat: Remove unused perf_counts.aggr field") > Signed-off-by: Sandipan Das > Cc: stable@vger.kernel.org # v6.2+ Acked-by: Namhyung Kim Thanks, Namhyung > --- > tools/perf/builtin-script.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c > index 006f522d0e7f..c57be48d65bb 100644 > --- a/tools/perf/builtin-script.c > +++ b/tools/perf/builtin-script.c > @@ -3647,6 +3647,13 @@ static int process_stat_config_event(struct perf_session *session __maybe_unused > union perf_event *event) > { > perf_event__read_stat_config(&stat_config, &event->stat_config); > + > + /* > + * Aggregation modes are not used since post-processing scripts are > + * supposed to take care of such requirements > + */ > + stat_config.aggr_mode = AGGR_NONE; > + > return 0; > } > > -- > 2.34.1 >