LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 2/2] Block: use round_jiffies_up()
@ 2008-11-04 16:15 Alan Stern
2008-11-05 3:34 ` Tejun Heo
0 siblings, 1 reply; 5+ messages in thread
From: Alan Stern @ 2008-11-04 16:15 UTC (permalink / raw)
To: Jens Axboe; +Cc: Tejun Heo, Kernel development list
This patch (as1159) changes the timeout routines in the block core to
use round_jiffies_up(). There's no point in rounding the timer
deadline down, since if it expires too early we will have to restart
it.
The patch also removes a redundant test of q->rq_timed_out_fn, and it
sets req->deadline back to 0 when req is removed from the timer list
(to indicate the req is no longer being timed).
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
---
Index: usb-2.6/block/blk-timeout.c
===================================================================
--- usb-2.6.orig/block/blk-timeout.c
+++ usb-2.6/block/blk-timeout.c
@@ -78,13 +78,14 @@ void blk_delete_timer(struct request *re
/*
* Nothing to detach
*/
- if (!q->rq_timed_out_fn || !req->deadline)
+ if (!req->deadline)
return;
list_del_init(&req->timeout_list);
if (list_empty(&q->timeout_list))
del_timer(&q->timeout);
+ req->deadline = 0;
}
static void blk_rq_timed_out(struct request *req)
@@ -142,7 +143,7 @@ void blk_rq_timed_out_timer(unsigned lon
}
if (next_set && !list_empty(&q->timeout_list))
- mod_timer(&q->timeout, round_jiffies(next));
+ mod_timer(&q->timeout, round_jiffies_up(next));
spin_unlock_irqrestore(q->queue_lock, flags);
}
@@ -201,7 +202,7 @@ void blk_add_timer(struct request *req)
* than an existing one, modify the timer. Round to next nearest
* second.
*/
- expiry = round_jiffies(req->deadline);
+ expiry = round_jiffies_up(req->deadline);
/*
* We use ->deadline == 0 to detect whether a timer was added or
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] Block: use round_jiffies_up()
2008-11-04 16:15 [PATCH 2/2] Block: use round_jiffies_up() Alan Stern
@ 2008-11-05 3:34 ` Tejun Heo
2008-11-05 16:21 ` Alan Stern
0 siblings, 1 reply; 5+ messages in thread
From: Tejun Heo @ 2008-11-05 3:34 UTC (permalink / raw)
To: Alan Stern; +Cc: Jens Axboe, Kernel development list
Hello,
Alan Stern wrote:
> @@ -78,13 +78,14 @@ void blk_delete_timer(struct request *re
> /*
> * Nothing to detach
> */
> - if (!q->rq_timed_out_fn || !req->deadline)
> + if (!req->deadline)
> return;
>
> list_del_init(&req->timeout_list);
>
> if (list_empty(&q->timeout_list))
> del_timer(&q->timeout);
> + req->deadline = 0;
> }
Actually, this can just be
blk_delete_timer()
{
list_del_init(&req->timeout_list);
if (list_empty(&q->timeout_list))
del_timer(&q->timeout);
}
and none of req->deadline trick is necessary.
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] Block: use round_jiffies_up()
2008-11-05 3:34 ` Tejun Heo
@ 2008-11-05 16:21 ` Alan Stern
2008-11-05 19:12 ` Jens Axboe
0 siblings, 1 reply; 5+ messages in thread
From: Alan Stern @ 2008-11-05 16:21 UTC (permalink / raw)
To: Tejun Heo; +Cc: Jens Axboe, Kernel development list
On Wed, 5 Nov 2008, Tejun Heo wrote:
> Hello,
>
> Alan Stern wrote:
> > @@ -78,13 +78,14 @@ void blk_delete_timer(struct request *re
> > /*
> > * Nothing to detach
> > */
> > - if (!q->rq_timed_out_fn || !req->deadline)
> > + if (!req->deadline)
> > return;
> >
> > list_del_init(&req->timeout_list);
> >
> > if (list_empty(&q->timeout_list))
> > del_timer(&q->timeout);
> > + req->deadline = 0;
> > }
>
> Actually, this can just be
>
> blk_delete_timer()
> {
> list_del_init(&req->timeout_list);
> if (list_empty(&q->timeout_list))
> del_timer(&q->timeout);
> }
>
> and none of req->deadline trick is necessary.
True. And if we do this, then there's no need to test and increment
req->deadline in blk_add_timer().
Alan Stern
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] Block: use round_jiffies_up()
2008-11-05 16:21 ` Alan Stern
@ 2008-11-05 19:12 ` Jens Axboe
2008-11-05 21:19 ` [PATCH 2/2 ver 2] " Alan Stern
0 siblings, 1 reply; 5+ messages in thread
From: Jens Axboe @ 2008-11-05 19:12 UTC (permalink / raw)
To: Alan Stern; +Cc: Tejun Heo, Kernel development list
On Wed, Nov 05 2008, Alan Stern wrote:
> On Wed, 5 Nov 2008, Tejun Heo wrote:
>
> > Hello,
> >
> > Alan Stern wrote:
> > > @@ -78,13 +78,14 @@ void blk_delete_timer(struct request *re
> > > /*
> > > * Nothing to detach
> > > */
> > > - if (!q->rq_timed_out_fn || !req->deadline)
> > > + if (!req->deadline)
> > > return;
> > >
> > > list_del_init(&req->timeout_list);
> > >
> > > if (list_empty(&q->timeout_list))
> > > del_timer(&q->timeout);
> > > + req->deadline = 0;
> > > }
> >
> > Actually, this can just be
> >
> > blk_delete_timer()
> > {
> > list_del_init(&req->timeout_list);
> > if (list_empty(&q->timeout_list))
> > del_timer(&q->timeout);
> > }
> >
> > and none of req->deadline trick is necessary.
>
> True. And if we do this, then there's no need to test and increment
> req->deadline in blk_add_timer().
It was an optimization for drivers that don't use block layer timers,
but we can get rid of it.
--
Jens Axboe
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/2 ver 2] Block: use round_jiffies_up()
2008-11-05 19:12 ` Jens Axboe
@ 2008-11-05 21:19 ` Alan Stern
0 siblings, 0 replies; 5+ messages in thread
From: Alan Stern @ 2008-11-05 21:19 UTC (permalink / raw)
To: Jens Axboe; +Cc: Tejun Heo, Kernel development list
This patch (as1159b) changes the timeout routines in the block core to
use round_jiffies_up(). There's no point in rounding the timer
deadline down, since if it expires too early we will have to restart
it.
The patch also removes some unnecessary tests when a request is
removed from the queue's timer list.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
---
Index: usb-2.6/block/blk-timeout.c
===================================================================
--- usb-2.6.orig/block/blk-timeout.c
+++ usb-2.6/block/blk-timeout.c
@@ -75,14 +75,7 @@ void blk_delete_timer(struct request *re
{
struct request_queue *q = req->q;
- /*
- * Nothing to detach
- */
- if (!q->rq_timed_out_fn || !req->deadline)
- return;
-
list_del_init(&req->timeout_list);
-
if (list_empty(&q->timeout_list))
del_timer(&q->timeout);
}
@@ -142,7 +135,7 @@ void blk_rq_timed_out_timer(unsigned lon
}
if (next_set && !list_empty(&q->timeout_list))
- mod_timer(&q->timeout, round_jiffies(next));
+ mod_timer(&q->timeout, round_jiffies_up(next));
spin_unlock_irqrestore(q->queue_lock, flags);
}
@@ -198,17 +191,10 @@ void blk_add_timer(struct request *req)
/*
* If the timer isn't already pending or this timeout is earlier
- * than an existing one, modify the timer. Round to next nearest
+ * than an existing one, modify the timer. Round up to next nearest
* second.
*/
- expiry = round_jiffies(req->deadline);
-
- /*
- * We use ->deadline == 0 to detect whether a timer was added or
- * not, so just increase to next jiffy for that specific case
- */
- if (unlikely(!req->deadline))
- req->deadline = 1;
+ expiry = round_jiffies_up(req->deadline);
if (!timer_pending(&q->timeout) ||
time_before(expiry, q->timeout.expires))
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-11-05 21:19 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-04 16:15 [PATCH 2/2] Block: use round_jiffies_up() Alan Stern
2008-11-05 3:34 ` Tejun Heo
2008-11-05 16:21 ` Alan Stern
2008-11-05 19:12 ` Jens Axboe
2008-11-05 21:19 ` [PATCH 2/2 ver 2] " Alan Stern
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).