Received: by 10.213.65.68 with SMTP id h4csp773549imn; Tue, 20 Mar 2018 15:11:08 -0700 (PDT) X-Google-Smtp-Source: AG47ELvlUaAGZZZsQFM7Kgew+aeu8zUUwhr0RbvZyQn+EFhSMv6TtlybERKPx7rh3WeChE+uHjGy X-Received: by 2002:a17:902:8f8c:: with SMTP id z12-v6mr8659865plo.400.1521583868003; Tue, 20 Mar 2018 15:11:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521583867; cv=none; d=google.com; s=arc-20160816; b=KWv1sppoA2cGLvcD4+9CU4oVgjajJ0jnzVBBss1DKmq/D8nTg06YzB1DXanMeo2I52 nxMEMwOun2juNk5PLL8GRt9PEk2trlt1QJZnNt4wi+0P+C5kYzGt9CpP7mtjHu+3sqbv gHnzxBlfpBPNWgu5AYhB9G9RStmUdsizvQzaGMQ+38qp8DIUlvvZuGVqz7PY4VR4Oz/f C9fbiUm8dVB4A53PtCZvB8rBokLtNRCvLCNcDnxOB7BJuFLpc6JWv84ki1CC0TD+ic7R bEvSu43+KWL8sOPDujxILC2o7OY0axkuWop3cJjn43wIadnz+HxJqdhb4pMpigM4HWAk PiVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature:arc-authentication-results; bh=MpvNwWwagnePeXMpWrVY8sMBCtPzlsn34NnYhjp1eCk=; b=K845r2KQ5G/IERgCEinajGyJ/gqi25h73goeDsGCisBsr1yWL0lSHJqnaL6U9KujXW moj+BvvW/l8lKkG9zfIFLw0KxWrY7EJQp31JBlch3QYW5d6SIE5YsDhuzDKrfolhLJDq dMQ22j7gPvN6+/bNoYGRKT58GGnP/gj30wsSkv7Wlw3O4zewROPCzU3bgFt90EEp3E/G AiGMJ4W24V6/9lg4k46HK3CAxncQqeJA+3wF8wcXIr0O2NfQ44Dq/P2uFgtgFHxO8HQG icMtwgD8VDZHyI4KPyKZ6SBEFp1Eots7eLeltNJNO+1ehSMOeDs+e2D6+L/DJ8Ubz3we h/PQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=selector1 header.b=bTGe/0at; 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=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a71si1659085pfc.178.2018.03.20.15.10.52; Tue, 20 Mar 2018 15:11:07 -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=@virtuozzo.com header.s=selector1 header.b=bTGe/0at; 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=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751729AbeCTWIs (ORCPT + 99 others); Tue, 20 Mar 2018 18:08:48 -0400 Received: from mail-eopbgr50134.outbound.protection.outlook.com ([40.107.5.134]:59566 "EHLO EUR03-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751372AbeCTWIn (ORCPT ); Tue, 20 Mar 2018 18:08:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=MpvNwWwagnePeXMpWrVY8sMBCtPzlsn34NnYhjp1eCk=; b=bTGe/0atQGXTWo2Cy+jyJiEcs9YXe8ODFZin/fOdqVvjNKFOX3LPOTuIkvMqhEwU3B01Hn77hTuzJrOyCgfz8FD+Awuf8uW4WuJcV6RrNyPhWv0Mm4DwLFq6NYt9VmFv620xHRjTEXWo5CSmLjX0WHp15YcY5LHD1Z05X3UsQDY= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=aryabinin@virtuozzo.com; Received: from [10.52.82.105] (84.47.128.244) by DB7PR08MB3258.eurprd08.prod.outlook.com (2603:10a6:5:1f::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.588.14; Tue, 20 Mar 2018 22:08:39 +0000 Subject: =?UTF-8?B?UmU6IOetlOWkjTog562U5aSNOiBbUEFUQ0hdIG1tL21lbWNvbnRyb2wu?= =?UTF-8?Q?c:_speed_up_to_force_empty_a_memory_cgroup?= To: David Rientjes , Michal Hocko Cc: "Li,Rongqing" , "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" , "cgroups@vger.kernel.org" , "hannes@cmpxchg.org" 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> From: Andrey Ryabinin Message-ID: <56508bd0-e8d7-55fd-5109-c8dacf26b13e@virtuozzo.com> Date: Wed, 21 Mar 2018 01:08:02 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [84.47.128.244] X-ClientProxiedBy: VI1PR08CA0211.eurprd08.prod.outlook.com (2603:10a6:802:15::20) To DB7PR08MB3258.eurprd08.prod.outlook.com (2603:10a6:5:1f::20) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4e38c6cc-16c1-4cd3-2a6d-08d58eaf2352 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020);SRVR:DB7PR08MB3258; X-Microsoft-Exchange-Diagnostics: 1;DB7PR08MB3258;3:1Py/3GHWKpHL36uL1NbhRH/qx2sVkyJ2sKmBFIPOe9pewf+4aJ/IarIU/7uyRn0fRMteBUU4J76fSbSJQHxT8LL66I6gzJ7kSGiDP9Mx0nX8VijpKAAS4Xws0Y/DwOWnKtoixQP0zR0mZ4MLKO/oUYOqPYg8895JUNwfr7W+xQ4u+R7AwfCbBrjm6e589GGLgrOVsIULlq7z+Np+RDoLom0Ip9F6H1oJT3rPXqrKBP2XLGfAu4vGZsEwlYlDWwhX;25:cqvdTA214cc5sPTt3JOrrMJ/R0FHaAAnNxtN0aXjxxNQsKjydwKLgdFLBbH31GV6tidiYmR+ODTZEZCPM85A1MRn7pgREUZXejUlJSC2mDImInsw9rp8fcs0crPYsXfgi7n3kNrMdBJ0EEEDPUG2ZjBpymOm4EO4K7mHiUXAESAJGbQtF/gQpsbuUL2pkTGCtCO0fecK+p63A8zqI/e9DIF0II/nfZCmFAtNMttwhczhenaLLRoQtfwPsWMBgPkhw6xwzDIZ94tAEAGITARUuTn2r0b9iZ5UnyjEn3khYlFn3qtp9g9qCymotojA+1xzPbFUcwjCpT37pUuDzN883w==;31:y1WbeLJV/ew+2fQcaC+eIw6Mr5z0nejTQz8WRyZqx7TQIPHUu52ZMwCBieeSds7bpc8P1ceEU38knFE7UA7CNJf0dpk0MqzmIGfXDwk2/MvCOkcvs+sRJo94TOoRJb8yocpV8sY5WW9OwCKVSpGE0vAM+qyrVE26n433WuuKHoeBbQY0Y2bvwPXmOJ/7mM5e+6h1NC2xxWJbXF20MLvebqrpNQ3w85xUTELppMwKwjw= X-MS-TrafficTypeDiagnostic: DB7PR08MB3258: X-Microsoft-Exchange-Diagnostics: 1;DB7PR08MB3258;20:Uqu46cmnTiK98aQoQhUK0mhit+xkDNMOgfF1FmXhazuiyrxvd9kwuiuXwNJlk4qJ27bt2i3WTPg8QSqBUqvNy+Yps0B9FVeRA7GYSiubtCycKGljD/u5vLEXBW4zqjpr8kgriPnxUPGjK4U8n3uhYT/UIriygqP/1sn/zQBPOS9rxMRPix2YHUFNgvctYTbNrV8bQEjYlDHBRUWU5KSlGxbryol1EYU1eDA/swIWTEpbuiZ+HnK2ZWUZIoubJcGtfIbVqKP8plM4NLoJwkp/hzD9EW9rnTClsGR6IijFaBuF36heUP4WNQZk+OGcoIcgk4Mvjwwp6YJ9jynqwylKHTJ/J0HwIY1t9lSIPvgQ45TLmKThus1ZoE0MIdmwsGDGLH00ui6kfMrSQOAlkXMsvzh1uiI7iZuNh4PAsxzwTrm0yhnJ4PujYnVY+qmIhGI4Vwi+/w2se40/ToOImbkqtBr9ps9z1F16pF/Tq9lBigYdPLeL6SHoGABQ78cIeMwC;4:n/zQNsd8YkCUi9tOWyAjBo6A395JzX5HfjjIRPfNOhNQe/7w0qkjdsiR7MBaZ2RIVfJbSq6x31cy+4Febwct/7cg8bujkHPjNOA0yGd4/kgYkXiMWuBjbJVzBQBPVvSDR+05ZynS56xsw1DGHVLspDnAHthtQ8Oh0WW0pBFWmJ+lxKRIDrTy55X8pD5M/6rNbdUcfPfjLZH4XXjWjCu7dWWOWDjUK+Eb8pKW8+VF1kGMuYdgbTU53m5YHHZgtEo73qAfxMhnkhQ0QvS5rbM5IA== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040522)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(3002001)(3231221)(944501244)(52105095)(6041310)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(20161123562045)(6072148)(201708071742011);SRVR:DB7PR08MB3258;BCL:0;PCL:0;RULEID:;SRVR:DB7PR08MB3258; X-Forefront-PRVS: 061725F016 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(6049001)(346002)(366004)(376002)(39850400004)(396003)(39380400002)(189003)(199004)(86362001)(2950100002)(230700001)(36756003)(16526019)(316002)(186003)(26005)(77096007)(53936002)(6116002)(3846002)(229853002)(6486002)(6246003)(31696002)(54906003)(2906002)(6666003)(52116002)(52146003)(23676004)(16576012)(2486003)(58126008)(76176011)(47776003)(59450400001)(53546011)(7736002)(97736004)(65956001)(65806001)(66066001)(105586002)(8936002)(68736007)(65826007)(50466002)(81156014)(386003)(81166006)(5660300001)(106356001)(224303003)(110136005)(478600001)(93886005)(4326008)(305945005)(31686004)(25786009)(64126003);DIR:OUT;SFP:1102;SCL:1;SRVR:DB7PR08MB3258;H:[10.52.82.105];FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; Received-SPF: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtEQjdQUjA4TUIzMjU4OzIzOi9NNk5yZGRPZzRXSzBYVEhXQ3NDQjZsQ1I5?= =?utf-8?B?L01Ba1dnU2RGZms4eE4wWGRCZmNOM0xwRDJ1Q1pYbWdHb3g3MWZlTVpqM1FF?= =?utf-8?B?d1lwZkVtWDlBdTlBQmtreWlxVHdqY05OQkVzWmZ3RkQvSllaaDc3SGxKWCs3?= =?utf-8?B?TVFQeVUxeXhiaURBc0JGaWxKQzUwdjZ4Rmc0Vy9SU0NURlFUbDd3MUxFdVBw?= =?utf-8?B?SDdKWmJQdC8vWWVLTjVNczNkOUpTWms5L1N5MGw0N3MxekNLRHZyZkxPazdO?= =?utf-8?B?QUVhTi9GM2d1MDRSNGMyVjlid29CK3dFSGFtOEt4U1Z4eU5kNXF5Y1RkTnZr?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Awes4RxeHN9xxo/rGW6lAGYqjicPi1BYRvCRMFt119c/911o7V8LRpgmM0vypx7vFs0k= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Mar 2018 22:08:39.5332 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4e38c6cc-16c1-4cd3-2a6d-08d58eaf2352 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB3258 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/20/2018 11:29 PM, David Rientjes wrote: > On Tue, 20 Mar 2018, Michal Hocko 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. >> >> Well, if the global lock is a bottleneck in your deployments then we >> can come up with something more clever. E.g. per hierarchy locking >> or even drop the lock for the reclaim altogether. If we reclaim in >> SWAP_CLUSTER_MAX then the potential over-reclaim risk quite low when >> multiple users are shrinking the same (sub)hierarchy. >> > > I don't believe this to be a bottleneck if nr_pages is increased in > mem_cgroup_resize_limit(). > >>> 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),