--- /dev/null
+From a8636ccb2d8bddbeec7264904f57cfa3325f4cb9 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+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 <tj@kernel.org>
+
+[ 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 <tj@kernel.org>
+Reported-by: Mel Gorman <mgorman@techsingularity.net>
+Link: http://lkml.kernel.org/r/20200409154413.GK3818@techsingularity.net
+Cc: v4.18+
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ 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
+
--- /dev/null
+From 07cbf6e3c11529a4dd316945b7c552627479721c Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+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 <luto@kernel.org>
+
+[ 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 <t.glaser@tarent.de>
+Signed-off-by: Andy Lutomirski <luto@kernel.org>
+Signed-off-by: Borislav Petkov <bp@suse.de>
+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 <sashal@kernel.org>
+---
+ 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
+