public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Petr Vandrovec <vandrove@vc.cvut.cz>
To: alan@lxorguk.ukuu.org.uk, torvalds@transmeta.com
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] Save 8 bytes in __{read,write}_lock_failed...
Date: Sat, 30 Nov 2002 00:40:35 +0100	[thread overview]
Message-ID: <20021129234035.GA22666@vana> (raw)

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
						vandrove@vc.cvut.cz

diff -urdN linux/arch/i386/kernel/semaphore.c linux/arch/i386/kernel/semaphore.c
--- linux/arch/i386/kernel/semaphore.c	2002-11-26 19:55:59.000000000 +0000
+++ linux/arch/i386/kernel/semaphore.c	2002-11-29 23:24:50.000000000 +0000
@@ -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

                 reply	other threads:[~2002-11-29 23:33 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20021129234035.GA22666@vana \
    --to=vandrove@vc.cvut.cz \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@transmeta.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox