From: Xiongchun Duan <duanxiongchun@bytedance.com>
To: cgroups@vger.kernel.org, linux-mm@kvack.org
Cc: shy828301@gmail.com, mhocko@kernel.org, tj@kernel.org,
hannes@cmpxchg.org, zhangyongsu@bytedance.com,
liuxiaozhou@bytedance.com, zhengfeiran@bytedance.com,
wangdongdong.6@bytedance.com,
Xiongchun Duan <duanxiongchun@bytedance.com>
Subject: [PATCH 2/5] Memcgroup: Add timer to trigger workqueue
Date: Sat, 19 Jan 2019 22:30:18 -0500 [thread overview]
Message-ID: <1547955021-11520-3-git-send-email-duanxiongchun@bytedance.com> (raw)
In-Reply-To: <1547955021-11520-1-git-send-email-duanxiongchun@bytedance.com>
Add timer to trigger workqueue which will scan offline memcgroup and call trigger
memcgroup force_empty worker to force_empty itself.
Signed-off-by: Xiongchun Duan <duanxiongchun@bytedance.com>
---
include/linux/memcontrol.h | 1 +
mm/memcontrol.c | 23 +++++++++++++++++++++++
2 files changed, 24 insertions(+)
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index d6fbb77..0a29f7f 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -313,6 +313,7 @@ struct mem_cgroup {
int max_retry;
int current_retry;
+ unsigned long timer_jiffies;
struct mem_cgroup_per_node *nodeinfo[0];
/* WARNING: nodeinfo must be the last member here */
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 2b13c2b..4db08b7 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -81,6 +81,8 @@
int sysctl_cgroup_default_retry_min;
int sysctl_cgroup_default_retry_max = 16;
+struct timer_list empty_trigger;
+
struct mem_cgroup *root_mem_cgroup __read_mostly;
#define MEM_CGROUP_RECLAIM_RETRIES 5
@@ -2933,6 +2935,11 @@ static ssize_t mem_cgroup_force_empty_write(struct kernfs_open_file *of,
return mem_cgroup_force_empty(memcg) ?: nbytes;
}
+static void add_force_empty_list(struct mem_cgroup *memcg)
+{
+
+}
+
static u64 mem_cgroup_hierarchy_read(struct cgroup_subsys_state *css,
struct cftype *cft)
{
@@ -4566,11 +4573,26 @@ static int mem_cgroup_css_online(struct cgroup_subsys_state *css)
return 0;
}
+void empty_timer_trigger(struct timer_list *t)
+{
+
+}
+
static void mem_cgroup_css_offline(struct cgroup_subsys_state *css)
{
struct mem_cgroup *memcg = mem_cgroup_from_css(css);
struct mem_cgroup_event *event, *tmp;
+ if (memcg->max_retry != 0) {
+ memcg->current_retry = 1;
+ mem_cgroup_force_empty(memcg);
+ if (page_counter_read(&memcg->memory) &&
+ memcg->max_retry != 1) {
+ memcg->timer_jiffies = jiffies + HZ;
+ add_force_empty_list(memcg);
+ }
+ }
+
/*
* Unregister events and notify userspace.
* Notify userspace about cgroup removing only after rmdir of cgroup
@@ -6368,6 +6390,7 @@ static int __init mem_cgroup_init(void)
memcg_kmem_cache_wq = alloc_workqueue("memcg_kmem_cache", 0, 1);
BUG_ON(!memcg_kmem_cache_wq);
#endif
+ timer_setup(&empty_trigger, empty_timer_trigger, 0);
cpuhp_setup_state_nocalls(CPUHP_MM_MEMCQ_DEAD, "mm/memctrl:dead", NULL,
memcg_hotplug_cpu_dead);
--
1.8.3.1
next prev parent reply other threads:[~2019-01-20 3:30 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-20 3:30 [PATCH 0/5] fix offline memcgroup still hold in memory Xiongchun Duan
2019-01-20 3:30 ` [PATCH 1/5] Memcgroup: force empty after memcgroup offline Xiongchun Duan
2019-01-21 18:52 ` kbuild test robot
2019-01-21 18:52 ` kbuild test robot
2019-01-21 19:09 ` kbuild test robot
2019-01-21 19:09 ` kbuild test robot
2019-01-20 3:30 ` Xiongchun Duan [this message]
2019-01-20 18:05 ` [PATCH 2/5] Memcgroup: Add timer to trigger workqueue Michal Hocko
2019-01-20 3:30 ` [PATCH 3/5] Memcgroup:add a global work Xiongchun Duan
2019-01-21 18:38 ` kbuild test robot
2019-01-21 18:38 ` kbuild test robot
2019-01-21 22:35 ` kbuild test robot
2019-01-21 22:35 ` kbuild test robot
2019-01-20 3:30 ` [PATCH 4/5] Memcgroup:Implement force empty work function Xiongchun Duan
2019-01-20 3:30 ` [PATCH 5/5] Memcgroup:add cgroup fs to show offline memcgroup status Xiongchun Duan
2019-01-20 18:12 ` [PATCH 0/5] fix offline memcgroup still hold in memory Michal Hocko
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=1547955021-11520-3-git-send-email-duanxiongchun@bytedance.com \
--to=duanxiongchun@bytedance.com \
--cc=cgroups@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=linux-mm@kvack.org \
--cc=liuxiaozhou@bytedance.com \
--cc=mhocko@kernel.org \
--cc=shy828301@gmail.com \
--cc=tj@kernel.org \
--cc=wangdongdong.6@bytedance.com \
--cc=zhangyongsu@bytedance.com \
--cc=zhengfeiran@bytedance.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