public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Nishanth Aravamudan <nacc@us.ibm.com>
To: George Anzinger <george@mvista.com>
Cc: Roman Zippel <zippel@linux-m68k.org>,
	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: [UPDATE PATCH] push rounding up of relative request to schedule_timeout()
Date: Wed, 17 Aug 2005 15:24:15 -0700	[thread overview]
Message-ID: <20050817222415.GA4398@us.ibm.com> (raw)
In-Reply-To: <43039535.2010600@mvista.com>

On 17.08.2005 [12:51:17 -0700], George Anzinger wrote:
> Nishanth Aravamudan wrote:
> ~
> >>IMNSHO we should not get too parental with kernel only interfaces. 
> >>Adding 1 is easy enough for the caller and even easier to explain in the 
> >>instructions (i.e. this call sleeps for X jiffies edges).  This allows 
> >>the caller to do more if needed and, should he ever just want to sync to 
> >>the next jiffie he does not have to deal with backing out that +1.
> >
> >
> >I don't want to be too parental either, but I also am trying to avoid
> >code duplication. Lots of drivers basically do something like
> >poll_event() does (or could do with some changes), i.e. looping a
> >constant amount multiple times, checking something every so often. The
> >patch was just a thought, though. I will keep evaluating drivers and see
> >if it's a useful interface to have eventually.
> >
> >I guess I'm just concerned with making an unintuitive interface. As was
> >brought up at OLS, drivers are a major source of bugs/buggy code. The
> >simpler, more useful we can make interfaces, the better, I think. I'm
> >not claiming you disagree, I just want to make my own motives clear.
> >While fixing up the schedule_timeout() comment would make it clear what
> >schedule_timeout() achieves, I'm not sure how useful such an interface
> >is, if every caller adds 1 :) I need to mull it over, though... Lots to
> >consider. I also, of course, want to stay flexible for the reasons you
> >mention (letting the driver adjust the timeout as they expect to).
> 
> I would leave the +1 alone and put in the correct documentation.  This 
> way _more_ folks will be made aware of the mid jiffie issue.  Far to 
> often we see (and let get in) patches that mess up user interfaces 
> around this issue.  The recent changes to itimer come to mind...

Ok, makes sense to me; does the following patch work for everybody? The
wording is a bit awkward, but so is the issue :)

Description: Fix schedule_timeout()'s comment, indicated the inter-tick
rounding issue. Since the kernel does not keep track of an inter-tick
position in jiffies, a caller which wishes to sleep for at least a
certain number of jiffies should add its request to the *next* jiffies
value (meaning add 1 to its relative request). Make that clear in the
comment.

Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>

---

diff -urpN 2.6.13-rc6/kernel/timer.c 2.6.13-rc6-dev/kernel/timer.c
--- 2.6.13-rc6/kernel/timer.c	2005-08-09 15:22:57.000000000 -0700
+++ 2.6.13-rc6-dev/kernel/timer.c	2005-08-17 15:21:35.000000000 -0700
@@ -1077,9 +1077,15 @@ static void process_timeout(unsigned lon
  * schedule_timeout - sleep until timeout
  * @timeout: timeout value in jiffies
  *
- * Make the current task sleep until @timeout jiffies have
- * elapsed. The routine will return immediately unless
- * the current task state has been set (see set_current_state()).
+ * Make the current task sleep until @timeout timer interrupts have
+ * occurred, meaning jiffies has incremented @timeout times and not
+ * necessarily that @timeout jiffies have elapsed. If the task wishes to
+ * sleep until (at least) @timeout jiffies have elapsed, then it should
+ * add 1 to its request. This is necessary, as the kernel does not keep
+ * track of an inter-jiffy position, so the caller must "round up" its
+ * request so that it begins at the next jiffy. The routine will return
+ * immediately unless the current task state has been set (see
+ * set_current_state()).
  *
  * You can set the task state as follows -
  *

  reply	other threads:[~2005-08-17 22:24 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 [this message]
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
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=20050817222415.GA4398@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=george@mvista.com \
    --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