From: "tip-bot2 for Yabin Cui" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Namhyung Kim <namhyung@kernel.org>, Yabin Cui <yabinc@google.com>,
Ingo Molnar <mingo@kernel.org>, Ian Rogers <irogers@google.com>,
x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: perf/core] perf/core: Check sample_type in perf_sample_save_callchain
Date: Tue, 19 Nov 2024 08:48:49 -0000 [thread overview]
Message-ID: <173200612962.412.14983453826690347800.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20240515193610.2350456-3-yabinc@google.com>
The following commit has been merged into the perf/core branch of tip:
Commit-ID: f226805bc5f60adf03783d8e4cbfe303ccecd64e
Gitweb: https://git.kernel.org/tip/f226805bc5f60adf03783d8e4cbfe303ccecd64e
Author: Yabin Cui <yabinc@google.com>
AuthorDate: Wed, 15 May 2024 12:36:08 -07:00
Committer: Ingo Molnar <mingo@kernel.org>
CommitterDate: Tue, 19 Nov 2024 09:23:42 +01:00
perf/core: Check sample_type in perf_sample_save_callchain
Check sample_type in perf_sample_save_callchain() to prevent
saving callchain data when it isn't required.
Suggested-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Yabin Cui <yabinc@google.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Ian Rogers <irogers@google.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20240515193610.2350456-3-yabinc@google.com
---
arch/x86/events/amd/ibs.c | 3 +--
arch/x86/events/intel/ds.c | 6 ++----
include/linux/perf_event.h | 5 +++++
3 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/arch/x86/events/amd/ibs.c b/arch/x86/events/amd/ibs.c
index c3a2f6f..f029396 100644
--- a/arch/x86/events/amd/ibs.c
+++ b/arch/x86/events/amd/ibs.c
@@ -1129,8 +1129,7 @@ fail:
* recorded as part of interrupt regs. Thus we need to use rip from
* interrupt regs while unwinding call stack.
*/
- if (event->attr.sample_type & PERF_SAMPLE_CALLCHAIN)
- perf_sample_save_callchain(&data, event, iregs);
+ perf_sample_save_callchain(&data, event, iregs);
throttle = perf_event_overflow(event, &data, ®s);
out:
diff --git a/arch/x86/events/intel/ds.c b/arch/x86/events/intel/ds.c
index 8afc4ad..4990a24 100644
--- a/arch/x86/events/intel/ds.c
+++ b/arch/x86/events/intel/ds.c
@@ -1789,8 +1789,7 @@ static void setup_pebs_fixed_sample_data(struct perf_event *event,
* previous PMI context or an (I)RET happened between the record and
* PMI.
*/
- if (sample_type & PERF_SAMPLE_CALLCHAIN)
- perf_sample_save_callchain(data, event, iregs);
+ perf_sample_save_callchain(data, event, iregs);
/*
* We use the interrupt regs as a base because the PEBS record does not
@@ -1957,8 +1956,7 @@ static void setup_pebs_adaptive_sample_data(struct perf_event *event,
* previous PMI context or an (I)RET happened between the record and
* PMI.
*/
- if (sample_type & PERF_SAMPLE_CALLCHAIN)
- perf_sample_save_callchain(data, event, iregs);
+ perf_sample_save_callchain(data, event, iregs);
*regs = *iregs;
/* The ip in basic is EventingIP */
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index f7c0a3f..3ac202d 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -1279,6 +1279,11 @@ static inline void perf_sample_save_callchain(struct perf_sample_data *data,
{
int size = 1;
+ if (!(event->attr.sample_type & PERF_SAMPLE_CALLCHAIN))
+ return;
+ if (WARN_ON_ONCE(data->sample_flags & PERF_SAMPLE_CALLCHAIN))
+ return;
+
data->callchain = perf_callchain(event, regs);
size += data->callchain->nr;
next prev parent reply other threads:[~2024-11-19 8:48 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-15 19:36 [PATCH v5 0/3] perf/core: Check sample_type in sample data saving helper functions Yabin Cui
2024-05-15 19:36 ` [PATCH v5 1/3] perf/core: Save raw sample data conditionally based on sample type Yabin Cui
2024-11-19 8:48 ` [tip: perf/core] " tip-bot2 for Yabin Cui
2024-05-15 19:36 ` [PATCH v5 2/3] perf/core: Check sample_type in perf_sample_save_callchain Yabin Cui
2024-11-19 8:48 ` tip-bot2 for Yabin Cui [this message]
2024-05-15 19:36 ` [PATCH v5 3/3] perf/core: Check sample_type in perf_sample_save_brstack Yabin Cui
2024-11-19 8:48 ` [tip: perf/core] " tip-bot2 for Yabin Cui
2024-05-22 16:26 ` [PATCH v5 0/3] perf/core: Check sample_type in sample data saving helper functions Namhyung Kim
2024-05-28 17:59 ` Yabin Cui
2024-06-11 20:33 ` Yabin Cui
2024-11-19 8:27 ` Ingo Molnar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=173200612962.412.14983453826690347800.tip-bot2@tip-bot2 \
--to=tip-bot2@linutronix.de \
--cc=irogers@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=x86@kernel.org \
--cc=yabinc@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®