From 8d682654937359cfbd42cefa3ea80592311f5578 Mon Sep 17 00:00:00 2001 From: Sasha Levin Date: Wed, 3 Jun 2020 10:29:19 -0400 Subject: [PATCH] Fixes for 5.6 Signed-off-by: Sasha Levin --- ...d-memory-barriers-to-plug-cgroup_rst.patch | 74 +++++++++++++++++++ queue-5.6/series | 2 + ...ert-x86-syscalls-make-__x32_syscall_.patch | 73 ++++++++++++++++++ 3 files changed, 149 insertions(+) create mode 100644 queue-5.6/revert-cgroup-add-memory-barriers-to-plug-cgroup_rst.patch create mode 100644 queue-5.6/series create mode 100644 queue-5.6/x86-syscalls-revert-x86-syscalls-make-__x32_syscall_.patch diff --git a/queue-5.6/revert-cgroup-add-memory-barriers-to-plug-cgroup_rst.patch b/queue-5.6/revert-cgroup-add-memory-barriers-to-plug-cgroup_rst.patch new file mode 100644 index 00000000000..fd663ca423c --- /dev/null +++ b/queue-5.6/revert-cgroup-add-memory-barriers-to-plug-cgroup_rst.patch @@ -0,0 +1,74 @@ +From a8636ccb2d8bddbeec7264904f57cfa3325f4cb9 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 9 Apr 2020 14:55:35 -0400 +Subject: Revert "cgroup: Add memory barriers to plug cgroup_rstat_updated() + race window" + +From: Tejun Heo + +[ Upstream commit d8ef4b38cb69d907f9b0e889c44d05fc0f890977 ] + +This reverts commit 9a9e97b2f1f2 ("cgroup: Add memory barriers to plug +cgroup_rstat_updated() race window"). + +The commit was added in anticipation of memcg rstat conversion which needed +synchronous accounting for the event counters (e.g. oom kill count). However, +the conversion didn't get merged due to percpu memory overhead concern which +couldn't be addressed at the time. + +Unfortunately, the patch's addition of smp_mb() to cgroup_rstat_updated() +meant that every scheduling event now had to go through an additional full +barrier and Mel Gorman noticed it as 1% regression in netperf UDP_STREAM test. + +There's no need to have this barrier in tree now and even if we need +synchronous accounting in the future, the right thing to do is separating that +out to a separate function so that hot paths which don't care about +synchronous behavior don't have to pay the overhead of the full barrier. Let's +revert. + +Signed-off-by: Tejun Heo +Reported-by: Mel Gorman +Link: http://lkml.kernel.org/r/20200409154413.GK3818@techsingularity.net +Cc: v4.18+ +Signed-off-by: Sasha Levin +--- + kernel/cgroup/rstat.c | 16 +++------------- + 1 file changed, 3 insertions(+), 13 deletions(-) + +diff --git a/kernel/cgroup/rstat.c b/kernel/cgroup/rstat.c +index 6f87352f8219..41ca996568df 100644 +--- a/kernel/cgroup/rstat.c ++++ b/kernel/cgroup/rstat.c +@@ -33,12 +33,9 @@ void cgroup_rstat_updated(struct cgroup *cgrp, int cpu) + return; + + /* +- * Paired with the one in cgroup_rstat_cpu_pop_updated(). Either we +- * see NULL updated_next or they see our updated stat. +- */ +- smp_mb(); +- +- /* ++ * Speculative already-on-list test. This may race leading to ++ * temporary inaccuracies, which is fine. ++ * + * Because @parent's updated_children is terminated with @parent + * instead of NULL, we can tell whether @cgrp is on the list by + * testing the next pointer for NULL. +@@ -134,13 +131,6 @@ static struct cgroup *cgroup_rstat_cpu_pop_updated(struct cgroup *pos, + *nextp = rstatc->updated_next; + rstatc->updated_next = NULL; + +- /* +- * Paired with the one in cgroup_rstat_cpu_updated(). +- * Either they see NULL updated_next or we see their +- * updated stat. +- */ +- smp_mb(); +- + return pos; + } + +-- +2.25.1 + diff --git a/queue-5.6/series b/queue-5.6/series new file mode 100644 index 00000000000..297415a264a --- /dev/null +++ b/queue-5.6/series @@ -0,0 +1,2 @@ +x86-syscalls-revert-x86-syscalls-make-__x32_syscall_.patch +revert-cgroup-add-memory-barriers-to-plug-cgroup_rst.patch diff --git a/queue-5.6/x86-syscalls-revert-x86-syscalls-make-__x32_syscall_.patch b/queue-5.6/x86-syscalls-revert-x86-syscalls-make-__x32_syscall_.patch new file mode 100644 index 00000000000..fd4d8d43a0d --- /dev/null +++ b/queue-5.6/x86-syscalls-revert-x86-syscalls-make-__x32_syscall_.patch @@ -0,0 +1,73 @@ +From 07cbf6e3c11529a4dd316945b7c552627479721c Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 8 May 2020 17:25:32 -0700 +Subject: x86/syscalls: Revert "x86/syscalls: Make __X32_SYSCALL_BIT be + unsigned long" + +From: Andy Lutomirski + +[ Upstream commit 700d3a5a664df267f01ec8887fd2d8ff98f67e7f ] + +Revert + + 45e29d119e99 ("x86/syscalls: Make __X32_SYSCALL_BIT be unsigned long") + +and add a comment to discourage someone else from making the same +mistake again. + +It turns out that some user code fails to compile if __X32_SYSCALL_BIT +is unsigned long. See, for example [1] below. + + [ bp: Massage and do the same thing in the respective tools/ header. ] + +Fixes: 45e29d119e99 ("x86/syscalls: Make __X32_SYSCALL_BIT be unsigned long") +Reported-by: Thorsten Glaser +Signed-off-by: Andy Lutomirski +Signed-off-by: Borislav Petkov +Cc: stable@kernel.org +Link: [1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=954294 +Link: https://lkml.kernel.org/r/92e55442b744a5951fdc9cfee10badd0a5f7f828.1588983892.git.luto@kernel.org +Signed-off-by: Sasha Levin +--- + arch/x86/include/uapi/asm/unistd.h | 11 +++++++++-- + tools/arch/x86/include/uapi/asm/unistd.h | 2 +- + 2 files changed, 10 insertions(+), 3 deletions(-) + +diff --git a/arch/x86/include/uapi/asm/unistd.h b/arch/x86/include/uapi/asm/unistd.h +index 196fdd02b8b1..be5e2e747f50 100644 +--- a/arch/x86/include/uapi/asm/unistd.h ++++ b/arch/x86/include/uapi/asm/unistd.h +@@ -2,8 +2,15 @@ + #ifndef _UAPI_ASM_X86_UNISTD_H + #define _UAPI_ASM_X86_UNISTD_H + +-/* x32 syscall flag bit */ +-#define __X32_SYSCALL_BIT 0x40000000UL ++/* ++ * x32 syscall flag bit. Some user programs expect syscall NR macros ++ * and __X32_SYSCALL_BIT to have type int, even though syscall numbers ++ * are, for practical purposes, unsigned long. ++ * ++ * Fortunately, expressions like (nr & ~__X32_SYSCALL_BIT) do the right ++ * thing regardless. ++ */ ++#define __X32_SYSCALL_BIT 0x40000000 + + #ifndef __KERNEL__ + # ifdef __i386__ +diff --git a/tools/arch/x86/include/uapi/asm/unistd.h b/tools/arch/x86/include/uapi/asm/unistd.h +index 196fdd02b8b1..30d7d04d72d6 100644 +--- a/tools/arch/x86/include/uapi/asm/unistd.h ++++ b/tools/arch/x86/include/uapi/asm/unistd.h +@@ -3,7 +3,7 @@ + #define _UAPI_ASM_X86_UNISTD_H + + /* x32 syscall flag bit */ +-#define __X32_SYSCALL_BIT 0x40000000UL ++#define __X32_SYSCALL_BIT 0x40000000 + + #ifndef __KERNEL__ + # ifdef __i386__ +-- +2.25.1 + -- 2.47.3