From mboxrd@z Thu Jan 1 00:00:00 1970 From: Glauber Costa Subject: Re: [PATCH v4 07/25] memcg: Reclaim when more than one page needed. Date: Mon, 25 Jun 2012 17:13:53 +0400 Message-ID: <4FE86411.5020708@parallels.com> References: <1340015298-14133-1-git-send-email-glommer@parallels.com> <1340015298-14133-8-git-send-email-glommer@parallels.com> <20120620134738.GG5541@tiehlicka.suse.cz> <4FE227F8.3000504@parallels.com> <20120621211923.GC31759@tiehlicka.suse.cz> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20120621211923.GC31759-VqjxzfR4DlwKmadIfiO5sKVXKuFTiq87@public.gmane.org> Sender: cgroups-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-ID: Content-Type: text/plain; charset="us-ascii"; format="flowed" To: Michal Hocko Cc: linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org, Pekka Enberg , Cristoph Lameter , David Rientjes , cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, devel-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org, kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Frederic Weisbecker , Suleiman Souhlal >>>> + >>>> ret = mem_cgroup_reclaim(mem_over_limit, gfp_mask, flags); >>>> if (mem_cgroup_margin(mem_over_limit) >= nr_pages) >>>> return CHARGE_RETRY; >>>> @@ -2234,8 +2235,10 @@ static int mem_cgroup_do_charge(struct mem_cgroup *memcg, gfp_t gfp_mask, >>>> * unlikely to succeed so close to the limit, and we fall back >>>> * to regular pages anyway in case of failure. >>>> */ >>>> - if (nr_pages == 1 && ret) >>>> + if (nr_pages <= (1 << PAGE_ALLOC_COSTLY_ORDER) && ret) { >>>> + cond_resched(); >>>> return CHARGE_RETRY; >>>> + } >>> >>> What prevents us from looping for unbounded amount of time here? >>> Maybe you need to consider the number of reclaimed pages here. >> >> Why would we even loop here? It will just return CHARGE_RETRY, it is >> up to the caller to decide whether or not it will retry. > > Yes, but the test was original to prevent oom when we managed to reclaim > something. And something might be enough for a single page but now you > have high order allocations so we can retry without any success. > So, Most of the kmem allocations are likely to be quite small as well. For the slab, we're dealing with the order of 2-3 pages, and for other allocations that may happen, like stack, they will be in the order of 2 pages as well. So one thing I could do here, is define a threshold, say, 3, and only retry for that very low threshold, instead of following COSTLY_ORDER. I don't expect two or three pages to be much less likely to be freed than a single page. I am fine with ripping of the cond_resched as well. Let me know if you would be okay with that. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx190.postini.com [74.125.245.190]) by kanga.kvack.org (Postfix) with SMTP id 690E96B033F for ; Mon, 25 Jun 2012 09:16:33 -0400 (EDT) Message-ID: <4FE86411.5020708@parallels.com> Date: Mon, 25 Jun 2012 17:13:53 +0400 From: Glauber Costa MIME-Version: 1.0 Subject: Re: [PATCH v4 07/25] memcg: Reclaim when more than one page needed. References: <1340015298-14133-1-git-send-email-glommer@parallels.com> <1340015298-14133-8-git-send-email-glommer@parallels.com> <20120620134738.GG5541@tiehlicka.suse.cz> <4FE227F8.3000504@parallels.com> <20120621211923.GC31759@tiehlicka.suse.cz> In-Reply-To: <20120621211923.GC31759@tiehlicka.suse.cz> Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Michal Hocko Cc: linux-mm@kvack.org, Pekka Enberg , Cristoph Lameter , David Rientjes , cgroups@vger.kernel.org, devel@openvz.org, kamezawa.hiroyu@jp.fujitsu.com, linux-kernel@vger.kernel.org, Frederic Weisbecker , Suleiman Souhlal >>>> + >>>> ret = mem_cgroup_reclaim(mem_over_limit, gfp_mask, flags); >>>> if (mem_cgroup_margin(mem_over_limit) >= nr_pages) >>>> return CHARGE_RETRY; >>>> @@ -2234,8 +2235,10 @@ static int mem_cgroup_do_charge(struct mem_cgroup *memcg, gfp_t gfp_mask, >>>> * unlikely to succeed so close to the limit, and we fall back >>>> * to regular pages anyway in case of failure. >>>> */ >>>> - if (nr_pages == 1 && ret) >>>> + if (nr_pages <= (1 << PAGE_ALLOC_COSTLY_ORDER) && ret) { >>>> + cond_resched(); >>>> return CHARGE_RETRY; >>>> + } >>> >>> What prevents us from looping for unbounded amount of time here? >>> Maybe you need to consider the number of reclaimed pages here. >> >> Why would we even loop here? It will just return CHARGE_RETRY, it is >> up to the caller to decide whether or not it will retry. > > Yes, but the test was original to prevent oom when we managed to reclaim > something. And something might be enough for a single page but now you > have high order allocations so we can retry without any success. > So, Most of the kmem allocations are likely to be quite small as well. For the slab, we're dealing with the order of 2-3 pages, and for other allocations that may happen, like stack, they will be in the order of 2 pages as well. So one thing I could do here, is define a threshold, say, 3, and only retry for that very low threshold, instead of following COSTLY_ORDER. I don't expect two or three pages to be much less likely to be freed than a single page. I am fine with ripping of the cond_resched as well. Let me know if you would be okay with that. -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756192Ab2FYNQc (ORCPT ); Mon, 25 Jun 2012 09:16:32 -0400 Received: from mx2.parallels.com ([64.131.90.16]:40150 "EHLO mx2.parallels.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752330Ab2FYNQb (ORCPT ); Mon, 25 Jun 2012 09:16:31 -0400 Message-ID: <4FE86411.5020708@parallels.com> Date: Mon, 25 Jun 2012 17:13:53 +0400 From: Glauber Costa User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120605 Thunderbird/13.0 MIME-Version: 1.0 To: Michal Hocko CC: , Pekka Enberg , Cristoph Lameter , David Rientjes , , , , , Frederic Weisbecker , Suleiman Souhlal Subject: Re: [PATCH v4 07/25] memcg: Reclaim when more than one page needed. References: <1340015298-14133-1-git-send-email-glommer@parallels.com> <1340015298-14133-8-git-send-email-glommer@parallels.com> <20120620134738.GG5541@tiehlicka.suse.cz> <4FE227F8.3000504@parallels.com> <20120621211923.GC31759@tiehlicka.suse.cz> In-Reply-To: <20120621211923.GC31759@tiehlicka.suse.cz> Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org >>>> + >>>> ret = mem_cgroup_reclaim(mem_over_limit, gfp_mask, flags); >>>> if (mem_cgroup_margin(mem_over_limit) >= nr_pages) >>>> return CHARGE_RETRY; >>>> @@ -2234,8 +2235,10 @@ static int mem_cgroup_do_charge(struct mem_cgroup *memcg, gfp_t gfp_mask, >>>> * unlikely to succeed so close to the limit, and we fall back >>>> * to regular pages anyway in case of failure. >>>> */ >>>> - if (nr_pages == 1 && ret) >>>> + if (nr_pages <= (1 << PAGE_ALLOC_COSTLY_ORDER) && ret) { >>>> + cond_resched(); >>>> return CHARGE_RETRY; >>>> + } >>> >>> What prevents us from looping for unbounded amount of time here? >>> Maybe you need to consider the number of reclaimed pages here. >> >> Why would we even loop here? It will just return CHARGE_RETRY, it is >> up to the caller to decide whether or not it will retry. > > Yes, but the test was original to prevent oom when we managed to reclaim > something. And something might be enough for a single page but now you > have high order allocations so we can retry without any success. > So, Most of the kmem allocations are likely to be quite small as well. For the slab, we're dealing with the order of 2-3 pages, and for other allocations that may happen, like stack, they will be in the order of 2 pages as well. So one thing I could do here, is define a threshold, say, 3, and only retry for that very low threshold, instead of following COSTLY_ORDER. I don't expect two or three pages to be much less likely to be freed than a single page. I am fine with ripping of the cond_resched as well. Let me know if you would be okay with that.