mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nadav Amit <nadav.amit@gmail.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: kan.liang@linux.intel.com, LKML <linux-kernel@vger.kernel.org>,
	linux-perf-users@vger.kernel.org
Subject: Re: Using perf_event_open() to sample multiple events of a process
Date: Fri, 5 Nov 2021 17:59:26 -0700	[thread overview]
Message-ID: <DB6138F5-29A4-40AE-8307-6C3ED07A0649@gmail.com> (raw)
In-Reply-To: <YYXQRYbRO193U4re@hirez.programming.kicks-ass.net>



> On Nov 5, 2021, at 5:45 PM, Peter Zijlstra <peterz@infradead.org> wrote:
> 
> On Thu, Nov 04, 2021 at 10:57:50PM -0700, Nadav Amit wrote:
>> Hello Ken, Peter,
>> 
>> I would appreciate some help regarding the use of perf_event_open()
>> to have multiple samples getting into the same mmap’d memory when they
>> are both attached to the same process.
>> 
>> I am doing so (using both PERF_FLAG_FD_NO_GROUP and PERF_FLAG_FD_OUTPUT),
>> but it results in -EINVAL. Debugging the code shows that
>> perf_event_set_output() fails due to the following check:
>> 
>>        /*
>>         * If its not a per-cpu rb, it must be the same task.
>>         */
>>        if (output_event->cpu == -1 && output_event->ctx != event->ctx)
>>                goto out;
>> 
>> However, it appears that at this point, event->ctx is not initialized
>> (it is null) so the test fails and the whole perf_event_open() syscall
>> fails.
>> 
>> Am I missing something? If not, I am unsure, unfortunately, what the
>> proper way to fix it is…
>> 
>> I include a small test that fails on my system. The second
>> perf_event_open fails due to the check in perf_event_set_output():
>> 
> 
> Works when you use the SET_OUTPUT ioctl()...
> 
> I think something went sideways in the syscall path and things went out
> of order :/ I'll try and have a look.

Highly appreciated.

While at it, I would note that there is a mistake in Intel SDM 31.4.2.27,
Table 31-47 “Block Item Packet Definition”. The ID[5:0] takes 6 bits,
when in fact I presume it is only 5 bits (according to the table).

Perhaps you can forward it to the relevant people.

Thanks again,
Nadav

      parent reply	other threads:[~2021-11-06  0:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-05  5:57 Nadav Amit
2021-11-06  0:45 ` Peter Zijlstra
2021-11-06  0:57   ` Peter Zijlstra
2021-11-08 15:24     ` Peter Zijlstra
2021-11-08 19:51       ` Nadav Amit
2021-11-06  0:59   ` Nadav Amit [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=DB6138F5-29A4-40AE-8307-6C3ED07A0649@gmail.com \
    --to=nadav.amit@gmail.com \
    --cc=kan.liang@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.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®