All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH]: jiffies wrap in ll_rw_blk.c
@ 2002-11-20 20:44 Luben Tuikov
  2002-11-20 21:06 ` Benjamin LaHaise
  2002-11-20 21:19 ` Alan Cox
  0 siblings, 2 replies; 8+ messages in thread
From: Luben Tuikov @ 2002-11-20 20:44 UTC (permalink / raw)
  To: linux-kernel, axboe

--- ll_rw_blk.c.old     Wed Nov 20 15:32:50 2002
+++ ll_rw_blk.c Wed Nov 20 15:33:06 2002
@@ -2092,7 +2092,7 @@
                complete(req->waiting);
 
        if (disk) {
-               unsigned long duration = jiffies - req->start_time;
+               unsigned long duration = (signed) jiffies - (signed) req->start_time;
                switch (rq_data_dir(req)) {
                    case WRITE:
                        disk->writes++;

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

* Re: [PATCH]: jiffies wrap in ll_rw_blk.c
  2002-11-20 21:19 ` Alan Cox
@ 2002-11-20 21:00   ` Luben Tuikov
  2002-11-20 21:31     ` Alan Cox
  2002-11-20 22:20   ` Olivier Galibert
  1 sibling, 1 reply; 8+ messages in thread
From: Luben Tuikov @ 2002-11-20 21:00 UTC (permalink / raw)
  To: Alan Cox; +Cc: Linux Kernel Mailing List, axboe

Alan Cox wrote:
> 
> On Wed, 2002-11-20 at 20:44, Luben Tuikov wrote:
> > --- ll_rw_blk.c.old     Wed Nov 20 15:32:50 2002
> > +++ ll_rw_blk.c Wed Nov 20 15:33:06 2002
> > @@ -2092,7 +2092,7 @@
> >                 complete(req->waiting);
> >
> >         if (disk) {
> > -               unsigned long duration = jiffies - req->start_time;
> > +               unsigned long duration = (signed) jiffies - (signed) req->start_time;
> >                 switch (rq_data_dir(req)) {
> 
> It was right before. Your patch breaks it. Think about it in unsigned
> maths
> 
>               0x00000002 - 0xFFFFFFFF = 0x00000003

0x2 - (-0x1) = 0x2 + 0x1 = 0x3

Right! I thought (signed) does the job. I actually tried
it both ways and works all right. I guess either way works fine.

-- 
Luben

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

* Re: [PATCH]: jiffies wrap in ll_rw_blk.c
  2002-11-20 20:44 [PATCH]: jiffies wrap in ll_rw_blk.c Luben Tuikov
@ 2002-11-20 21:06 ` Benjamin LaHaise
  2002-11-20 21:18   ` Luben Tuikov
  2002-11-20 21:19 ` Alan Cox
  1 sibling, 1 reply; 8+ messages in thread
From: Benjamin LaHaise @ 2002-11-20 21:06 UTC (permalink / raw)
  To: Luben Tuikov; +Cc: linux-kernel, axboe

Erm, you just truncated a long to an int.

		-ben

On Wed, Nov 20, 2002 at 03:44:03PM -0500, Luben Tuikov wrote:
> --- ll_rw_blk.c.old     Wed Nov 20 15:32:50 2002
> +++ ll_rw_blk.c Wed Nov 20 15:33:06 2002
> @@ -2092,7 +2092,7 @@
>                 complete(req->waiting);
>  
>         if (disk) {
> -               unsigned long duration = jiffies - req->start_time;
> +               unsigned long duration = (signed) jiffies - (signed) req->start_time;
>                 switch (rq_data_dir(req)) {
>                     case WRITE:
>                         disk->writes++;
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

-- 
"Do you seek knowledge in time travel?"

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

* Re: [PATCH]: jiffies wrap in ll_rw_blk.c
  2002-11-20 21:31     ` Alan Cox
@ 2002-11-20 21:15       ` Luben Tuikov
  0 siblings, 0 replies; 8+ messages in thread
From: Luben Tuikov @ 2002-11-20 21:15 UTC (permalink / raw)
  To: Alan Cox; +Cc: Linux Kernel Mailing List, axboe

Alan Cox wrote:
> 
> On Wed, 2002-11-20 at 21:00, Luben Tuikov wrote:sk) {
> > > > -               unsigned long duration = jiffies - req->start_time;
> > > > +               unsigned long duration = (signed) jiffies - (signed) req->start_time;
> > > >                 switch (rq_data_dir(req)) {
> > >
> > > It was right before. Your patch breaks it. Think about it in unsigned
> > > maths
> > >
> > >               0x00000002 - 0xFFFFFFFF = 0x00000003
> >
> > 0x2 - (-0x1) = 0x2 + 0x1 = 0x3
> >
> > Right! I thought (signed) does the job. I actually tried
> > it both ways and works all right. I guess either way works fine.
> 
> (signed long) maybe - but not signed - long is 64bit on Alpha, (signed)
> is 32

Aaaah, I see where you're coming from.

I basically tried to stay away from knowing _what_ actual
type it is and just to make it signed and do the arithmetic,
but didn't know the specific for the Alpha.

Shouldn't this be (symbolically:) (signed (typeof(jiffes)) jiffies -
(signed (typeof(start)) start -- you know what I mean.

But yes both ways should work:
a, b are both unsigned, then a-b = a+(-b) and there's just no
other way to compute the result.

Anyway, doesn't matter,
-- 
Luben

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

* Re: [PATCH]: jiffies wrap in ll_rw_blk.c
  2002-11-20 21:06 ` Benjamin LaHaise
@ 2002-11-20 21:18   ` Luben Tuikov
  0 siblings, 0 replies; 8+ messages in thread
From: Luben Tuikov @ 2002-11-20 21:18 UTC (permalink / raw)
  To: Benjamin LaHaise; +Cc: linux-kernel, axboe

Benjamin LaHaise wrote:
> 
> Erm, you just truncated a long to an int.

Yep, totally forgot about no type == int, hehehhee.

Boy, last time I thought about that _rule_ was over 12 years ago...

-- 
Luben

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

* Re: [PATCH]: jiffies wrap in ll_rw_blk.c
  2002-11-20 20:44 [PATCH]: jiffies wrap in ll_rw_blk.c Luben Tuikov
  2002-11-20 21:06 ` Benjamin LaHaise
@ 2002-11-20 21:19 ` Alan Cox
  2002-11-20 21:00   ` Luben Tuikov
  2002-11-20 22:20   ` Olivier Galibert
  1 sibling, 2 replies; 8+ messages in thread
From: Alan Cox @ 2002-11-20 21:19 UTC (permalink / raw)
  To: Luben Tuikov; +Cc: Linux Kernel Mailing List, axboe

On Wed, 2002-11-20 at 20:44, Luben Tuikov wrote:
> --- ll_rw_blk.c.old     Wed Nov 20 15:32:50 2002
> +++ ll_rw_blk.c Wed Nov 20 15:33:06 2002
> @@ -2092,7 +2092,7 @@
>                 complete(req->waiting);
>  
>         if (disk) {
> -               unsigned long duration = jiffies - req->start_time;
> +               unsigned long duration = (signed) jiffies - (signed) req->start_time;
>                 switch (rq_data_dir(req)) {

It was right before. Your patch breaks it. Think about it in unsigned
maths

              0x00000002 - 0xFFFFFFFF = 0x00000003

Alan


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

* Re: [PATCH]: jiffies wrap in ll_rw_blk.c
  2002-11-20 21:00   ` Luben Tuikov
@ 2002-11-20 21:31     ` Alan Cox
  2002-11-20 21:15       ` Luben Tuikov
  0 siblings, 1 reply; 8+ messages in thread
From: Alan Cox @ 2002-11-20 21:31 UTC (permalink / raw)
  To: Luben Tuikov; +Cc: Linux Kernel Mailing List, axboe

On Wed, 2002-11-20 at 21:00, Luben Tuikov wrote:sk) {
> > > -               unsigned long duration = jiffies - req->start_time;
> > > +               unsigned long duration = (signed) jiffies - (signed) req->start_time;
> > >                 switch (rq_data_dir(req)) {
> > 
> > It was right before. Your patch breaks it. Think about it in unsigned
> > maths
> > 
> >               0x00000002 - 0xFFFFFFFF = 0x00000003
> 
> 0x2 - (-0x1) = 0x2 + 0x1 = 0x3
> 
> Right! I thought (signed) does the job. I actually tried
> it both ways and works all right. I guess either way works fine.

(signed long) maybe - but not signed - long is 64bit on Alpha, (signed)
is 32


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

* Re: [PATCH]: jiffies wrap in ll_rw_blk.c
  2002-11-20 21:19 ` Alan Cox
  2002-11-20 21:00   ` Luben Tuikov
@ 2002-11-20 22:20   ` Olivier Galibert
  1 sibling, 0 replies; 8+ messages in thread
From: Olivier Galibert @ 2002-11-20 22:20 UTC (permalink / raw)
  To: Linux Kernel Mailing List

On Wed, Nov 20, 2002 at 09:19:33PM +0000, Alan Cox wrote:
> On Wed, 2002-11-20 at 20:44, Luben Tuikov wrote:
> > --- ll_rw_blk.c.old     Wed Nov 20 15:32:50 2002
> > +++ ll_rw_blk.c Wed Nov 20 15:33:06 2002
> > @@ -2092,7 +2092,7 @@
> >                 complete(req->waiting);
> >  
> >         if (disk) {
> > -               unsigned long duration = jiffies - req->start_time;
> > +               unsigned long duration = (signed) jiffies - (signed) req->start_time;
> >                 switch (rq_data_dir(req)) {
> 
> It was right before. Your patch breaks it. Think about it in unsigned
> maths
> 
>               0x00000002 - 0xFFFFFFFF = 0x00000003

Signed vs. unsigned is actually irrelevant in two-complement systems
as long as you don't compare.  Only the int/long issue has an actual
effect.

  OG.


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

end of thread, other threads:[~2002-11-20 22:13 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-11-20 20:44 [PATCH]: jiffies wrap in ll_rw_blk.c Luben Tuikov
2002-11-20 21:06 ` Benjamin LaHaise
2002-11-20 21:18   ` Luben Tuikov
2002-11-20 21:19 ` Alan Cox
2002-11-20 21:00   ` Luben Tuikov
2002-11-20 21:31     ` Alan Cox
2002-11-20 21:15       ` Luben Tuikov
2002-11-20 22:20   ` Olivier Galibert

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.