From: James Clark <james.clark@arm.com>
To: Anshuman Khandual <anshuman.khandual@arm.com>,
linux-kernel@vger.kernel.org
Cc: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>,
linux-perf-users@vger.kernel.org
Subject: Re: [PATCH] perf/core: Reset remaining bits in perf_clear_branch_entry_bitfields()
Date: Thu, 1 Dec 2022 10:24:09 +0000 [thread overview]
Message-ID: <a1312c5e-b03f-8116-7e86-cff618e9e080@arm.com> (raw)
In-Reply-To: <20221201055103.302019-1-anshuman.khandual@arm.com>
On 01/12/2022 05:51, Anshuman Khandual wrote:
> perf_clear_branch_entry_bitfields() resets all struct perf_branch_entry bit
> fields before capturing branch records. This resets remaining bit fields
> except 'new_type', which is valid only when 'type' is PERF_BR_EXTEND_ABI.
>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
> Cc: Jiri Olsa <jolsa@kernel.org>
> Cc: Namhyung Kim <namhyung@kernel.org>
> Cc: linux-perf-users@vger.kernel.org>
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
> ---
> This applies on v6.1-rc6
>
> 'perf_branch_entry.new_type' can remain uninitialized as explained earlier.
> Also there is no PERF_BR_NEW_UNKNOWN to spare, because 'perf_branch_entry.
> new_type' enumeration starts at PERF_BR_NEW_FAULT_ALGN, to save a position
> for the extended branch types instead.
>
> include/linux/perf_event.h | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
> index 0031f7b4d9ab..c97b5f6f77a4 100644
> --- a/include/linux/perf_event.h
> +++ b/include/linux/perf_event.h
> @@ -1110,8 +1110,9 @@ static inline void perf_clear_branch_entry_bitfields(struct perf_branch_entry *b
> br->in_tx = 0;
> br->abort = 0;
> br->cycles = 0;
> - br->type = 0;
> + br->type = PERF_BR_UNKNOWN;
> br->spec = PERF_BR_SPEC_NA;
> + br->priv = PERF_BR_PRIV_UNKNOWN;
> br->reserved = 0;
> }
I would vote for just memsetting the whole struct to 0 at this point and
making it work by ensuring the cleared from and to values are only set
after this function.
Or do the thing where it's wrapped in a union and the 'u64 value' member
is assigned 0. See union perf_mem_data_src. I don't know if this would
be a breaking change, but it doesn't look like it.
Currently this is a bit too fragile and the kind of bugs it will cause
are almost undetectable.
But as my proposal is an extra change on top of this:
Reviewed-by: James Clark <james.clark@arm.com>
James
>
next prev parent reply other threads:[~2022-12-01 10:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-01 5:51 Anshuman Khandual
2022-12-01 10:24 ` James Clark [this message]
2022-12-05 3:41 ` Anshuman Khandual
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=a1312c5e-b03f-8116-7e86-cff618e9e080@arm.com \
--to=james.clark@arm.com \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=anshuman.khandual@arm.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
/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®