Received: by 10.213.65.68 with SMTP id h4csp1113651imn; Wed, 21 Mar 2018 03:01:40 -0700 (PDT) X-Google-Smtp-Source: AG47ELu9l9XH2jJ2xiob6KY/xhi2vL5kvmIaFjRrRySGWoM9JE0BHzw3H2Yu1sm2elLP+9rlLLs6 X-Received: by 2002:a17:902:bf03:: with SMTP id bi3-v6mr19975113plb.343.1521626500651; Wed, 21 Mar 2018 03:01:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521626500; cv=none; d=google.com; s=arc-20160816; b=m8lnnC4LrnmQtZdoBZgc8njVjzH6v5ZG8mT1dMWrZwi5j8QuLvXFvr8oVuvxQDEHDr 5akzBGdQxcQ4XLOUm/BADgCJdiwBMz5BavZrgFhaGFuy2YXwFFxVkCXOQfCPaWyuJtR3 c45+W8725wqtpEEXzFi1SOfelOY+SUqoLgaXozUJUb7rfB+KjxsehI8231Vf1d1oZ3f2 qDYczhuUqmCPZia/XLze8ZnBCV5/AFNAjEuSw5Gr7jKETn9VARQKm3U2peUuzF+O5baZ IF8dk+9YK693y/pCmAK58xDy+2BBXNgubnjQ4WJHS1gW6fBNHvG3UMucPwJkhiF1Myzq i2Qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=OUY4RI+mTdbAvh1l9iT8BXdXoHf43BsgMHBVoQyX/s0=; b=pl6GRPFd4g/T4qviF2vITkycKZjYwipKhlP2drWiofEfLDf/1dp2hnB9Pb2XPM9sRr HWjYJJp5u6t6YfjoGFJLKbTEqzWlV0SZahQeZVaCJ0DwvD0Zn/fSdIzHGC1gJ9mBS/BY 6NYSGvsEnzXNPEq4NGotV/hvPkq+Y/pMWxoe0NwnpbNk4yB/GDMbY7h/VbRVhDfKjlcf GuJowzIkcCQit3G1TDu5X2N5csQDtLY7aTOY/1/Qwo2oUoVddWhkG1PAl0dPqgd7dLCb 5sFrbyJcmYJEvsTmeYkkf/sIGa8IMjlF4O8V21X6aYN1BDl7qxYlyZ3Tm0KG7/nI3d1w P47A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v7-v6si3494642plp.538.2018.03.21.03.01.25; Wed, 21 Mar 2018 03:01:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751857AbeCUJ7R (ORCPT + 99 others); Wed, 21 Mar 2018 05:59:17 -0400 Received: from mx2.suse.de ([195.135.220.15]:56400 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751505AbeCUJ7Q (ORCPT ); Wed, 21 Mar 2018 05:59:16 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id A44F3AF36; Wed, 21 Mar 2018 09:59:14 +0000 (UTC) Date: Wed, 21 Mar 2018 10:59:13 +0100 From: Michal Hocko To: Andrey Ryabinin Cc: David Rientjes , "Li,Rongqing" , "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" , "cgroups@vger.kernel.org" , "hannes@cmpxchg.org" Subject: Re: =?utf-8?B?562U5aSNOiDnrZTlpI06IFtQQVRD?= =?utf-8?Q?H=5D?= mm/memcontrol.c: speed up to force empty a memory cgroup Message-ID: <20180321095913.GE23100@dhcp22.suse.cz> References: <20180319085355.GQ23100@dhcp22.suse.cz> <2AD939572F25A448A3AE3CAEA61328C23745764B@BC-MAIL-M28.internal.baidu.com> <20180319103756.GV23100@dhcp22.suse.cz> <2AD939572F25A448A3AE3CAEA61328C2374589DC@BC-MAIL-M28.internal.baidu.com> <20180320083950.GD23100@dhcp22.suse.cz> <56508bd0-e8d7-55fd-5109-c8dacf26b13e@virtuozzo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 21-03-18 01:35:05, Andrey Ryabinin wrote: > On 03/21/2018 01:15 AM, David Rientjes wrote: > > On Wed, 21 Mar 2018, Andrey Ryabinin wrote: > > > >>>>> It would probably be best to limit the > >>>>> nr_pages to the amount that needs to be reclaimed, though, rather than > >>>>> over reclaiming. > >>>> > >>>> How do you achieve that? The charging path is not synchornized with the > >>>> shrinking one at all. > >>>> > >>> > >>> The point is to get a better guess at how many pages, up to > >>> SWAP_CLUSTER_MAX, that need to be reclaimed instead of 1. > >>> > >>>>> If you wanted to be invasive, you could change page_counter_limit() to > >>>>> return the count - limit, fix up the callers that look for -EBUSY, and > >>>>> then use max(val, SWAP_CLUSTER_MAX) as your nr_pages. > >>>> > >>>> I am not sure I understand > >>>> > >>> > >>> Have page_counter_limit() return the number of pages over limit, i.e. > >>> count - limit, since it compares the two anyway. Fix up existing callers > >>> and then clamp that value to SWAP_CLUSTER_MAX in > >>> mem_cgroup_resize_limit(). It's a more accurate guess than either 1 or > >>> 1024. > >>> > >> > >> JFYI, it's never 1, it's always SWAP_CLUSTER_MAX. > >> See try_to_free_mem_cgroup_pages(): > >> .... > >> struct scan_control sc = { > >> .nr_to_reclaim = max(nr_pages, SWAP_CLUSTER_MAX), > >> > > > > Is SWAP_CLUSTER_MAX the best answer if I'm lowering the limit by 1GB? > > > > Absolutely not. I completely on your side here. > I've tried to fix this recently - http://lkml.kernel.org/r/20180119132544.19569-2-aryabinin@virtuozzo.com > I guess that Andrew decided to not take my patch, because Michal wasn't > happy about it (see mail archives if you want more details). I was unhappy about the explanation and justification of the patch. It is still not clear to me why try_to_free_mem_cgroup_pages with a single target should be slower than multiple calls of this function with smaller batches when the real reclaim is still SWAP_CLUSTER_MAX batched. There is also a theoretical risk of over reclaim. Especially with large targets. -- Michal Hocko SUSE Labs