From: Peter Zijlstra <peterz@infradead.org>
To: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@redhat.com>,
linux-kernel@vger.kernel.org, jolsa@redhat.com
Subject: Re: [PATCH v1 4/6] perf: Allow using AUX data in perf samples
Date: Thu, 26 Sep 2019 16:44:50 +0200 [thread overview]
Message-ID: <20190926144450.GC4519@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <87lfw234ew.fsf@ashishki-desk.ger.corp.intel.com>
On Fri, Aug 09, 2019 at 03:32:39PM +0300, Alexander Shishkin wrote:
> The other problem is sampling SW events, that would require a ctx->lock
> to prevent racing with event_function_call()s from other cpus, resulting
> in somewhat cringy "if (!in_nmi()) raw_spin_lock(...)", but I don't have
> better idea as to how to handle that.
> +int perf_pmu_aux_sample_output(struct perf_event *event,
> + struct perf_output_handle *handle,
> + unsigned long size)
> +{
> + unsigned long flags;
> + int ret;
> +
> + /*
> + * NMI vs IRQ
> + *
> + * Normal ->start()/->stop() callbacks run in IRQ mode in scheduler
> + * paths. If we start calling them in NMI context, they may race with
> + * the IRQ ones, that is, for example, re-starting an event that's just
> + * been stopped.
> + */
> + if (!in_nmi())
> + raw_spin_lock_irqsave(&event->ctx->lock, flags);
> +
> + ret = event->pmu->snapshot_aux(event, handle, size);
> +
> + if (!in_nmi())
> + raw_spin_unlock_irqrestore(&event->ctx->lock, flags);
> +
> + return ret;
> +}
I'm confused... would not something like:
unsigned long flags;
local_irq_save(flags);
ret = event->pmu->snapshot_aux(...);
local_irq_restore(flags);
return ret;
Be sufficient? By disabling IRQs we already hold off remote
event_function_call()s.
Or am I misunderstanding the race here?
next prev parent reply other threads:[~2019-09-26 14:44 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-12 7:51 [PATCH v1 0/6] perf: Add AUX data sampling Alexander Shishkin
2018-06-12 7:51 ` [PATCH v1 1/6] perf: Disable PMU around address filter adjustment Alexander Shishkin
2018-06-12 20:11 ` Peter Zijlstra
2018-06-12 7:51 ` [PATCH v1 2/6] perf: Disable IRQs in address filter sync path Alexander Shishkin
2018-06-12 7:51 ` [PATCH v1 3/6] perf: Add an iterator for AUX data Alexander Shishkin
2018-06-12 7:51 ` [PATCH v1 4/6] perf: Allow using AUX data in perf samples Alexander Shishkin
2018-06-14 19:25 ` Peter Zijlstra
2018-06-14 19:39 ` Peter Zijlstra
2018-06-19 10:51 ` Alexander Shishkin
2018-06-14 19:30 ` Peter Zijlstra
2018-06-14 19:47 ` Peter Zijlstra
2018-06-19 11:00 ` Alexander Shishkin
2018-06-14 20:03 ` Peter Zijlstra
2018-06-14 20:20 ` Peter Zijlstra
2018-06-19 10:47 ` Alexander Shishkin
2018-06-21 20:16 ` Peter Zijlstra
2018-10-02 14:00 ` Alexander Shishkin
2019-08-09 12:32 ` Alexander Shishkin
2019-09-26 12:04 ` Alexander Shishkin
2019-09-26 14:44 ` Peter Zijlstra [this message]
2019-09-30 11:50 ` Alexander Shishkin
2018-06-12 7:51 ` [PATCH v1 5/6] perf: Drop PERF_FLAG_FD_OUTPUT Alexander Shishkin
2018-06-12 7:51 ` [PATCH v1 6/6] perf: Allow set-output for task contexts of different types Alexander Shishkin
2018-06-14 19:36 ` Peter Zijlstra
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=20190926144450.GC4519@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=acme@redhat.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.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