From: Yafang Shao <laoar.shao@gmail.com>
To: akpm@linux-foundation.org, ktkhai@virtuozzo.com, mhocko@suse.com,
hannes@cmpxchg.org, vdavydov.dev@gmail.com,
mgorman@techsingularity.net
Cc: linux-mm@kvack.org, Yafang Shao <laoar.shao@gmail.com>
Subject: [PATCH 1/2] mm/vmscan: add a new member reclaim_state in struct shrink_control
Date: Fri, 21 Jun 2019 18:14:45 +0800 [thread overview]
Message-ID: <1561112086-6169-2-git-send-email-laoar.shao@gmail.com> (raw)
In-Reply-To: <1561112086-6169-1-git-send-email-laoar.shao@gmail.com>
The struct reclaim_state is used to record how many slab caches are
reclaimed in one reclaim path.
The struct shrink_control is used to control one reclaim path.
So we'd better put reclaim_state into shrink_control.
Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
---
mm/vmscan.c | 20 ++++++++------------
1 file changed, 8 insertions(+), 12 deletions(-)
diff --git a/mm/vmscan.c b/mm/vmscan.c
index b79f584..18a66e5 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -131,6 +131,9 @@ struct scan_control {
unsigned int file_taken;
unsigned int taken;
} nr;
+
+ /* for recording the reclaimed slab by now */
+ struct reclaim_state reclaim_state;
};
#ifdef ARCH_HAS_PREFETCH
@@ -3461,6 +3464,7 @@ static int balance_pgdat(pg_data_t *pgdat, int order, int classzone_idx)
.may_unmap = 1,
};
+ current->reclaim_state = &sc.reclaim_state;
psi_memstall_enter(&pflags);
__fs_reclaim_acquire();
@@ -3642,6 +3646,8 @@ static int balance_pgdat(pg_data_t *pgdat, int order, int classzone_idx)
snapshot_refaults(NULL, pgdat);
__fs_reclaim_release();
psi_memstall_leave(&pflags);
+ current->reclaim_state = NULL;
+
/*
* Return the order kswapd stopped reclaiming at as
* prepare_kswapd_sleep() takes it into account. If another caller
@@ -3766,15 +3772,10 @@ static int kswapd(void *p)
unsigned int classzone_idx = MAX_NR_ZONES - 1;
pg_data_t *pgdat = (pg_data_t*)p;
struct task_struct *tsk = current;
-
- struct reclaim_state reclaim_state = {
- .reclaimed_slab = 0,
- };
const struct cpumask *cpumask = cpumask_of_node(pgdat->node_id);
if (!cpumask_empty(cpumask))
set_cpus_allowed_ptr(tsk, cpumask);
- current->reclaim_state = &reclaim_state;
/*
* Tell the memory management that we're a "memory allocator",
@@ -3836,7 +3837,6 @@ static int kswapd(void *p)
}
tsk->flags &= ~(PF_MEMALLOC | PF_SWAPWRITE | PF_KSWAPD);
- current->reclaim_state = NULL;
return 0;
}
@@ -3897,7 +3897,6 @@ void wakeup_kswapd(struct zone *zone, gfp_t gfp_flags, int order,
*/
unsigned long shrink_all_memory(unsigned long nr_to_reclaim)
{
- struct reclaim_state reclaim_state;
struct scan_control sc = {
.nr_to_reclaim = nr_to_reclaim,
.gfp_mask = GFP_HIGHUSER_MOVABLE,
@@ -3915,8 +3914,7 @@ unsigned long shrink_all_memory(unsigned long nr_to_reclaim)
fs_reclaim_acquire(sc.gfp_mask);
noreclaim_flag = memalloc_noreclaim_save();
- reclaim_state.reclaimed_slab = 0;
- p->reclaim_state = &reclaim_state;
+ p->reclaim_state = &sc.reclaim_state;
nr_reclaimed = do_try_to_free_pages(zonelist, &sc);
@@ -4085,7 +4083,6 @@ static int __node_reclaim(struct pglist_data *pgdat, gfp_t gfp_mask, unsigned in
/* Minimum pages needed in order to stay on node */
const unsigned long nr_pages = 1 << order;
struct task_struct *p = current;
- struct reclaim_state reclaim_state;
unsigned int noreclaim_flag;
struct scan_control sc = {
.nr_to_reclaim = max(nr_pages, SWAP_CLUSTER_MAX),
@@ -4110,8 +4107,7 @@ static int __node_reclaim(struct pglist_data *pgdat, gfp_t gfp_mask, unsigned in
*/
noreclaim_flag = memalloc_noreclaim_save();
p->flags |= PF_SWAPWRITE;
- reclaim_state.reclaimed_slab = 0;
- p->reclaim_state = &reclaim_state;
+ p->reclaim_state = &sc.reclaim_state;
if (node_pagecache_reclaimable(pgdat) > pgdat->min_unmapped_pages) {
/*
--
1.8.3.1
next prev parent reply other threads:[~2019-06-21 10:15 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-21 10:14 [PATCH 0/2] mm/vmscan: calculate reclaimed slab in all reclaim paths Yafang Shao
2019-06-21 10:14 ` Yafang Shao [this message]
2019-06-21 10:14 ` [PATCH 2/2] mm/vmscan: calculate reclaimed slab caches " Yafang Shao
2019-06-22 3:30 ` Andrew Morton
2019-06-22 6:31 ` Yafang Shao
2019-06-24 8:53 ` Kirill Tkhai
2019-06-24 12:30 ` Yafang Shao
2019-06-24 12:33 ` Kirill Tkhai
2019-06-24 12:40 ` Yafang Shao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1561112086-6169-2-git-send-email-laoar.shao@gmail.com \
--to=laoar.shao@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=hannes@cmpxchg.org \
--cc=ktkhai@virtuozzo.com \
--cc=linux-mm@kvack.org \
--cc=mgorman@techsingularity.net \
--cc=mhocko@suse.com \
--cc=vdavydov.dev@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).