public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Frederic Weisbecker <fweisbec@gmail.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Preeti U Murthy <preeti@linux.vnet.ibm.com>,
	Christoph Lameter <cl@linux.com>, Ingo Molnar <mingo@kernel.org>,
	Viresh Kumar <viresh.kumar@linaro.org>,
	Rik van Riel <riel@redhat.com>
Subject: Re: [PATCH 7/8] nohz: Evaluate tick dependency once on context switch
Date: Mon, 6 Jul 2015 18:14:14 +0200	[thread overview]
Message-ID: <20150706161413.GC4981@lerouge> (raw)
In-Reply-To: <20150612073650.GP3644@twins.programming.kicks-ass.net>

On Fri, Jun 12, 2015 at 09:36:50AM +0200, Peter Zijlstra wrote:
> On Thu, Jun 11, 2015 at 07:36:07PM +0200, Frederic Weisbecker wrote:
> > +static void tick_nohz_full_update_dependencies(void)
> > +{
> > +	struct tick_sched *ts = this_cpu_ptr(&tick_cpu_sched);
> > +
> > +	if (!posix_cpu_timers_can_stop_tick(current))
> > +		ts->tick_needed |= TICK_NEEDED_POSIX_CPU_TIMER;
> > +
> > +	if (!perf_event_can_stop_tick())
> > +		ts->tick_needed |= TICK_NEEDED_PERF_EVENT;
> > +
> > +	if (!sched_can_stop_tick())
> > +		ts->tick_needed |= TICK_NEEDED_SCHED;
> >  
> >  #ifdef CONFIG_HAVE_UNSTABLE_SCHED_CLOCK
> >  	/*
> > +	 * sched_clock_tick() needs us?
> > +	 *
> >  	 * TODO: kick full dynticks CPUs when
> >  	 * sched_clock_stable is set.
> >  	 */
> >  	if (!sched_clock_stable()) {
> > +		ts->tick_needed |= TICK_NEEDED_CLOCK_UNSTABLE;
> >  		/*
> >  		 * Don't allow the user to think they can get
> >  		 * full NO_HZ with this machine.
> >  		 */
> >  		WARN_ONCE(tick_nohz_full_running,
> >  			  "NO_HZ FULL will not work with unstable sched clock");
> >  	}
> >  #endif
> >  }
> 
> Colour me confused; why does this function exist at all? Should not
> these bits be managed by those respective subsystems?

So we have two choices here:

1) Something changes in a subsystem which needs the tick and that subsystem
   sends an IPI to the CPU that is concerned such that it changes the tick
   dependency state.
   
   pros: The dependency bits are always modified and read locally
   cons: We need to also check the subsystems from task switch because the next
         task may have different dependencies than prev. So that's context switch
	 overhead

2) Whenever a subsystem changes its dependency to the tick (needs or doesn't need
   anymore), that subsystem remotely changes the dependency bits then sends an IPI
   in case we switched from "tick needed" to "tick not needed".

   pros: Less context switch overhead
   cons: Works for some subsystems for which dependency is per CPU: (scheduler)
         Others for which dependency is per task exclusively or system wide need
	 more complicated treatment: posix cpu timers would then need to switch to
	 a seperate global flag.
	 perf depends on both a global state and a per cpu state.
	 The flags are read remotely. This involve some ordering but no full barrier
	 since we have the IPI.

This patchset takes the simple 1) way which definetly can be improved.

Perhaps we should do 2) with one global mask and one per cpu mask and all flags
atomically and remotely set and clear by the relevant subsystems.

  reply	other threads:[~2015-07-06 16:14 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-11 17:36 [PATCH 0/8] tick/nohz: Tick dependency quick check + cleanups Frederic Weisbecker
2015-06-11 17:36 ` [PATCH 1/8] jiffies: Remove HZ > USEC_PER_SEC special case Frederic Weisbecker
2015-06-11 20:46   ` Rik van Riel
2015-06-11 17:36 ` [PATCH 2/8] apm32: Fix cputime == jiffies assumption Frederic Weisbecker
2015-06-11 20:47   ` Rik van Riel
2015-06-11 17:36 ` [PATCH 3/8] alpha: Fix jiffies based cputime assumption Frederic Weisbecker
2015-06-11 20:47   ` Rik van Riel
2015-06-11 17:36 ` [PATCH 4/8] nohz: Remove idle task special case Frederic Weisbecker
2015-06-11 20:47   ` Rik van Riel
2015-06-14  1:44   ` Preeti U Murthy
2015-07-07 14:45     ` Frederic Weisbecker
2015-06-11 17:36 ` [PATCH 5/8] nohz: Restart the tick from irq exit Frederic Weisbecker
2015-06-11 20:48   ` Rik van Riel
2015-06-12  7:32   ` Peter Zijlstra
2015-06-12 12:38     ` Frederic Weisbecker
2015-06-12 12:59       ` Peter Zijlstra
2015-06-12 13:06         ` Frederic Weisbecker
2015-06-14  9:30       ` Preeti U Murthy
2015-07-07 14:23         ` Frederic Weisbecker
2015-06-14  9:18   ` Preeti U Murthy
2015-06-14  9:19   ` Preeti U Murthy
2015-07-07 14:20     ` Frederic Weisbecker
2015-06-11 17:36 ` [PATCH 6/8] nohz: Move tick_nohz_restart_sched_tick() above its users Frederic Weisbecker
2015-06-11 20:48   ` Rik van Riel
2015-06-11 17:36 ` [PATCH 7/8] nohz: Evaluate tick dependency once on context switch Frederic Weisbecker
2015-06-11 20:46   ` Rik van Riel
2015-06-17  5:59     ` Preeti U Murthy
2015-07-07 14:30     ` Frederic Weisbecker
2015-06-12  7:36   ` Peter Zijlstra
2015-07-06 16:14     ` Frederic Weisbecker [this message]
2015-06-11 17:36 ` [PATCH 8/8] nohz: Remove useless argument on tick_nohz_task_switch() Frederic Weisbecker

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=20150706161413.GC4981@lerouge \
    --to=fweisbec@gmail.com \
    --cc=cl@linux.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=preeti@linux.vnet.ibm.com \
    --cc=riel@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=viresh.kumar@linaro.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