Updated performance patch series - resend
[email protected]
maintainerHi all, apologies if some of you will get this twice. Some of the arguments to git send-email were wrong the first time so some of the messages bounced.
I have removed the "use glibc strings" patch leaving only xor (needed for crypto and filesystems), futex (anything multi-threaded) and the cpu flags transfer from host which is a pre-requisite.
Rationale: prior to the glibc 2.33 which is at least one-two releases away (next debian will be using 2.31-9), the "hardware optimized support" in the host glibc is not fully complete. It has various issues in covering corner cases, etc. As a result the tests are not fully reproducible and the performance gain is not worth it except some of the newer Intel CPUs.
It works and there will be clear benefit when various bits and pieces catch up. We can deal with it then as it will be much easier to demonstrate.
While at it, there is no point to implement "alternatives" as used in the kernel at least on newer AMD processors. I applied them to the various key functions in string.h by hand (by commenting/uncommenting code) and tested the various combinations.
There is practically no difference.
_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um
[email protected]
maintainerPATCH v7 1/3 um: Add support for host CPU flags and alignment
From: Anton Ivanov <[email protected]>
1. Reflect host cpu flags into the UML instance so they can be used to select the correct implementations for xor, crypto, etc.
2. Reflect host cache alignment into UML instance. This is important when running 32 bit on a 64 bit host as 32 bit by default aligns to 32 while the actual alignment should be 64. Ditto for some Xeons which align at 128.
--- arch/um/Kconfig | 3 + arch/um/include/asm/cpufeature.h | 157 ++++++++++++++++++++++++ arch/um/include/asm/processor-generic.h | 8 ++ arch/um/include/shared/os.h | 3 + arch/um/kernel/Makefile | 13 +- arch/um/kernel/um_arch.c | 48 +++++++- arch/um/os-Linux/start_up.c | 32 +++++ 7 files changed, 258 insertions(+), 6 deletions(-) create mode 100644 arch/um/include/asm/cpufeature.h
arch/um/Kconfig +3 -0
@@ -60,6 +60,9 @@ config NR_CPUS range 1 1 default 1 +config ARCH_HAS_CACHE_LINE_SIZE + def_bool y + source "arch/$(HEADER_ARCH)/um/Kconfig" config MAY_HAVE_RUNTIME_DEPS
arch/um/include/asm/cpufeature.h new file +157 -0
157 lines not on this page · raw message
arch/um/include/asm/processor-generic.h +8 -0
@@ -16,6 +16,8 @@ struct task_struct;#include <linux/prefetch.h> +#include <asm/cpufeatures.h> +struct mm_struct ;struct thread_struct {
@@ -90,12 +92,18 @@ extern void start_thread(struct pt_regs *regs, unsigned long entry,struct cpuinfo_um {unsigned long loops_per_jiffy;int ipi_pipe[2 ]; +int cache_alignment; +union { +__u32 x86_capability[NCAPINTS +NBUGINTS ]; +unsigned long x86_capability_alignment; + }; };extern struct cpuinfo_um boot_cpu_data;#define cpu_data (&boot_cpu_data)#define current_cpu_data boot_cpu_data +#define cache_line_size () (boot_cpu_data.cache_alignment)#define KSTK_REG (tsk, reg) get_thread_reg(reg, &tsk->thread.switch_buf)extern unsigned long get_wchan (struct task_struct *p);
arch/um/include/shared/os.h +3 -0
@@ -187,6 +187,9 @@ int os_poll(unsigned int n, const int *fds);extern void os_early_checks (void );extern void os_check_bugs (void );extern void check_host_supports_tls (int *supports_tls,int *tls_min); +extern void get_host_cpu_features ( +void (*flags_helper_func)(char *line), +void (*cache_helper_func)(char *line));/* mem.c */ extern int create_mem_file (unsigned long long len);
arch/um/kernel/Makefile +11 -2
@@ -17,7 +17,7 @@ extra-y := vmlinux.lds obj-y = config.o exec.o exitcode.o irq.o ksyms.o mem.o \ physmem.o process.o ptrace.o reboot.o sigio.o \ signal.o syscall.o sysrq.o time.o tlb.o trap.o \ - um_arch.o umid.o maccess.o kmsg_dump.o skas/ + um_arch.o umid.o maccess.o kmsg_dump.o capflags.o skas/ obj-$(CONFIG_BLK_DEV_INITRD) += initrd.o obj-$(CONFIG_GPROF) += gprof_syms.o
@@ -29,7 +29,7 @@ USER_OBJS := config.o include arch/um/scripts/Makefile.rules -targets := config.c config.tmp +targets := config.c config.tmp capflags.c # Be careful with the below Sed code - sed is pitfall-rich! # We use sed to lower build requirements, for "embedded" builders for instance.
@@ -44,6 +44,15 @@ quiet_cmd_quote1 = QUOTE $@ $(obj)/config.c: $(src)/config.c.in $(obj)/config.tmp FORCE $(call if_changed,quote2) +quiet_cmd_mkcapflags = MKCAP $@ + cmd_mkcapflags = $(CONFIG_SHELL) $(srctree)/$(src)/../../x86/kernel/cpu/mkcapflags.sh $@ $^ + +cpufeature = $(src)/../../x86/include/asm/cpufeatures.h +vmxfeature = $(src)/../../x86/include/asm/vmxfeatures.h + +$(obj)/capflags.c: $(cpufeature) $(vmxfeature) $(src)/../../x86/kernel/cpu/mkcapflags.sh FORCE + $(call if_changed,mkcapflags) + quiet_cmd_quote2 = QUOTE $@ cmd_quote2 = sed -e '/CONFIG/{' \ -e 's/"CONFIG"//' \
arch/um/kernel/um_arch.c +44 -4
94 lines not on this page · raw message
arch/um/os-Linux/start_up.c +32 -0
@@ -321,6 +321,38 @@ static void __init check_coredump_limit(void)os_info ("%llu\n" , (unsigned long long )lim.rlim_max); } +void __init get_host_cpu_features ( +void (*flags_helper_func)(char *line), +void (*cache_helper_func)(char *line)) +{ +FILE *cpuinfo; +char *line =NULL ; +size_t len =0 ; +int done_parsing =0 ; + + cpuinfo =fopen ("/proc/cpuinfo" ,"r" ); +if (cpuinfo ==NULL ) { +os_info ("Failed to get host CPU features\n" ); + }else { +while ((getline (&line, &len, cpuinfo)) !=-1 ) { +if (strstr (line,"flags" )) { +flags_helper_func (line); + done_parsing++; + } +if (strstr (line,"cache_alignment" )) { +cache_helper_func (line); + done_parsing++; + } +free (line); + line =NULL ; +if (done_parsing >1 ) +break ; + } +fclose (cpuinfo); + } +} + +void __init os_early_checks (void ) {int pid;
Signature · 7 lines
2.20.1 _______________________________________________ linux-um mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-um
[email protected]
maintainerPATCH v7 2/3 um: enable the use of optimized xor routines in UML
In reply to [email protected]From: Anton Ivanov <[email protected]>
This patch enables the use of optimized xor routines from the x86 tree as well as the necessary fpu api shims so they can work on UML.
--- arch/um/include/asm/fpu/api.h | 20 ++++++++++++++++++++ arch/um/include/asm/xor.h | 17 ++++++++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 arch/um/include/asm/fpu/api.h
arch/um/include/asm/fpu/api.h new file +20 -0
@@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +#ifndef _ASM_UM_FPU_API_H +#define _ASM_UM_FPU_API_H + +/* Copyright (c) 2020 Cambridge Greys Ltd +* Copyright (c) 2020 Red Hat Inc. +* A set of "dummy" defines to allow the direct inclusion +* of x86 optimized copy, xor, etc routines into the +* UML code tree. */ + +#define kernel_fpu_begin () (void)0 +#define kernel_fpu_end () (void)0 + +static inline bool irq_fpu_usable (void ) +{ +return true; +} + + +#endif
arch/um/include/asm/xor.h +16 -1
@@ -1,7 +1,22 @@/* SPDX-License-Identifier: GPL-2.0 */ -#include <asm-generic/xor.h> +#ifndef _ASM_UM_XOR_H +#define _ASM_UM_XOR_H + +#ifdef CONFIG_64BIT +#undef CONFIG_X86_32 +#else +#define CONFIG_X86_32 1 +#endif + +#include <asm/cpufeature.h> +#include <../../x86/include/asm/xor.h> #include <linux/time-internal.h> +#ifdef CONFIG_UML_TIME_TRAVEL_SUPPORT +#undef XOR_SELECT_TEMPLATE/* pick an arbitrary one - measuring isn't possible with inf-cpu */ #define XOR_SELECT_TEMPLATE (x) \ (time_travel_mode == TT_MODE_INFCPU ? &xor_block_8regs : NULL) +#endif + +#endif
Signature · 7 lines
2.20.1 _______________________________________________ linux-um mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-um
[email protected]
maintainerPATCH v7 3/3 um: add a UML specific futex implementation
In reply to [email protected]From: Anton Ivanov <[email protected]>
The generic asm futex implementation emulates atomic access to memory by doing a get_user followed by put_user. These translate to two mapping operations on UML with paging enabled in the meantime. This, in turn may end up changing interrupts, invoking the signal loop, etc.
This replaces the generic implementation by a mapping followed by an operation on the mapped segment.
--- arch/um/include/asm/Kbuild | 1 - arch/um/include/asm/futex.h | 14 ++++ arch/um/kernel/skas/uaccess.c | 136 ++++++++++++++++++++++++++++++++++ 3 files changed, 150 insertions(+), 1 deletion(-) create mode 100644 arch/um/include/asm/futex.h
arch/um/include/asm/Kbuild +0 -1
@@ -8,7 +8,6 @@ generic-y += emergency-restart.h generic-y += exec.h generic-y += extable.h generic-y += ftrace.h -generic-y += futex.h generic-y += hw_irq.h generic-y += irq_regs.h generic-y += irq_work.h
arch/um/include/asm/futex.h new file +14 -0
@@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_UM_FUTEX_H +#define _ASM_UM_FUTEX_H + +#include <linux/futex.h> +#include <linux/uaccess.h> +#include <asm/errno.h> + + +int arch_futex_atomic_op_inuser (int op,u32 oparg,int *oval,u32 __user *uaddr); +int futex_atomic_cmpxchg_inatomic (u32 *uval,u32 __user *uaddr, +u32 oldval,u32 newval); + +#endif
arch/um/kernel/skas/uaccess.c +136 -0
145 lines not on this page · raw message
Signature · 7 lines
2.20.1 _______________________________________________ linux-um mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-um