From: David Howells <dhowells@cambridge.redhat.com>
To: linux-kernel@vger.kernel.org
Cc: arjanv@redhat.com
Subject: i386 assembly timing issue
Date: Fri, 20 Apr 2001 13:36:02 +0100 [thread overview]
Message-ID: <32402.987770162@warthog.cambridge.redhat.com> (raw)
I've attached two slightly different bits of i386 assembly that achieve the
same end, but in slightly different ways. Can some one tell me why Case 1 is
faster than Case 2? Case 1 involves an extra CALL instruction.
* Case 1 has a little wrapper function that saves ECX and EDX before
calling rwsem_wake().
* Case 2 merges the contents of the wrapper with the caller.
Case 1 is what's generated by the rw-semaphore inline assembly code as of
2.4.4-pre5. Case 2 looks like it ought to be a faster version of the same
thing.
David
###############################################################################
#
# CASE 1: registers saved in the rwsem_wake register saving stub
#
.text
.align 16
#
# void test_up_read(struct rw_semaphore *sem)
# {
# up_read(sem);
# }
#
.globl test_up_read
.type test_up_read,@function
test_up_read:
movl 4(%esp), %eax
movl $-1, %edx
xadd %edx,(%eax)
js test_up_read_contention
test_up_read_done:
ret
#
# Register saving stub for rwsem_wake
#
.globl __rwsem_wake
__rwsem_wake:
pushl %edx
pushl %ecx
call rwsem_wake
popl %ecx
popl %edx
ret
#
# Contention handler stub for up_read
#
.section .text.lock,"ax"
test_up_read_contention:
decl %edx
testl $65535,%edx
jnz test_up_read_done
call __rwsem_wake
jmp test_up_read_done
###############################################################################
#
# CASE 2: registers saved in the contention handler stub
#
.text
.align 16
#
# void test_up_read(struct rw_semaphore *sem)
# {
# up_read(sem);
# }
#
.globl test_up_read
.type test_up_read,@function
test_up_read:
movl 4(%esp), %eax
movl $-1, %edx
xadd %edx,(%eax)
js test_up_read_contention
test_up_read_done:
ret
#
# Contention handler stub for up_read
#
.section .text.lock,"ax"
test_up_read_contention:
decl %edx
testl $65535,%edx
jnz test_up_read_done
pushl %edx
pushl %ecx
call __rwsem_wake
popl %ecx
popl %edx
jmp test_up_read_done
reply other threads:[~2001-04-20 12:36 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=32402.987770162@warthog.cambridge.redhat.com \
--to=dhowells@cambridge.redhat.com \
--cc=arjanv@redhat.com \
--cc=linux-kernel@vger.kernel.org \
/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
all inboxes | Powered by JetHome®