From patchwork Thu Dec 15 06:47:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 33495 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp181551wrn; Wed, 14 Dec 2022 22:49:22 -0800 (PST) X-Google-Smtp-Source: AA0mqf6klvOkaJ/XtGagaFLSAncZxiYh+Ybeas8AtUO05q6ocpl7fZUYZ6B+9aWwYtlj6/xKv1MX X-Received: by 2002:a17:907:7d88:b0:78d:f456:1eb1 with SMTP id oz8-20020a1709077d8800b0078df4561eb1mr28722574ejc.2.1671086961851; Wed, 14 Dec 2022 22:49:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671086961; cv=none; d=google.com; s=arc-20160816; b=CWYJ0lHUMlkOTBS207WW+dU2cJuecXf66pHyLZQQXBNFCbHSyaKaVME4k3zbBlvwOP C5dlHfQkkQThiUP8uhtSp4s3zef8dsIGY8uDZFvEIStcCTIfAgPV8mHhpx/tHY26+f1k CQjljSOPGd98kgmXs0hZ8SjYV68YeuOW/3NZJQgz7MFqqEwsqRC/9E5/RLUjB/k1QUnd CxjI70NuOjLM7jfrnM7h4Nb5D2EdUCbk7t8jRz3tCKdNSSQKo6lwuKDcpKySmRddgZJc BXr9V2pOZiypRelHQGwf0H3RlgLTa/Z91I83YTrRlSEhFsa9qOXdMolPwaWKzmxEEiyN xoOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=xuUtjr5keE4Mx0YV4hQdh4hNFeDESLw77jscKu2CoiM=; b=dnnCVFNcyPCgBUuDYwmcndBS8nr6euziFSG8/chb3XCfLGGnWNGn7DmCKSCLV/jLVx bgd2zys/trNm6b/L6hwYAytuTW67niNL/DyvJ1vc+kUPk6hWiAGiLK3/0HbFS/34yiOQ JXZ54k6HTedzf+qc5UQ/eR+r3ewQJgwKSxezKFWB7Rt21cE+dsuIN7g9zTqGaJEa2ZEl otLY2+WW1xAjDBGSQNJf3CUsemqs5a0Yu+uqs586AMOneZZGCR+xuFDuD2F+5PgQX4xJ gxE0BXd6AaNDgC0rG/z9X5n0yHcUswSMuHjQCY4cvpJPQegyloQhXDKItrWV23nTzI1q SbPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=GEnpJQtl; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ga26-20020a1709070c1a00b007c151fd4953si14268054ejc.213.2022.12.14.22.48.58; Wed, 14 Dec 2022 22:49:21 -0800 (PST) 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; dkim=pass header.i=@google.com header.s=20210112 header.b=GEnpJQtl; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229459AbiLOGsX (ORCPT + 99 others); Thu, 15 Dec 2022 01:48:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229596AbiLOGsP (ORCPT ); Thu, 15 Dec 2022 01:48:15 -0500 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0531B5C0EC for ; Wed, 14 Dec 2022 22:48:15 -0800 (PST) Received: by mail-yb1-xb49.google.com with SMTP id b4-20020a253404000000b006fad1bb09f4so2667967yba.1 for ; Wed, 14 Dec 2022 22:48:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=xuUtjr5keE4Mx0YV4hQdh4hNFeDESLw77jscKu2CoiM=; b=GEnpJQtlsZpw6NLVnvIBmIHsHDx+p6RULDeC/EcVcDgLV2/2p90+FG2YlMWaRea5Co 2d20WQCEk47gD6g/m7kLqm1UEYQ6bccY72F9Fb9v5oraS9FnEAzymvvXDQ5J+Ca4vM2o 4QwJato9O0KtmPipcH+GQjG2DkZeXxTf9hs5+Mz9YsU/gdPwyV5F8hpKeiMIdlHScisJ g9gOAZlpCBwui0Tgc4ti3QWs6ib1odbtZf0SdBuvnsuMIRoz5b+w4QiolhR4TARx/LLM bIehm+KxboUKQtv2i9v6clt+e8CgvucKODSFGywAOdRQLa19Jqj7FsK+4KeYxv8jDE9c htkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=xuUtjr5keE4Mx0YV4hQdh4hNFeDESLw77jscKu2CoiM=; b=YYi/3waQhZ7as0f6OdTKOIl60Vzus7h0Gsq75p0cJn3JeeT54Y/yztpfwBa3bPI/xb dutEiLRIfloqzCq4BpObNJ+OBH8dhOMZZFbm+VD+thZITOtQSiWW6kzrlIPhqBvtGshY iBlLhuWzo5VGUWV7c5lzPUhaq3Vvr+ugfprML9p7LuBR8o2J0KIROUvLAUSbfMZPo2sK 1TKQk3jKL+/xlNRgb0IqTFLLsm1OH/tPM3dKxYEsS1NaIlDQkb0GY1tVWkTylkhToSch SqnESWzzlv6G9F1aCcvZhnZDCeEYKX0SP7ooyfB/TxxpdnkME8WnGo2hJCyyTEMpo7Gp Mu2w== X-Gm-Message-State: ANoB5pl27rB8FeJcWn3cM+LbZ0REt6hlA3IkSIU4z0vV673+WMBK0NqK zblYEgKWDOQtk9ewlCQ5XC5cf/B99gJs X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:c7dc:d96f:4f9:f59d]) (user=irogers job=sendgmr) by 2002:a25:ab73:0:b0:6f3:7b95:353 with SMTP id u106-20020a25ab73000000b006f37b950353mr60929460ybi.394.1671086894259; Wed, 14 Dec 2022 22:48:14 -0800 (PST) Date: Wed, 14 Dec 2022 22:47:24 -0800 In-Reply-To: <20221215064755.1620246-1-irogers@google.com> Message-Id: <20221215064755.1620246-2-irogers@google.com> Mime-Version: 1.0 References: <20221215064755.1620246-1-irogers@google.com> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog Subject: [PATCH v1 01/32] perf test pmu-events: Fake PMU metric workaround From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Adrian Hunter , Kan Liang , Xing Zhengjun , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Cc: John Garry , Stephane Eranian , Perry Taylor , Caleb Biggers , Ian Rogers X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752261682189466357?= X-GMAIL-MSGID: =?utf-8?q?1752261682189466357?= We test metrics with fake events with fake values. The fake values may yield division by zero and so we count both up and down to try to avoid this. Unfortunately this isn't sufficient for some metrics and so don't fail the test for them. Add the metric name to debug output. Signed-off-by: Ian Rogers --- tools/perf/tests/pmu-events.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/tools/perf/tests/pmu-events.c b/tools/perf/tests/pmu-events.c index f7b9dbbad97f..a29dd6af8d33 100644 --- a/tools/perf/tests/pmu-events.c +++ b/tools/perf/tests/pmu-events.c @@ -959,7 +959,7 @@ static struct test_metric metrics[] = { { "(imx8_ddr0@read\\-cycles@ + imx8_ddr0@write\\-cycles@)", }, }; -static int metric_parse_fake(const char *str) +static int metric_parse_fake(const char *metric_name, const char *str) { struct expr_parse_ctx *ctx; struct hashmap_entry *cur; @@ -968,7 +968,7 @@ static int metric_parse_fake(const char *str) size_t bkt; int i; - pr_debug("parsing '%s'\n", str); + pr_debug("parsing '%s': '%s'\n", metric_name, str); ctx = expr__ctx_new(); if (!ctx) { @@ -1006,8 +1006,13 @@ static int metric_parse_fake(const char *str) hashmap__for_each_entry(ctx->ids, cur, bkt) expr__add_id_val(ctx, strdup(cur->key), i--); if (expr__parse(&result, ctx, str)) { - pr_err("expr__parse failed\n"); - ret = -1; + pr_err("expr__parse failed for %s\n", metric_name); + /* The following have hard to avoid divide by zero. */ + if (!strcmp(metric_name, "tma_clears_resteers") || + !strcmp(metric_name, "tma_mispredicts_resteers")) + ret = 0; + else + ret = -1; } } @@ -1023,7 +1028,7 @@ static int test__parsing_fake_callback(const struct pmu_event *pe, if (!pe->metric_expr) return 0; - return metric_parse_fake(pe->metric_expr); + return metric_parse_fake(pe->metric_name, pe->metric_expr); } /* @@ -1037,7 +1042,7 @@ static int test__parsing_fake(struct test_suite *test __maybe_unused, int err = 0; for (size_t i = 0; i < ARRAY_SIZE(metrics); i++) { - err = metric_parse_fake(metrics[i].str); + err = metric_parse_fake("", metrics[i].str); if (err) return err; }