Skip to contentSkip to conversation

bitops.h ext2_ ops save/restore flags

PATCH Florian Lohoff 1 participant 2 messages Jun 19, 2001 MIPS

lore
Share & tools
lore
#0 lore raw

Hi,
i am just staring at the bitops as it seems they are the culprit for the non working ext2 currently - While staring and comparing i found that the mips ext2_set_bit and co do an save_and_cli/restore_flags which is very obscure. I cant find any similar in other archs - I guess the above is due to a possible "atomic" requirement which ext2 doesnt seem to have (upper layer locking ?)

IMHO the patch cleans this:

Index: include/asm-mips/bitops.h
===================================================================
RCS file: /cvs/linux/include/asm-mips/bitops.h,v
retrieving revision 1.16

asm-mips/bitops.h +2 -6
diff -u -r1.16 bitops.h
@@ -797,28 +797,24 @@
 #ifdef __MIPSEB__
 extern __inline__ int ext2_set_bit(int nr,void * addr)
 {
-	int		mask, retval, flags;
+	int		mask, retval;
 	unsigned char	*ADDR = (unsigned char *) addr;
 
 	mask = 1 << (nr & 0x07);
-	save_and_cli(flags);
 	retval = (mask & *ADDR) != 0;
 	*ADDR |= mask;
-	restore_flags(flags);
 	return retval;
 }
 
 extern __inline__ int ext2_clear_bit(int nr, void * addr)
 {
-	int		mask, retval, flags;
+	int		mask, retval;
 	unsigned char	*ADDR = (unsigned char *) addr;
 
 	ADDR += nr >> 3;
 	mask = 1 << (nr & 0x07);
-	save_and_cli(flags);
 	retval = (mask & *ADDR) != 0;
 	*ADDR &= ~mask;
-	restore_flags(flags);
 	return retval;
 }
 

Comments ?

Flo

Signature · 2 lines
Florian Lohoff                  [email protected]             +49-5201-669912
     Why is it called "common sense" when nobody seems to have any?
#1 lore raw
Quoted 7 lines · Florian Lohoff

Hi,
i am just staring at the bitops as it seems they are the culprit for the non working ext2 currently - While staring and comparing i found that the mips ext2_set_bit and co do an save_and_cli/restore_flags which is very obscure. I cant find any similar in other archs - I guess the above is due to a possible "atomic" requirement which ext2 doesnt seem to have (upper layer locking ?)

Another one - This only fixes the big endian case - the little endian case still has the penalty of cli/restore on every bit set as the ext2 macros get defined to the "atomic" ops defined there

I propose this patch

Index: include/asm-mips/bitops.h
===================================================================
RCS file: /cvs/linux/include/asm-mips/bitops.h,v
retrieving revision 1.16

asm-mips/bitops.h +2 -2
diff -u -r1.16 bitops.h
@@ -887,8 +883,8 @@
 #else /* !(__MIPSEB__) */
 
 /* Native ext2 byte ordering, just collapse using defines. */
-#define ext2_set_bit(nr, addr) test_and_set_bit((nr), (addr))
-#define ext2_clear_bit(nr, addr) test_and_clear_bit((nr), (addr))
+#define ext2_set_bit(nr, addr) __test_and_set_bit((nr), (addr))
+#define ext2_clear_bit(nr, addr) __test_and_clear_bit((nr), (addr))
 #define ext2_test_bit(nr, addr) test_bit((nr), (addr))
 #define ext2_find_first_zero_bit(addr, size) find_first_zero_bit((addr), (size))
 #define ext2_find_next_zero_bit(addr, size, offset) \

Comments ?

Flo

Signature · 2 lines
Florian Lohoff                  [email protected]             +49-5201-669912
     Why is it called "common sense" when nobody seems to have any?