Received: by 10.213.65.68 with SMTP id h4csp787827imn; Tue, 20 Mar 2018 15:38:01 -0700 (PDT) X-Google-Smtp-Source: AG47ELsTEhs5qT7N4JDh7r3y0TFFU/4FliX0TK8PwNe6ZapxVR1AG2JcEekWLLO/wLJoCTYTwGeE X-Received: by 10.101.82.12 with SMTP id o12mr13220614pgp.126.1521585481602; Tue, 20 Mar 2018 15:38:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521585481; cv=none; d=google.com; s=arc-20160816; b=AOD8uHoeyFKzWYzwDYB1Zh7p+Xy2FXvBW4YRK83wnc6pseUOW0beANtgBOh+CaXnks 5PyUt+sbua5oeOtoOjayVnczTlFonng1nFuo8XMYXlmsPYiEFoWkTZHKCqExVvmmhLWS CO85+dnyOI/ptVE9HBpq3KUYjAWcDcgGkzGd58qE0r2ooum7hLAzPr8wGH5WApcwVVMw 6bGpTyW4nRZj+8xsGNeC3cUPgt2dOtwacB+u8ywOvAA+x9ULUrjzjXCkKtV1asHecE4O OxtJ40WtgC7TbWJ9vtc6TUulnuKuJGKZvy5zd83hsYTDX/nPvd6ppcq31CxHs5owHRCj unvg== 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=gamGeXGyujYd0AOpLGqaHQ1E9FW0z4w9y7Nx2ygDzUY=; b=wOjkY8Cd8a7vBLRCkoJQHBDoxFDyuhgOU99zChinIx0j7O3bvJLNmVO+BX8n9QS+NF FVm0HDNde75oZVHU6m/qGOveFf0iH2H+nmIDGg8/YaPx8amHTbTlg4716fvjABBnZKyq 63qlBEv9zFEK0c05JXSn4rMBkzgL/b5dt2oO+rW4XpqWI5VjtUuuopdlI/GrVww7HdNZ 5wxO7p87AOdUnLQzXOiByIpkeTXhyKASgXxRuv4UG18CNV2SRUfCRt18XSedlMKvChwf UcvdyaxA9PLfRgsN2cS32Fs+rDhDhkTBMLnwmO1jcWIkfRheUmMDAR2HX4XRXvKTG1RH i56g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=selector1 header.b=J2Xtoh5/; 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 k1si2004083pfg.38.2018.03.20.15.37.47; Tue, 20 Mar 2018 15:38:01 -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=J2Xtoh5/; 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 S1752186AbeCTWfv (ORCPT + 99 others); Tue, 20 Mar 2018 18:35:51 -0400 Received: from mail-eopbgr20094.outbound.protection.outlook.com ([40.107.2.94]:63584 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752084AbeCTWfp (ORCPT ); Tue, 20 Mar 2018 18:35:45 -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=gamGeXGyujYd0AOpLGqaHQ1E9FW0z4w9y7Nx2ygDzUY=; b=J2Xtoh5/RWmMTwhf2DeNuh404Adu9FIzqqtxI535dyqTNGCieHDhCuQYJSl+yfK/fiIH1eFgKpu0CFFuNEXMTXigLEKapN5chva3jK6lnMVcV12wTIPa/ffIS83KD95fwb/FQ9NQkyy0EnXFeHI50nsF54ERGMHbxhzhzael6aI= 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:35:41 +0000 Subject: =?UTF-8?B?UmU6IOetlOWkjTog562U5aSNOiBbUEFUQ0hdIG1tL21lbWNvbnRyb2wu?= =?UTF-8?Q?c:_speed_up_to_force_empty_a_memory_cgroup?= To: David Rientjes Cc: Michal Hocko , "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> <56508bd0-e8d7-55fd-5109-c8dacf26b13e@virtuozzo.com> From: Andrey Ryabinin Message-ID: Date: Wed, 21 Mar 2018 01:35:05 +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: LO2P265CA0146.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:9::14) To DB7PR08MB3258.eurprd08.prod.outlook.com (2603:10a6:5:1f::20) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b3c7ea99-4f14-49d0-24ec-08d58eb2ea08 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:e2YQweoZgyDYqh+ewjEPfYbJmRQbtRErG//5x5+SF1fQFrF7feQ2tMOc1FRigvDFpQVyM+gRAa6EUKjFrO1a6sAWMEWY8lhqdwBq8cKzEYmiDsvxoAufV6XD3hDWM85YZT7FzH8bxswt8J+EP4C2mGH9zRDnEZ7/ZbKO+mmuVlQCMYGl4g6hxYEmZKmGhktMlQvrbCg5HCDxssoWzq6hBpWxj5Zvuuvlc3YoQ5x7KADhBfA2i6nppvOCAkiAevRd;25:dZo654RXJk5v0Duap5Eiwhsk+BeC2yllEgvCZ0nEDDlTKvAUz4iK1TEN3GNOGHhwc2uwfSUs50A8TvyLuHTW2wz14RxKbTsl9yaz9UJXys7EW7DTfCMi5c2R9SpFOFPfTpOg70VmKmY1t/KqWwkos7mVJau/np/fiKKBwaG8jeCOdc00w9iXG99usVIbeEQnUa7zsHXb3z+iEIelJJiTdiTgQY02BhMDgv+6j8IDBEGnXNCSmZqe1p3ENVMDX7KTNyRy95JgsWBAKpvDMhikHHg2OLyXqItg8mWSUSBBbm57GMypSu/l1q2hpE9HGd6RQR+4IS04WkCvbbtew4gbvA==;31:NajbuJdi6jvOkwkJ0Zz54xqQvlCA9eEE7qh+HAwZJYRFzokFVIsYNkbyW1p7aZ8eFkcudN1l4TgQOksWzFQZxMFhAdJRCe+At+JFtxvUn/Orz3nYwFMO4zdM6SxBYRrWKkAAIwNd3gMEpicvgOejkpTq1k7DToY0v80aCDOlHzx2fJTcYzqAXvUSKEtI098o/WH5f4/0fGEwgX45mJe/l9/pYTsGzi1uVmf1rw8VhKA= X-MS-TrafficTypeDiagnostic: DB7PR08MB3258: X-Microsoft-Exchange-Diagnostics: 1;DB7PR08MB3258;20:lYvyeiRe20kvblyaYqPpgXo5vftOMGOdhzDv5kK8IwW2fIMDnyhzzHnnOSNJ7v9JIjMWuEIcCJcRvvyVg4cPtyraL7+hSMVW45dUxe5gSr3IbOTPiXvmk4wY7ZdM5VlPR0QXB7nErFb3zlKVCFc6tUoqWj9neNDz7yVNvkNxSP0WVzDTLEqFbb+Gx/j1RzUGRIGU3Ospn586qt0ei47wcfbGq8nqHRYIT1GjBTnUwz05KlXMho34T7ChOTQ/57XpKS/GaYIRJoMEr/Zorh0V58glA6UMCKB3HjqlRRuGjbRa7wrWF8a/CeJwlq0dfHslO9Ah86Rz8Ty5qj1tFDMRSxHEBeIb/p3rRQgvPMnIhCzVbSowH0P6MZlPS5rVwiuajlNUd+FGaAFDHuxBejmk5Xqu10jZYianZunmZqnTCzNJCcLw2chFTZST0AIk+zl7jX7vKK6p4bcykiZF7DiPEu1PI6BLcGyG0+mDy2lopYhCy3YQ0ybg9qA8dIa2igMA;4:Mb4VrdeyDY758ZH3Csk/PIcMWacugM2qybvcjwT5dUkp1UvzGJu7x+NkM0k7GeID//1pLE4ALuhdkoMJnPVLXBsGiqoboue/S1yIf6VRJzA8xCyeFV6L1ZGcSpXxrshUjg3VtW74FOVqs7dhhdWg5FEVBhA2LCNhyMGRzAF/M/yo2nRP7fQ82NGoWLthHCxMW8p/UCPW4wImvSUtGEY7F2TFU229ot0LK+SmxBwynZrJ9VfzxHQG9ooB2ZYhVkzvol8CbtTHWP256JslJbZNM5sExzxbFgWZN8etJvktbKlObYYON773ls50I9ZB/YfP X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(42068640409301); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040522)(2401047)(8121501046)(5005006)(3002001)(3231221)(944501244)(52105095)(93006095)(93001095)(10201501046)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(20161123562045)(20161123558120)(6072148)(201708071742011);SRVR:DB7PR08MB3258;BCL:0;PCL:0;RULEID:;SRVR:DB7PR08MB3258; X-Forefront-PRVS: 061725F016 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(6049001)(366004)(346002)(39850400004)(376002)(39380400002)(396003)(189003)(199004)(86362001)(2950100002)(6916009)(230700001)(36756003)(16526019)(316002)(6306002)(186003)(26005)(77096007)(53936002)(6116002)(3846002)(229853002)(6246003)(6486002)(31696002)(54906003)(2906002)(6666003)(52116002)(52146003)(23676004)(16576012)(2486003)(58126008)(76176011)(966005)(47776003)(59450400001)(53546011)(7736002)(97736004)(65956001)(65806001)(66066001)(105586002)(68736007)(8936002)(65826007)(50466002)(81156014)(386003)(81166006)(5660300001)(106356001)(224303003)(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?MTtEQjdQUjA4TUIzMjU4OzIzOnFOVjVEYzg2V3NwWEJ1K0NmUFF6c283dHpZ?= =?utf-8?B?TmlZS2p3U3pQenJUVWJIbjI0Yi8zYjF5c1JkdkY4QmZycjVqazdzR1c4OERv?= =?utf-8?B?bmNzaHBBbTlXemd0M2k3M3YwcHVEZGNvQmFiRTlrR0N4MnVGRUw0SExmcnlW?= =?utf-8?B?RzdJQUluU25OcTFDMkE2YWV4T1ZSME9VRlBIZWNBN0lZbVpBNlVTbmJScEpG?= =?utf-8?B?Y0hMbkpReDI0ckRETnFxdWhCQWt6ZE92RlllMkFjd1B1QmY3WXVWRU4rUklT?= =?utf-8?B?dS8za05IV3JzbHA1bE44cno1VVBESU4zQXR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1;DB7PR08MB3258;20:W9IsBLMjPY31Mwa1RPIEn1V1GjdwsIb+ES9tEHPuvvZjRqJm8hdN1BHHMDEjA4NqoWHPepS6VbwRpP5+W9wJqhHoMUryC38/HAyxDKAiWXlAEbbJndU4nEgBy1QA59hrGQeEj9C8JymEaRbFTYH8B+ChTNWr9P5+cPoTUHxxDUA= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Mar 2018 22:35:41.8580 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b3c7ea99-4f14-49d0-24ec-08d58eb2ea08 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/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).