Received: by 10.213.65.68 with SMTP id h4csp776350imn; Tue, 20 Mar 2018 15:16:28 -0700 (PDT) X-Google-Smtp-Source: AG47ELtyMTJb699v6p4EJOPOSiVS50dlXdzM9VlgR+VXl/JrCPpbrqRoqq8+RBR8F+nRB2OYm7by X-Received: by 10.99.100.132 with SMTP id y126mr13001318pgb.77.1521584188256; Tue, 20 Mar 2018 15:16:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521584188; cv=none; d=google.com; s=arc-20160816; b=c9poZA5KHU95n89nOdjwdabSek/geiWle4EdrH0xFO+GyskeNE87pOF5Dorie/PNly o9DnKHu7jL/MHqzO4Vzv9bBiZubHsfm+aqgNePogBikyDf6vTFfz1IB2uTMIGz6UyXoV 0/wX/vYjcbpdqXQwbaFHQaWyBbFmRyyFJ0eXGilntc/jkBhBsKMLvxP6csNqgN58yKZI 7Sz0MZYbWQkXaZfW+B0NjVlmnfdJ5vjaL04LFCCT2xM7hg7zwwlNrC8EshbbZ3/qd1zb uXb4BLqV1Ki2ZxPrrDKFlSYnocOrV4hQm1f6TdmaCopS0DkzqK4enUB3gaprH4ourqGh HIGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=WM83ES9ChzxYq8wYgGkaY9KT5XiyfYxqLQARkZmKa/o=; b=UCcoB/SqhZRYBZEGLspUUEd5O9jE4PNr3fqru2KeEmB/HJHjvD1LDzJjk8oXsdix3S B0I0+Wxr/+RvmASNp6D19qtnk6GbU037/SZeKObk/apsy6EgaN52ohlARGnlDiVYb/Ab uqBB9Yr6Fq4fFDro+HO0+3x2TEwOVIJ4Ct5DyH2xgzrj7PxhkMMcTNJ/v1+RFZ2fernY R++5/OkbHDE4oXcpTZt4g9lhzfglaV7uOkR+fIe3m1ilcG/Wb9jpQZvTR+kqafIpIxwH Ov8R4VSoI6m1Q0dEMnyLaZ64DxLa/6WfyeIiJN5oZLE2SBwxeL5Xa40lCx51a9Cmz0vM NyXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=aQZ0qSJ2; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u137si1771850pgb.651.2018.03.20.15.16.13; Tue, 20 Mar 2018 15:16:28 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=aQZ0qSJ2; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751480AbeCTWPU (ORCPT + 99 others); Tue, 20 Mar 2018 18:15:20 -0400 Received: from mail-pg0-f54.google.com ([74.125.83.54]:41506 "EHLO mail-pg0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751334AbeCTWPQ (ORCPT ); Tue, 20 Mar 2018 18:15:16 -0400 Received: by mail-pg0-f54.google.com with SMTP id m24so1192061pgv.8 for ; Tue, 20 Mar 2018 15:15:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=WM83ES9ChzxYq8wYgGkaY9KT5XiyfYxqLQARkZmKa/o=; b=aQZ0qSJ2EtUgVeCTVBUS13XO0I1tI+cB3qQXizFznV15k7C63VMYn8vf+iYB+xyyw7 fpT5yJML97SLzgsYl/vURU2mMIe2e5JxHfRg2OxfAyCIJ7yAZYOx7K04e31XnK9ddwJX pGrxqyxG/I4Pf9crDuA4HRTV+F+pof35PIH5rg27ivbl6e4xp2Hn2MJYC3wLjBcdx8D1 jEl6pqOAklMAAhKMdpopxdie+hL6QEYM5IcZfdUaRxpH+fQAhW3lqZ2t7kx94O4RlRDn A7omvZ8nsyz93799CPUYlLNwJqO918DE7wX9fGDqoTmhRxEA/+VgkJbCgkXtU5vy4Mqn jKPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=WM83ES9ChzxYq8wYgGkaY9KT5XiyfYxqLQARkZmKa/o=; b=jSUxlTqVwCoGpcXaWbL3/NKCk4cdypf4a0rdYQtJqJjChcl++5TUo/tE0i1sOLouD6 fPrTBt5pROh048OYodLjdQ1AdcrFBtgQ2GCvcJ4sxpuhVKk9prhAgxguI88eWA9efGXG iSIboA0KoleA/5RCGq/WlGr+8CItAS08Sc4AkubG3hpsdLiin5EJAYJ9jWECy64aKIvm xG5xS0wEjSTS3i6dX7HzRlL36fWNJel08l7bu0cBFLTfGpT30xi9rH7zzV9R6KTzGoUR 6mz4qnxywZ9jh3qi5+6c+Rt0WmQRUaDiJ+mPfEUkmINkWFJ/kdEeb2R6umjG1J/6RqFO mAhA== X-Gm-Message-State: AElRT7GVXIdIsIsjIJo2exwaVgBou1GiZpQWqAUIqxeyWB/fu2gFuV5R MTBq+pTE3sdCfkl9Y0g6afbDpitZrGc= X-Received: by 10.98.36.25 with SMTP id r25mr15074535pfj.106.1521584115368; Tue, 20 Mar 2018 15:15:15 -0700 (PDT) Received: from [2620:15c:17:3:3a5:23a7:5e32:4598] ([2620:15c:17:3:3a5:23a7:5e32:4598]) by smtp.gmail.com with ESMTPSA id b64sm5709082pfl.148.2018.03.20.15.15.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Mar 2018 15:15:14 -0700 (PDT) Date: Tue, 20 Mar 2018 15:15:13 -0700 (PDT) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Andrey Ryabinin cc: Michal Hocko , "Li,Rongqing" , "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" , "cgroups@vger.kernel.org" , "hannes@cmpxchg.org" Subject: =?UTF-8?Q?Re=3A_=E7=AD=94=E5=A4=8D=3A_=E7=AD=94=E5=A4=8D=3A_=5BPATCH=5D_mm=2Fmemcontrol=2Ec=3A_speed_up_to_force_empty_a_memory_cgroup?= In-Reply-To: <56508bd0-e8d7-55fd-5109-c8dacf26b13e@virtuozzo.com> Message-ID: References: <1521448170-19482-1-git-send-email-lirongqing@baidu.com> <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> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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?