[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v2] x86/atomic: Improvements and simplifications to assembly constraints


  • To: Jan Beulich <JBeulich@xxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Mon, 18 Mar 2019 14:49:42 +0000
  • Autocrypt: addr=andrew.cooper3@xxxxxxxxxx; prefer-encrypt=mutual; keydata= mQINBFLhNn8BEADVhE+Hb8i0GV6mihnnr/uiQQdPF8kUoFzCOPXkf7jQ5sLYeJa0cQi6Penp VtiFYznTairnVsN5J+ujSTIb+OlMSJUWV4opS7WVNnxHbFTPYZVQ3erv7NKc2iVizCRZ2Kxn srM1oPXWRic8BIAdYOKOloF2300SL/bIpeD+x7h3w9B/qez7nOin5NzkxgFoaUeIal12pXSR Q354FKFoy6Vh96gc4VRqte3jw8mPuJQpfws+Pb+swvSf/i1q1+1I4jsRQQh2m6OTADHIqg2E ofTYAEh7R5HfPx0EXoEDMdRjOeKn8+vvkAwhviWXTHlG3R1QkbE5M/oywnZ83udJmi+lxjJ5 YhQ5IzomvJ16H0Bq+TLyVLO/VRksp1VR9HxCzItLNCS8PdpYYz5TC204ViycobYU65WMpzWe LFAGn8jSS25XIpqv0Y9k87dLbctKKA14Ifw2kq5OIVu2FuX+3i446JOa2vpCI9GcjCzi3oHV e00bzYiHMIl0FICrNJU0Kjho8pdo0m2uxkn6SYEpogAy9pnatUlO+erL4LqFUO7GXSdBRbw5 gNt25XTLdSFuZtMxkY3tq8MFss5QnjhehCVPEpE6y9ZjI4XB8ad1G4oBHVGK5LMsvg22PfMJ ISWFSHoF/B5+lHkCKWkFxZ0gZn33ju5n6/FOdEx4B8cMJt+cWwARAQABtClBbmRyZXcgQ29v cGVyIDxhbmRyZXcuY29vcGVyM0BjaXRyaXguY29tPokCOgQTAQgAJAIbAwULCQgHAwUVCgkI CwUWAgMBAAIeAQIXgAUCWKD95wIZAQAKCRBlw/kGpdefoHbdD/9AIoR3k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ASHMHBqxMVSwZNN/d +NZ7Y0UlWxMykPS5pV6X0BeQT3ZlgZnl7Ck2OGfn7RbhLJWZbKToanETYa/+o05XTvdgrj/8 WJX13Lna1VvRwwDLGSRCpKkOwQvUGOBhKhR79J3YWXgl8NTXsceK/meUT9CxxkQdTPE9Y6CW FPcRmJoS1num9P7g5dfOp3QBSwazqdw9FQjVwohbl2MI7vMLhjNTr15QDPSu+nXbISQSWYWw XEZquUVoIZ3dawX/OJVj66l0gyN5YgSnMi1D76HKj9xKanG78iLD2a8WjKb7cMpby9UeLpgN g9PpEy9wovpMoNWg6xNRo4qcEu6RULznQ4cA9tapb07xFgn5xSBuQ7/XfxMkKRo70sRWImhJ 2CR4C+anBQSR8+MIYcD4mR7AwytIP5AZwrdr3O6Kw2YpEeXkyeeP/3F6Ld7iYORPY2XZELEH Rg+HErpzBAHOsupwmRJBGNG3QG3HOEcVx1qpENCLNaREM7nLdjOPzZPcZ/7zE6XiBLqC5Jla so8F/DwTIGamb4zf7YU0pL3c0Ve/Jwig/V2eeghV/dj1igfTNxx4Xkpi4/wsAO2DA3DYShyJ n0PDH0lIOhqegbR36znFGDyggZtxk568mKETxqEANCfT0VZROyoq56wKpTf6w4f9KPg7dqon bp4nzf11lMxbyUOagdA1YJAqaLLQN4NrZrKKTEIUdGEruT5eSYcSSR1hbl+OH9uLyveFl/ax cEes77XnGKVVBCdBolUTCOj9oBYLlKIMkifJXNg5ZIeUs/isSO6GUN8krau/KchwbG5LdyiC XTm/hCp7Y6uNJeM1MlMraEzb7dLbQZ
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Openpgp: preference=signencrypt

