Re: [PATCH][V2] mm: memcontrol: fix the margin computation in mem_cgroup_margin

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

 



On Tue 24-05-16 13:37:46, roy.qing.li@xxxxxxxxx wrote:
> From: Li RongQing <roy.qing.li@xxxxxxxxx>
> 
> The margin may be set to the difference value between memory limit and
> memory count firstly. which maybe returned wrongly if memsw.count excess
> memsw.limit, because try_charge forces charging __GFP_NOFAIL allocations,
> which may result in memsw.limit excess. If we are below memory.limit
> and there's nothing to reclaim to reduce memsw.usage, might end up
> looping in try_charge forever.

This is quite hard for me to grasp. What would you say about the
following:
"
mem_cgroup_margin might return memory.limit - memory_count when
the memsw.limit is in excess. This
doesn't happen usually because we do not allow excess on hard limits and
memory.limit <= memsw.limit but __GFP_NOFAIL charges can force the charge
and cause the excess when no memory is really swapable (swap is full or
no anonymous memory is left).
"

> 
> Signed-off-by: Li RongQing <roy.qing.li@xxxxxxxxx>
> Acked-by: Vladimir Davydov <vdavydov@xxxxxxxxxxxxx>
> Cc: Michal Hocko <mhocko@xxxxxxxx>

Acked-by: Michal Hocko <mhocko@xxxxxxxx>

> ---
>  mm/memcontrol.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 00981d2..12aaadd 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -1090,6 +1090,8 @@ static unsigned long mem_cgroup_margin(struct mem_cgroup *memcg)
>  		limit = READ_ONCE(memcg->memsw.limit);
>  		if (count <= limit)
>  			margin = min(margin, limit - count);
> +		else
> +			margin = 0;
>  	}
>  
>  	return margin;
> -- 
> 2.1.4

-- 
Michal Hocko
SUSE Labs
--
To unsubscribe from this list: send the line "unsubscribe cgroups" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[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