All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [TRIVIAL] Re: UP went into unexpected trashing
@ 2002-11-08 14:35 Petr Vandrovec
  2002-11-08 19:53 ` Dipankar Sarma
  0 siblings, 1 reply; 7+ messages in thread
From: Petr Vandrovec @ 2002-11-08 14:35 UTC (permalink / raw)
  To: Rusty Trivial Russell; +Cc: linux-kernel, torvalds

On  8 Nov 02 at 19:33, Rusty Trivial Russell wrote:
> --- trivial-2.5-bk/include/asm-i386/bitops.h.orig   2002-11-08 18:47:20.000000000 +1100
> +++ trivial-2.5-bk/include/asm-i386/bitops.h    2002-11-08 18:47:20.000000000 +1100
> @@ -311,12 +311,13 @@
>         "repe; scasl\n\t"
>         "jz 1f\n\t"
>         "leal -4(%%edi),%%edi\n\t"
> -       "bsfl (%%edi),%%eax\n"
> -       "1:\tsubl %%ebx,%%edi\n\t"
> +       "bsfl (%%edi),%%edx\n"
> +       "subl %%ebx,%%edi\n\t"
>         "shll $3,%%edi\n\t"
> -       "addl %%edi,%%eax"
> +       "addl %%edi,%%edx\n\t"
> +       "1:\tmovl %%edx,%%eax\n\t"
>         :"=a" (res), "=&c" (d0), "=&D" (d1)
> -       :"1" ((size + 31) >> 5), "2" (addr), "b" (addr));
> +       :"1" ((size + 31) >> 5), "2" (addr), "b" (addr), "d" (size));
>     return res;

EDX is modified, should not you list "=d" as output, with new variable (d2)?

Or better, drop last line of assembly code, and say that (res) is in
"d", and list "a" as clobbered or dummy output register.

And BTW, if you'll do 

unsigned long b = 0x8000;
find_first_bit(&b, 1);

return value will be 15 even with patched function. So either more
fixing is needed, or code which calls find_first_bit() with value which
is not multiple of 32 should take special care that last dword does
not contain set bits after last interesting bit.

So maybe callers should just treat any return value >= size as "not found",
leaving older smaller code in place.
                                            Best regards,
                                                Petr Vandrovec
                                                vandrove@vc.cvut.cz
                                                

^ permalink raw reply	[flat|nested] 7+ messages in thread
* [TRIVIAL] Re: UP went into unexpected trashing
@ 2002-11-08  8:33 Rusty Trivial Russell
  0 siblings, 0 replies; 7+ messages in thread
From: Rusty Trivial Russell @ 2002-11-08  8:33 UTC (permalink / raw)
  To: torvalds, linux-kernel

[ find_first_bit on x86 returns 32 even if you said to stop at (say) 5
  bits.  Uncovered by the larger cpu mask patch. ]

From:  dipankar@in.ibm.com

  Well, my earlier find_first_bit() implementation was completely bogus.
  My sanity has now returned and I coded this patch below that fixes 
  find_find_bit() to return "size" if all bits are zero. I have tested it 
  extensively in userspace and it boots 2.5.44-mm5 which crashed with the earlier
  version of the bitops_fix patch. I have coded the assembly routine
  as optimal as I could think of and without introducing any new
  branches or memory loads.
  
  Along with this patch, I applied the larger_cpu_mask patch to -mm5
  and sanity tested both UP and SMP kernels for dcache leaks in a 4CPU P3 box.
  An ls -lR and subsequent unmounting of that filesystems showed that
  the dentries were correctly getting returned the dcache slab and
  that indicates that the larger_cpu_mask patch no longer breaks RCU.
  I will do some more testing with this combination later with
  rcu_stats applied on this tree (just to be sure), but so far it looks good.
  
  Thanks
  -- 
  Dipankar Sarma  <dipankar@in.ibm.com> http://lse.sourceforge.net
  Linux Technology Center, IBM Software Lab, Bangalore, India.
  
  
  bitops_fix.patch
  -----------------
  

--- trivial-2.5-bk/include/asm-i386/bitops.h.orig	2002-11-08 18:47:20.000000000 +1100
+++ trivial-2.5-bk/include/asm-i386/bitops.h	2002-11-08 18:47:20.000000000 +1100
@@ -311,12 +311,13 @@
 		"repe; scasl\n\t"
 		"jz 1f\n\t"
 		"leal -4(%%edi),%%edi\n\t"
-		"bsfl (%%edi),%%eax\n"
-		"1:\tsubl %%ebx,%%edi\n\t"
+		"bsfl (%%edi),%%edx\n"
+		"subl %%ebx,%%edi\n\t"
 		"shll $3,%%edi\n\t"
-		"addl %%edi,%%eax"
+		"addl %%edi,%%edx\n\t"
+		"1:\tmovl %%edx,%%eax\n\t"
 		:"=a" (res), "=&c" (d0), "=&D" (d1)
-		:"1" ((size + 31) >> 5), "2" (addr), "b" (addr));
+		:"1" ((size + 31) >> 5), "2" (addr), "b" (addr), "d" (size));
 	return res;
 }
 
-- 
  Don't blame me: the Monkey is driving
  File: dipankar@in.ibm.com: Re: [long]2.5.44-mm3 UP went into unexpected trashing

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

end of thread, other threads:[~2002-11-10  3:51 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-11-08 14:35 [TRIVIAL] Re: UP went into unexpected trashing Petr Vandrovec
2002-11-08 19:53 ` Dipankar Sarma
2002-11-08 20:10   ` Linus Torvalds
2002-11-09  3:16     ` Rusty Russell
2002-11-09  4:40       ` Linus Torvalds
2002-11-10  3:09         ` Rusty Russell
  -- strict thread matches above, loose matches on Subject: below --
2002-11-08  8:33 Rusty Trivial Russell

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.