From: Tony Lindgren <tony@atomide.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: akpm@osdl.org, heiko.carstens@de.ibm.com, johnstul@us.ibm.com,
rmk@arm.linux.org.uk, schwidefsky@de.ibm.com,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: + fix-next_timer_interrupt-for-hrtimer.patch added to -mm tree
Date: Sat, 25 Feb 2006 10:57:31 -0800 [thread overview]
Message-ID: <20060225185731.GA4294@atomide.com> (raw)
In-Reply-To: <1140884243.5237.104.camel@localhost.localdomain>
* Thomas Gleixner <tglx@linutronix.de> [060225 08:16]:
> > +#ifdef CONFIG_NO_IDLE_HZ
> > +/**
> > + * hrtimer_get_next - get next hrtimer to expire
> > + *
> > + * @bases: ktimer base array
> > + */
> > +static inline struct hrtimer *hrtimer_get_next(struct hrtimer_base *bases)
> > +{
> > + unsigned long flags;
> > + struct hrtimer *timer = NULL;
> > + int i;
> > +
> > + for (i = 0; i < MAX_HRTIMER_BASES; i++) {
> > + struct hrtimer_base *base;
> > + struct hrtimer *cur;
> > +
> > + base = &bases[i];
> > + spin_lock_irqsave(&base->lock, flags);
> > + cur = rb_entry(base->first, struct hrtimer, node);
> > + spin_unlock_irqrestore(&base->lock, flags);
> > +
> > + if (cur == NULL)
> > + continue;
> > +
> > + if (timer == NULL || cur->expires.tv64 < timer->expires.tv64)
> > + timer = cur;
> > + }
> > +
> > + return timer;
> > +}
>
> This is racy on SMP. nanosleep hrtimers are on the stack and can go away
> due to a signal. posix timers can be removed and destroyed on another
> CPU.
This should be fixed. But just as a note, we can tolerate some removed
timer values values as it would be just an extra timer interrupt.
> Also the expires fields of CLOCK_MONOTONIC and CLOCK_REALTIME based
> tiemrs can not really be compared. Expiry value is absolute time of the
> respective base clock.
OK. How can we get the first event in nanoseconds easily?
> > +/**
> > + * ktime_to_jiffies - converts ktime to jiffies
> > + *
> > + * @event: ktime event to be converted to jiffies
> > + *
> > + * Caller must take care of xtime locking.
> > + */
> > +static inline unsigned long ktime_to_jiffies(const ktime_t event)
> > +{
> > + ktime_t now, delta;
> > +
> > + now = timespec_to_ktime(xtime);
> > + delta = ktime_sub(event, now);
> > +
> > + return jiffies + (((delta.tv64 * NSEC_CONVERSION) >>
> > + (NSEC_JIFFIE_SC - SEC_JIFFIE_SC)) >> SEC_JIFFIE_SC);
> > +}
>
> Only CLOCK_REALTIME based timers are based on xtime. For CLOCK_MONOTONIC
> based timers this calculation is off by wall_to_monotonic.
Needs to be fixed then.
> > +/**
> > + * hrtimer_next_jiffie - get next hrtimer event in jiffies
> > + *
> > + * Called from next_timer_interrupt() to get the next hrtimer event.
> > + * Eventually we should change next_timer_interrupt() to return
> > + * results in nanoseconds instead of jiffies. Caller must host xtime_lock.
>
> S390 does not hold xtime lock when calling next_timer_interrupt !
Good point. Needs to be fixed.
> I look for a sane solution.
We really should fix this for 2.6.16. Then maybe after 2.6.16 we can
convert next_timer_interrupt() to return nanosecond instead of jiffies.
And then we can get rid of jiffies again in the hrtimer code :)
Tony
next prev parent reply other threads:[~2006-02-25 18:58 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <200602250219.k1P2JLqY018864@shell0.pdx.osdl.net>
2006-02-25 16:17 ` + fix-next_timer_interrupt-for-hrtimer.patch added to -mm tree Thomas Gleixner
2006-02-25 18:57 ` Tony Lindgren [this message]
2006-02-28 3:29 ` Tony Lindgren
2006-02-28 9:05 ` Thomas Gleixner
2006-02-28 9:51 ` Tony Lindgren
2006-02-28 10:06 ` Thomas Gleixner
2006-02-28 19:34 ` Tony Lindgren
2006-02-28 8:36 ` Thomas Gleixner
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=20060225185731.GA4294@atomide.com \
--to=tony@atomide.com \
--cc=akpm@osdl.org \
--cc=heiko.carstens@de.ibm.com \
--cc=johnstul@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rmk@arm.linux.org.uk \
--cc=schwidefsky@de.ibm.com \
--cc=tglx@linutronix.de \
/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.