Received: by 10.213.65.68 with SMTP id h4csp1910511imn; Mon, 19 Mar 2018 17:17:37 -0700 (PDT) X-Google-Smtp-Source: AG47ELutJrjpbKu/IMz/LtZUN92LI+uzjGAnC5eFH7W+VxQOyRAWjB03Vo5kKDDNEP6eEUVmBw4C X-Received: by 2002:a17:902:20e6:: with SMTP id v35-v6mr14352439plg.226.1521505057640; Mon, 19 Mar 2018 17:17:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521505057; cv=none; d=google.com; s=arc-20160816; b=l5s/n5AKASnE1CgOXsyOxUm9X5KiFCSBmjosHpqVLKH0Jc5vlXFWS8vnwUz4XVPy+M uEAYk5zBvxh6XLH6KI9DzDygxscpJTOZmqeEiv40mwr4y7AHCuiClffw9fXR5nJKmgSg GKzEaelKE5UnPYXiY+20+BXh79j5i2rO5AT/I7dCxnhTprRPqfbBh1aol92nCFLyL9n0 lYbFdXgax6PKsI5KFx9PHIZRJxmIor6vLWPpSlJx5z1QZHe+WaQATZ/oa8pE5eaIUbaq 94FzgCVKlHfpbgnsXcyFj5egaHUpzmx5KvsJpYpbD/VFksv75GPKPK9SuR4QRpKt56tR Da+Q== 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=00hVlNXFMIiuvNZxzSHHf9n4hfJDmKRqabqtUXhAKcQ=; b=iUWnSQ+9KquAIRPDOTtBUHg5B6WqAUxkBYZxzo9iJwM481aLpqk/doak8d+YVZJN19 hd/tFKy2Mh6BdZzjV4kuktj1x0WpJiiWsfiPye/aQhJgASy9sD3F0RoYmmqtOIhWXNxh pkh+DTDQP1t/1vSkHttkGmrXiGXh8l/HZPF5dKggoedaxYjAWn1qAeIKo5QRzQ+4lute y6EDFkHfBtrn8wBbikeEAJoOf4APWzFGG923g2MfrMR5aRdjxNTOcqdMO2LgA4SBNc52 G2vtJDNQyQdzTskP7dxVNpLAo5WQu/V+Gnrbydzw0gB8CxlbyOkBo10kZH64smjcVAac OuWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=CQY7u07c; 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 w188si277664pgb.739.2018.03.19.17.17.23; Mon, 19 Mar 2018 17:17:37 -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=CQY7u07c; 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 S968267AbeCSRwF (ORCPT + 99 others); Mon, 19 Mar 2018 13:52:05 -0400 Received: from mail-pg0-f51.google.com ([74.125.83.51]:41744 "EHLO mail-pg0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965837AbeCSRv7 (ORCPT ); Mon, 19 Mar 2018 13:51:59 -0400 Received: by mail-pg0-f51.google.com with SMTP id m24so1517106pgv.8 for ; Mon, 19 Mar 2018 10:51:59 -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=00hVlNXFMIiuvNZxzSHHf9n4hfJDmKRqabqtUXhAKcQ=; b=CQY7u07coNzYrPcm0ylwcJhn/fxIlSuFeMMpaxiyVUBkw9D8+xFbgLqamTjfpvL8hD qnbd9wmMOOA4vyZRBQDUHdSbBsZQze7n/BFIpxnXwDlhvwa2UjrtmyErsmNB3XUmv4b/ vHUpSzaksf1C/pwg4f5X+Szt2RXPlq/Ga4yg9HmE6oogBdJXEQiHKIsAW6ywOZql/+7Z AN6jzrpGe/nD7VLzcnRBdDw0ZeFJYYlikjMLZmJdNjwetJeAd2zU+QPRWdkZsoi03xgt kIgxC+8sOlpRPYIBNpC77joGPhXM/Q7J1fNC7EIOHgVxyvEMjF3qAEixgn6gKGAWkBGV iuwg== 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=00hVlNXFMIiuvNZxzSHHf9n4hfJDmKRqabqtUXhAKcQ=; b=tFics+rsZULuKkTCC4J0hSUObK5eyf51KxewTcOADIfAlEfmCimjj9ZdLkWlqgWKE4 qomlpdeRnmlrxlx8RQR8Hq9FFDZSRq60E2wWrKn5NH0ImcIZqKjrZL6RVNeNR+uwZDiG 576XJEU85rM+OXB9HjhBMYJJ8wc1c2bv5gnX9BCdh5oG+fNcPDrER/Uwwxv3aCKy1Lg6 aChMP+15itUPXKgopqrQ0tQlNyJBGYyBvW2GftdPZKsV5YEXGq9zO6/5QQDFLZ8xigx3 zKpyOMeF1+V5RsFiDdzvsopfR3sX7AHJfokK24ba91nlwEVfcgo8PD9KysET6NUYgXYH gcJg== X-Gm-Message-State: AElRT7EduHV6eRKWL5eOrmnhGM7xoQqGVEHo/2m9SG+ld2p391OPyVm7 H75PP5Gr/1tykYavBNmQzmP9RQ== X-Received: by 10.98.51.129 with SMTP id z123mr11013395pfz.132.1521481918803; Mon, 19 Mar 2018 10:51:58 -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 z79sm1057990pfa.139.2018.03.19.10.51.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Mar 2018 10:51:58 -0700 (PDT) Date: Mon, 19 Mar 2018 10:51:57 -0700 (PDT) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: "Li,Rongqing" cc: Michal Hocko , "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" , "cgroups@vger.kernel.org" , "hannes@cmpxchg.org" , Andrey Ryabinin 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: <2AD939572F25A448A3AE3CAEA61328C2374589DC@BC-MAIL-M28.internal.baidu.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> 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 Mon, 19 Mar 2018, Li,Rongqing wrote: > > > Although SWAP_CLUSTER_MAX is used at the lower level, but the call > > > stack of try_to_free_mem_cgroup_pages is too long, increase the > > > nr_to_reclaim can reduce times of calling > > > function[do_try_to_free_pages, shrink_zones, hrink_node ] > > > > > > mem_cgroup_resize_limit > > > --->try_to_free_mem_cgroup_pages: .nr_to_reclaim = max(1024, > > > --->SWAP_CLUSTER_MAX), > > > ---> do_try_to_free_pages > > > ---> shrink_zones > > > --->shrink_node > > > ---> shrink_node_memcg > > > ---> shrink_list <-------loop will happen in this place > > [times=1024/32] > > > ---> shrink_page_list > > > > Can you actually measure this to be the culprit. Because we should rethink > > our call path if it is too complicated/deep to perform well. > > Adding arbitrary batch sizes doesn't sound like a good way to go to me. > > Ok, I will try > Looping in mem_cgroup_resize_limit(), which takes memcg_limit_mutex on every iteration which contends with lowering limits in other cgroups (on our systems, thousands), calling try_to_free_mem_cgroup_pages() with less than SWAP_CLUSTER_MAX is lame. It would probably be best to limit the nr_pages to the amount that needs to be reclaimed, though, rather than over reclaiming. 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.