Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp2583764rdg; Mon, 14 Aug 2023 07:12:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFNstLgx8w9xjQHBSBY+ZIrlvfbJpAc8D/zf1U/lIK06n9CITCBPEe8s37635uioudRJoRK X-Received: by 2002:a05:6808:2a59:b0:3a7:385d:2911 with SMTP id fa25-20020a0568082a5900b003a7385d2911mr6941989oib.35.1692022365006; Mon, 14 Aug 2023 07:12:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692022364; cv=none; d=google.com; s=arc-20160816; b=fbINFIr4JD4uJkIFuAycgH/mn9dJH/S1EIJTb/MGupRG+kTpzpxACbWo982qmTLlhX CseVVKDV5FpMpevfmxU0tCqJxei/Wvc9pCT9hw1Qm3TN5+J/njqoePZDyacOvoUvours wEJ2TCdmQAGpDD4f+Kdl6tvFZrHuM7K/xH6qzkkstVozTU5C1WGzf/z5ksNnvCB55UoY s1RbnQmBdDHHuo230BXy6Roxr6pvjbg2zlbkoEBTK6G+5fCOB1OLsifQCkF/kAlTK5Ot cMJIYaZQIKtqYl7gKVs9fAwphIyboEJRKr3QEl/Ryy23N2Wyh+Dv8jKUqi7j+I+IrgTV rcAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id; bh=svKQKMBhJFuAoodD0s5NiiQajoISlwJoaV5iKs2JMNA=; fh=s6T/eZZO41zqLwSFX/tOOKztAdn9CTXnbg++oScbKfE=; b=YB/g/H0oa9RenPziB69LtDWDjJBvPvisOsMemXYTue4Fei3Wv+v2Wbx5uoBb0jv0MY /basHS0wVmyzW7yg/q8P1xX9Y5nnLJFEiUdh+kHAZabbbh9XBK1/unXj0M5Ifq7p6iFQ cqYBF7M2nFUfhyzwuvqsUgrDtV0wiv10bP1JVk1LzNYK1LP/gIMrSpOxNND/jvzdLJsJ 4YXiLZuShI40kkn9FSDoSL7q47J2W/0kwzdvaQCm8n3pD33NTB6p9y9tJTxq49U+4jl0 fcrcEOwlaVQG+St0IfUg07LduWH+2CahhYAESh4oS34i9JKjVIgkXquSV/xp+zGJfYG0 KUBg== 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z2-20020a63e542000000b0056418c0864csi8068229pgj.456.2023.08.14.07.12.32; Mon, 14 Aug 2023 07:12:44 -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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231577AbjHNNoY (ORCPT + 99 others); Mon, 14 Aug 2023 09:44:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231845AbjHNNoV (ORCPT ); Mon, 14 Aug 2023 09:44:21 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 03830171D; Mon, 14 Aug 2023 06:44:10 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id ED16F1063; Mon, 14 Aug 2023 06:44:51 -0700 (PDT) Received: from [10.57.3.178] (unknown [10.57.3.178]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 925953F64C; Mon, 14 Aug 2023 06:44:06 -0700 (PDT) Message-ID: Date: Mon, 14 Aug 2023 14:44:05 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [PATCH v5 5/6] perf vendor events arm64: Update stall_slot workaround for N2 r0p3 To: John Garry , linux-perf-users@vger.kernel.org, irogers@google.com, renyu.zj@linux.alibaba.com Cc: Will Deacon , Mike Leach , Leo Yan , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Adrian Hunter , Suzuki K Poulose , Kan Liang , Kajol Jain , Nick Forrington , Eduard Zingerman , Sohom Datta , Rob Herring , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org References: <20230811144017.491628-1-james.clark@arm.com> <20230811144017.491628-6-james.clark@arm.com> <8a4ebdbc-c2c9-9f61-329f-8fd235f5f65c@oracle.com> Content-Language: en-US From: James Clark In-Reply-To: <8a4ebdbc-c2c9-9f61-329f-8fd235f5f65c@oracle.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.5 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE autolearn=ham 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 On 14/08/2023 14:02, John Garry wrote: > >>     try: >>       parsed = ast.parse(py, mode='eval') >>     except SyntaxError as e: >> diff --git a/tools/perf/util/expr.c b/tools/perf/util/expr.c >> index 7410a165f68b..0985a3cbc6f9 100644 >> --- a/tools/perf/util/expr.c >> +++ b/tools/perf/util/expr.c >> @@ -13,6 +13,8 @@ >>   #include >>   #include >>   #include "util/hashmap.h" >> +#include "util/header.h" >> +#include "util/pmu.h" >>   #include "smt.h" >>   #include "tsc.h" >>   #include >> @@ -495,3 +497,19 @@ double expr__has_event(const struct >> expr_parse_ctx *ctx, bool compute_ids, const >>       evlist__delete(tmp); >>       return ret; >>   } >> + >> +double expr__strcmp_cpuid_str(const struct expr_parse_ctx *ctx >> __maybe_unused, >> +               bool compute_ids __maybe_unused, const char *test_id) >> +{ >> +    double ret; >> +    struct perf_pmu *pmu = pmu__find_core_pmu(); >> +    char *cpuid = perf_pmu__getcpuid(pmu); >> + >> +    if (!cpuid) >> +        return NAN; >> + >> +    ret = !strcmp_cpuid_str(test_id, cpuid); > > It seems that strcmp_cpuid_str() is only added in arm64 arch code - > should there be a weak version for other archs? I think there is one in tools/perf/util/header.c. I tested the build on x86 as well as arm so it should be working. > >> + >> +    free(cpuid); >> +    return ret; >> +} >> diff --git a/tools/perf/util/expr.h b/tools/perf/util/expr.h >> index 3c1e49b3e35d..c0cec29ddc29 100644 >> --- a/tools/perf/util/expr.h >> +++ b/tools/perf/util/expr.h >> @@ -55,5 +55,6 @@ double expr_id_data__value(const struct expr_id_data >> *data); >>   double expr_id_data__source_count(const struct expr_id_data *data); >>   double expr__get_literal(const char *literal, const struct >> expr_scanner_ctx *ctx); >>   double expr__has_event(const struct expr_parse_ctx *ctx, bool >> compute_ids, const char *id); >> +double expr__strcmp_cpuid_str(const struct expr_parse_ctx *ctx, bool >> compute_ids, const char *id); >>     #endif >> diff --git a/tools/perf/util/expr.l b/tools/perf/util/expr.l >> index dbb117414710..0feef0726c48 100644 >> --- a/tools/perf/util/expr.l >> +++ b/tools/perf/util/expr.l >> @@ -114,6 +114,7 @@ if        { return IF; } >>   else        { return ELSE; } >>   source_count    { return SOURCE_COUNT; } >>   has_event    { return HAS_EVENT; } >> +strcmp_cpuid_str    { return STRCMP_CPUID_STR; } >>   {literal}    { return literal(yyscanner, sctx); } >>   {number}    { return value(yyscanner); } >>   {symbol}    { return str(yyscanner, ID, sctx->runtime); } >> diff --git a/tools/perf/util/expr.y b/tools/perf/util/expr.y >> index 65d54a6f29ad..6c93b358cc2d 100644 >> --- a/tools/perf/util/expr.y >> +++ b/tools/perf/util/expr.y >> @@ -39,7 +39,7 @@ int expr_lex(YYSTYPE * yylval_param , void *yyscanner); >>       } ids; >>   } >>   -%token ID NUMBER MIN MAX IF ELSE LITERAL D_RATIO SOURCE_COUNT >> HAS_EVENT EXPR_ERROR >> +%token ID NUMBER MIN MAX IF ELSE LITERAL D_RATIO SOURCE_COUNT >> HAS_EVENT STRCMP_CPUID_STR EXPR_ERROR >>   %left MIN MAX IF >>   %left '|' >>   %left '^' >> @@ -207,6 +207,12 @@ expr: NUMBER >>       $$.ids = NULL; >>       free($3); >>   } >> +| STRCMP_CPUID_STR '(' ID ')' >> +{ >> +    $$.val = expr__strcmp_cpuid_str(ctx, compute_ids, $3); >> +    $$.ids = NULL; >> +    free($3); >> +} >>   | expr '|' expr >>   { >>       if (is_const($1.val) && is_const($3.val)) { >> diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c >> index b6654b9f55d2..b6948021fe29 100644 >> --- a/tools/perf/util/pmu.c >> +++ b/tools/perf/util/pmu.c >> @@ -1779,3 +1779,20 @@ void perf_pmu__delete(struct perf_pmu *pmu) >>       zfree(&pmu->alias_name); >>       free(pmu); >>   } >> + >> +struct perf_pmu *pmu__find_core_pmu(void) > > Why was this relocated? I don't see anywhere changed which referenced > pmu__find_core_pmu() in this patch > It's in expr__strcmp_cpuid_str(), I added a new call to it. >> +{ >> +    struct perf_pmu *pmu = NULL; >> + >> +    while ((pmu = perf_pmus__scan_core(pmu))) { >> +        /* >> +         * The cpumap should cover all CPUs. Otherwise, some CPUs may >> +         * not support some events or have different event IDs. >> +         */ >> +        if (RC_CHK_ACCESS(pmu->cpus)->nr != cpu__max_cpu().cpu) >> +            return NULL; >> + >> +        return pmu; >> +    } >> +    return NULL; >> +} >> diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h >> index 203b92860e3c..580b8d65bd65 100644 >> --- a/tools/perf/util/pmu.h >> +++ b/tools/perf/util/pmu.h >> @@ -288,5 +288,6 @@ int perf_pmu__pathname_fd(int dirfd, const char >> *pmu_name, const char *filename, >>   struct perf_pmu *perf_pmu__lookup(struct list_head *pmus, int dirfd, >> const char *lookup_name); >>   struct perf_pmu *perf_pmu__create_placeholder_core_pmu(struct >> list_head *core_pmus); >>   void perf_pmu__delete(struct perf_pmu *pmu); >> +struct perf_pmu *pmu__find_core_pmu(void); >>     #endif /* __PMU_H */ >