linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>,
	linux-kernel@vger.kernel.org, vince@deater.net,
	eranian@google.com, Arnaldo Carvalho de Melo <acme@infradead.org>
Subject: Re: [PATCH v2 2/5] perf: Free aux pages in unmap path
Date: Mon, 14 Mar 2016 17:42:18 +0100	[thread overview]
Message-ID: <20160314164218.GP6344@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <87fuvtyx37.fsf@ashishki-desk.ger.corp.intel.com>

On Mon, Mar 14, 2016 at 04:04:44PM +0200, Alexander Shishkin wrote:
> Peter Zijlstra <peterz@infradead.org> writes:

> >> +static void perf_pmu_output_stop(struct perf_event *event)
> >> +{
> >> +	int cpu, err;
> >> +
> >> +	/* better be thorough */
> >> +	get_online_cpus();
> >> +restart:
> >> +	for_each_online_cpu(cpu) {
> >> +		err = cpu_function_call(cpu, __perf_pmu_output_stop, event);
> >> +		if (err)
> >> +			goto restart;
> >> +	}
> >> +	put_online_cpus();
> >> +}
> >
> > This seems wildly overkill, could we not iterate rb->event_list like we
> > do for the normal buffer?
> 
> Actually we can. One problem though is that iterating rb::event_list
> requires rcu read section or irqsafe rb::event_lock and we need to send
> IPIs. 

We should be able to send IPIs with rcu_read_lock() held; doing so with
IRQs disabled is a bit harder.

> The normal buffer case tears down the rb::event_list as it goes,
> so it can close the rcu read section right after it fetches one event
> from it. In this case however, we must keep the list intact.

Yep..

> > Sure, we need to IPI for each event found, but that seems better than
> > unconditionally sending IPIs to all CPUs.
> 
> Actually, won't it "often" be the case that the number of events will be
> a multiple of the number of cpus? The usual use case being one event per
> task per cpu and inheritance enabled. In this case we'll zap multiple
> events per IPI.

Right, but then each event (or set thereof) will be for one particular
CPU. So for the one munmap() you typically only end up sending IPIs to
that one CPU.

If OTOH you send IPIs to all CPUs for all events, you end up with n^2
IPIs, because for each CPUs munmap() you send IPIs to all other CPUs.

  reply	other threads:[~2016-03-14 16:42 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-04 13:42 [PATCH v2 0/5] perf: Untangle aux refcounting Alexander Shishkin
2016-03-04 13:42 ` [PATCH v2 1/5] perf: Refuse to begin aux transaction after aux_mmap_count drops Alexander Shishkin
2016-03-31  9:23   ` [tip:perf/core] perf/ring_buffer: Refuse to begin AUX transaction after rb->aux_mmap_count drops tip-bot for Alexander Shishkin
2016-03-04 13:42 ` [PATCH v2 2/5] perf: Free aux pages in unmap path Alexander Shishkin
2016-03-14 12:38   ` Peter Zijlstra
2016-03-14 14:04     ` Alexander Shishkin
2016-03-14 16:42       ` Peter Zijlstra [this message]
2016-03-17 13:05         ` Alexander Shishkin
2016-03-23  8:34           ` Peter Zijlstra
2016-03-31  9:24           ` [tip:perf/core] perf/core: Free AUX " tip-bot for Alexander Shishkin
2016-03-04 13:42 ` [PATCH v2 3/5] perf: Document aux api usage Alexander Shishkin
2016-03-31  9:24   ` [tip:perf/core] perf/ring_buffer: Document AUX API usage tip-bot for Alexander Shishkin
2016-03-04 13:42 ` [PATCH v2 4/5] perf/x86/intel/pt: Move transaction start/stop to pmu start/stop callbacks Alexander Shishkin
2016-03-31  9:24   ` [tip:perf/core] perf/x86/intel/pt: Move transaction start/stop to PMU " tip-bot for Alexander Shishkin
2016-03-04 13:42 ` [PATCH v2 5/5] perf/x86/intel/bts: Move transaction start/stop to " Alexander Shishkin
2016-03-31  9:25   ` [tip:perf/core] " tip-bot for Alexander Shishkin

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=20160314164218.GP6344@twins.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=acme@infradead.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=eranian@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=vince@deater.net \
    /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).