linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: James Clark <james.clark@arm.com>
To: Namhyung Kim <namhyung@kernel.org>, Ben Gainey <Ben.Gainey@arm.com>
Cc: "alexander.shishkin@linux.intel.com"
	<alexander.shishkin@linux.intel.com>,
	"peterz@infradead.org" <peterz@infradead.org>,
	"acme@kernel.org" <acme@kernel.org>,
	"mingo@redhat.com" <mingo@redhat.com>,
	"adrian.hunter@intel.com" <adrian.hunter@intel.com>,
	"irogers@google.com" <irogers@google.com>,
	"jolsa@kernel.org" <jolsa@kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-perf-users@vger.kernel.org"
	<linux-perf-users@vger.kernel.org>,
	Mark Rutland <Mark.Rutland@arm.com>
Subject: Re: [PATCH v6 4/4] tools/perf: Allow inherit + PERF_SAMPLE_READ when opening events
Date: Thu, 30 May 2024 13:54:42 +0100	[thread overview]
Message-ID: <193884e6-0911-4a5f-9676-74e1630f9a28@arm.com> (raw)
In-Reply-To: <CAM9d7cjmH=nkEt-z_XpZ1J0oL-EY2d52oz70-KpN+uzM5SEk6A@mail.gmail.com>



On 29/05/2024 20:18, Namhyung Kim wrote:
> Hello,
> 
> On Wed, May 29, 2024 at 10:48 AM Ben Gainey <Ben.Gainey@arm.com> wrote:
>>
>> On Mon, 2024-05-27 at 18:47 +0100, Ben Gainey wrote:
>>> On Thu, 2024-05-23 at 18:41 -0700, Namhyung Kim wrote:
>>>> On Tue, May 21, 2024 at 6:30 AM Ben Gainey <ben.gainey@arm.com>
>>>> wrote:
>>>>>
>>>>> The tool will now default to this new mode if the user specifies
>>>>> a
>>>>> sampling group when not in system-wide mode, and when --no-
>>>>> inherit
>>>>> is not specified.
>>>>>
>>>>> This change updates evsel to allow the combination of inherit
>>>>> and PERF_SAMPLE_READ.
>>>>>
>>>>> A fallback is implemented for kernel versions where this feature
>>>>> is
>>>>> not
>>>>> supported.
>>>>
>>>> But I'm afraid the test would fail on old kernels.  Maybe we need
>>>> to
>>>> put it in the selftests.
>>>>
>>>
>>> Sorry, not clear what you mean?
>>>
>>> Is the issue that the fallback on older kernels fails, or that the
>>> "perf test" tests fail?
>>>
>>> Thanks
>>> Ben
>>
>> Just to follow up, I've rechecked the fallback on an unmodified 6.9.1
>> kernel with the following:
>>
>>     perf record -vv -e '{cycles,instructions}:S' ls
>>
>> With an unpatched version of perf running on an unpatched kernel, the
>> cycles event is opened as:
>>
>>     ------------------------------------------------------------
>>     perf_event_attr:
>>       type                             0 (PERF_TYPE_HARDWARE)
>>       size                             136
>>       config                           0 (PERF_COUNT_HW_CPU_CYCLES)
>>       { sample_period, sample_freq }   4000
>>       sample_type                      IP|TID|TIME|READ|ID|PERIOD
>>       read_format                      ID|GROUP|LOST
>>       disabled                         1
>>       exclude_kernel                   1
>>       exclude_hv                       1
>>       mmap                             1
>>       comm                             1
>>       freq                             1
>>       enable_on_exec                   1
>>       task                             1
>>       sample_id_all                    1
>>       exclude_guest                    1
>>       mmap2                            1
>>       comm_exec                        1
>>       ksymbol                          1
>>       bpf_event                        1
>>     ------------------------------------------------------------
>>
>> whereas with these patches applied to perf, on an unpatched kernel, the
>> output is as follows
>>
>>     ------------------------------------------------------------
>>     perf_event_attr:
>>       type                             0 (PERF_TYPE_HARDWARE)
>>       size                             136
>>       config                           0 (PERF_COUNT_HW_CPU_CYCLES)
>>       { sample_period, sample_freq }   4000
>>       sample_type                      IP|TID|TIME|READ|ID|PERIOD
>>       read_format                      ID|GROUP|LOST
>>       disabled                         1
>>       inherit                          1
>>       exclude_kernel                   1
>>       exclude_hv                       1
>>       mmap                             1
>>       comm                             1
>>       freq                             1
>>       enable_on_exec                   1
>>       task                             1
>>       sample_id_all                    1
>>       exclude_guest                    1
>>       mmap2                            1
>>       comm_exec                        1
>>       ksymbol                          1
>>       bpf_event                        1
>>     ------------------------------------------------------------
>>     sys_perf_event_open: pid 3442954  cpu 0  group_fd -1  flags 0x8
>>     sys_perf_event_open failed, error -22
>>     Using PERF_SAMPLE_READ / :S modifier is not compatible with
>> inherit, falling back to no-inherit.
>>     ------------------------------------------------------------
>>     perf_event_attr:
>>       type                             0 (PERF_TYPE_HARDWARE)
>>       size                             136
>>       config                           0 (PERF_COUNT_HW_CPU_CYCLES)
>>       { sample_period, sample_freq }   4000
>>       sample_type                      IP|TID|TIME|READ|ID|PERIOD
>>       read_format                      ID|GROUP|LOST
>>       disabled                         1
>>       exclude_kernel                   1
>>       exclude_hv                       1
>>       mmap                             1
>>       comm                             1
>>       freq                             1
>>       enable_on_exec                   1
>>       task                             1
>>       sample_id_all                    1
>>       exclude_guest                    1
>>       mmap2                            1
>>       comm_exec                        1
>>       ksymbol                          1
>>       bpf_event                        1
>>     ------------------------------------------------------------
>>
>> The command falls back to the same configuration as was previously
>> used. The same is true for the instructions event.
>>
>> `perf test` fails on an unpatched kernel in "15: Setup struct
>> perf_event_attr" for the test "test-record-group-sampling1" but that is
>> surely expected for unpatched kernels?
>>
>> Is there some very-old kernel version where this would be expected to
>> succeed by accident?
> 
> I don't think so but I don't want the test to fail depending on the
> kernel version.  Maybe we can check the allowed combination
> first and skip the test if perf_event_open() fails.  And then it can
> verify if the kernel rejects the unsupported combinations.  Not
> sure if it's easy to do that in the current attr test framework.
> 
> Thanks,
> Namhyung

