From: Nishanth Aravamudan <nacc@us.ibm.com>
To: Roman Zippel <zippel@linux-m68k.org>
Cc: Arjan van de Ven <arjan@infradead.org>,
Andrew Morton <akpm@osdl.org>,
domen@coderock.org, linux-kernel@vger.kernel.org,
clucas@rotomalug.org
Subject: Re: [PATCH] push rounding up of relative request to schedule_timeout()
Date: Thu, 4 Aug 2005 07:33:39 -0700 [thread overview]
Message-ID: <20050804143339.GE4520@us.ibm.com> (raw)
In-Reply-To: <Pine.LNX.4.61.0508041123220.3728@scrub.home>
On 04.08.2005 [11:38:33 +0200], Roman Zippel wrote:
> Hi,
>
> Andrew, please drop this patch.
> Nish, please stop fucking around with kernel APIs.
The comment for schedule_timeout() claims:
* Make the current task sleep until @timeout jiffies have
* elapsed.
Currently, it does not do so. I was simply trying to make the function
do what it claims it does.
> On Wed, 3 Aug 2005, Nishanth Aravamudan wrote:
>
> > > The "jiffies_to_msecs(msecs_to_jiffies(timeout_msecs) + 1)" case (when the
> > > process is immediately woken up again) makes the caller suspectible to
> > > timeout manipulations and requires constant reauditing, that no caller
> > > gets it wrong, so it's better to avoid this error source completely.
>
> Nish, did you read this? Is my English this bad?
Your English is fine. My point was that the +1 issues (potential
infinite timeouts) are a problem with *jiffies* not milliseconds. And
thus need to be pushed down to the jiffies layer. I think my explanation
was pretty clear.
>
> > --- 2.6.13-rc5/kernel/timer.c 2005-08-01 12:31:53.000000000 -0700
> > +++ 2.6.13-rc5-dev/kernel/timer.c 2005-08-03 17:30:10.000000000 -0700
> > @@ -1134,7 +1134,7 @@ fastcall signed long __sched schedule_ti
> > }
> > }
> >
> > - expire = timeout + jiffies;
> > + expire = timeout + jiffies + 1;
> >
> > init_timer(&timer);
> > timer.expires = expire;
>
> And a little later it does:
>
> timeout = expire - jiffies;
>
> which means callers can get back a larger timeout.
Hrm, maybe I will need to cache the parameter. But the only way you
would get a return value greater than requested is if schedule() returns
before the next jiffy? Which I guess could happen if a wait-queue event
or signal (if the task is set as such) occurs before the next interrupt
*and* there are no other threads running, I believe, as
process_timeout() -> try_to_wake_up() only puts the task back on the run
queue; I don't think it actually preempts the currently running task,
does it? Just an FYI, though, that is a problem in the current code, in
the sense that we will pass back the exact same value again Let me take
a look, maybe we need to do some -1 later (or just cache the request, as
I mentioned). Thanks for pointing this out.
> Nish, did you check and fix _all_ users? I can easily find a number of
> users which immediately use the return value as next timeout.
I haven't fixed all users yet. I plan on trying to do that today. Would
those callers that do immediately use the return value as the next
timeout fall under the functions that should be using
time_after()/time_before()?
> There are _a_lot_ of schedule_timeout(1) for small busy loops, these are
> asking for "please schedule until next tick". Did you check that these are
> still ok?
According to the comment for schedule_timeout(), that is not true. They
are asking to sleep for *1* ticks, no the *next* tick. If the assumption
in the code is the latter, they have been calling this function
inappropriately for a while. They probably should be requesting
schedule_timeout(0), i.e. no sleep at all (but we still will add a timer
internally and it won't expire until the next interrupt occurs).
> schedule_timeout() is arguably a broken API, but can we please _first_
> come up with a plan to fix this, before we break even more?
It *is* broken, and my patch *does* fix it. I'm not suggesting it go to
Linus today, but it's ok in Andrew's tree, especially if I'm able to get
the depending patches sent out soon.
I am pretty sure there is no way to fix the problems of adding 1 without
an inter-tick position. The +1 is the closest thing we have to a
"ceiling" function with jiffies.
Thanks,
Nish
next prev parent reply other threads:[~2005-08-04 14:38 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-07-07 21:31 [patch 1/4] drivers/char/ip2/i2lib.c: replace direct assignment with set_current_state() domen
2005-07-08 23:08 ` Andrew Morton
2005-07-08 23:22 ` Nish Aravamudan
2005-07-23 0:27 ` [PATCH] Add schedule_timeout_{interruptible,uninterruptible}{,_msecs}() interfaces Nishanth Aravamudan
2005-07-23 0:31 ` Arjan van de Ven
2005-07-23 1:08 ` [UPDATE PATCH] Add schedule_timeout_{interruptible,uninterruptible}_msecs() interfaces Nishanth Aravamudan
2005-07-23 2:30 ` Andrew Morton
2005-07-23 16:23 ` Nishanth Aravamudan
2005-07-23 10:50 ` [PATCH] Add schedule_timeout_{interruptible,uninterruptible}{,_msecs}() interfaces Roman Zippel
2005-07-23 11:09 ` Arjan van de Ven
2005-07-23 11:55 ` Roman Zippel
2005-07-23 12:51 ` Arjan van de Ven
2005-07-23 13:04 ` Roman Zippel
2005-07-23 13:12 ` Arjan van de Ven
2005-07-23 13:29 ` Roman Zippel
2005-07-23 13:32 ` Arjan van de Ven
2005-07-23 15:56 ` Roman Zippel
2005-07-23 16:44 ` Nishanth Aravamudan
2005-07-23 16:43 ` Nishanth Aravamudan
2005-07-23 17:17 ` Roman Zippel
2005-07-23 19:10 ` Nishanth Aravamudan
2005-07-23 20:12 ` Roman Zippel
2005-07-27 22:29 ` Nishanth Aravamudan
2005-07-30 23:35 ` Roman Zippel
2005-08-01 19:35 ` [UPDATE PATCH] Add schedule_timeout_{intr,unintr}{,_msecs}() interfaces Nishanth Aravamudan
2005-08-03 14:20 ` Roman Zippel
2005-08-04 0:51 ` [PATCH] push rounding up of relative request to schedule_timeout() Nishanth Aravamudan
2005-08-04 5:14 ` [UPDATE PATCH] " Nishanth Aravamudan
2005-08-04 16:45 ` George Anzinger
2005-08-04 18:48 ` Nish Aravamudan
2005-08-16 23:05 ` Nishanth Aravamudan
2005-08-17 0:39 ` George Anzinger
2005-08-17 5:56 ` Nishanth Aravamudan
2005-08-17 19:51 ` George Anzinger
2005-08-17 22:24 ` Nishanth Aravamudan
2005-08-04 17:05 ` George Anzinger
2005-08-04 18:49 ` Nish Aravamudan
2005-08-04 9:38 ` [PATCH] " Roman Zippel
2005-08-04 14:33 ` Nishanth Aravamudan [this message]
2005-08-04 18:59 ` Roman Zippel
2005-08-04 19:11 ` Nishanth Aravamudan
2005-08-04 23:20 ` Roman Zippel
2005-08-04 17:08 ` Andrew Morton
2005-08-04 19:00 ` [PATCH] add schedule_timeout_{,un}intr() interfaces Nishanth Aravamudan
2005-08-05 7:38 ` Andrew Morton
2005-07-23 16:37 ` [PATCH] Add schedule_timeout_{interruptible,uninterruptible}{,_msecs}() interfaces Nishanth Aravamudan
2005-07-23 17:01 ` Roman Zippel
2005-07-23 19:06 ` Nishanth Aravamudan
2005-07-23 20:22 ` Roman Zippel
2005-07-23 16:30 ` Nishanth Aravamudan
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=20050804143339.GE4520@us.ibm.com \
--to=nacc@us.ibm.com \
--cc=akpm@osdl.org \
--cc=arjan@infradead.org \
--cc=clucas@rotomalug.org \
--cc=domen@coderock.org \
--cc=linux-kernel@vger.kernel.org \
--cc=zippel@linux-m68k.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox