-From foo@baz Sat Apr 3 10:50:40 AM CEST 2021
-From: Frank van der Linden <fllinden@amazon.com>
+From ff9e6d0148913f65e252eacb30cee895cc9f18e0 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
Date: Tue, 30 Mar 2021 18:19:08 +0000
-Subject: mem_cgroup: make sure moving_account, move_lock_task and stat_cpu in the same cacheline
-To: <stable@vger.kernel.org>
-Cc: <fllinden@amazon.com>
-Message-ID: <20210330181910.15378-4-fllinden@amazon.com>
-
-From: Frank van der Linden <fllinden@amazon.com>
+Subject: mem_cgroup: make sure moving_account, move_lock_task and stat_cpu in
+ the same cacheline
From: Aaron Lu <aaron.lu@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
---
- include/linux/memcontrol.h | 23 +++++++++++++++++++----
+ include/linux/memcontrol.h | 23 +++++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)
+diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
+index 6503a9ca27c1..c7876eadd206 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -155,6 +155,15 @@ enum memcg_kmem_state {
unsigned long socket_pressure;
+--
+2.30.2
+
-From foo@baz Sat Apr 3 10:50:40 AM CEST 2021
-From: Frank van der Linden <fllinden@amazon.com>
+From e1fd32798f5f59f098b06c2eb5cfeaa69714a6b4 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
Date: Tue, 30 Mar 2021 18:19:09 +0000
Subject: mm: fix oom_kill event handling
-To: <stable@vger.kernel.org>
-Cc: <fllinden@amazon.com>
-Message-ID: <20210330181910.15378-5-fllinden@amazon.com>
-
-From: Frank van der Linden <fllinden@amazon.com>
From: Roman Gushchin <guro@fb.com>
[fllinden@amazon.com: backport to 4.14, minor contextual changes]
Signed-off-by: Frank van der Linden <fllinden@amazon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
---
- include/linux/memcontrol.h | 26 ++++++++++++++++++++++----
- mm/memcontrol.c | 6 ++++--
- mm/oom_kill.c | 2 +-
+ include/linux/memcontrol.h | 26 ++++++++++++++++++++++----
+ mm/memcontrol.c | 6 ++++--
+ mm/oom_kill.c | 2 +-
3 files changed, 27 insertions(+), 7 deletions(-)
+diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
+index c7876eadd206..b5cd86e320ff 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -53,6 +53,7 @@ enum memcg_memory_event {
MEMCG_NR_MEMORY_EVENTS,
};
-@@ -706,11 +707,8 @@ static inline void count_memcg_event_mm(
+@@ -706,11 +707,8 @@ static inline void count_memcg_event_mm(struct mm_struct *mm,
rcu_read_lock();
memcg = mem_cgroup_from_task(rcu_dereference(mm->owner));
rcu_read_unlock();
}
-@@ -721,6 +719,21 @@ static inline void memcg_memory_event(st
+@@ -721,6 +719,21 @@ static inline void memcg_memory_event(struct mem_cgroup *memcg,
cgroup_file_notify(&memcg->events_file);
}
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
void mem_cgroup_split_huge_fixup(struct page *head);
#endif
-@@ -742,6 +755,11 @@ static inline void memcg_memory_event(st
+@@ -742,6 +755,11 @@ static inline void memcg_memory_event(struct mem_cgroup *memcg,
{
}
static inline bool mem_cgroup_low(struct mem_cgroup *root,
struct mem_cgroup *memcg)
{
+diff --git a/mm/memcontrol.c b/mm/memcontrol.c
+index 31972189a827..ef6d996a920a 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
-@@ -3648,7 +3648,8 @@ static int mem_cgroup_oom_control_read(s
+@@ -3648,7 +3648,8 @@ static int mem_cgroup_oom_control_read(struct seq_file *sf, void *v)
seq_printf(sf, "oom_kill_disable %d\n", memcg->oom_kill_disable);
seq_printf(sf, "under_oom %d\n", (bool)memcg->under_oom);
return 0;
}
-@@ -5320,7 +5321,8 @@ static int memory_events_show(struct seq
+@@ -5320,7 +5321,8 @@ static int memory_events_show(struct seq_file *m, void *v)
atomic_long_read(&memcg->memory_events[MEMCG_MAX]));
seq_printf(m, "oom %lu\n",
atomic_long_read(&memcg->memory_events[MEMCG_OOM]));
return 0;
}
+diff --git a/mm/oom_kill.c b/mm/oom_kill.c
+index 6482d743c5c8..6f1bed211122 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
-@@ -917,7 +917,7 @@ static void oom_kill_process(struct oom_
+@@ -917,7 +917,7 @@ static void oom_kill_process(struct oom_control *oc, const char *message)
/* Raise event before sending signal: task reaper must see this */
count_vm_event(OOM_KILL);
/*
* We should send SIGKILL before granting access to memory reserves
+--
+2.30.2
+
-From foo@baz Sat Apr 3 10:50:40 AM CEST 2021
-From: Frank van der Linden <fllinden@amazon.com>
+From 9fe735731d156fe2fc88d9bae1d8479b4021929c Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
Date: Tue, 30 Mar 2021 18:19:07 +0000
Subject: mm: memcg: make sure memory.events is uptodate when waking pollers
-To: <stable@vger.kernel.org>
-Cc: <fllinden@amazon.com>
-Message-ID: <20210330181910.15378-3-fllinden@amazon.com>
-
-From: Frank van der Linden <fllinden@amazon.com>
From: Johannes Weiner <hannes@cmpxchg.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
---
- include/linux/memcontrol.h | 35 ++++++++++++++++++-----------------
- mm/memcontrol.c | 28 ++++++++++++++++------------
- mm/vmscan.c | 2 +-
+ include/linux/memcontrol.h | 35 ++++++++++++++++++-----------------
+ mm/memcontrol.c | 28 ++++++++++++++++------------
+ mm/vmscan.c | 2 +-
3 files changed, 35 insertions(+), 30 deletions(-)
+diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
+index c46016bb25eb..6503a9ca27c1 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -48,13 +48,12 @@ enum memcg_stat_item {
unsigned long socket_pressure;
-@@ -645,9 +646,9 @@ unsigned long mem_cgroup_soft_limit_recl
+@@ -645,9 +646,9 @@ unsigned long mem_cgroup_soft_limit_reclaim(pg_data_t *pgdat, int order,
gfp_t gfp_mask,
unsigned long *total_scanned);
{
unsigned long x;
-@@ -663,7 +664,8 @@ static inline void __count_memcg_events(
+@@ -663,7 +664,8 @@ static inline void __count_memcg_events(struct mem_cgroup *memcg,
}
static inline void count_memcg_events(struct mem_cgroup *memcg,
{
unsigned long flags;
-@@ -672,9 +674,8 @@ static inline void count_memcg_events(st
+@@ -672,9 +674,8 @@ static inline void count_memcg_events(struct mem_cgroup *memcg,
local_irq_restore(flags);
}
{
if (page->mem_cgroup)
count_memcg_events(page->mem_cgroup, idx, 1);
-@@ -698,10 +699,10 @@ static inline void count_memcg_event_mm(
+@@ -698,10 +699,10 @@ static inline void count_memcg_event_mm(struct mm_struct *mm,
rcu_read_unlock();
}
cgroup_file_notify(&memcg->events_file);
}
-@@ -721,8 +722,8 @@ static inline bool mem_cgroup_disabled(v
+@@ -721,8 +722,8 @@ static inline bool mem_cgroup_disabled(void)
return true;
}
{
}
+diff --git a/mm/memcontrol.c b/mm/memcontrol.c
+index 4e763cdccb33..31972189a827 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
-@@ -1872,7 +1872,7 @@ static int memcg_hotplug_cpu_dead(unsign
+@@ -1872,7 +1872,7 @@ static int memcg_hotplug_cpu_dead(unsigned int cpu)
}
}
long x;
x = this_cpu_xchg(memcg->stat_cpu->events[i], 0);
-@@ -1891,7 +1891,7 @@ static void reclaim_high(struct mem_cgro
+@@ -1891,7 +1891,7 @@ static void reclaim_high(struct mem_cgroup *memcg,
do {
if (page_counter_read(&memcg->memory) <= memcg->high)
continue;
try_to_free_mem_cgroup_pages(memcg, nr_pages, gfp_mask, true);
} while ((memcg = parent_mem_cgroup(memcg)));
}
-@@ -1982,7 +1982,7 @@ retry:
+@@ -1982,7 +1982,7 @@ static int try_charge(struct mem_cgroup *memcg, gfp_t gfp_mask,
if (!gfpflags_allow_blocking(gfp_mask))
goto nomem;
nr_reclaimed = try_to_free_mem_cgroup_pages(mem_over_limit, nr_pages,
gfp_mask, may_swap);
-@@ -2025,7 +2025,7 @@ retry:
+@@ -2025,7 +2025,7 @@ static int try_charge(struct mem_cgroup *memcg, gfp_t gfp_mask,
if (fatal_signal_pending(current))
goto force;
mem_cgroup_oom(mem_over_limit, gfp_mask,
get_order(nr_pages * PAGE_SIZE));
-@@ -2790,10 +2790,10 @@ static void tree_events(struct mem_cgrou
+@@ -2790,10 +2790,10 @@ static void tree_events(struct mem_cgroup *memcg, unsigned long *events)
struct mem_cgroup *iter;
int i;
events[i] += memcg_sum_events(iter, i);
}
}
-@@ -5299,7 +5299,7 @@ static ssize_t memory_max_write(struct k
+@@ -5299,7 +5299,7 @@ static ssize_t memory_max_write(struct kernfs_open_file *of,
continue;
}
if (!mem_cgroup_out_of_memory(memcg, GFP_KERNEL, 0))
break;
}
-@@ -5312,10 +5312,14 @@ static int memory_events_show(struct seq
+@@ -5312,10 +5312,14 @@ static int memory_events_show(struct seq_file *m, void *v)
{
struct mem_cgroup *memcg = mem_cgroup_from_css(seq_css(m));
seq_printf(m, "oom_kill %lu\n", memcg_sum_events(memcg, OOM_KILL));
return 0;
-@@ -5325,7 +5329,7 @@ static int memory_stat_show(struct seq_f
+@@ -5325,7 +5329,7 @@ static int memory_stat_show(struct seq_file *m, void *v)
{
struct mem_cgroup *memcg = mem_cgroup_from_css(seq_css(m));
unsigned long stat[MEMCG_NR_STAT];
int i;
/*
+diff --git a/mm/vmscan.c b/mm/vmscan.c
+index 5ee6fbdec8a8..b37e6dd50925 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
-@@ -2628,7 +2628,7 @@ static bool shrink_node(pg_data_t *pgdat
+@@ -2628,7 +2628,7 @@ static bool shrink_node(pg_data_t *pgdat, struct scan_control *sc)
sc->memcg_low_skipped = 1;
continue;
}
}
reclaimed = sc->nr_reclaimed;
+--
+2.30.2
+
-From foo@baz Sat Apr 3 10:50:40 AM CEST 2021
-From: Frank van der Linden <fllinden@amazon.com>
+From cf8150077bcd64063c1e2eb9b36b1404fe732208 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
Date: Tue, 30 Mar 2021 18:19:06 +0000
Subject: mm: memcontrol: fix NR_WRITEBACK leak in memcg and system stats
-To: <stable@vger.kernel.org>
-Cc: <fllinden@amazon.com>
-Message-ID: <20210330181910.15378-2-fllinden@amazon.com>
-
-From: Frank van der Linden <fllinden@amazon.com>
From: Johannes Weiner <hannes@cmpxchg.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
---
- include/linux/memcontrol.h | 24 ++++++++++++++++--------
+ include/linux/memcontrol.h | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
+diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
+index 882046863581..c46016bb25eb 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
-@@ -523,9 +523,11 @@ static inline void __mod_memcg_state(str
+@@ -523,9 +523,11 @@ static inline void __mod_memcg_state(struct mem_cgroup *memcg,
static inline void mod_memcg_state(struct mem_cgroup *memcg,
int idx, int val)
{
}
/**
-@@ -606,9 +608,11 @@ static inline void __mod_lruvec_state(st
+@@ -606,9 +608,11 @@ static inline void __mod_lruvec_state(struct lruvec *lruvec,
static inline void mod_lruvec_state(struct lruvec *lruvec,
enum node_stat_item idx, int val)
{
}
static inline void __mod_lruvec_page_state(struct page *page,
-@@ -630,9 +634,11 @@ static inline void __mod_lruvec_page_sta
+@@ -630,9 +634,11 @@ static inline void __mod_lruvec_page_state(struct page *page,
static inline void mod_lruvec_page_state(struct page *page,
enum node_stat_item idx, int val)
{
}
unsigned long mem_cgroup_soft_limit_reclaim(pg_data_t *pgdat, int order,
-@@ -659,9 +665,11 @@ static inline void __count_memcg_events(
+@@ -659,9 +665,11 @@ static inline void __count_memcg_events(struct mem_cgroup *memcg,
static inline void count_memcg_events(struct mem_cgroup *memcg,
int idx, unsigned long count)
{
}
/* idx can be of type enum memcg_event_item or vm_event_item */
+--
+2.30.2
+
-From foo@baz Sat Apr 3 10:50:40 AM CEST 2021
-From: Frank van der Linden <fllinden@amazon.com>
+From 5f20039dc5262295bf7113b9822418bbee9b1dc2 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
Date: Tue, 30 Mar 2021 18:19:10 +0000
Subject: mm: writeback: use exact memcg dirty counts
-To: <stable@vger.kernel.org>
-Cc: <fllinden@amazon.com>
-Message-ID: <20210330181910.15378-6-fllinden@amazon.com>
-
-From: Frank van der Linden <fllinden@amazon.com>
From: Greg Thelen <gthelen@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
---
- include/linux/memcontrol.h | 5 ++++-
- mm/memcontrol.c | 20 ++++++++++++++++++--
+ include/linux/memcontrol.h | 5 ++++-
+ mm/memcontrol.c | 20 ++++++++++++++++++--
2 files changed, 22 insertions(+), 3 deletions(-)
+diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
+index b5cd86e320ff..365d5079d1cb 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
-@@ -507,7 +507,10 @@ struct mem_cgroup *lock_page_memcg(struc
+@@ -507,7 +507,10 @@ struct mem_cgroup *lock_page_memcg(struct page *page);
void __unlock_page_memcg(struct mem_cgroup *memcg);
void unlock_page_memcg(struct page *page);
static inline unsigned long memcg_page_state(struct mem_cgroup *memcg,
int idx)
{
+diff --git a/mm/memcontrol.c b/mm/memcontrol.c
+index ef6d996a920a..5e8b8e1b7d90 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
-@@ -3701,6 +3701,22 @@ struct wb_domain *mem_cgroup_wb_domain(s
+@@ -3701,6 +3701,22 @@ struct wb_domain *mem_cgroup_wb_domain(struct bdi_writeback *wb)
return &memcg->cgwb_domain;
}
/**
* mem_cgroup_wb_stats - retrieve writeback related stats from its memcg
* @wb: bdi_writeback in question
-@@ -3726,10 +3742,10 @@ void mem_cgroup_wb_stats(struct bdi_writ
+@@ -3726,10 +3742,10 @@ void mem_cgroup_wb_stats(struct bdi_writeback *wb, unsigned long *pfilepages,
struct mem_cgroup *memcg = mem_cgroup_from_css(wb->memcg_css);
struct mem_cgroup *parent;
*pfilepages = mem_cgroup_nr_lru_pages(memcg, (1 << LRU_INACTIVE_FILE) |
(1 << LRU_ACTIVE_FILE));
*pheadroom = PAGE_COUNTER_MAX;
+--
+2.30.2
+