mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Juri Lelli <juri.lelli@arm.com>
To: Frederic Weisbecker <fweisbec@gmail.com>,
	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 07/10] sched: Migrate sched to use new tick dependency mask model
Date: Mon, 10 Aug 2015 16:43:51 +0100	[thread overview]
Message-ID: <55C8C6B7.9010707@arm.com> (raw)
In-Reply-To: <20150810152920.GB31251@lerouge>

Hi,

On 10/08/15 16:29, Frederic Weisbecker wrote:
> On Mon, Aug 10, 2015 at 05:11:51PM +0200, Peter Zijlstra wrote:
>> On Mon, Aug 10, 2015 at 04:28:47PM +0200, Peter Zijlstra wrote:
>>> On Mon, Aug 10, 2015 at 04:16:58PM +0200, Frederic Weisbecker wrote:
>>>
>>>> I considered many times relying on hrtick btw but everyone seem to say it has a lot
>>>> of overhead, especially due to clock reprogramming on schedule() calls.
>>>
>>> Yeah, I have some vague ideas of how to take out much of that overhead
>>> (tglx will launch frozen sharks at me I suspect), but we cannot get
>>> around the overhead of actually having to program the hardware and that
>>> is still a significant amount on many machines.
>>>
>>> Supposedly machines with TSC deadline are better, but I've not tried
>>> to benchmark that.
>>
>> Basically something along these lines.. which avoids a whole bunch of
>> hrtimer stuff.
>>
>> But without fast hardware its all still pointless.
>>
>> diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h
>> index 76dd4f0da5ca..c279950cb8c3 100644
>> --- a/include/linux/hrtimer.h
>> +++ b/include/linux/hrtimer.h
>> @@ -200,6 +200,7 @@ struct hrtimer_cpu_base {
>>  	unsigned int			nr_retries;
>>  	unsigned int			nr_hangs;
>>  	unsigned int			max_hang_time;
>> +	ktime_t				expires_sched;
>>  #endif
>>  	struct hrtimer_clock_base	clock_base[HRTIMER_MAX_CLOCK_BASES];
>>  } ____cacheline_aligned;
>> diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
>> index 5c7ae4b641c4..be9c0a555eaa 100644
>> --- a/kernel/time/hrtimer.c
>> +++ b/kernel/time/hrtimer.c
>> @@ -68,6 +68,7 @@ DEFINE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases) =
>>  {
>>  	.lock = __RAW_SPIN_LOCK_UNLOCKED(hrtimer_bases.lock),
>>  	.seq = SEQCNT_ZERO(hrtimer_bases.seq),
>> +	.expires_sched = { .tv64 = KTIME_MAX, },
>>  	.clock_base =
>>  	{
>>  		{
>> @@ -460,7 +461,7 @@ static inline void hrtimer_update_next_timer(struct hrtimer_cpu_base *cpu_base,
>>  static ktime_t __hrtimer_get_next_event(struct hrtimer_cpu_base *cpu_base)
>>  {
>>  	struct hrtimer_clock_base *base = cpu_base->clock_base;
>> -	ktime_t expires, expires_next = { .tv64 = KTIME_MAX };
>> +	ktime_t expires, expires_next = cpu_base->expires_sched;
>>  	unsigned int active = cpu_base->active_bases;
>>  
>>  	hrtimer_update_next_timer(cpu_base, NULL);
>> @@ -1289,6 +1290,33 @@ static void __hrtimer_run_queues(struct hrtimer_cpu_base *cpu_base, ktime_t now)
>>  
>>  #ifdef CONFIG_HIGH_RES_TIMERS
>>  
>> +void sched_hrtick_set(u64 ns)
>> +{
>> +	struct hrtimer_cpu_base *cpu_base = this_cpu_ptr(&hrtimer_bases);
>> +	ktime_t expires = ktime_add_ns(ktime_get(), ns);
>> +
>> +	raw_spin_lock(&cpu_base->lock);
>> +	cpu_base->expires_sched = expires;
>> +
>> +	if (expires.tv64 < cpu_base->expires_next.tv64)
>> +		hrtimer_force_reprogram(cpu_base, 0);
>> +
>> +	raw_spin_unlock(&cpu_base->lock);
>> +}
>> +
>> +void sched_hrtick_cancel(void)
>> +{
>> +	struct hrtimer_cpu_base *cpu_base = this_cpu_ptr(&hrtimer_bases);
>> +
>> +	raw_spin_lock(&cpu_base->lock);
>> +	/*
>> +	 * If the current event was this sched event, eat the superfluous
>> +	 * interrupt rather than touch the hardware again.
>> +	 */
>> +	cpu_base->expires_sched.tv64 = KTIME_MAX;
>> +	raw_spin_unlock(&cpu_base->lock);
>> +}
> 
> Well, there could be a more proper way to do this without tying that to the scheduler
> tick. This could be some sort of hrtimer_cancel_soft() which more generally cancels a
> timer without cancelling the interrupt itself. We might want to still keep track of that
> lost interrupt though in case of later clock reprogramming that fits the lost interrupt.
> With a field like cpu_base->expires_interrupt. I thought about expires_soft and expires_hard
> but I think that terminology is already used :-)
> 
> That said that feature at least wouldn't fit nohz full which really wants to avoid spurious
> interrupts.
> 

Quite a detailed reply to my naive question :).
Thanks a lot Frederic and Peter for this!

For what concerns SCHED_DEADLINE, I guess the bottom line is
that it makes sense to use hrtick for sub-millisecond accounting
only (without nohz full).

Best,

- Juri


  reply	other threads:[~2015-08-10 15:43 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-23 16:42 [PATCH 00/10] nohz: Tick dependency mask v2 Frederic Weisbecker
2015-07-23 16:42 ` [PATCH 01/10] nohz: Remove idle task special case Frederic Weisbecker
2015-07-23 16:42 ` [PATCH 02/10] nohz: Restart nohz full tick from irq exit Frederic Weisbecker
2015-07-23 16:42 ` [PATCH 03/10] nohz: Move tick_nohz_restart_sched_tick() above its users Frederic Weisbecker
2015-07-23 16:42 ` [PATCH 04/10] nohz: Remove useless argument on tick_nohz_task_switch() Frederic Weisbecker
2015-08-03 12:39   ` Peter Zijlstra
2015-08-03 12:49     ` Frederic Weisbecker
2015-08-03 13:04       ` Peter Zijlstra
2015-07-23 16:42 ` [PATCH 05/10] nohz: New tick dependency mask Frederic Weisbecker
2015-07-24 16:55   ` Chris Metcalf
2015-07-24 17:16     ` Frederic Weisbecker
2015-07-24 17:43       ` Chris Metcalf
2015-08-03 12:48         ` Peter Zijlstra
2015-08-03 12:43   ` Peter Zijlstra
2015-08-03 13:05     ` Frederic Weisbecker
2015-08-03 13:24       ` Peter Zijlstra
2015-08-03 13:49         ` Frederic Weisbecker
2015-08-03 12:57   ` Peter Zijlstra
2015-08-03 13:09     ` Frederic Weisbecker
2015-08-03 13:29       ` Peter Zijlstra
2015-08-03 13:55         ` Frederic Weisbecker
2015-08-03 14:11           ` Peter Zijlstra
2015-07-23 16:42 ` [PATCH 06/10] perf: Migrate perf to use new tick dependency mask model Frederic Weisbecker
2015-07-23 16:42 ` [PATCH 07/10] sched: Migrate sched " Frederic Weisbecker
2015-07-23 16:55   ` Frederic Weisbecker
2015-07-24 16:56   ` Chris Metcalf
2015-07-29 13:01     ` Frederic Weisbecker
2015-08-03 14:00   ` Peter Zijlstra
2015-08-03 14:50     ` Frederic Weisbecker
2015-08-03 17:09       ` Peter Zijlstra
2015-08-03 17:30         ` Frederic Weisbecker
2015-08-04  7:41           ` Peter Zijlstra
2015-08-10 14:02             ` Juri Lelli
2015-08-10 14:16               ` Frederic Weisbecker
2015-08-10 14:28                 ` Peter Zijlstra
2015-08-10 15:11                   ` Peter Zijlstra
2015-08-10 15:29                     ` Frederic Weisbecker
2015-08-10 15:43                       ` Juri Lelli [this message]
2015-08-10 16:41                       ` Peter Zijlstra
2015-08-10 15:33                 ` Christoph Lameter
2015-07-23 16:42 ` [PATCH 08/10] posix-cpu-timers: Migrate " Frederic Weisbecker
2015-07-24 16:57   ` Chris Metcalf
2015-07-29 13:23     ` Frederic Weisbecker
2015-07-29 17:24       ` Chris Metcalf
2015-07-30  0:44         ` Frederic Weisbecker
2015-07-30 14:31           ` Luiz Capitulino
2015-07-30 14:46             ` Frederic Weisbecker
2015-07-30 19:35           ` Chris Metcalf
2015-07-30 19:45             ` Frederic Weisbecker
2015-07-30 19:52               ` Chris Metcalf
2015-07-31 14:49                 ` Frederic Weisbecker
2015-08-03 15:59                   ` Chris Metcalf
2015-08-03 18:01                     ` Frederic Weisbecker
2015-08-03 17:12                   ` Peter Zijlstra
2015-08-03 17:39                     ` Frederic Weisbecker
2015-08-03 19:07                       ` Peter Zijlstra
2015-08-06 17:13                       ` Chris Metcalf
2015-07-23 16:42 ` [PATCH 09/10] sched-clock: " Frederic Weisbecker
2015-07-23 16:42 ` [PATCH 10/10] nohz: Remove task switch obsolete tick dependency check 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=55C8C6B7.9010707@arm.com \
    --to=juri.lelli@arm.com \
    --cc=cl@linux.com \
    --cc=fweisbec@gmail.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

Powered by JetHome