Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp767137pxb; Thu, 12 Nov 2020 16:21:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJzFXxAkxLXf81s5nePlPg7Ex1+Ap8IFDHIFtL9ksvU6Lq5ECFWyIaKzA3Cmh0B6pK3W7cUT X-Received: by 2002:a05:6402:1ca6:: with SMTP id cz6mr2577961edb.129.1605226889159; Thu, 12 Nov 2020 16:21:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605226889; cv=none; d=google.com; s=arc-20160816; b=K1NbOwku/2TkxlE8K389eJoFJkPbgNwLayG8N/cUyDuBptJqis7KoL3Jn/kg/rYlqG 0KnlISzue9bYXojHwunzhXT0Ae2UxD3rGOMqxtnFfGq03iH7WRYovOp+klI7uTdrRQuv Lq2WsHZJEHh2Jwkn3dqmm6pv+rJKgcw4ZjxgtqJXLr0+GEltrxiT+zsDS0uItjYZBTai 2frNZ+MA9+GZq/QyZT6zY9ukKQR/p73B4vQKqbJe08YHxJeYro/r58is+ko/WRy6waU8 7Zcc07J2sttyLBHVJJP7n1cV+8oYNAyncT3f7TUZUDQbLv1SFkAMYtiSehmLOLiUI2SJ YwwA== 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:mime-version:message-id:date :sender:dkim-signature; bh=SF2/0cBD4SDXrx4kSO5jpkw3cm1P8On8XdzbrxLvYHc=; b=hmkF2fpQ9d7KwzJ/pECJUl0vxIg7CSpm2cB97fztiGpm6N7z7O61wh1L4g56Xwjios tFzeeUZwBptOBSlBQXU8rkqIY6BvTvb1qw5HzRtFiM19Z2B2jYezNzlN3j9Poz6cYt8u 1h0FpmlpFuaJZJO86irbTmrquFE1LJLNjTw/rq8VSKV+ZrzKjULuoZpR1QZ1nNDooGhM MaLWHyD0ishSJlfrhLvoM7NxJMeuicKhuLRZ+CpJbu0QD1NL58z+fc0tXlek8z6bB0cF zRL7k0NMKkYrA6KDbWUGm5XyIxUexSPpa0JsDMpfI6wljCte1uSYbT9RYJoXNib6Z6Fd yQjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=eSV+mjSX; 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 k26si4608635ejz.41.2020.11.12.16.21.06; Thu, 12 Nov 2020 16:21:29 -0800 (PST) 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=20161025 header.b=eSV+mjSX; 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 S1726204AbgKMARB (ORCPT + 99 others); Thu, 12 Nov 2020 19:17:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726097AbgKMAQ4 (ORCPT ); Thu, 12 Nov 2020 19:16:56 -0500 Received: from mail-qk1-x749.google.com (mail-qk1-x749.google.com [IPv6:2607:f8b0:4864:20::749]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15AAFC0613D1 for ; Thu, 12 Nov 2020 16:16:56 -0800 (PST) Received: by mail-qk1-x749.google.com with SMTP id q25so5511249qkm.17 for ; Thu, 12 Nov 2020 16:16:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=SF2/0cBD4SDXrx4kSO5jpkw3cm1P8On8XdzbrxLvYHc=; b=eSV+mjSXgJcCb1CVnnrLnnD0ABu+pRfHzud1Sn/xHVeRS4cxxt3tssKBrDRO+fvBNl 0ZI6atxrCJKqLTib4fLCMfKcyXqzMMxqRmGwZB6kZV3d713uwHTsAWiAPQ3BP8h1qrKb TU/OoojdIdLIvGZ2Q9zoAbQNUsq5rpuuqHYWv0yEp01ATsqJ0+fOGFjYxlzCgCIpJtE1 0dYhn80pwsJbwuLdnT6UhKvH87Q9JzkmnPKU1YYnmaiZ4hVkpGoABNePD8RMumgQqvJ0 Mm01M3GvVx8X6GiaFUjEvzf+UinZIO31niJV0uM+tFxVRvcEMyUkRi8RADxJxfiEJzOO 3QYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=SF2/0cBD4SDXrx4kSO5jpkw3cm1P8On8XdzbrxLvYHc=; b=jPtKDHX08nNrFcvuF9bXrjfVKpI1XGJikPT/QQB/I+BWyv24xeoyK+SXhaxpFsreok AsJHsuJsVI7eYE2ZKFkq2aXOOIyoUtgy41MLEYIuSQTbKhoC0xwan8INwz5tr1d3AqXr 4YgCFnqS2zllgDMBUvA12kyncNAryWnUh03E3WV+lgtk+hfACZU+xwWgB8c3qzq8IXv1 oRJ90Mk1rAKB5JkBhux/ShWVM2IVGrxjJ3wFCuj5s3pLu8D/igIOY/UZnC9YN2deKpHQ v+PpbSpEUm6FMuGgrThHjikmNvODWPF1OZhpS/OmgUDsNibIgDYtGFTQzJJumgZYRgPN LazQ== X-Gm-Message-State: AOAM530pH5geQ4A4i1gXjk0Gf6YDiz6TlvH3V76vpk81Tu3mtDhjBMa+ ricznZEuMKht6tgxCa3LTZVBVNUzQG4E Sender: "irogers via sendgmr" X-Received: from irogers.svl.corp.google.com ([2620:15c:2cd:2:f693:9fff:fef4:4583]) (user=irogers job=sendgmr) by 2002:a0c:c18a:: with SMTP id n10mr2475691qvh.54.1605226615225; Thu, 12 Nov 2020 16:16:55 -0800 (PST) Date: Thu, 12 Nov 2020 16:16:46 -0800 Message-Id: <20201113001651.544348-1-irogers@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.29.2.299.gdc1121823c-goog Subject: [PATCH 0/5] Don't compute events that won't be used in a metric. 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 Cc: Stephane Eranian , Sandeep Dasgupta , linux-perf-users@vger.kernel.org, Ian Rogers Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For a metric like: EVENT1 if #smt_on else EVENT2 currently EVENT1 and EVENT2 will be measured and then when the metric is reported EVENT1 or EVENT2 will be printed depending on the value from smt_on() during the expr parsing. Computing both events is unnecessary and can lead to multiplexing as discussed in this thread: https://lore.kernel.org/lkml/20201110100346.2527031-1-irogers@google.com/ This change modifies expression parsing so that constants are considered when building the set of ids (events) and only events not contributing to a constant value are measured. Ian Rogers (5): perf metric: Restructure struct expr_parse_ctx. perf metric: Use NAN for missing event IDs. perf metric: Rename expr__find_other. perf metric: Add utilities to work on ids map. perf metric: Don't compute unused events. tools/perf/tests/expr.c | 148 ++++++++++----- tools/perf/tests/pmu-events.c | 42 +++-- tools/perf/util/expr.c | 136 ++++++++++++-- tools/perf/util/expr.h | 17 +- tools/perf/util/expr.l | 9 - tools/perf/util/expr.y | 343 +++++++++++++++++++++++++++------- tools/perf/util/metricgroup.c | 44 +++-- tools/perf/util/stat-shadow.c | 54 ++++-- 8 files changed, 586 insertions(+), 207 deletions(-) -- 2.29.2.299.gdc1121823c-goog