From: Ric Wheeler <rwheeler@redhat.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Josef Bacik <jbacik@redhat.com>,
Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@elte.hu>,
linux-fsdevel@vger.kernel.org,
Chris Mason <chris.mason@oracle.com>,
linux-kernel@vger.kernel.org
Subject: Re: high resolution timers, scheduling & sleep granularity
Date: Fri, 01 Aug 2008 11:03:12 -0400 [thread overview]
Message-ID: <489325B0.8050305@redhat.com> (raw)
In-Reply-To: <1217602211.4684.9.camel@twins>
Peter Zijlstra wrote:
> On Fri, 2008-08-01 at 09:25 -0400, Josef Bacik wrote:
>
>
>> Index: linux-2.6/fs/jbd/transaction.c
>> ===================================================================
>> --- linux-2.6.orig/fs/jbd/transaction.c
>> +++ linux-2.6/fs/jbd/transaction.c
>>
>
>
>> @@ -63,6 +65,32 @@ get_transaction(journal_t *journal, tran
>> return transaction;
>> }
>>
>> +static void precision_sleep(unsigned long time)
>> +{
>> + struct hrtimer_sleeper t;
>> +
>> + hrtimer_init_on_stack(&t.timer, CLOCK_REALTIME, HRTIMER_MODE_ABS);
>> + hrtimer_init_sleeper(&t, current);
>> + t.timer.expires = ktime_add_ns(ktime_get_real(), time);
>> +
>> + do {
>> + set_current_state(TASK_UNINTERRUPTIBLE);
>> +
>> + hrtimer_start(&t.timer, t.timer.expires, HRTIMER_MODE_ABS);
>> + if (!hrtimer_active(&t.timer))
>> + t.task = NULL;
>> +
>> + if (likely(t.task))
>> + schedule();
>> +
>> + hrtimer_cancel(&t.timer);
>> + } while (t.task);
>> +
>> + set_current_state(TASK_RUNNING);
>> +
>> + destroy_hrtimer_on_stack(&t.timer);
>> +}
>> +
>> /*
>> * Handle management.
>> *
>>
>
> I was convinced we already had such a creature,. but I guess I was wrong
> as I can't find it ;-)
>
> Anyway, I'm thinking this function ought to live in kernel/hrtimer.c and
> possibly get renamed to something like hrtimer_sleep_ns() or some such
> (means you can also reuse the do_nanosleep helper in there).
>
> Also, have you considered the impact on platforms that do not support
> hrtimers, or don't have high resolution clock events available?
>
I agree that this is definitely a much more generically interesting
function.
With high res timers, falling back to the jiffie's granularity (or not
sleeping at all in the case of the file system transaction batching)
seems to be a reasonable fall back,
ric
>
>> Index: linux-2.6/kernel/hrtimer.c
>> ===================================================================
>> --- linux-2.6.orig/kernel/hrtimer.c
>> +++ linux-2.6/kernel/hrtimer.c
>> @@ -1458,6 +1458,7 @@ void hrtimer_init_sleeper(struct hrtimer
>> sl->timer.cb_mode = HRTIMER_CB_IRQSAFE_NO_SOFTIRQ;
>> #endif
>> }
>> +EXPORT_SYMBOL_GPL(hrtimer_init_sleeper);
>>
>> static int __sched do_nanosleep(struct hrtimer_sleeper *t, enum hrtimer_mode mode)
>> {
>>
>
> That also gets rid of this export..
>
>
next prev parent reply other threads:[~2008-08-01 15:03 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-01 12:05 high resolution timers, scheduling & sleep granularity Ric Wheeler
2008-08-01 13:25 ` Josef Bacik
2008-08-01 13:57 ` Ric Wheeler
2008-08-01 13:55 ` Josef Bacik
2008-08-01 14:50 ` Peter Zijlstra
2008-08-01 14:34 ` Josef Bacik
2008-08-01 15:03 ` Ric Wheeler [this message]
2008-08-01 18:16 ` Andreas Dilger
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=489325B0.8050305@redhat.com \
--to=rwheeler@redhat.com \
--cc=chris.mason@oracle.com \
--cc=jbacik@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=peterz@infradead.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).