Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp406943pxb; Sat, 18 Sep 2021 06:18:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz5Xm6iu9CrevnGz1ECotuBHrkPfJwEw5uTz/FMTGKYPFjlSdXkNm1IShQNcyUCG4CE/nFN X-Received: by 2002:a05:6602:3404:: with SMTP id n4mr12243784ioz.45.1631971109001; Sat, 18 Sep 2021 06:18:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631971108; cv=none; d=google.com; s=arc-20160816; b=m8x6xH9CBER1Y8fJC9HuS6RR3mPDDMDPo4ulULipmg2VOaX+NGOvFglWuXcaUKGjCQ MBjCvleZ6oaVpXZi0ZUWsLxSt5JJU6rfStSnFGx6+baGWMOQ4OLd6ybDF7I3eXQtINIs kYF6WQXeROekej2g6dcE0XZn0VnYcPfCwnc49I27Cz18OPzj6rYZVCSuBv6EwbE7sala fYKTnB8zPL8JFPB52AbVNLcWx+mJh9sFXuvnRAUT0xtyDheGaEy/tSn1EhwNqVnTBgdA 3N/wcmYV2eFYenRBx1VOIS1LYZsBxQnUnAu2RzuktQAag15Ojr785uYeo+dTRG0q//Wx tREQ== 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=MM9weOAXJkFMRdlpsJ2tVi3yPALgR9GzmZzrMn/EhJY=; b=PF2lf8gqVod+sZOsoefrTUNnbZ0C/HnkaW6gCZrJRXCNANFIJ88JAZR0t1bmp8k5yT zxLy4pVUqCs7T+ZVvl31vZyvKdXf7HroNIkZAS/RI/LEjKTDBpaokmAiaJl9aHuElL68 ft5kfB8Mz73TUBJoHMJ41RW8K8dj/LoiuyVnD01eDTChcxz+XtqJVHPQIdSyoHwwEtv3 OF4iB4wNhTEhErUTeB2CA5uR1EvRs9uTWeAmqe1woXL1tWOeGmMVBo17oIWxV25YXbUG R2WkfQPn8QXedrJe7QunNTvFsYo5anoFKzsFhsSe7IAGxxX1g7fA8PmfPszZFhm8eHGD 3yZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=eUU71ti4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 132si8164360jay.7.2021.09.18.06.18.17; Sat, 18 Sep 2021 06:18:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=eUU71ti4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S241763AbhIRGh3 (ORCPT + 99 others); Sat, 18 Sep 2021 02:37:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238999AbhIRGhI (ORCPT ); Sat, 18 Sep 2021 02:37:08 -0400 Received: from mail-qt1-x849.google.com (mail-qt1-x849.google.com [IPv6:2607:f8b0:4864:20::849]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DF93C06175F for ; Fri, 17 Sep 2021 23:35:43 -0700 (PDT) Received: by mail-qt1-x849.google.com with SMTP id e6-20020ac84e46000000b0029baad9aaa0so102673730qtw.11 for ; Fri, 17 Sep 2021 23:35:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=MM9weOAXJkFMRdlpsJ2tVi3yPALgR9GzmZzrMn/EhJY=; b=eUU71ti4ArZoK/O9dYp2jofp3SUGRHhK8ptF9r6/U50bA620C5TbmRbbYjSmIMDlth Kcyu01Z2YfphZAtxbkNmx+g2UrUYEKU0baBmVz/OzQeai6UCS3wPW+VG/JYft4B2W0Kz QUnKL0UCHAZX3qB19nB3W8lEWSM2GY8THVULlaWdIfR8d2PpMVjoN0F/qUKCfFkwekH7 pFl72iHmlaPz2/i8BoRVu3H3QWVA/Z9NPSGztYAtn21ds0LrYfyZa32KRk9vm2T+xTxX 8kdIhDkv0ZwvG4EevvSdr2Dv4JxIg+bgXN9rTh8XMdSZSFXLwqyS4Si16SpXjTk0WIAJ 5nWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=MM9weOAXJkFMRdlpsJ2tVi3yPALgR9GzmZzrMn/EhJY=; b=K76tQgVxsLBRT3VBuB2GgfANtXahxscwuZCNgoXuDpY32iJZVQkeaNm6C7UZ5q6ZPz 2UdgMoNjojUnFlv/i9MAyq4Mjv3HL25ZqM9mLDz4w5YQkN3yoD6WjJalOWExnXIG/1I7 sxZ+OrweSNtjJoUUy4BCj7yjFr/YWneJaFVeexhLoPTiVz6PixFheAmax+9QeppdaQXT VUto4Gx23RjBapc+hlA8r//1lxjGjgpTtOCMDK+AnURjZJTnImutUgRPXe0QhxkQWXjq BJ0B8xFS20MLkGR2F/byhpYg/LrQ2brbH8AasrwcDrdIwVsS4bbbtzayP0qGJLcoisef r9hg== X-Gm-Message-State: AOAM530yxlSb32Gv2NJsu7S2NJeGtndJ3LLJ/9zOA1hBL5Nv5rih1sCE IcWL39Gm6gbAFUTOaSc0x3/gVqzpIlpT X-Received: from irogers.svl.corp.google.com ([2620:15c:2cd:202:6399:5df3:21d3:3cca]) (user=irogers job=sendgmr) by 2002:a05:6214:2e4:: with SMTP id h4mr15305382qvu.3.1631946942292; Fri, 17 Sep 2021 23:35:42 -0700 (PDT) Date: Fri, 17 Sep 2021 23:35:13 -0700 In-Reply-To: <20210918063513.2356923-1-irogers@google.com> Message-Id: <20210918063513.2356923-9-irogers@google.com> Mime-Version: 1.0 References: <20210918063513.2356923-1-irogers@google.com> X-Mailer: git-send-email 2.33.0.464.g1972c5931b-goog Subject: [PATCH v8 8/8] perf test: Add metric test for eliminating events From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-kernel@vger.kernel.org, Andi Kleen , Jin Yao , John Garry , Paul Clarke , kajoljain , linux-perf-users@vger.kernel.org Cc: Stephane Eranian , Sandeep Dasgupta , Ian Rogers Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add test that ensures we remove events based on #smt_on, or if evaluating the event has no impact on the output. Signed-off-by: Ian Rogers --- tools/perf/tests/expr.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tools/perf/tests/expr.c b/tools/perf/tests/expr.c index 1c881bea7fca..5cab5960b257 100644 --- a/tools/perf/tests/expr.c +++ b/tools/perf/tests/expr.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 #include "util/debug.h" #include "util/expr.h" +#include "util/smt.h" #include "tests.h" #include #include @@ -132,6 +133,22 @@ int test__expr(struct test *t __maybe_unused, int subtest __maybe_unused) TEST_ASSERT_VAL("find ids", hashmap__find(ctx->ids, "EVENT2,param=3/", (void **)&val_ptr)); + /* Only EVENT1 or EVENT2 need be measured depending on the value of smt_on. */ + expr__ctx_clear(ctx); + TEST_ASSERT_VAL("find ids", + expr__find_ids("EVENT1 if #smt_on else EVENT2", + NULL, ctx, 0) == 0); + TEST_ASSERT_VAL("find ids", hashmap__size(ctx->ids) == 1); + TEST_ASSERT_VAL("find ids", hashmap__find(ctx->ids, + smt_on() ? "EVENT1" : "EVENT2", + (void **)&val_ptr)); + + /* The expression is a constant 1.0 without needing to evaluate EVENT1. */ + expr__ctx_clear(ctx); + TEST_ASSERT_VAL("find ids", + expr__find_ids("1.0 if EVENT1 > 100.0 else 1.0", + NULL, ctx, 0) == 0); + TEST_ASSERT_VAL("find ids", hashmap__size(ctx->ids) == 0); expr__ctx_free(ctx); return 0; -- 2.33.0.464.g1972c5931b-goog