Skip to contentSkip to conversation

Save 8 bytes in __{read,write}_lock_failed...

PATCH New Petr Vandrovec 1 participant 1 message Nov 29, 2002

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Save 8 bytes in __{read,write}_lock_failed...

Hi,
recent bugreport from Chris Rankin pointed out to me
that last jump in both __read_lock_failed and __write_lock_failed uses 4 byte offset, although 1 byte is enough. It happens because of __write_lock_failed is .globl, and so gas emits 4 byte offset + R_386_PC32 relocation (should it? I always thought that only .weak symbols may be overwritten from other file).

Simple patch below makes SMP kernel 8 bytes shorter.
Best regards,
Petr Vandrovec [email protected]

arch/i386/kernel/semaphore.c +4 -2
diff -urdN linux/arch/i386/kernel/semaphore.c linux/arch/i386/kernel/semaphore.c
@@ -275,12 +275,13 @@
 ".align	4\n"
 ".globl	__write_lock_failed\n"
 "__write_lock_failed:\n\t"
+"0:\n\t"
 	LOCK "addl	$" RW_LOCK_BIAS_STR ",(%eax)\n"
 "1:	rep; nop\n\t"
 	"cmpl	$" RW_LOCK_BIAS_STR ",(%eax)\n\t"
 	"jne	1b\n\t"
 	LOCK "subl	$" RW_LOCK_BIAS_STR ",(%eax)\n\t"
-	"jnz	__write_lock_failed\n\t"
+	"jnz	0b\n\t"
 	"ret"
 );
 
@@ -289,12 +290,13 @@
 ".align	4\n"
 ".globl	__read_lock_failed\n"
 "__read_lock_failed:\n\t"
+"0:\n\t"
 	LOCK "incl	(%eax)\n"
 "1:	rep; nop\n\t"
 	"cmpl	$1,(%eax)\n\t"
 	"js	1b\n\t"
 	LOCK "decl	(%eax)\n\t"
-	"js	__read_lock_failed\n\t"
+	"js	0b\n\t"
 	"ret"
 );
 #endif