I added the kernel version feature to the attr tests. Seems like you can
add two tests, one for before and one for after.

Search "kernel_until" in tests/attr

      reply	other threads:[~2024-05-30 12:54 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-21 13:30 [PATCH v6 0/4] perf: Support PERF_SAMPLE_READ with inherit Ben Gainey
2024-05-21 13:30 ` [PATCH v6 1/4] " Ben Gainey
2024-05-24  1:38   ` Namhyung Kim
2024-05-21 13:30 ` [PATCH v6 2/4] tools/perf: Track where perf_sample_ids need per-thread periods Ben Gainey
2024-05-21 13:30 ` [PATCH v6 3/4] tools/perf: Correctly calculate sample period for inherited SAMPLE_READ values Ben Gainey
2024-05-21 13:30 ` [PATCH v6 4/4] tools/perf: Allow inherit + PERF_SAMPLE_READ when opening events Ben Gainey
2024-05-24  1:41   ` Namhyung Kim
2024-05-27 17:47     ` Ben Gainey
2024-05-29 17:47       ` Ben Gainey
2024-05-29 19:18         ` Namhyung Kim
2024-05-30 12:54           ` James Clark [this message]

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=193884e6-0911-4a5f-9676-74e1630f9a28@arm.com \
    --to=james.clark@arm.com \
    --cc=Ben.Gainey@arm.com \
    --cc=Mark.Rutland@arm.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).