On 18/03/2019 14:11, Andrew Cooper wrote:


        
@@ -63,36 +65,38 @@ static always_inline __uint128_t cmpxchg16b_local_(
  * If no fault occurs then _o is updated to the value we saw at _p. If this
  * is the same as the initial value of _o then _n is written to location _p.
  */
-#define __cmpxchg_user(_p,_o,_n,_isuff,_oppre,_regtype)                 \
+#define __cmpxchg_user(_p, _o, _n, _oppre)                              \
     stac();                                                             \
     asm volatile (                                                      \
-        "1: lock; cmpxchg"_isuff" %"_oppre"2,%3\n"                      \
+        "1: lock cmpxchg %"_oppre"[new], %[ptr]\n"                      \
         "2:\n"                                                          \
         ".section .fixup,\"ax\"\n"                                      \
-        "3:     movl $1,%1\n"                                           \
+        "3:     movl $1, %[rc]\n"                                       \
         "       jmp 2b\n"                                               \
         ".previous\n"                                                   \
         _ASM_EXTABLE(1b, 3b)                                            \
-        : "=a" (_o), "=r" (_rc)                                         \
-        : _regtype (_n), "m" (*__xg((volatile void *)_p)), "0" (_o), "1" (0) \
+        : "+a" (_o), [rc] "=r" (_rc),                                   \
+          [ptr] "+m" (*(volatile typeof(*(_p)) *)(_p))                  \
+        : [new] "r" (_n), "[rc]" (0)                                    \
Wouldn't it further help readability a little if _rc was initialized to zero
right when getting declared, eliminating the last input arg here (the
output then would need to be "+r" of course)?
I can do.

I've got the following incremental fix which I intend to fold in.

diff --git a/xen/include/asm-x86/x86_64/system.h b/xen/include/asm-x86/x86_64/system.h
index 5b6e964..d65562b 100644
--- a/xen/include/asm-x86/x86_64/system.h
+++ b/xen/include/asm-x86/x86_64/system.h
@@ -65,7 +65,7 @@ static always_inline __uint128_t cmpxchg16b_local_(
  * If no fault occurs then _o is updated to the value we saw at _p. If this
  * is the same as the initial value of _o then _n is written to location _p.
  */
-#define __cmpxchg_user(_p, _o, _n, _oppre)                              \
+#define __cmpxchg_user(_p, _o, _n, _rc, _oppre)                         \
     stac();                                                             \
     asm volatile (                                                      \
         "1: lock cmpxchg %"_oppre"[new], %[ptr]\n"                      \
@@ -75,28 +75,29 @@ static always_inline __uint128_t cmpxchg16b_local_(
         "       jmp 2b\n"                                               \
         ".previous\n"                                                   \
         _ASM_EXTABLE(1b, 3b)                                            \
-        : "+a" (_o), [rc] "=r" (_rc),                                   \
+        : "+a" (_o), [rc] "+r" (_rc),                                   \
           [ptr] "+m" (*(volatile typeof(*(_p)) *)(_p))                  \
-        : [new] "r" (_n), "[rc]" (0)                                    \
+        : [new] "r" (_n)                                                \
         : "memory");                                                    \
     clac()
 
 #define cmpxchg_user(_p, _o, _n)                                        \
 ({                                                                      \
-    int _rc;                                                            \
+    int _rc = 0;                                                        \
+                                                                        \
     switch ( sizeof(*(_p)) )                                            \
     {                                                                   \
     case 1:                                                             \
-        __cmpxchg_user(_p, _o, _n, "b");                                \
+        __cmpxchg_user(_p, _o, _n, _rc, "b");                           \
         break;                                                          \
     case 2:                                                             \
-        __cmpxchg_user(_p, _o, _n, "w");                                \
+        __cmpxchg_user(_p, _o, _n, _rc, "w");                           \
         break;                                                          \
     case 4:                                                             \
-        __cmpxchg_user(_p, _o, _n, "k");                                \
+        __cmpxchg_user(_p, _o, _n, _rc, "k");                           \
         break;                                                          \
     case 8:                                                             \
-        __cmpxchg_user(_p, _o, _n, "q");                                \
+        __cmpxchg_user(_p, _o, _n, _rc, "q");                           \
         break;                                                          \
     }                                                                   \
     _rc;                                                                \

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.