Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp527048ybj; Thu, 7 May 2020 01:16:51 -0700 (PDT) X-Google-Smtp-Source: APiQypJwWcBn+7Qfl3WKASYzGrrTc7M/uQSsS4vzOJx3R89pHM0jkJWkOOoFT+Fox7FjnL4W869s X-Received: by 2002:aa7:cdcb:: with SMTP id h11mr10222979edw.264.1588839410864; Thu, 07 May 2020 01:16:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588839410; cv=none; d=google.com; s=arc-20160816; b=efiCJLZZNB+M/EiRqMpyPoDIDvSBMS+IVTCXH5KKtW7SULgwk4mNLyFzQpn8CQUZtg zIprFMRlMZZkiAJz0W/GDFipc/h/7J9P1KdCnpIqRjyeTw58h19I9uLCpM5PjjS6CiQn cPsopdOKnlH+iS4QY1UMFJtWCoqaDAUntwBv97Z5WDStXMWzDBS9vBMybSAyOIwZ6EOF 0cedQkA6RrK9nnEGALBuBMZ2YIiBjhoulcNwQhDNMtUw6zA2ZthXhEylzvnQun9bLrPZ d0KU1/oAkNoB0CDrxcfCxs5MHafArOBDdoGcyJitxYbIcHkCWihVKVDQ+XfgyXv/V/8Q SJSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:mime-version :message-id:date:dkim-signature; bh=jJ+0WVT0o7QnePYWoDu2DLbS3PF1WBgkVDF9XXQH2a0=; b=TpYxTjnAyefG30bj6d43IB1AMopTC49HHwfldfFJr/ysZTjcwP0MlXWsCiDYIcc0mq +zqz4/Kdsm7C76KBd+Bcz4q+bn8KTpBh/Z6J5NG2h9F8HfsMbCUWuFnQimVTeMqs2nB7 DOdGfdsef6OAGmRh6kxclMXA+CnevLX72u/lhZg2G35aqr3JGfP281+XaMyXEgu3KMkL RBhxtSRufLZccqmSZybFOtxa0GUPkPRiUJzG1mJOPS4yF5VZ+TPmLkX4lVMSjaea5yVg h6q88ke8TlMJcjVJ+U/87CKbZR+xNNHWMgjGtYKHJYMzx3k3gisFTUGg1ZjYF41w38Jt HyOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ivglXwvD; 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 j5si3003382ejj.183.2020.05.07.01.16.28; Thu, 07 May 2020 01:16:50 -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=20161025 header.b=ivglXwvD; 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 S1727082AbgEGIO6 (ORCPT + 99 others); Thu, 7 May 2020 04:14:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1725802AbgEGIOt (ORCPT ); Thu, 7 May 2020 04:14:49 -0400 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 4D7AEC061A10 for ; Thu, 7 May 2020 01:14:48 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id x13so6005170ybg.23 for ; Thu, 07 May 2020 01:14:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=jJ+0WVT0o7QnePYWoDu2DLbS3PF1WBgkVDF9XXQH2a0=; b=ivglXwvDfB4/pd8fDyiSer//832TB2EZ2jFXvGPGLpLtmfFxysFjth6U6ltV45e+nh 7cTyxgyoN8J/Vr8cBP0YOGwzl/YjLBCwWYRxSG6UP6VveKOyIvjOXDHYw0jL89LVAoA5 0b4nLuEjj8WZXKHMuua05G+Qf04QbzB5HgbeAgqN1gA2nRLqzTU8HLqEtYpXKHSscRS7 TUC/edfu14DK8bZ1RqEcE3pQmG+QxeueS7pi1KAQLqNIe4MmLwBfjQ3ViQdwoC7andKg Z9UZjTS//VfS7phn1QXJyIPu2JCmIxtmyvkFhp6kH/v4Q1kXkm/FdmGy5r6cEXDwRvSc jzHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=jJ+0WVT0o7QnePYWoDu2DLbS3PF1WBgkVDF9XXQH2a0=; b=p0Y0DfdPdFTUarC4N+ifxGOJVXJebl8KJZjypyAvnI++3yc4UjWhlEGHLHTpFAs0lZ TTW9SeM3YPs3Z3QUfi2DfkQ0RpH2EIOBrwbEoxXeVT1pEes2XhG1QVik5pZ5kZKj3EmE vclXhexHfB/YOXY83Is1ojZ74TT/yN/ITu3pW4vk6++0R4AYoqsAyRjQRcjmx6MX7TBc JDOoxpYLxiEjig8hZWKpSPWn0ZdnaFhZNHVd8O9BMlS4Vh2EivYuceqKza0nWtN06DRc lVWiwuU9Olb27VoYDbsnWszvnSY/qBGhGADMjg4e0MJxYTRsRkROJe3Re9vreHKW8PLM 7hJA== X-Gm-Message-State: AGi0PubrKk7qkzIJbg2lNtjnAKKc8HWpTwbyX4l17ibC0FmQmQCSypeW 6CJ+QewS1MuOPmeU4HkS0YAO6Yu+enZs X-Received: by 2002:a25:c246:: with SMTP id s67mr19644886ybf.317.1588839287376; Thu, 07 May 2020 01:14:47 -0700 (PDT) Date: Thu, 7 May 2020 01:14:29 -0700 Message-Id: <20200507081436.49071-1-irogers@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.26.2.526.g744177e7f7-goog Subject: [RFC PATCH 0/7] Share events between metrics From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , Andrii Nakryiko , John Fastabend , KP Singh , Kajol Jain , Andi Kleen , John Garry , Jin Yao , Kan Liang , Cong Wang , Kim Phillips , linux-kernel@vger.kernel.org Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, linux-perf-users@vger.kernel.org, Stephane Eranian , Ian Rogers Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Metric groups contain metrics. Metrics create groups of events to ideally be scheduled together. Often metrics refer to the same events, for example, a cache hit and cache miss rate. Using separate event groups means these metrics are multiplexed at different times and the counts don't sum to 100%. More multiplexing also decreases the accuracy of the measurement. This change orders metrics from groups or the command line, so that the ones with the most events are set up first. Later metrics see if groups already provide their events, and reuse them if possible. Unnecessary events and groups are eliminated. RFC because: - without this change events within a metric may get scheduled together, after they may appear as part of a larger group and be multiplexed at different times, lowering accuracy - however, less multiplexing may compensate for this. - libbpf's hashmap is used, however, libbpf is an optional requirement for building perf. - other things I'm not thinking of. Thanks! Ian Rogers (7): perf expr: migrate expr ids table to libbpf's hashmap perf metricgroup: change evlist_used to a bitmap perf metricgroup: free metric_events on error perf metricgroup: always place duration_time last perf metricgroup: delay events string creation perf metricgroup: order event groups by size perf metricgroup: remove duped metric group events tools/perf/tests/expr.c | 32 ++--- tools/perf/tests/pmu-events.c | 22 ++-- tools/perf/util/expr.c | 125 ++++++++++-------- tools/perf/util/expr.h | 22 ++-- tools/perf/util/expr.y | 22 +--- tools/perf/util/metricgroup.c | 242 +++++++++++++++++++++------------- tools/perf/util/stat-shadow.c | 46 ++++--- 7 files changed, 280 insertions(+), 231 deletions(-) -- 2.26.2.526.g744177e7f7-goog