Re: [PATCH 2/5] Memcgroup: Add timer to trigger workqueue

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat 19-01-19 22:30:18, Xiongchun Duan wrote:
> Add timer to trigger workqueue which will scan offline memcgroup and call trigger
> memcgroup force_empty worker to force_empty itself.

This requires much more explanation but it looks like a complete hack to
me. Why do we need a timer at all? Why is the hardcoded timeout a
generic enough?

> Signed-off-by: Xiongchun Duan <duanxiongchun@xxxxxxxxxxxxx>
> ---
>  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

-- 
Michal Hocko
SUSE Labs



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [Monitors]

  Powered by Linux