Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp4248462imm; Fri, 18 May 2018 01:46:17 -0700 (PDT) X-Google-Smtp-Source: AB8JxZq7JKjanGidNZV0Zz9Vns8g89boLRWnAtzRNKD0qQ+ArLDw2Pgb59uRZ8HvYJqAlcoH/AKU X-Received: by 2002:a17:902:6686:: with SMTP id e6-v6mr8636768plk.35.1526633177148; Fri, 18 May 2018 01:46:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526633177; cv=none; d=google.com; s=arc-20160816; b=YXr9/DZOMBNCFXYx0d9qWa5XUV3uDjG6fX+wjSv4ranfDeu+qCqBeSflzhGdEGRby4 dnea7t5N1eVZ8D+y+J0lGI4wfI05W4EczDgpWaTBjsYsVZaGZjfu2HMA9e7Wcv066Qz8 tTzs0cL1GNyH/2mh6Rd3tIfJNXNqeDQLhJ4orP2LlBJVHwVGjlAB8zWAf4xQnUUpqYhq KnhYxeb1WXDYr+5racrwC/8DPxyUBnjZ5NDtbdw1XRbgqTRtzjkY4ZZ6jSJY/sjoTsnV EsKF2J7eFsVl4lpCWIgHd157DPLJypHsPTZVyCIOTrlm7Bp+zBfJ+D6Vuu/yhfLP6cwv eAlg== 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:mime-version :user-agent:references:in-reply-to:message-id:date:to:from:subject :dkim-signature:arc-authentication-results; bh=pZEIKPJMNER2+OPwDROMS4u39DjnCMBJmadM26RI6pY=; b=sF3OAwj7O24+DzQyViZLIsEwOd46crONv1chaEVMwUX3Th5NjW7O8tZScVQxWrCHjb nwjafXsuoKHGkhyOBY6SAWEAUBAXikQTdPvb5tH+lzelNjqE3viZbEIchJssYIZXYWSu vEuV2fCOU43KdLjpR3I2cEJTRGoUMiMY7aIsfFUHqpWSu5zHJA+F3nwfjnlxEjDA+yhh 4f7P23WnE8wFNVQ0kt/h3sypPhvubeNfPKgqWD09qyoixBGnCBcOORqEHGiWZjxfBbXY 0WcXM9W7d1PZOYvBiYtyzmGBsClTFX7Emg5UYyDycAUSJX0XOv7Nxm046GMuptDk+k+X EriQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=selector1 header.b=d1cudF0E; 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 u9-v6si7186233plk.516.2018.05.18.01.46.02; Fri, 18 May 2018 01:46:17 -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=d1cudF0E; 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 S932072AbeERIop (ORCPT + 99 others); Fri, 18 May 2018 04:44:45 -0400 Received: from mail-ve1eur01on0139.outbound.protection.outlook.com ([104.47.1.139]:15280 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753552AbeERIo1 (ORCPT ); Fri, 18 May 2018 04:44:27 -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:X-MS-Exchange-SenderADCheck; bh=pZEIKPJMNER2+OPwDROMS4u39DjnCMBJmadM26RI6pY=; b=d1cudF0EDxXjYIWdiyRJrZ82Axq70qpLN15EvHSgZPZVUEFk45E08fq8xyiU3ifS4POI5j+0XT3wOk/0t5JYF6ZAOaRE8rPbEzp9kW6MiFvQm1+OHH5C4tYMr51U59NvQ4J7JGNsBu4/c3i7coSzs0JJuvtkCAJlgYpMrUh4sCo= Received: from localhost.localdomain (195.214.232.6) by HE1PR0801MB1339.eurprd08.prod.outlook.com (2603:10a6:3:3a::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.776.11; Fri, 18 May 2018 08:44:24 +0000 Subject: [PATCH v6 16/17] mm: Add SHRINK_EMPTY shrinker methods return value From: Kirill Tkhai To: akpm@linux-foundation.org, vdavydov.dev@gmail.com, shakeelb@google.com, viro@zeniv.linux.org.uk, hannes@cmpxchg.org, mhocko@kernel.org, ktkhai@virtuozzo.com, tglx@linutronix.de, pombredanne@nexb.com, stummala@codeaurora.org, gregkh@linuxfoundation.org, sfr@canb.auug.org.au, guro@fb.com, mka@chromium.org, penguin-kernel@I-love.SAKURA.ne.jp, chris@chris-wilson.co.uk, longman@redhat.com, minchan@kernel.org, ying.huang@intel.com, mgorman@techsingularity.net, jbacik@fb.com, linux@roeck-us.net, linux-kernel@vger.kernel.org, linux-mm@kvack.org, willy@infradead.org, lirongqing@baidu.com, aryabinin@virtuozzo.com Date: Fri, 18 May 2018 11:44:22 +0300 Message-ID: <152663306223.5308.4934186553719870551.stgit@localhost.localdomain> In-Reply-To: <152663268383.5308.8660992135988724014.stgit@localhost.localdomain> References: <152663268383.5308.8660992135988724014.stgit@localhost.localdomain> User-Agent: StGit/0.18 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [195.214.232.6] X-ClientProxiedBy: HE1PR07CA0046.eurprd07.prod.outlook.com (2603:10a6:7:66::32) To HE1PR0801MB1339.eurprd08.prod.outlook.com (2603:10a6:3:3a::7) X-MS-PublicTrafficType: Email X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(5600026)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020);SRVR:HE1PR0801MB1339; X-Microsoft-Exchange-Diagnostics: 1;HE1PR0801MB1339;3:S4pkcA1HngBGcecZLYBf+WTM6QK6ER4afILZJ9DmXvztHfpxjAmm28n2Z/rxtqKGXGDxjuX0gospM89y6mtoxn834TEKMfBWwiqDn17QkcJfgXZE/aKs+WEwIcit3FUtuCJP7c2P7+o+V4NSlc2fOykxyHaZ5SDpk/6Ki9+0/yk+My3SJz6FMKrDfW7M6AMUp4sCR9NvlOVrblB3ceMHrK/RWqIxYJjjcXeVcBYsRXsRtR6BONd/jC4dj1P9joD+;25:1P+G9utiWxoV9dqyobAgGdWu88f1pB4PEqkp+VT7G63dRR8eU7KbaUizwjwCtjyFdWJo36r5wglbidy+xXE0iM65sllvWvakcCO+7DqqeppCh2SDU8XD1qK2q/i0ty6pzKcphQAAio4ktYRijlDdYfgAT5L+cur01oWTjVRAHXWKKKr/s3LP28TcDK7NFL1lNN89trrf6ypQi+T/aV8VdnFD89CGrQ2qDh22XZ4ceOb/mNEfDNv2Ij0X6d/HWWfiaaeDrKCVFsP1Z5RwPqi19INysw7eJh9mqCw7OV4gLhSC/eOSdPVo58XJ58HUJFggLhwENqG10+Qwybdkn2xs8w==;31:zND2jjhoGNHWQeQCIgf4R1OX2ZFmaKnEqBJmnmS954wNrUOaQPO5QJLA7npoQrHm2LnCPIzf+6jn+SkLIgcy4eSD/ugDaEfWIkzK1wPMjnR3P+w0L69MzBZDoRBi1GEJ9YvQJuu2W/MzaQNvl3PGECOtBj/8PMY/80hOMLuIgo+l2SJ8AFhuBHQnv5DCsZoaLpWelAU/cmGIxjNFFZC2M6eamgMVBd431iA0LtAdxMc= X-MS-TrafficTypeDiagnostic: HE1PR0801MB1339: Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=ktkhai@virtuozzo.com; X-Microsoft-Exchange-Diagnostics: 1;HE1PR0801MB1339;20:rJEut3Yi//nMv+bK07Z3km+UO5CDHaxGMV65IUQuEgCNHpXabJQV02BHa5PW+FeE8+yxq982kWdoGDiflQCjgpIWbpwpFyMN0d0OlkWczbxbrLQtQXQmwIUNul+nuyw3iyRn95F7PmYsXZk09AgGhzZ6CdDm0j/E5gUjuTYlieWCmdQZeyVmmXmaVPlc9BxN8McDIRPPZrYN/+ZMRb2x0rmyyrIjH16s4q8SFqSFFnoPsKSU+YSfvqmlZzmIhMpGUQmK3/vNaKPH1uKL0j5oNJXxasoCALZjnpgGwAH655iREhxhO51XkW7ojU6yimvxJ3kJAjX9L6w3SiCdayhcdZ1+XBOXODpOE9q3Mf0xABLAyMN+mscGYFwGkEcPaVhWmAW9veew8D5YJVRaXMiAxJqsuE9PODXXfn5CzB/WU1UONzXLiPIOuwduvlwPnDEUmXmkZ1SWXlwYeXQ06e1fhiDc1q7AGrbU46LBGrL7tYb2NE/1WT20eAp4DhtOuxax;4:kAM0CyRqAtWwrO7XLRU+oXZFeu8/r19Gsk/gmp0olualMTGrBuA1Ko1mzoSNkvISN62Do7tgQu0c8+oj3bXE37KdQIoDpiy742eAuTQr5uwj8Yow4gTfZdQ+XwPqorr1cKStgq88BznpZqTYJ62E0626HMoHgAcOld6mXop/yJN7xFtZnQNFFWhpqbPR9gLjPJKOCevqf3grfimds51AZP4auK2qklFoNxq0n3QgzVpgT1XGv3Vm0y8LOjoTDDxj7lblGTW37GyHH9PLfjFSNQ== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040522)(2401047)(8121501046)(5005006)(3231254)(944501410)(52105095)(93006095)(93001095)(3002001)(10201501046)(149027)(150027)(6041310)(20161123562045)(20161123558120)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016);SRVR:HE1PR0801MB1339;BCL:0;PCL:0;RULEID:;SRVR:HE1PR0801MB1339; X-Forefront-PRVS: 0676F530A9 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(6069001)(366004)(346002)(376002)(39850400004)(396003)(39380400002)(189003)(199004)(230700001)(97736004)(386003)(6636002)(6506007)(316002)(58126008)(16526019)(103116003)(7416002)(5660300001)(186003)(105586002)(106356001)(52116002)(7696005)(2906002)(55236004)(8676002)(81166006)(81156014)(68736007)(47776003)(575784001)(53936002)(8936002)(86362001)(76176011)(59450400001)(39060400002)(25786009)(23676004)(33896004)(7736002)(26005)(478600001)(66066001)(2486003)(956004)(446003)(476003)(50466002)(486006)(55016002)(305945005)(61506002)(3846002)(6116002)(9686003)(11346002)(921003)(1121003);DIR:OUT;SFP:1102;SCL:1;SRVR:HE1PR0801MB1339;H:localhost.localdomain;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; Received-SPF: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtIRTFQUjA4MDFNQjEzMzk7MjM6bEpuZDMveUlWb1pFTnQ3dm43bGc4UW1t?= =?utf-8?B?anFtWFNOWGpVRWpDM2RkblBXYUROL3BzYmk1L3VPVkF0bE84S3pGeXNxRTlX?= =?utf-8?B?NktzejRMcHQyM3VCTGI4ckgzMGZrMmpyQkZybFlFMW0yRVlkZzBGZkE0a1U0?= =?utf-8?B?L2RpZy8yanJtMlY4UjlNY0NHb2FjaEEyMlM2bjlHcVZYVzVWV1o0blV2V0JK?= =?utf-8?B?b0FRcUJDTGFaRTI1bXFtMG8wVmNCNWJmY2RVbXhXcTJ1YVpScjQ5dXVaZm1H?= =?utf-8?B?dldWN1VmVTR3V0tyTFdHMTFWdWQ5ZjRqTXRzN2FGZXM3R09xKzQrQTExVkh5?= =?utf-8?B?bVBBVkQzRmNRZm8wdi91TjJzcjlBSmlYUXhE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Ijf2SNOfI8l0m1F5w/1svdW0aHS3MeR2w3SwS10SRqn2M2pmAGGN78TLKZVFy4811MZTX0R1cRl7Fy94BExNWgMTAiKx4mTwrHUT0Qzv51QfXNrljERZK0HOIeBs9wMinjWmih39hiDigsWdBNNtGeIVYQ93lYIkQvqfj1LpxX8KetpXO1NKfhXiWRr3iyyVGBMGo/lmCV93uMh7LmseTPr/ORgxZW9fdvFs5DFBoJk+z863kpP9YE3Msb2HPK1ChajT5TytXO2eeNEBYjlhvG+4I3igfy9yz2JhKaDLoW5nt4KI9k/dWLwpZP+g2h6Q==;5:u3EXcYzWVcUbidi3efcCs3uJNiy/8ZJq6GotDeOVzcMGhh9A7/poYmO1NMFkW6PMe9A3mQHCYKNJV/OWvjxulYrYAZMUUhXL+0VvJz841eexBjRhFvBBMODGn7gQllNJWMPMK7zyMtHX0HqePrxmAbGFcsxTVBWCCXvL7MfB/GY=;24:/P1XEJKWJMmRvyQYK1jPDnXAALO6efXCgisTNPIYhNc5Wj7MMRUFci8fmLx793aiUnxBlpS+p6jCTKvO5aiHKeL4yLnL+I7JU071m3N6ldM= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;HE1PR0801MB1339;7:2g69ZRsZbontyvkjD6ozfGjzmJKMYfxg39AbcM2G9lTPtjX0O2aKYaKY/l+gcojD4Skf7Dxu2gGReASZmhPRQ9M8+0479ZZTbD2b61gg8gqkdY/yNNuAoqmGrnqapBhtOw94OZNEs+vdptWgSZC3uk9djkE6ebxs8a1MVg/dXsp1m36U5as2jp095LA0looJFhemG9A1IyFbmHXSKBrVRaPW5EJ7zyHkngkV2HZRskpNGKzKmvNu669OZW7IlT89;20:6wCEEI9oM8XRPslmSu57n8nrGav7HQ6W3D//B+Fm1AG7pK8IP4u6fUb5+JFJN3gIFF4eiLE74OZzbbG/LMlYjd2fWoa1Do8BDxIpAMp9ivcDOWQ55gb4CUpywAo2MHRhAe68p/b2cFKPu3XoCHcOr4/Pmo/Z9PQC8EySu0yEzLY= X-MS-Office365-Filtering-Correlation-Id: 56954916-a812-47dc-c8ca-08d5bc9b8f57 X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 May 2018 08:44:24.5203 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 56954916-a812-47dc-c8ca-08d5bc9b8f57 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0801MB1339 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We need to differ the situations, when shrinker has very small amount of objects (see vfs_pressure_ratio() called from super_cache_count()), and when it has no objects at all. Currently, in the both of these cases, shrinker::count_objects() returns 0. The patch introduces new SHRINK_EMPTY return value, which will be used for "no objects at all" case. It's is a refactoring mostly, as SHRINK_EMPTY is replaced by 0 by all callers of do_shrink_slab() in this patch, and all the magic will happen in further. Signed-off-by: Kirill Tkhai --- fs/super.c | 3 +++ include/linux/shrinker.h | 7 +++++-- mm/vmscan.c | 12 +++++++++--- mm/workingset.c | 3 +++ 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/fs/super.c b/fs/super.c index f5f96e52e0cd..7429588d6b49 100644 --- a/fs/super.c +++ b/fs/super.c @@ -144,6 +144,9 @@ static unsigned long super_cache_count(struct shrinker *shrink, total_objects += list_lru_shrink_count(&sb->s_dentry_lru, sc); total_objects += list_lru_shrink_count(&sb->s_inode_lru, sc); + if (!total_objects) + return SHRINK_EMPTY; + total_objects = vfs_pressure_ratio(total_objects); return total_objects; } diff --git a/include/linux/shrinker.h b/include/linux/shrinker.h index 7ca9c18cf130..b154fd2b084c 100644 --- a/include/linux/shrinker.h +++ b/include/linux/shrinker.h @@ -34,12 +34,15 @@ struct shrink_control { }; #define SHRINK_STOP (~0UL) +#define SHRINK_EMPTY (~0UL - 1) /* * A callback you can register to apply pressure to ageable caches. * * @count_objects should return the number of freeable items in the cache. If - * there are no objects to free or the number of freeable items cannot be - * determined, it should return 0. No deadlock checks should be done during the + * there are no objects to free, it should return SHRINK_EMPTY, while 0 is + * returned in cases of the number of freeable items cannot be determined + * or shrinker should skip this cache for this time (e.g., their number + * is below shrinkable limit). No deadlock checks should be done during the * count callback - the shrinker relies on aggregating scan counts that couldn't * be executed due to potential deadlocks to be run at a later call when the * deadlock condition is no longer pending. diff --git a/mm/vmscan.c b/mm/vmscan.c index f1d23e2df988..6639d1e7b6a6 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -456,8 +456,8 @@ static unsigned long do_shrink_slab(struct shrink_control *shrinkctl, long scanned = 0, next_deferred; freeable = shrinker->count_objects(shrinker, shrinkctl); - if (freeable == 0) - return 0; + if (freeable == 0 || freeable == SHRINK_EMPTY) + return freeable; /* * copy the current shrinker scan count into a local variable @@ -600,6 +600,8 @@ static unsigned long shrink_slab_memcg(gfp_t gfp_mask, int nid, continue; ret = do_shrink_slab(&sc, shrinker, priority); + if (ret == SHRINK_EMPTY) + ret = 0; freed += ret; if (rwsem_is_contended(&shrinker_rwsem)) { @@ -647,6 +649,7 @@ static unsigned long shrink_slab(gfp_t gfp_mask, int nid, { struct shrinker *shrinker; unsigned long freed = 0; + int ret; if (memcg && !mem_cgroup_is_root(memcg)) return shrink_slab_memcg(gfp_mask, nid, memcg, priority); @@ -664,7 +667,10 @@ static unsigned long shrink_slab(gfp_t gfp_mask, int nid, if (!(shrinker->flags & SHRINKER_NUMA_AWARE)) sc.nid = 0; - freed += do_shrink_slab(&sc, shrinker, priority); + ret = do_shrink_slab(&sc, shrinker, priority); + if (ret == SHRINK_EMPTY) + ret = 0; + freed += ret; /* * Bail out if someone want to register a new shrinker to * prevent the regsitration from being stalled for long periods diff --git a/mm/workingset.c b/mm/workingset.c index 79099bc5c256..3bac1b2f649a 100644 --- a/mm/workingset.c +++ b/mm/workingset.c @@ -402,6 +402,9 @@ static unsigned long count_shadow_nodes(struct shrinker *shrinker, } max_nodes = cache >> (RADIX_TREE_MAP_SHIFT - 3); + if (!nodes) + return SHRINK_EMPTY; + if (nodes <= max_nodes) return 0; return nodes - max_nodes;