All of lore.kernel.org
 help / color / mirror / Atom feed
From: Frederic Weisbecker <fweisbec@gmail.com>
To: Viresh Kumar <viresh.kumar@linaro.org>
Cc: tglx@linutronix.de, linaro-kernel@lists.linaro.org,
	linux-kernel@vger.kernel.org, arvind.chauhan@arm.com,
	preeti@linux.vnet.ibm.com, khilman@linaro.org
Subject: Re: [RFC 1/7] hrtimer: Warn if hrtimer_start*() failed to enqueue hrtimer
Date: Thu, 10 Jul 2014 00:21:33 +0200	[thread overview]
Message-ID: <20140709222131.GD23881@localhost.localdomain> (raw)
In-Reply-To: <bc8cabd00810c2f91cb45a64514f5c4ca12d584c.1404888801.git.viresh.kumar@linaro.org>

On Wed, Jul 09, 2014 at 12:25:33PM +0530, Viresh Kumar wrote:
> hrtimer_start*() family never fails to enqueue a hrtimer to a clock-base. The
> only special case is when the hrtimer was in past. If it is getting enqueued to
> local CPUs's clock-base, we raise a softirq and exit, else we handle that on
> next interrupt on remote CPU.
> 
> At several places in kernel we check if hrtimer is enqueued properly with
> hrtimer_active(). This isn't required and can be dropped.
> 
> Before fixing that, lets make sure hrtimer is always enqueued properly by adding
> 
> 	WARN_ON_ONCE(!hrtimer_active(timer));
> 
> towards the end of __hrtimer_start_range_ns().
> 
> Suggested-by: Frederic Weisbecker <fweisbec@gmail.com>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
>  kernel/hrtimer.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
> index 3ab2899..cf40209 100644
> --- a/kernel/hrtimer.c
> +++ b/kernel/hrtimer.c
> @@ -1037,6 +1037,8 @@ int __hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim,
>  
>  	unlock_hrtimer_base(timer, &flags);
>  
> +	/* Make sure timer is enqueued */
> +	WARN_ON_ONCE(!hrtimer_active(timer));

Hmm, after reading Thomas reply, I think it's possible that the hrtimer expires
right after we unlock it and, if we are unlucky enough, before the hrtimer_active()
check.

In this case we might hit a false positive.

>  	return ret;
>  }
>  EXPORT_SYMBOL_GPL(__hrtimer_start_range_ns);
> -- 
> 2.0.0.rc2
> 

  reply	other threads:[~2014-07-09 22:21 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-09  6:55 [RFC 0/7] hrtimer: drop active hrtimer checks after adding it Viresh Kumar
2014-07-09  6:55 ` [RFC 1/7] hrtimer: Warn if hrtimer_start*() failed to enqueue hrtimer Viresh Kumar
2014-07-09 22:21   ` Frederic Weisbecker [this message]
2014-07-09 23:58     ` Thomas Gleixner
2014-07-09  6:55 ` [RFC 2/7] hrtimer: don't check for active hrtimer after adding it Viresh Kumar
2014-07-09 10:34   ` Chris Redpath
2014-07-09 15:25     ` Viresh Kumar
2014-07-09  6:55 ` [RFC 3/7] tick: " Viresh Kumar
2014-07-09  6:55 ` [RFC 4/7] sched: " Viresh Kumar
2014-07-09  6:55 ` [RFC 5/7] futex: " Viresh Kumar
2014-07-09  6:55 ` [RFC 6/7] rtmutex: " Viresh Kumar
2014-07-09  6:55 ` [RFC 7/7] net: " Viresh Kumar
2014-07-09 10:32   ` Chris Redpath
2014-07-09 10:44     ` Viresh Kumar
2014-07-09 10:48       ` Chris Redpath
2014-07-09 15:23       ` Viresh Kumar
2014-07-09 21:30 ` [RFC 0/7] hrtimer: drop active hrtimer checks " Thomas Gleixner
2014-07-10  1:34   ` Frederic Weisbecker
2014-07-14  4:41     ` Viresh Kumar

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=20140709222131.GD23881@localhost.localdomain \
    --to=fweisbec@gmail.com \
    --cc=arvind.chauhan@arm.com \
    --cc=khilman@linaro.org \
    --cc=linaro-kernel@lists.linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=preeti@linux.vnet.ibm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.