Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp3082562lqo; Tue, 21 May 2024 06:31:16 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUshwj/Qds7eXkcq9xHpFQrmhEfix++Kzw9fUqqmzrN2co7ai6QM5M9mSJl/1e+bSwsDJyS8QFss6IQ8wjvciChxdHRkFhSlDDOsqYt9w== X-Google-Smtp-Source: AGHT+IEbQ9KvWu0WwW1+/i9VF4u+jhaEyrDz5kLeTgiAnELtSfYylFTVreG9MYggzxtzLN09kP0Z X-Received: by 2002:a05:622a:15c1:b0:43a:74ea:89b with SMTP id d75a77b69052e-43dfdb4969cmr357637401cf.16.1716298275807; Tue, 21 May 2024 06:31:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716298275; cv=pass; d=google.com; s=arc-20160816; b=J7m0qmqxQhIJ6syD271xhVLTXbhyDm//tqLcXjurd3aTA7fQefZq7HcScnF+tqXqBU RzOdkD79pX6caxT+88+6NiDR0Ry7XS7xrY598i/39NgvBOoJaZEQP3LZmiGeokzPMItJ NTp6uQa6cVAxe9tGCNbT3zw/qChvOHyazn1jJtK4Chi2IRpKLOx5MxI37HpYbP2NPIj0 cMMFxYg9l2K7mZjLZB2jl9Wh4t8p+BlBF8EuDDu+aOPl/JlGV7i5sWRgEwjmO6+mcsxj HZY0wvWNIwxarIlVonjajxKxonJuY3gzp+dSoogotDcEyw6WouNzZI3RVc2VB6knChu1 uoRA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=RS+Q4PgWXL4+FLkvGwHPnx239E2U7NzeSavWPsJm+UM=; fh=qmyFNe8t+IUXUkrxfdZt+VGwiwY4q6x1nzoI5t8Y/1U=; b=CUSpJgZ6sxIYdL5gElyUemdAhh0vqIe5z3NVHiJ5zrBjWtPciXXVxGgnskhmTVFgFS 1k8HQwUUyzZb7Ha7jZw+sAgX2R0KdIEP0w2ppqChPQ8dKFcww12kSDQDcAMgywWwPVkO 0852uHOrWM3Bh1xVFBIcZtr7A1hicHdwBZc1Y0mL8Pg7JbZE06tHp/3F5xBzwgLAV3js dbsfbOh84tquMlLBAMMelOYTw5o0DOxbhTtGEYbzCAbkSwTH6EuUAXEUhQt5NR735t2A HjrCjrWDKXilTUBpjvEZQaK0p3ENQrBVCoUpTkSZz55X+7HOFnd81JLNdzqqOK0fZ/kX jgdA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-185015-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-185015-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d75a77b69052e-43e0edd8a08si242026591cf.751.2024.05.21.06.31.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 May 2024 06:31:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-185015-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-185015-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-185015-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 887BC1C21AF0 for ; Tue, 21 May 2024 13:31:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9454A7F7CE; Tue, 21 May 2024 13:30:44 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9F78C7F482; Tue, 21 May 2024 13:30:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716298244; cv=none; b=WlIm3BkQ31fVfCiTxhd5rk88c8/qbqgpFVj3zYA6hcgvmzvO1zgeQJbWElqwUgZOrekreowISBxEgnciV61rjbgkF47GhoxTyCkZV1M4ATyDbGpPHwMzn3/9QJIgyCfz4gtrzG04Ge0UiHVHQbFryHCP2pj6/am6BBUtoP2RJs8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716298244; c=relaxed/simple; bh=9KsvWJ0unbJTziuYOcxjeYSAUdeTmy5OO9IsWvSeBtk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FOK+KA+LDEcnejm68NypUtYSRn1EWXbxF8gYyX2CSKWAQzQYUVycF/xR1RteQmHAMUBF9tQIyGT4yvxxTa23mXLArVYuqFd84/Yw62PXoWKpBZEE7maYlnhfJNuxx7my4Qxb54K+D51a2l41LWTtdR18qN7dnvAjbDTVVGUT3JA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 0C83B1042; Tue, 21 May 2024 06:31:05 -0700 (PDT) Received: from e126817.cambridge.arm.com (e126817.cambridge.arm.com [10.2.3.5]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 4F2003F641; Tue, 21 May 2024 06:30:39 -0700 (PDT) From: Ben Gainey To: peterz@infradead.org, mingo@redhat.com, acme@kernel.org, namhyung@kernel.org Cc: james.clark@arm.com, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@kernel.org, irogers@google.com, adrian.hunter@intel.com, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Ben Gainey Subject: [PATCH v6 2/4] tools/perf: Track where perf_sample_ids need per-thread periods Date: Tue, 21 May 2024 14:30:27 +0100 Message-ID: <20240521133029.83654-3-ben.gainey@arm.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240521133029.83654-1-ben.gainey@arm.com> References: <20240521133029.83654-1-ben.gainey@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit perf_sample_ids and related evlist/evsel code are modified to track which events combine inherit+PERF_SAMPLE_READ+PERF_SAMPLE_TID. Events with this combination of properties must be handled differently when calculating each sample period. They must use the combination of (ID + TID) to uniquely identify each distinct sequence of values. Signed-off-by: Ben Gainey --- tools/lib/perf/evlist.c | 1 + tools/lib/perf/evsel.c | 7 +++++++ tools/lib/perf/include/internal/evsel.h | 9 +++++++++ 3 files changed, 17 insertions(+) diff --git a/tools/lib/perf/evlist.c b/tools/lib/perf/evlist.c index c6d67fc9e57ef..d17288eeaee48 100644 --- a/tools/lib/perf/evlist.c +++ b/tools/lib/perf/evlist.c @@ -255,6 +255,7 @@ static void perf_evlist__id_hash(struct perf_evlist *evlist, sid->id = id; sid->evsel = evsel; + sid->period_per_thread = perf_evsel__attr_has_per_thread_sample_period(evsel); hash = hash_64(sid->id, PERF_EVLIST__HLIST_BITS); hlist_add_head(&sid->node, &evlist->heads[hash]); } diff --git a/tools/lib/perf/evsel.c b/tools/lib/perf/evsel.c index c07160953224a..f7abb879f416e 100644 --- a/tools/lib/perf/evsel.c +++ b/tools/lib/perf/evsel.c @@ -537,6 +537,13 @@ void perf_evsel__free_id(struct perf_evsel *evsel) evsel->ids = 0; } +bool perf_evsel__attr_has_per_thread_sample_period(struct perf_evsel *evsel) +{ + return (evsel->attr.sample_type & PERF_SAMPLE_READ) + && (evsel->attr.sample_type & PERF_SAMPLE_TID) + && evsel->attr.inherit; +} + void perf_counts_values__scale(struct perf_counts_values *count, bool scale, __s8 *pscaled) { diff --git a/tools/lib/perf/include/internal/evsel.h b/tools/lib/perf/include/internal/evsel.h index 5cd220a61962e..f8de2bf89c76b 100644 --- a/tools/lib/perf/include/internal/evsel.h +++ b/tools/lib/perf/include/internal/evsel.h @@ -36,6 +36,13 @@ struct perf_sample_id { /* Holds total ID period value for PERF_SAMPLE_READ processing. */ u64 period; + + /* + * When inherit is combined with PERF_SAMPLE_READ, the period value is + * per (id, thread) tuple, rather than per id, so use the stream_id to + * uniquely identify the period, rather than the id. + */ + bool period_per_thread; }; struct perf_evsel { @@ -88,4 +95,6 @@ int perf_evsel__apply_filter(struct perf_evsel *evsel, const char *filter); int perf_evsel__alloc_id(struct perf_evsel *evsel, int ncpus, int nthreads); void perf_evsel__free_id(struct perf_evsel *evsel); +bool perf_evsel__attr_has_per_thread_sample_period(struct perf_evsel *evsel); + #endif /* __LIBPERF_INTERNAL_EVSEL_H */ -- 2.45.1