Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp1113137lqp; Fri, 22 Mar 2024 06:09:33 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVXh5KMN4RZTmBaMf5CSKRrim9iRxoaePOitd09CsMT6Qib+f8GGpE1rB4a4/FJ79VPKdIwVMfLymjdgkLeBHMoNZ0ocbS2MxW/eviGiQ== X-Google-Smtp-Source: AGHT+IFMFDsoB9QOvboYirV+TESxLg9XJdRj0tYEn0med+eUMr80CAYtX/0oZIDj5o2/aMsj8356 X-Received: by 2002:a05:6a00:182a:b0:6e9:c2db:def2 with SMTP id y42-20020a056a00182a00b006e9c2dbdef2mr3187148pfa.28.1711112973517; Fri, 22 Mar 2024 06:09:33 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711112973; cv=pass; d=google.com; s=arc-20160816; b=YFEw+D5EKxk7wTdkt+Pg3AQ5bXSgBf+R+yxFX1b7viGVK7WF1FqwaT349pfGYlaH1Q WwsR0MG6niCu6ZXQaJQga1z7WXLFiDN9a0gmCsLmOB6dp2GgTNADui93slGbkI8atv2u +/eA26MzfESYnnbjoQFqnwv/IZFTiiSuOBT/LB8b7BOWuIgn0/7zM5JBWzaSPxxpSuuc K3sX89eOEmnrY4vyBWTzid6xVMIiD875XFeuf9fc4XMsOaIu5U9YJqmSCzyDr9HRd+rW pkh/kldmWqLjFmS73hZCfE/F7GbNvGez/nl2w6O3ke07J1GQ0jKFnXs1HOigKHtbfYXZ 3lYg== 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=DmMFnmIWfqr8tKDhbtImK95YgrXZPVntBFF1zZ03faQ=; fh=qmyFNe8t+IUXUkrxfdZt+VGwiwY4q6x1nzoI5t8Y/1U=; b=pj6FnZP7cziwU6Vw29Tkp6FdLzWkIhPoM8+fYeszwdR5/OdpcBD3mxGjHYjNGkxGpO 6fAuyHqt0xmVGAtOgZ2sLdl2h5+Ij8Lwr95D6OSLs+knBZ+GibKCt/s+weIeyIHgzlFC 5puI9RWAzbWOi7JWwRHb4yoJdSIHisVSGNZCfKpeht8IJdBhoNHXX3z4YWuZqEhH9jo6 hG58RgOoCGiZMy796nXs9XIG6nSYe7k+HqaUB4M9yusSImw/fa7Bt0pGZ30AqSCNEgpr y1RiHV5PdiCy8CQkVwQM/vTGa8ol2U1ab0lNsfbHCgx5B7SiaPzo/3JujZgiOBX0qbnI 44vQ==; 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-111451-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-111451-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id c12-20020a65420c000000b005e857e45186si1985779pgq.202.2024.03.22.06.09.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Mar 2024 06:09:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-111451-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; 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-111451-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-111451-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id C8150B22BEF for ; Fri, 22 Mar 2024 13:05:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B02DA47768; Fri, 22 Mar 2024 13:04:36 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 76F964502D; Fri, 22 Mar 2024 13:04:34 +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=1711112676; cv=none; b=VVVgCdhDDbhEOXzUC3w7eb0oH/BgtJ6S6gwCFkDQSR/roJnMWtBj3XxbCuPncgG0vkGFPTU2PtuUoZGdxLoRplVMhOUEY+OqhLQ8VCRW5y+WwJ1OUDfmcgtG53AYumArDpp5hoGsEtnXpafLjT4A4i9iT/5foBtuz1nCMv21mpE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711112676; c=relaxed/simple; bh=XQSKmN1TVfytkq7r8tlE3KspdUqFU8nJv4BPKNrYrio=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=q3VHh6fCo0xe/XzwM8jVIJ49QnWcW2DQucMYJ4EToW5iDH/aqiBn5sO86rumQthdJ5rwxdBEY3l0uT3J47AdIYWOSX2Eq6t3QBma502QQZvwf55vJ4EeBb19dJlKGMzlTJMLTSS/DX3spoxGxp05bhzQ9awTelMphN4chQYi6GI= 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 0185E1063; Fri, 22 Mar 2024 06:05:08 -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 245263F762; Fri, 22 Mar 2024 06:04:32 -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 v3 2/4] tools/perf: Track where perf_sample_ids need per-thread periods Date: Fri, 22 Mar 2024 13:04:12 +0000 Message-ID: <20240322130414.70186-3-ben.gainey@arm.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240322130414.70186-1-ben.gainey@arm.com> References: <20240322130414.70186-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+inherit_stat+PERF_SAMPLE_READ. Events with this combination of properties must be handled differently when tracking each streams sample period, as their stream-id is now only unique per thread, rather than globally unique. 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 058e3ff10f9b..c585c49491a5 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 c07160953224..dd60ee0557d8 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.inherit + && evsel->attr.inherit_stat; +} + 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 5cd220a61962..8dd58149986c 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+inherit_stat is combined with PERF_SAMPLE_READ, the + * period value is per (sample_id, thread) tuple, rather than per + * sample_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.44.0