From: Namhyung Kim <namhyung@kernel.org>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Jiri Olsa <jolsa@kernel.org>, LKML <linux-kernel@vger.kernel.org>,
Song Liu <songliubraving@fb.com>,
Ravi Bangoria <ravi.bangoria@amd.com>,
Stephane Eranian <eranian@google.com>,
Kan Liang <kan.liang@linux.intel.com>
Subject: [PATCH 2/2] perf: Use sample_flags for raw_data
Date: Wed, 21 Sep 2022 15:00:32 -0700 [thread overview]
Message-ID: <20220921220032.2858517-2-namhyung@kernel.org> (raw)
In-Reply-To: <20220921220032.2858517-1-namhyung@kernel.org>
Use the new sample_flags to indicate whether the raw data field is
filled by the PMU driver. Although it could check with the NULL,
follow the same rule with other fields.
Remove the raw field from the perf_sample_data_init() to minimize
the number of cache lines touched.
Cc: Kan Liang <kan.liang@linux.intel.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
arch/s390/kernel/perf_cpum_cf.c | 1 +
arch/s390/kernel/perf_pai_crypto.c | 1 +
arch/x86/events/amd/ibs.c | 1 +
include/linux/perf_event.h | 5 ++---
kernel/events/core.c | 3 ++-
5 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/arch/s390/kernel/perf_cpum_cf.c b/arch/s390/kernel/perf_cpum_cf.c
index f7dd3c849e68..f043a7ff220b 100644
--- a/arch/s390/kernel/perf_cpum_cf.c
+++ b/arch/s390/kernel/perf_cpum_cf.c
@@ -664,6 +664,7 @@ static int cfdiag_push_sample(struct perf_event *event,
raw.frag.data = cpuhw->stop;
raw.size = raw.frag.size;
data.raw = &raw;
+ data.sample_flags |= PERF_SAMPLE_RAW;
}
overflow = perf_event_overflow(event, &data, ®s);
diff --git a/arch/s390/kernel/perf_pai_crypto.c b/arch/s390/kernel/perf_pai_crypto.c
index b38b4ae01589..6826e2a69a21 100644
--- a/arch/s390/kernel/perf_pai_crypto.c
+++ b/arch/s390/kernel/perf_pai_crypto.c
@@ -366,6 +366,7 @@ static int paicrypt_push_sample(void)
raw.frag.data = cpump->save;
raw.size = raw.frag.size;
data.raw = &raw;
+ data.sample_flags |= PERF_SAMPLE_RAW;
}
overflow = perf_event_overflow(event, &data, ®s);
diff --git a/arch/x86/events/amd/ibs.c b/arch/x86/events/amd/ibs.c
index ce5720bfb350..c29a006954c7 100644
--- a/arch/x86/events/amd/ibs.c
+++ b/arch/x86/events/amd/ibs.c
@@ -781,6 +781,7 @@ static int perf_ibs_handle_irq(struct perf_ibs *perf_ibs, struct pt_regs *iregs)
},
};
data.raw = &raw;
+ data.sample_flags |= PERF_SAMPLE_RAW;
}
/*
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index f4a13579b0e8..e9b151cde491 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -1028,7 +1028,6 @@ struct perf_sample_data {
* minimize the cachelines touched.
*/
u64 sample_flags;
- struct perf_raw_record *raw;
u64 period;
/*
@@ -1040,6 +1039,7 @@ struct perf_sample_data {
union perf_mem_data_src data_src;
u64 txn;
u64 addr;
+ struct perf_raw_record *raw;
u64 type;
u64 ip;
@@ -1078,8 +1078,7 @@ static inline void perf_sample_data_init(struct perf_sample_data *data,
u64 addr, u64 period)
{
/* remaining struct members initialized in perf_prepare_sample() */
- data->sample_flags = 0;
- data->raw = NULL;
+ data->sample_flags = PERF_SAMPLE_PERIOD;
data->period = period;
if (addr) {
diff --git a/kernel/events/core.c b/kernel/events/core.c
index a91f74db9fe9..04e19a857d4b 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -7332,7 +7332,7 @@ void perf_prepare_sample(struct perf_event_header *header,
struct perf_raw_record *raw = data->raw;
int size;
- if (raw) {
+ if (raw && (data->sample_flags & PERF_SAMPLE_RAW)) {
struct perf_raw_frag *frag = &raw->frag;
u32 sum = 0;
@@ -7348,6 +7348,7 @@ void perf_prepare_sample(struct perf_event_header *header,
frag->pad = raw->size - sum;
} else {
size = sizeof(u64);
+ data->raw = NULL;
}
header->size += size;
--
2.37.3.968.ga6b4b080e4-goog
next prev parent reply other threads:[~2022-09-21 22:00 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-21 22:00 [PATCH 1/2] perf: Use sample_flags for addr Namhyung Kim
2022-09-21 22:00 ` Namhyung Kim [this message]
2022-09-28 6:57 ` [tip: perf/core] perf: Use sample_flags for raw_data tip-bot2 for Namhyung Kim
2022-10-06 16:00 ` [PATCH] " Sumanth Korikkar
2022-10-06 17:12 ` Namhyung Kim
2022-10-06 18:58 ` Jiri Olsa
2022-10-07 8:13 ` [PATCH] bpf: fix sample_flags for bpf_perf_event_output Sumanth Korikkar
2022-10-07 9:45 ` Jiri Olsa
2022-10-07 15:18 ` Peter Zijlstra
2022-10-19 4:57 ` Alexei Starovoitov
2022-10-21 1:36 ` Alexei Starovoitov
2022-10-23 1:16 ` bpf+perf is still broken. Was: " Alexei Starovoitov
2022-10-23 16:55 ` Linus Torvalds
2022-10-23 17:19 ` Linus Torvalds
2022-10-23 17:28 ` Alexei Starovoitov
2022-10-17 14:45 ` [tip: perf/urgent] bpf: Fix " tip-bot2 for Sumanth Korikkar
2022-10-17 19:27 ` [PATCH] bpf: fix " SeongJae Park
2022-10-17 22:52 ` Namhyung Kim
2022-10-17 23:35 ` SeongJae Park
2022-10-19 10:44 ` [tip: perf/core] perf: Use sample_flags for raw_data Athira Rajeev
2022-09-22 14:48 ` [PATCH 1/2] perf: Use sample_flags for addr Peter Zijlstra
2022-09-22 16:32 ` Namhyung Kim
2022-09-22 20:55 ` [PATCH] perf: Change the layout of perf_sample_data Namhyung Kim
2022-09-23 7:45 ` [PATCH 1/2] perf: Use sample_flags for addr Peter Zijlstra
2022-09-28 6:57 ` [tip: perf/core] " tip-bot2 for Namhyung Kim
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=20220921220032.2858517-2-namhyung@kernel.org \
--to=namhyung@kernel.org \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=eranian@google.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=ravi.bangoria@amd.com \
--cc=songliubraving@fb.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®