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

[PATCH v2] x86: help inlining of functions involving alternative_call()


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Fri, 12 Aug 2022 11:14:14 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=dqpMOTaZxDtYwoblaF22Ik5Dgt5Lak3ElJ+MWxm/G5g=; b=FnZWQWE4UwFXYKgBJgEYoJRLVCGqZO7cCp1F+6EvbiTEr2aea6U5virHiT/+AJNBpMj8CIpyqUNENrCrI60cLwqpRnsdDy50hlK9r+ZcxnzC23VIIShFB3NjlMG3uINRZx/pzT3+q9e8iFSjtel7oHMk3q/u4nJwuWTb0RspAcMQo/dEiCAWJweCW6Bs2SrIAhnQIkxsmcO2HLoYtEZT1DWula5PtLUUuFL3MrFKKfthqIJWFNkA2G/5+7MOI2IwixJk8JYxdi3mbyyAoeiIL6K5G9emDvR7gtIfOwudhpOFSjv40bI6d9Pg3CoYwKNX7gRoQme8Rl5hichIbtM4tA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VQEbIH6tLLIx6koGT2eDSvitG7LG4ITN/xt8lZQ8m3IzVO5R8izJWch/yE1WE4wTNDlGiejk3g1ZsWa3O8vb5zGe5xQY1GO0YmdqTPBjH0q0Sviw++3Cq0KzByOAW9zq72lg5yzJx36h93pwJ/rkbenJATMxdqnZqXNcdPQeTPCFzdNkZSjp80xb5e33HmTbO6AwWvsUAPsN8zKgtL9mrrSQXBXNSXI3xLAN0Y/uQ8Ny2aQdQ/0jsJS+99xQWTMH7Z4jSfawtfRj+3IdjU9hgbyLDfaSwN5M+uhNZjqst71+M+GMAm/o63JWDMQHlMGgGl7J7QJRG7CY3qhqTXHXAQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Fri, 12 Aug 2022 09:14:21 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

The involved asm() expands to large enough a construct that often the
compiler would decide against inlining when a containing function is
used more than once in a CU. Use the "inline" keyword when supported by
the compiler in conjunction with asm().

The INIT_SECTIONS_ONLY dependency is because in that case "inline" gets
expanded to "__inline__ __init", which obviously can't be used with
asm(). But for init-time only code we're also less worried ...

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---
v2: Re-base.
---
Perhaps this wants extending to other asm()-s involving ALTERNATIVE().
At which point the question is whether instead of altcall_asm we'd want
to have something like asm_inline.

I understand that Linux uses Kconfig for the feature detection. The
discussion on whether we want to generally follow this model continues
to be pending / stalled. In this particular case the error output from
the compiler when "inline" is not supported can be huge (thousands of
lines, partly because of the many nested levels of macro expansions),
making it close to impossible to recognize what the actual issue is. Yet
that's what would be happening if one switched the compiler from one
supporting the feature to one not supporting it, without remembering to
explicitly have xen/.config re-generated.

--- a/xen/Makefile
+++ b/xen/Makefile
@@ -386,6 +386,7 @@ CFLAGS += -Werror -Wredundant-decls -Wno
 $(call cc-option-add,CFLAGS,CC,-Wvla)
 CFLAGS += -pipe -D__XEN__ -include $(srctree)/include/xen/config.h
 CFLAGS-$(CONFIG_DEBUG_INFO) += -g
+CFLAGS-$(call success, echo 'void _(void) { asm inline (""); }' | $(CC) -x c - 
-c -o /dev/null) += -DCC_HAS_ASM_INLINE
 
 ifneq ($(CONFIG_CC_IS_CLANG),y)
 # Clang doesn't understand this command line argument, and doesn't appear to
--- a/xen/arch/x86/include/asm/alternative.h
+++ b/xen/arch/x86/include/asm/alternative.h
@@ -203,11 +203,17 @@ extern void alternative_branches(void);
 #define ALT_CALL6_OUT "+r" (a1_), "+r" (a2_), "+r" (a3_), \
                       "+r" (a4_), "+r" (a5_), "+r" (a6_)
 
+#if defined(INIT_SECTIONS_ONLY) || !defined(CC_HAS_ASM_INLINE)
+# define altcall_asm asm volatile
+#else
+# define altcall_asm asm volatile inline
+#endif
+
 #define alternative_callN(n, rettype, func) ({                     \
     rettype ret_;                                                  \
     register unsigned long r10_ asm("r10");                        \
     register unsigned long r11_ asm("r11");                        \
-    asm volatile (ALTERNATIVE("call *%c[addr](%%rip)", "call .",   \
+    altcall_asm ( ALTERNATIVE("call *%c[addr](%%rip)", "call .",   \
                               X86_FEATURE_ALWAYS)                  \
                   : ALT_CALL ## n ## _OUT, "=a" (ret_),            \
                     "=r" (r10_), "=r" (r11_) ASM_CALL_CONSTRAINT   \



 


Rackspace

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