From: Andrew Morton <akpm@linux-foundation.org>
To: Dmitry Antipov <dmitry.antipov@linaro.org>
Cc: Thomas Gleixner <tglx@linutronix.de>,
linux-kernel@vger.kernel.org, patches@linaro.org
Subject: Re: [PATCH] hrtimers: teach usleep_range() to return how many usecs was slept
Date: Thu, 26 Jan 2012 01:05:16 -0800 [thread overview]
Message-ID: <20120126010516.c5af4a4e.akpm@linux-foundation.org> (raw)
In-Reply-To: <1326718403-28156-1-git-send-email-dmitry.antipov@linaro.org>
On Mon, 16 Jan 2012 16:53:23 +0400 Dmitry Antipov <dmitry.antipov@linaro.org> wrote:
> Teach usleep_range() to return how many usecs was actually spent
> in sleep. The rationale beyond this is to convert jiffies-based
> wait-for-hardware loops like:
>
> unsigned long timeout = jiffies + msecs_to_jiffies(1000);
> while (hw_is_not_ready()) {
> if (time_after(jiffies, timeout))
> return -ETIMEDOUT;
> msleep(1);
> }
>
> to:
>
> unsigned long timeout = 0;
> while (hw_is_not_ready()) {
> if (timeout > USEC_PER_SEC)
> return -ETIMEDOUT;
> timeout += usleep_range(1000, 2000);
> }
>
Is that useful enough to justify making the change?
>
> int __sched schedule_hrtimeout_range(ktime_t *expires, unsigned long delta,
> - const enum hrtimer_mode mode)
> + const enum hrtimer_mode mode, unsigned long *elapsed)
Rather than adding another argument, I suggest you change the return
type to long and use return value semantics similar to schedule_timeout().
schedule_timeout() never returns -ve numbers and it returns jiffies,
but it will be close(r).
Returning usecs is odd. One would expect it to return a ktime_t. That
might inflict some code-size cost in callers.
prev parent reply other threads:[~2012-01-26 8:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-16 12:53 Dmitry Antipov
2012-01-26 9:05 ` Andrew Morton [this message]
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=20120126010516.c5af4a4e.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=dmitry.antipov@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=patches@linaro.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
Powered by JetHome