From: "Liang, Kan" <kan.liang@linux.intel.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: acme@kernel.org, mingo@kernel.org, linux-kernel@vger.kernel.org,
eranian@google.com, namhyung@kernel.org, jolsa@redhat.com,
ak@linux.intel.com, yao.jin@linux.intel.com
Subject: Re: [PATCH 01/12] perf/core: Add PERF_SAMPLE_WEIGHT_EXT
Date: Tue, 26 Jan 2021 10:33:18 -0500 [thread overview]
Message-ID: <d018282d-f47d-4382-2538-59c6930a74c3@linux.intel.com> (raw)
In-Reply-To: <YBAqYyTuqxsH8tqR@hirez.programming.kicks-ass.net>
On 1/26/2021 9:42 AM, Peter Zijlstra wrote:
> On Tue, Jan 19, 2021 at 12:38:20PM -0800, kan.liang@linux.intel.com wrote:
>
>> @@ -900,6 +901,13 @@ enum perf_event_type {
>> * char data[size]; } && PERF_SAMPLE_AUX
>> * { u64 data_page_size;} && PERF_SAMPLE_DATA_PAGE_SIZE
>> * { u64 code_page_size;} && PERF_SAMPLE_CODE_PAGE_SIZE
>> + * { union {
>> + * u64 weight_ext;
>> + * struct {
>> + * u64 instr_latency:16,
>> + * reserved:48;
>> + * };
>> + * } && PERF_SAMPLE_WEIGHT_EXT
>> * };
>> */
>> PERF_RECORD_SAMPLE = 9,
>> @@ -1248,4 +1256,12 @@ struct perf_branch_entry {
>> reserved:40;
>> };
>>
>> +union perf_weight_ext {
>> + __u64 val;
>> + struct {
>> + __u64 instr_latency:16,
>> + reserved:48;
>> + };
>> +};
>> +
>> #endif /* _UAPI_LINUX_PERF_EVENT_H */
>> diff --git a/kernel/events/core.c b/kernel/events/core.c
>> index 55d1879..9363d12 100644
>> --- a/kernel/events/core.c
>> +++ b/kernel/events/core.c
>> @@ -1903,6 +1903,9 @@ static void __perf_event_header_size(struct perf_event *event, u64 sample_type)
>> if (sample_type & PERF_SAMPLE_CODE_PAGE_SIZE)
>> size += sizeof(data->code_page_size);
>>
>> + if (sample_type & PERF_SAMPLE_WEIGHT_EXT)
>> + size += sizeof(data->weight_ext);
>> +
>> event->header_size = size;
>> }
>>
>> @@ -6952,6 +6955,9 @@ void perf_output_sample(struct perf_output_handle *handle,
>> perf_aux_sample_output(event, handle, data);
>> }
>>
>> + if (sample_type & PERF_SAMPLE_WEIGHT_EXT)
>> + perf_output_put(handle, data->weight_ext);
>> +
>> if (!event->attr.watermark) {
>> int wakeup_events = event->attr.wakeup_events;
>>
>
> This patch is broken and will expose uninitialized kernel stack.
>
Could we initialize the 'weight_ext' in perf_sample_data_init()?
I understand that we prefer not to set the field in
perf_sample_data_init() to minimize the cachelines touched.
However, the perf_sample_data_init() should be the most proper place to
do the initialization. Also, the 'weight' is already initialized in it.
As an extension, I think the 'weight_ext' should be initialized in it as
well.
In the perf_prepare_sample(), I think we can only clear the unused
fields. The [0:15] bits may still leak the data.
Thanks,
Kan
next prev parent reply other threads:[~2021-01-26 15:35 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-19 20:38 [PATCH 00/12] perf core PMU support for Sapphire Rapids kan.liang
2021-01-19 20:38 ` [PATCH 01/12] perf/core: Add PERF_SAMPLE_WEIGHT_EXT kan.liang
2021-01-26 14:42 ` Peter Zijlstra
2021-01-26 15:33 ` Liang, Kan [this message]
2021-01-26 15:55 ` Peter Zijlstra
2021-01-19 20:38 ` [PATCH 02/12] perf/x86/intel: Factor out intel_update_topdown_event() kan.liang
2021-01-19 20:38 ` [PATCH 03/12] perf/x86/intel: Add perf core PMU support for Sapphire Rapids kan.liang
2021-01-26 14:43 ` Peter Zijlstra
2021-01-26 15:34 ` Liang, Kan
2021-01-26 14:44 ` Peter Zijlstra
2021-01-26 15:44 ` Liang, Kan
2021-01-27 19:16 ` Peter Zijlstra
2021-01-26 14:49 ` Peter Zijlstra
2021-01-26 15:37 ` Peter Zijlstra
2021-01-26 16:21 ` Liang, Kan
2021-01-19 20:38 ` [PATCH 04/12] perf/x86/intel: Support CPUID 10.ECX to disable fixed counters kan.liang
2021-01-26 15:44 ` Peter Zijlstra
2021-01-26 15:53 ` Peter Zijlstra
2021-01-19 20:38 ` [PATCH 05/12] tools headers uapi: Update tools's copy of linux/perf_event.h kan.liang
2021-01-19 20:38 ` [PATCH 06/12] perf tools: Support data block and addr block kan.liang
2021-01-19 20:38 ` [PATCH 07/12] perf c2c: " kan.liang
2021-01-19 20:38 ` [PATCH 08/12] perf tools: Support PERF_SAMPLE_WEIGHT_EXT kan.liang
2021-01-19 20:38 ` [PATCH 09/12] perf report: Support instruction latency kan.liang
2021-01-19 20:38 ` [PATCH 10/12] perf test: Support PERF_SAMPLE_WEIGHT_EXT kan.liang
2021-01-19 20:38 ` [PATCH 11/12] perf stat: Support L2 Topdown events kan.liang
2021-01-19 20:38 ` [PATCH 12/12] perf, tools: Update topdown documentation for Sapphire Rapids kan.liang
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=d018282d-f47d-4382-2538-59c6930a74c3@linux.intel.com \
--to=kan.liang@linux.intel.com \
--cc=acme@kernel.org \
--cc=ak@linux.intel.com \
--cc=eranian@google.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=yao.jin@linux.intel.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®