Commit 6caa6a07 authored by Johannes Weiner's avatar Johannes Weiner Committed by Linus Torvalds

mm: memcontrol: move out cgroup swaprate throttling

The cgroup swaprate throttling is about matching new anon allocations to
the rate of available IO when that is being throttled.  It's the io
controller hooking into the VM, rather than a memory controller thing.

Rename mem_cgroup_throttle_swaprate() to cgroup_throttle_swaprate(), and
drop the @memcg argument which is only used to check whether the preceding
page charge has succeeded and the fault is proceeding.

We could decouple the call from mem_cgroup_try_charge() here as well, but
that would cause unnecessary churn: the following patches convert all
callsites to a new charge API and we'll decouple as we go along.
Signed-off-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Reviewed-by: default avatarAlex Shi <alex.shi@linux.alibaba.com>
Reviewed-by: default avatarJoonsoo Kim <iamjoonsoo.kim@lge.com>
Reviewed-by: default avatarShakeel Butt <shakeelb@google.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: "Kirill A. Shutemov" <kirill@shutemov.name>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Roman Gushchin <guro@fb.com>
Cc: Balbir Singh <bsingharora@gmail.com>
Link: http://lkml.kernel.org/r/20200508183105.225460-5-hannes@cmpxchg.orgSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 14235ab3
...@@ -651,11 +651,9 @@ static inline int mem_cgroup_swappiness(struct mem_cgroup *mem) ...@@ -651,11 +651,9 @@ static inline int mem_cgroup_swappiness(struct mem_cgroup *mem)
#endif #endif
#if defined(CONFIG_SWAP) && defined(CONFIG_MEMCG) && defined(CONFIG_BLK_CGROUP) #if defined(CONFIG_SWAP) && defined(CONFIG_MEMCG) && defined(CONFIG_BLK_CGROUP)
extern void mem_cgroup_throttle_swaprate(struct mem_cgroup *memcg, int node, extern void cgroup_throttle_swaprate(struct page *page, gfp_t gfp_mask);
gfp_t gfp_mask);
#else #else
static inline void mem_cgroup_throttle_swaprate(struct mem_cgroup *memcg, static inline void cgroup_throttle_swaprate(struct page *page, gfp_t gfp_mask)
int node, gfp_t gfp_mask)
{ {
} }
#endif #endif
......
...@@ -6553,12 +6553,11 @@ int mem_cgroup_try_charge(struct page *page, struct mm_struct *mm, ...@@ -6553,12 +6553,11 @@ int mem_cgroup_try_charge(struct page *page, struct mm_struct *mm,
int mem_cgroup_try_charge_delay(struct page *page, struct mm_struct *mm, int mem_cgroup_try_charge_delay(struct page *page, struct mm_struct *mm,
gfp_t gfp_mask, struct mem_cgroup **memcgp) gfp_t gfp_mask, struct mem_cgroup **memcgp)
{ {
struct mem_cgroup *memcg;
int ret; int ret;
ret = mem_cgroup_try_charge(page, mm, gfp_mask, memcgp); ret = mem_cgroup_try_charge(page, mm, gfp_mask, memcgp);
memcg = *memcgp; if (*memcgp)
mem_cgroup_throttle_swaprate(memcg, page_to_nid(page), gfp_mask); cgroup_throttle_swaprate(page, gfp_mask);
return ret; return ret;
} }
......
...@@ -3798,11 +3798,12 @@ static void free_swap_count_continuations(struct swap_info_struct *si) ...@@ -3798,11 +3798,12 @@ static void free_swap_count_continuations(struct swap_info_struct *si)
} }
#if defined(CONFIG_MEMCG) && defined(CONFIG_BLK_CGROUP) #if defined(CONFIG_MEMCG) && defined(CONFIG_BLK_CGROUP)
void mem_cgroup_throttle_swaprate(struct mem_cgroup *memcg, int node, void cgroup_throttle_swaprate(struct page *page, gfp_t gfp_mask)
gfp_t gfp_mask)
{ {
struct swap_info_struct *si, *next; struct swap_info_struct *si, *next;
if (!(gfp_mask & __GFP_IO) || !memcg) int nid = page_to_nid(page);
if (!(gfp_mask & __GFP_IO))
return; return;
if (!blk_cgroup_congested()) if (!blk_cgroup_congested())
...@@ -3816,11 +3817,10 @@ void mem_cgroup_throttle_swaprate(struct mem_cgroup *memcg, int node, ...@@ -3816,11 +3817,10 @@ void mem_cgroup_throttle_swaprate(struct mem_cgroup *memcg, int node,
return; return;
spin_lock(&swap_avail_lock); spin_lock(&swap_avail_lock);
plist_for_each_entry_safe(si, next, &swap_avail_heads[node], plist_for_each_entry_safe(si, next, &swap_avail_heads[nid],
avail_lists[node]) { avail_lists[nid]) {
if (si->bdev) { if (si->bdev) {
blkcg_schedule_throttle(bdev_get_queue(si->bdev), blkcg_schedule_throttle(bdev_get_queue(si->bdev), true);
true);
break; break;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment