Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1389973

[tip:locking/rwsem] locking/rwsem, x86: Clean up ____down_write()

From tip-bot for Borislav Petkov <tipbot@zytor.com>
Newsgroups linux.kernel
Subject [tip:locking/rwsem] locking/rwsem, x86: Clean up ____down_write()
Date 2016-04-28 12:30 +0200
Message-ID <rsRmO-1va-11@gated-at.bofh.it> (permalink)
References <rsws1-11E-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Commit-ID:  71c01930b42e5dd65d4820dea116bcbe95a0b768
Gitweb:     http://git.kernel.org/tip/71c01930b42e5dd65d4820dea116bcbe95a0b768
Author:     Borislav Petkov <bp@suse.de>
AuthorDate: Wed, 27 Apr 2016 13:47:32 +0200
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Thu, 28 Apr 2016 10:42:56 +0200

locking/rwsem, x86: Clean up ____down_write()

Move the RWSEM_ACTIVE_WRITE_BIAS out of the inline asm to reduce the
number of arguments. Also, make it an input argument only (why it was an
output operand, I still don't know...).

For better readability, use symbolic names for the arguments and move
the linebreak backspace to 80 cols.

Resulting asm differs only in the temporary GCC variable names and
locations:

  -- before      2016-04-27 13:39:05.320778458 +0200
  ++ after       2016-04-27 13:52:37.336778994 +0200
  @@ -11,8 +11,8 @@ down_write_killable:
   .LBB84:
   .LBB85:
   .LBB86:
  -        .loc 2 128 0
  -        movabsq $-4294967295, %rdx      #, tmp
  +        .loc 2 130 0
  +        movabsq $-4294967295, %rdx      #, tmp94
           movq    %rdi, %rax      # sem, sem
   .LBE86:
   .LBE85:
  @@ -23,17 +23,17 @@ down_write_killable:
   .LBB89:
   .LBB88:
   .LBB87:
  -        .loc 2 128 0
  +        .loc 2 130 0
   #APP
  -# 128 "./arch/x86/include/asm/rwsem.h" 1
  +# 130 "./arch/x86/include/asm/rwsem.h" 1
           # beginning down_write
           .pushsection .smp_locks,"a"
   .balign 4
   .long 671f - .
   .popsection
   671:
  -        lock;   xadd      %rdx,(%rax)   # tmp, sem
  -          test  %edx , %edx     # tmp
  +        lock;   xadd      %rdx,(%rax)   # tmp94, sem
  +          test  %edx , %edx     # tmp94
             jz        1f
     call call_rwsem_down_write_failed_killable
   1:

Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Chris Zankel <chris@zankel.net>
Cc: David S. Miller <davem@davemloft.net>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tony Luck <tony.luck@intel.com>
Cc: linux-alpha@vger.kernel.org
Cc: linux-arch@vger.kernel.org
Cc: linux-ia64@vger.kernel.org
Cc: linux-s390@vger.kernel.org
Cc: linux-sh@vger.kernel.org
Cc: linux-xtensa@linux-xtensa.org
Cc: sparclinux@vger.kernel.org
Link: http://lkml.kernel.org/r/20160427120217.GE21011@pd.tnic
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/include/asm/rwsem.h | 36 +++++++++++++++++++-----------------
 1 file changed, 19 insertions(+), 17 deletions(-)

diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
index 453744c..d2f8d10 100644
--- a/arch/x86/include/asm/rwsem.h
+++ b/arch/x86/include/asm/rwsem.h
@@ -99,23 +99,25 @@ static inline int __down_read_trylock(struct rw_semaphore *sem)
 /*
  * lock for writing
  */
-#define ____down_write(sem, slow_path)			\
-({							\
-	long tmp;					\
-	struct rw_semaphore* ret;			\
-	asm volatile("# beginning down_write\n\t"	\
-		     LOCK_PREFIX "  xadd      %1,(%3)\n\t"	\
-		     /* adds 0xffff0001, returns the old value */ \
-		     "  test " __ASM_SEL(%w1,%k1) "," __ASM_SEL(%w1,%k1) "\n\t" \
-		     /* was the active mask 0 before? */\
-		     "  jz        1f\n"			\
-		     "  call " slow_path "\n"		\
-		     "1:\n"				\
-		     "# ending down_write"		\
-		     : "+m" (sem->count), "=d" (tmp), "=a" (ret)	\
-		     : "a" (sem), "1" (RWSEM_ACTIVE_WRITE_BIAS) \
-		     : "memory", "cc");			\
-	ret;						\
+#define ____down_write(sem, slow_path)						\
+({										\
+	long tmp = RWSEM_ACTIVE_WRITE_BIAS;					\
+	struct rw_semaphore* ret;						\
+										\
+	asm volatile("# beginning down_write\n\t"				\
+		     LOCK_PREFIX "  xadd      %[tmp],(%[sem])\n\t"		\
+		     /* adds 0xffff0001, returns the old value */		\
+		     "  test " __ASM_SEL(%w[tmp],%k[tmp]) ","			\
+			       __ASM_SEL(%w[tmp],%k[tmp]) "\n\t"		\
+		     /* was the active mask 0 before? */			\
+		     "  jz        1f\n"						\
+		     "  call " slow_path "\n"					\
+		     "1:\n"							\
+		     "# ending down_write"					\
+		     : "+m" (sem->count), "=a" (ret)				\
+		     : [sem] "a" (sem), [tmp] "r" (tmp)				\
+		     : "memory", "cc");						\
+	ret;									\
 })
 
 static inline void __down_write(struct rw_semaphore *sem)

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: [PATCH 10/11] x86, rwsem: provide __down_write_killable Peter Zijlstra <peterz@infradead.org> - 2016-04-20 15:50 +0200
  Re: [PATCH 10/11] x86, rwsem: provide __down_write_killable "H. Peter Anvin" <hpa@zytor.com> - 2016-04-20 20:10 +0200
    Re: [PATCH 10/11] x86, rwsem: provide __down_write_killable Borislav Petkov <bp@alien8.de> - 2016-04-20 22:50 +0200
      Re: [PATCH 10/11] x86, rwsem: provide __down_write_killable Michal Hocko <mhocko@kernel.org> - 2016-04-20 23:00 +0200
      Re: [PATCH 10/11] x86, rwsem: provide __down_write_killable "H. Peter Anvin" <hpa@zytor.com> - 2016-04-20 23:10 +0200
        Re: [PATCH 10/11] x86, rwsem: provide __down_write_killable Borislav Petkov <bp@alien8.de> - 2016-04-20 23:40 +0200
          Re: [PATCH 10/11] x86, rwsem: provide __down_write_killable "H. Peter Anvin" <hpa@zytor.com> - 2016-04-21 00:40 +0200
            Re: [PATCH 10/11] x86, rwsem: provide __down_write_killable Borislav Petkov <bp@alien8.de> - 2016-04-21 13:40 +0200
              Re: [PATCH 10/11] x86, rwsem: provide __down_write_killable Michal Hocko <mhocko@kernel.org> - 2016-04-21 15:10 +0200
                Re: [PATCH 10/11] x86, rwsem: provide __down_write_killable Borislav Petkov <bp@alien8.de> - 2016-04-21 15:30 +0200
            [PATCH] x86/locking/rwsem: Cleanup ____down_write() Borislav Petkov <bp@alien8.de> - 2016-04-27 14:10 +0200
              [tip:locking/rwsem] locking/rwsem, x86: Clean up ____down_write() tip-bot for Borislav Petkov <tipbot@zytor.com> - 2016-04-28 12:30 +0200
  Re: [PATCH 10/11] x86, rwsem: provide __down_write_killable Ingo Molnar <mingo@kernel.org> - 2016-04-22 09:00 +0200

csiph-web