|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH] xen/common: Drop function calls for Xen compile/version information
On Mon, 16 Jan 2017, Andrew Cooper wrote:
> The chageset/version/compile information is currently exported as a set of
> function calls into a separate translation unit, which is inefficient for all
> callers.
>
> Replace the function calls with externs pointing appropriately into .rodata,
> which allows all users to generate code referencing the data directly.
>
> No functional change, but causes smaller and more efficient compiled code.
>
> Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
Acked-by: Stefano Stabellini <sstabellini@xxxxxxxxxx>
> CC: Jan Beulich <JBeulich@xxxxxxxx>
> CC: Stefano Stabellini <sstabellini@xxxxxxxxxx>
> CC: Julien Grall <julien.grall@xxxxxxx>
>
> Restricted to $ARCH maintainers as this is a tree-wide change with no
> behavioural change.
> ---
> xen/arch/arm/traps.c | 2 +-
> xen/arch/x86/hvm/viridian.c | 2 +-
> xen/arch/x86/traps.c | 2 +-
> xen/arch/x86/x86_64/traps.c | 2 +-
> xen/common/hvm/save.c | 2 +-
> xen/common/kernel.c | 18 ++++++------
> xen/common/kexec.c | 14 ++++-----
> xen/common/version.c | 72
> ++++++++-------------------------------------
> xen/drivers/char/console.c | 10 +++----
> xen/include/xen/version.h | 25 ++++++++--------
> 10 files changed, 52 insertions(+), 97 deletions(-)
>
> diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c
> index 35d8e8b..5730452 100644
> --- a/xen/arch/arm/traps.c
> +++ b/xen/arch/arm/traps.c
> @@ -144,7 +144,7 @@ static void print_xen_info(void)
> char taint_str[TAINT_STRING_MAX_LEN];
>
> printk("----[ Xen-%d.%d%s %s debug=%c " gcov_string " %s ]----\n",
> - xen_major_version(), xen_minor_version(), xen_extra_version(),
> + xen_major_version, xen_minor_version, xen_extra_version,
> #ifdef CONFIG_ARM_32
> "arm32",
> #else
> diff --git a/xen/arch/x86/hvm/viridian.c b/xen/arch/x86/hvm/viridian.c
> index 37c8f68..aebf6c1 100644
> --- a/xen/arch/x86/hvm/viridian.c
> +++ b/xen/arch/x86/hvm/viridian.c
> @@ -95,7 +95,7 @@ void cpuid_viridian_leaves(const struct vcpu *v, uint32_t
> leaf,
> if ( d->arch.hvm_domain.viridian.guest_os_id.raw == 0 )
> break;
> res->a = 1; /* Build number */
> - res->b = (xen_major_version() << 16) | xen_minor_version();
> + res->b = (xen_major_version << 16) | xen_minor_version;
> res->c = 0; /* SP */
> res->d = 0; /* Service branch and number */
> break;
> diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c
> index 4f29c3a..5dfd31a 100644
> --- a/xen/arch/x86/traps.c
> +++ b/xen/arch/x86/traps.c
> @@ -931,7 +931,7 @@ void cpuid_hypervisor_leaves(const struct vcpu *v,
> uint32_t leaf,
> break;
>
> case 1:
> - res->a = (xen_major_version() << 16) | xen_minor_version();
> + res->a = (xen_major_version << 16) | xen_minor_version;
> break;
>
> case 2:
> diff --git a/xen/arch/x86/x86_64/traps.c b/xen/arch/x86/x86_64/traps.c
> index fc8cde6..b82872f 100644
> --- a/xen/arch/x86/x86_64/traps.c
> +++ b/xen/arch/x86/x86_64/traps.c
> @@ -32,7 +32,7 @@ static void print_xen_info(void)
> char taint_str[TAINT_STRING_MAX_LEN];
>
> printk("----[ Xen-%d.%d%s x86_64 debug=%c " gcov_string " %s ]----\n",
> - xen_major_version(), xen_minor_version(), xen_extra_version(),
> + xen_major_version, xen_minor_version, xen_extra_version,
> debug_build() ? 'y' : 'n', print_tainted(taint_str));
> }
>
> diff --git a/xen/common/hvm/save.c b/xen/common/hvm/save.c
> index dd2c547..245e852 100644
> --- a/xen/common/hvm/save.c
> +++ b/xen/common/hvm/save.c
> @@ -152,7 +152,7 @@ int hvm_save(struct domain *d, hvm_domain_context_t *h)
> hdr.version = HVM_FILE_VERSION;
>
> /* Save xen changeset */
> - c = strrchr(xen_changeset(), ':');
> + c = strrchr(xen_changeset, ':');
> if ( c )
> hdr.changeset = simple_strtoll(c, NULL, 16);
> else
> diff --git a/xen/common/kernel.c b/xen/common/kernel.c
> index d0edb13..8008e40 100644
> --- a/xen/common/kernel.c
> +++ b/xen/common/kernel.c
> @@ -233,14 +233,14 @@ DO(xen_version)(int cmd, XEN_GUEST_HANDLE_PARAM(void)
> arg)
> switch ( cmd )
> {
> case XENVER_version:
> - return (xen_major_version() << 16) | xen_minor_version();
> + return (xen_major_version << 16) | xen_minor_version;
>
> case XENVER_extraversion:
> {
> xen_extraversion_t extraversion;
>
> memset(extraversion, 0, sizeof(extraversion));
> - safe_strcpy(extraversion, deny ? xen_deny() : xen_extra_version());
> + safe_strcpy(extraversion, deny ? xen_deny : xen_extra_version);
> if ( copy_to_guest(arg, extraversion, ARRAY_SIZE(extraversion)) )
> return -EFAULT;
> return 0;
> @@ -251,10 +251,10 @@ DO(xen_version)(int cmd, XEN_GUEST_HANDLE_PARAM(void)
> arg)
> xen_compile_info_t info;
>
> memset(&info, 0, sizeof(info));
> - safe_strcpy(info.compiler, deny ? xen_deny() : xen_compiler());
> - safe_strcpy(info.compile_by, deny ? xen_deny() :
> xen_compile_by());
> - safe_strcpy(info.compile_domain, deny ? xen_deny() :
> xen_compile_domain());
> - safe_strcpy(info.compile_date, deny ? xen_deny() :
> xen_compile_date());
> + safe_strcpy(info.compiler, deny ? xen_deny : xen_compiler);
> + safe_strcpy(info.compile_by, deny ? xen_deny : xen_compile_by);
> + safe_strcpy(info.compile_domain, deny ? xen_deny :
> xen_compile_domain);
> + safe_strcpy(info.compile_date, deny ? xen_deny : xen_compile_date);
> if ( copy_to_guest(arg, &info, 1) )
> return -EFAULT;
> return 0;
> @@ -290,7 +290,7 @@ DO(xen_version)(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
> xen_changeset_info_t chgset;
>
> memset(chgset, 0, sizeof(chgset));
> - safe_strcpy(chgset, deny ? xen_deny() : xen_changeset());
> + safe_strcpy(chgset, deny ? xen_deny : xen_changeset);
> if ( copy_to_guest(arg, chgset, ARRAY_SIZE(chgset)) )
> return -EFAULT;
> return 0;
> @@ -371,9 +371,9 @@ DO(xen_version)(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
> size_t len = ARRAY_SIZE(saved_cmdline);
>
> if ( deny )
> - len = strlen(xen_deny()) + 1;
> + len = strlen(xen_deny) + 1;
>
> - if ( copy_to_guest(arg, deny ? xen_deny() : saved_cmdline, len) )
> + if ( copy_to_guest(arg, deny ? xen_deny : saved_cmdline, len) )
> return -EFAULT;
> return 0;
> }
> diff --git a/xen/common/kexec.c b/xen/common/kexec.c
> index c83d48f..8d9ef79 100644
> --- a/xen/common/kexec.c
> +++ b/xen/common/kexec.c
> @@ -311,13 +311,13 @@ crash_xen_info_t *kexec_crash_save_info(void)
> BUG_ON(!cpumask_test_and_set_cpu(cpu, &crash_saved_cpus));
>
> memset(&info, 0, sizeof(info));
> - info.xen_major_version = xen_major_version();
> - info.xen_minor_version = xen_minor_version();
> - info.xen_extra_version = __pa(xen_extra_version());
> - info.xen_changeset = __pa(xen_changeset());
> - info.xen_compiler = __pa(xen_compiler());
> - info.xen_compile_date = __pa(xen_compile_date());
> - info.xen_compile_time = __pa(xen_compile_time());
> + info.xen_major_version = xen_major_version;
> + info.xen_minor_version = xen_minor_version;
> + info.xen_extra_version = __pa(xen_extra_version);
> + info.xen_changeset = __pa(xen_changeset);
> + info.xen_compiler = __pa(xen_compiler);
> + info.xen_compile_date = __pa(xen_compile_date);
> + info.xen_compile_time = __pa(xen_compile_time);
> info.tainted = tainted;
>
> /* Copy from guaranteed-aligned local copy to possibly-unaligned dest. */
> diff --git a/xen/common/version.c b/xen/common/version.c
> index 223cb52..65b74c1 100644
> --- a/xen/common/version.c
> +++ b/xen/common/version.c
> @@ -10,65 +10,19 @@
>
> #include <asm/cache.h>
>
> -const char *xen_compile_date(void)
> -{
> - return XEN_COMPILE_DATE;
> -}
> -
> -const char *xen_compile_time(void)
> -{
> - return XEN_COMPILE_TIME;
> -}
> -
> -const char *xen_compile_by(void)
> -{
> - return XEN_COMPILE_BY;
> -}
> -
> -const char *xen_compile_domain(void)
> -{
> - return XEN_COMPILE_DOMAIN;
> -}
> -
> -const char *xen_compile_host(void)
> -{
> - return XEN_COMPILE_HOST;
> -}
> -
> -const char *xen_compiler(void)
> -{
> - return XEN_COMPILER;
> -}
> -
> -unsigned int xen_major_version(void)
> -{
> - return XEN_VERSION;
> -}
> -
> -unsigned int xen_minor_version(void)
> -{
> - return XEN_SUBVERSION;
> -}
> -
> -const char *xen_extra_version(void)
> -{
> - return XEN_EXTRAVERSION;
> -}
> -
> -const char *xen_changeset(void)
> -{
> - return XEN_CHANGESET;
> -}
> -
> -const char *xen_banner(void)
> -{
> - return XEN_BANNER;
> -}
> -
> -const char *xen_deny(void)
> -{
> - return "<denied>";
> -}
> +const unsigned int xen_major_version = XEN_VERSION;
> +const unsigned int xen_minor_version = XEN_SUBVERSION;
> +
> +const char xen_compile_date[] = XEN_COMPILE_DATE;
> +const char xen_compile_time[] = XEN_COMPILE_TIME;
> +const char xen_compile_by[] = XEN_COMPILE_BY;
> +const char xen_compile_domain[] = XEN_COMPILE_DOMAIN;
> +const char xen_compile_host[] = XEN_COMPILE_HOST;
> +const char xen_compiler[] = XEN_COMPILER;
> +const char xen_extra_version[] = XEN_EXTRAVERSION;
> +const char xen_changeset[] = XEN_CHANGESET;
> +const char xen_banner[] = XEN_BANNER;
> +const char xen_deny[] = "<denied>";
>
> static const void *build_id_p __read_mostly;
> static unsigned int build_id_len __read_mostly;
> diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c
> index eb21e7c..7324595 100644
> --- a/xen/drivers/char/console.c
> +++ b/xen/drivers/char/console.c
> @@ -777,13 +777,13 @@ void __init console_init_preirq(void)
>
> /* HELLO WORLD --- start-of-day banner text. */
> spin_lock(&console_lock);
> - __putstr(xen_banner());
> + __putstr(xen_banner);
> spin_unlock(&console_lock);
> printk("Xen version %d.%d%s (%s@%s) (%s) debug=%c " gcov_string " %s\n",
> - xen_major_version(), xen_minor_version(), xen_extra_version(),
> - xen_compile_by(), xen_compile_domain(),
> - xen_compiler(), debug_build() ? 'y' : 'n', xen_compile_date());
> - printk("Latest ChangeSet: %s\n", xen_changeset());
> + xen_major_version, xen_minor_version, xen_extra_version,
> + xen_compile_by, xen_compile_domain,
> + xen_compiler, debug_build() ? 'y' : 'n', xen_compile_date);
> + printk("Latest ChangeSet: %s\n", xen_changeset);
>
> if ( opt_sync_console )
> {
> diff --git a/xen/include/xen/version.h b/xen/include/xen/version.h
> index 97c247a..dba3803 100644
> --- a/xen/include/xen/version.h
> +++ b/xen/include/xen/version.h
> @@ -4,18 +4,19 @@
> #include <xen/types.h>
> #include <xen/elfstructs.h>
>
> -const char *xen_compile_date(void);
> -const char *xen_compile_time(void);
> -const char *xen_compile_by(void);
> -const char *xen_compile_domain(void);
> -const char *xen_compile_host(void);
> -const char *xen_compiler(void);
> -unsigned int xen_major_version(void);
> -unsigned int xen_minor_version(void);
> -const char *xen_extra_version(void);
> -const char *xen_changeset(void);
> -const char *xen_banner(void);
> -const char *xen_deny(void);
> +extern const unsigned int xen_major_version, xen_minor_version;
> +
> +extern const char xen_compile_date[];
> +extern const char xen_compile_time[];
> +extern const char xen_compile_by[];
> +extern const char xen_compile_domain[];
> +extern const char xen_compile_host[];
> +extern const char xen_compiler[];
> +extern const char xen_extra_version[];
> +extern const char xen_changeset[];
> +extern const char xen_banner[];
> +extern const char xen_deny[];
> +
> int xen_build_id(const void **p, unsigned int *len);
>
> #ifdef BUILD_ID
> --
> 2.1.4
>
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |