Linux Perf Users
 help / color / mirror / Atom feed
From: Ping Li <leeonion.muyu@gmail.com>
To: leo.yan@arm.com
Cc: leeonion.muyu@gmail.com, will@kernel.org, mark.rutland@arm.com,
	robh@kernel.org, james.clark@linaro.org,
	linux-arm-kernel@lists.infradead.org,
	linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/2] perf: arm_spe: Validate the data source filter per-bit
Date: Mon, 30 Nov 2026 21:17:48 +0800	[thread overview]
Message-ID: <20261130131748.1487948-1-leeonion.muyu@gmail.com> (raw)
In-Reply-To: <"20261130104035.GJ861809@e132581.arm.com">

From: leeonion.muyu@gmail.com

Hi Leo,

Thanks for looking at this. I actually spent quite a while on the
direction when Sashiko first flagged it, so let me lay out my
reasoning with a concrete config - happy to reshape if I have
something wrong.

Assume an implementation where PMSDSFR_EL1 implements bits 0-7 and
bits 8-63 are RAZ/WI. Probing gives:

    write 0xffffffffffffffff, read back 0x00000000000000ff
    pmsdsfr_res0 = 0xffffffffffffff00

so bits 8-63 ignore writes and always read 0. Per DDI 0487 D17.5.4,
a sampled load with data source DS is "recorded only if
PMSDSFR_EL1[UInt(DS[5:0])] is 1", so while the filter is enabled,
sources 8-63 are never recorded.

Example: inv_data_src_filter=0x8 (exclude source 3, keep the rest)

    config4                = 0x0000000000000008
    written to PMSDSFR_EL1 = ~config4 = 0xfffffffffffffff7

    reg  & pmsdsfr_res0 = 0xfffffffffffffff7 & 0xffffffffffffff00
                        = 0xffffffffffffff00 != 0
        -> current check rejects: perf_event_open() fails with
           -EOPNOTSUPP

    ~reg & pmsdsfr_res0 = 0x0000000000000008 & 0xffffffffffffff00
                        = 0x0000000000000000 == 0
        -> proposed check passes: the session runs, source 3 is
           excluded as requested, but sources 8-63 are silently
           missing although the config asked to include them

The crux is the bits the user never explicitly set: with the
inverted ABI, a cleared bit asks for the source to be included, so
inv_data_src_filter=0x8 also asks for sources 8-63 to be included,
and their bits are not implemented. That is what reg & pmsdsfr_res0
rejects, so the user knows up front instead of finding those
sources missing afterwards. (A set bit is always honoured for free,
and on a full implementation both checks are vacuous.)

What do you think about exposing ~pmsdsfr_res0 as a caps entry, as
you did for the event filter with caps/event_filter? The rejected
config then becomes actionable:

    cat caps/data_src_filter    # 0x00000000000000ff
    perf record -e arm_spe_0/inv_data_src_filter=0xffffffffffffff08/

with 0xffffffffffffff08 = 0x8 | ~0xff - excluding source 3 and the
unfilterable sources, so it passes the check.

Happy to go with your preference if you see it differently.

Thanks,
Ping

       reply	other threads:[~2026-11-30 13:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <"20261130104035.GJ861809@e132581.arm.com">
2026-11-30 13:17 ` Ping Li [this message]
2026-11-30 14:50   ` [PATCH v2 2/2] perf: arm_spe: Validate the data source filter per-bit Leo Yan
2026-11-30  6:13 [PATCH v2 0/2] perf: arm_spe: Validate the filter configs per-bit Ping Li
2026-11-30  6:13 ` [PATCH v2 2/2] perf: arm_spe: Validate the data source filter per-bit Ping Li
2026-11-30 10:40   ` Leo Yan
2026-11-30 14:51   ` James Clark

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=20261130131748.1487948-1-leeonion.muyu@gmail.com \
    --to=leeonion.muyu@gmail.com \
    --cc=james.clark@linaro.org \
    --cc=leo.yan@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=robh@kernel.org \
    --cc=will@kernel.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