mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Stephane Eranian <eranian@google.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Andi Kleen <ak@linux.intel.com>,
	"Liang, Kan" <kan.liang@intel.com>,
	mingo@elte.hu, nelson.dsouza@intel.com,
	Jiri Olsa <jolsa@redhat.com>,
	tonyj@suse.com
Subject: Re: [PATCH 3/3] perf/x86/intel: force resched when TFA sysctl is modified
Date: Fri, 5 Apr 2019 22:26:20 +0200	[thread overview]
Message-ID: <20190405202620.GG4038@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <CABPqkBTzBYSN_k6FV=iOmmBfZWmG2N9fYHke_MdiCCgO=KFeUw@mail.gmail.com>

On Fri, Apr 05, 2019 at 10:00:03AM -0700, Stephane Eranian wrote:

> > > +static void update_tfa_sched(void *ignored)
> > > +{
> > > +     struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);
> > > +     struct pmu *pmu = x86_get_pmu();
> > > +     struct perf_cpu_context *cpuctx = this_cpu_ptr(pmu->pmu_cpu_context);
> > > +     struct perf_event_context *task_ctx = cpuctx->task_ctx;
> > > +
> > > +     /* prevent any changes to the two contexts */
> > > +     perf_ctx_lock(cpuctx, task_ctx);
> > > +
> > > +     /*
> > > +      * check if PMC3 is used
> > > +      * and if so force schedule out for all event types all contexts
> > > +      */
> > > +     if (test_bit(3, cpuc->active_mask))
> > > +             perf_ctx_resched(cpuctx, task_ctx, EVENT_ALL|EVENT_CPU);
> > > +
> > > +     perf_ctx_unlock(cpuctx, task_ctx);
> >
> > I'm not particularly happy with exporting all that. Can't we create this
> > new perf_ctx_resched() to include the locking and everything. Then the
> > above reduces to:
> >
> >         if (test_bit(3, cpuc->active_mask))
> >                 perf_ctx_resched(cpuctx);
> >
> > And we don't get to export the tricky bits.
> >
> The only reason I exported the locking is to protect
> cpuc->active_mask. But if you
> think there is no race, then sure,  we can just export a new
> perf_ctx_resched() that
> does the locking and invokes the ctx_resched() function.

It doesn't matter if it races, if it was used and isn't anymore, it's
a pointless reschedule, if it isn't used and we don't reschedule, it
cannot be used because we've already set the flag.

  reply	other threads:[~2019-04-05 20:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-04 18:32 [PATCH 0/3] perf/x86/intel: force reschedule on TFA changes Stephane Eranian
2019-04-04 18:32 ` [PATCH 1/3] perf/core: make perf_ctx_*lock() global inline functions Stephane Eranian
2019-04-04 18:32 ` [PATCH 2/3] perf/core: make ctx_resched() a global function Stephane Eranian
2019-04-04 18:32 ` [PATCH 3/3] perf/x86/intel: force resched when TFA sysctl is modified Stephane Eranian
2019-04-05  7:13   ` Peter Zijlstra
2019-04-05 17:00     ` Stephane Eranian
2019-04-05 20:26       ` Peter Zijlstra [this message]
2019-04-06  0:49         ` Stephane Eranian

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=20190405202620.GG4038@hirez.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=ak@linux.intel.com \
    --cc=eranian@google.com \
    --cc=jolsa@redhat.com \
    --cc=kan.liang@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=nelson.dsouza@intel.com \
    --cc=tglx@linutronix.de \
    --cc=tonyj@suse.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

Powered by JetHome