linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ioat: Use time_before()
@ 2014-05-22 20:11 Manuel Schölling
  2014-08-21 17:10 ` Dan Williams
  0 siblings, 1 reply; 4+ messages in thread
From: Manuel Schölling @ 2014-05-22 20:11 UTC (permalink / raw)
  To: vinod.koul
  Cc: dan.j.williams, b.zolnierkie, dmaengine, linux-kernel,
	kernel-janitors, Manuel Schölling

To be future-proof and for better readability the time comparisons are modified
to use time_before() instead of plain, error-prone math.

Signed-off-by: Manuel Schölling <manuel.schoelling@gmx.de>
---
 drivers/dma/ioat/dma_v2.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/ioat/dma_v2.c b/drivers/dma/ioat/dma_v2.c
index 8d10580..fdd60c7 100644
--- a/drivers/dma/ioat/dma_v2.c
+++ b/drivers/dma/ioat/dma_v2.c
@@ -735,7 +735,8 @@ int ioat2_check_space_lock(struct ioat2_dma_chan *ioat, int num_descs)
 	 * called under bh_disabled so we need to trigger the timer
 	 * event directly
 	 */
-	if (jiffies > chan->timer.expires && timer_pending(&chan->timer)) {
+	if (time_before(chan->timer.expires, jiffies)
+	    && timer_pending(&chan->timer)) {
 		struct ioatdma_device *device = chan->device;
 
 		mod_timer(&chan->timer, jiffies + COMPLETION_TIMEOUT);
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] ioat: Use time_before()
  2014-05-22 20:11 [PATCH] ioat: Use time_before() Manuel Schölling
@ 2014-08-21 17:10 ` Dan Williams
  2014-08-21 17:44   ` Joe Perches
  0 siblings, 1 reply; 4+ messages in thread
From: Dan Williams @ 2014-08-21 17:10 UTC (permalink / raw)
  To: Manuel Schölling
  Cc: Vinod Koul, Bartlomiej Zolnierkiewicz, dmaengine, linux-kernel,
	kernel-janitors

On Thu, May 22, 2014 at 1:11 PM, Manuel Schölling
<manuel.schoelling@gmx.de> wrote:
> To be future-proof and for better readability the time comparisons are modified
> to use time_before() instead of plain, error-prone math.
>
> Signed-off-by: Manuel Schölling <manuel.schoelling@gmx.de>
> ---
>  drivers/dma/ioat/dma_v2.c |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/dma/ioat/dma_v2.c b/drivers/dma/ioat/dma_v2.c
> index 8d10580..fdd60c7 100644
> --- a/drivers/dma/ioat/dma_v2.c
> +++ b/drivers/dma/ioat/dma_v2.c
> @@ -735,7 +735,8 @@ int ioat2_check_space_lock(struct ioat2_dma_chan *ioat, int num_descs)
>          * called under bh_disabled so we need to trigger the timer
>          * event directly
>          */
> -       if (jiffies > chan->timer.expires && timer_pending(&chan->timer)) {
> +       if (time_before(chan->timer.expires, jiffies)
> +           && timer_pending(&chan->timer)) {
>                 struct ioatdma_device *device = chan->device;

Thanks, let's use time_is_before_jiffies() for this cleanup... I'll
fix up and apply.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ioat: Use time_before()
  2014-08-21 17:10 ` Dan Williams
@ 2014-08-21 17:44   ` Joe Perches
  2014-08-22 16:52     ` Julia Lawall
  0 siblings, 1 reply; 4+ messages in thread
From: Joe Perches @ 2014-08-21 17:44 UTC (permalink / raw)
  To: Dan Williams, Andrew Morton, Dave Young
  Cc: Manuel Schölling, Vinod Koul, Bartlomiej Zolnierkiewicz,
	dmaengine, linux-kernel, kernel-janitors

