public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Song Liu <songliubraving@fb.com>
Cc: open list <linux-kernel@vger.kernel.org>,
	Kernel Team <Kernel-team@fb.com>,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Jiri Olsa <jolsa@kernel.org>,
	Alexey Budankov <alexey.budankov@linux.intel.com>,
	Namhyung Kim <namhyung@kernel.org>, Tejun Heo <tj@kernel.org>
Subject: Re: [PATCH v8] perf: Sharing PMU counters across compatible events
Date: Thu, 12 Dec 2019 19:52:20 +0100	[thread overview]
Message-ID: <20191212185220.GD2827@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <990C21F3-A93B-414A-9DB7-C17AADF037C7@fb.com>

On Thu, Dec 12, 2019 at 03:45:49PM +0000, Song Liu wrote:
> > On Dec 12, 2019, at 7:39 AM, Peter Zijlstra <peterz@infradead.org> wrote:

> > Yuck!
> > 
> > Why do you do a full reschedule when you take out a master?
> 
> If there is active slave using this master, we need to schedule out
> them before removing the master. 
> 
> We can improve the check though. We only need to do it if the master
> is in state PERF_EVENT_STATE_ENABLED. 
> 
> Or we can add a different function to only schedule out slaves. 

So I've been thinking, this is because an NMI from another event can
come in and then does PERF_SAMPLE_READ which covers our event, right?

AFAICT every other case will run under ctx->lock, which we own at this
point.

So can't we:

 1 - stop the current master (such that the counts are frozen)
 2 - pick the new master
 3 - initialize the new master (such that the counts match)
 4 - set the new master on all other events
 5 - start the new master (counters run again)

Then, no matter where the NMI lands, it will always find either the old
or the new master and their counts will match.

You really don't need to stop all events.

  parent reply	other threads:[~2019-12-12 18:52 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-07  0:24 [PATCH v8] perf: Sharing PMU counters across compatible events Song Liu
2019-12-11 18:50 ` Song Liu
2019-12-12 13:42 ` Peter Zijlstra
2019-12-12 15:18   ` Song Liu
2019-12-12 13:49 ` Peter Zijlstra
2019-12-12 15:37   ` Song Liu
2019-12-12 15:44     ` Peter Zijlstra
2019-12-12 15:47       ` Song Liu
2019-12-12 15:39 ` Peter Zijlstra
2019-12-12 15:45   ` Song Liu
2019-12-12 16:00     ` Song Liu
2019-12-12 18:01       ` Song Liu
2019-12-12 18:52     ` Peter Zijlstra [this message]
2019-12-12 23:49       ` Song Liu

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=20191212185220.GD2827@hirez.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=Kernel-team@fb.com \
    --cc=acme@redhat.com \
    --cc=alexey.budankov@linux.intel.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=namhyung@kernel.org \
    --cc=songliubraving@fb.com \
    --cc=tj@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