From: John Stultz <john.stultz@linaro.org>
To: Richard Cochran <richardcochran@gmail.com>
Cc: lkml <linux-kernel@vger.kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@kernel.org>,
Prarit Bhargava <prarit@redhat.com>,
Sharvil Nanavati <sharvil@google.com>,
stable <stable@vger.kernel.org>
Subject: Re: [PATCH] alarmtimer: Fix bug where relative alarm timers were treated as absolute
Date: Tue, 8 Jul 2014 09:34:32 +0200 [thread overview]
Message-ID: <CALAqxLUixKYE1z8GcZzkfrSNqZwtJNBqyYuxo78t+UtswmC68Q@mail.gmail.com> (raw)
In-Reply-To: <20140708064204.GD3977@localhost.localdomain>
On Tue, Jul 8, 2014 at 8:42 AM, Richard Cochran
<richardcochran@gmail.com> wrote:
> On Mon, Jul 07, 2014 at 02:06:11PM -0700, John Stultz wrote:
>> @@ -597,8 +602,16 @@ static int alarm_timer_set(struct k_itimer *timr, int flags,
>>
>> /* start the timer */
>> timr->it.alarm.interval = timespec_to_ktime(new_setting->it_interval);
>> - alarm_start(&timr->it.alarm.alarmtimer,
>> - timespec_to_ktime(new_setting->it_value));
>> + exp = timespec_to_ktime(new_setting->it_value);
>> + /* Convert (if necessary) to absolute time */
>> + if (flags != TIMER_ABSTIME) {
>> + ktime_t now;
>> +
>> + now = alarm_bases[timr->it.alarm.alarmtimer.type].gettime();
>> + exp = ktime_add(now, exp);
>> + }
>> +
>> + alarm_start(&timr->it.alarm.alarmtimer, exp);
>
> Nothing protects 'exp' from becoming invalid before queuing the alarm,
> if the time base is reset on another cpu. Or would that be harmless
> here?
Hrmn.. So that's a separate question, but a good one to validate as well.
common_timer_set() has a similar behavior where the return value of
hrtimer_start_expires() isn't passed up. This is because the userspace
behavior is that if the time has already passed, the timer should fire
immediately.
If you look in __hrtimer_start_range_ns(), you'll see the chunk of
logic at the bottom which (if I'm reading it right) raises the softirq
(to fire the timer) if our timer is the earliest and
enqueue_reprogram fails (due to the clockevent logic returning ETIME
due to the time being in the past).
So its definitely subtle but looks like its ok. But I'll add a
validation test to be sure I'm not missing anything there as well.
thanks
-john
next prev parent reply other threads:[~2014-07-08 7:34 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-07 21:06 John Stultz
2014-07-08 6:42 ` Richard Cochran
2014-07-08 7:34 ` John Stultz [this message]
2014-07-08 8:52 ` [tip:timers/urgent] " tip-bot for John Stultz
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=CALAqxLUixKYE1z8GcZzkfrSNqZwtJNBqyYuxo78t+UtswmC68Q@mail.gmail.com \
--to=john.stultz@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=prarit@redhat.com \
--cc=richardcochran@gmail.com \
--cc=sharvil@google.com \
--cc=stable@vger.kernel.org \
--cc=tglx@linutronix.de \
--subject='Re: [PATCH] alarmtimer: Fix bug where relative alarm timers were treated as absolute' \
/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
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.