On Thu, 2014-08-21 at 10:10 -0700, Dan Williams wrote:
> On Thu, May 22, 2014 at 1:11 PM, Manuel Schölling
> <manuel.schoelling@gmx.de> wrote:
> > To be future-proof and for better readability the time comparisons are modified
> > to use time_before() instead of plain, error-prone math.
[]
> > diff --git a/drivers/dma/ioat/dma_v2.c b/drivers/dma/ioat/dma_v2.c
[]
> > @@ -735,7 +735,8 @@ int ioat2_check_space_lock(struct ioat2_dma_chan *ioat, int num_descs)
> >          * called under bh_disabled so we need to trigger the timer
> >          * event directly
> >          */
> > -       if (jiffies > chan->timer.expires && timer_pending(&chan->timer)) {
> > +       if (time_before(chan->timer.expires, jiffies)
> > +           && timer_pending(&chan->timer)) {
> >                 struct ioatdma_device *device = chan->device;
> 
> Thanks, let's use time_is_before_jiffies() for this cleanup... I'll
> fix up and apply.

There are thousands of uses of time_before( and time_after(
with jiffies, and 6 years after being added, a little more
than a dozen or so of time_is_[before|after]_jiffies.

I also think the "time_is_[before|after]_jiffies" macros are
not very well named.

Using them is more text than using jiffies directly.
There is a small benefit in argument ordering correctness.

	time_after(jiffies, foo)
	time_is_after_jiffies(foo)

I'd rather just drop jiffies altogether
	time_is_after(foo)
or maybe add and use
	jiffies_is_after(foo)

(all the other after_eq/before/before_eq variants too).


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ioat: Use time_before()
  2014-08-21 17:44   ` Joe Perches
@ 2014-08-22 16:52     ` Julia Lawall
  0 siblings, 0 replies; 4+ messages in thread
From: Julia Lawall @ 2014-08-22 16:52 UTC (permalink / raw)
  To: Joe Perches
  Cc: Dan Williams, Andrew Morton, Dave Young, Manuel Schölling,
	Vinod Koul, Bartlomiej Zolnierkiewicz, dmaengine, linux-kernel,
	kernel-janitors

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1663 bytes --]



On Thu, 21 Aug 2014, Joe Perches wrote:

> On Thu, 2014-08-21 at 10:10 -0700, Dan Williams wrote:
> > On Thu, May 22, 2014 at 1:11 PM, Manuel Schölling
> > <manuel.schoelling@gmx.de> wrote:
> > > To be future-proof and for better readability the time comparisons are modified
> > > to use time_before() instead of plain, error-prone math.
> []
> > > diff --git a/drivers/dma/ioat/dma_v2.c b/drivers/dma/ioat/dma_v2.c
> []
> > > @@ -735,7 +735,8 @@ int ioat2_check_space_lock(struct ioat2_dma_chan *ioat, int num_descs)
> > >          * called under bh_disabled so we need to trigger the timer
> > >          * event directly
> > >          */
> > > -       if (jiffies > chan->timer.expires && timer_pending(&chan->timer)) {
> > > +       if (time_before(chan->timer.expires, jiffies)
> > > +           && timer_pending(&chan->timer)) {
> > >                 struct ioatdma_device *device = chan->device;
> > 
> > Thanks, let's use time_is_before_jiffies() for this cleanup... I'll
> > fix up and apply.
> 
> There are thousands of uses of time_before( and time_after(
> with jiffies, and 6 years after being added, a little more
> than a dozen or so of time_is_[before|after]_jiffies.
> 
> I also think the "time_is_[before|after]_jiffies" macros are
> not very well named.
> 
> Using them is more text than using jiffies directly.
> There is a small benefit in argument ordering correctness.
> 
> 	time_after(jiffies, foo)
> 	time_is_after_jiffies(foo)
> 
> I'd rather just drop jiffies altogether
> 	time_is_after(foo)
> or maybe add and use
> 	jiffies_is_after(foo)

jiffies_is_after is very understandable.  The others seem to require some 
thought.

julia

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-08-22 16:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-22 20:11 [PATCH] ioat: Use time_before() Manuel Schölling
2014-08-21 17:10 ` Dan Williams
2014-08-21 17:44   ` Joe Perches
2014-08-22 16:52     ` Julia Lawall

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).