Received: by 10.192.165.148 with SMTP id m20csp923876imm; Thu, 10 May 2018 02:55:07 -0700 (PDT) X-Google-Smtp-Source: AB8JxZro0BWWznqQJBbqfj+KrTeN+sFHeLK2oHi0ONpA+UklhjLxj6aBcvhmXO5TTI/e3hx/Akwt X-Received: by 2002:a17:902:4303:: with SMTP id i3-v6mr745464pld.394.1525946107512; Thu, 10 May 2018 02:55:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525946107; cv=none; d=google.com; s=arc-20160816; b=OeSFu74hJ3pWMXAhWQNYDfLcICJfmyxKMN00apOlC+nwmjYziWstP6OdeB/f73NM4O 4O697svKXoBbSNfutJtTinj8oZNGdJ7D1ZbjqE746q1Sc1uUytoA5m/5DuSlKnpwDmKr Sjg0bQRhUC8S5F4OibaNi/Zgr+4h56CNlJykMR9U/SdR80RwpcHzcA3Q112lZG1bqtCd Iq7uAhFGH8e/GVG7yrazodp3LuS4WZ7i/tnBAVusR9js5cOtHP/PuW5ONBvixSRK8Uv2 Wgzpbx1zPeAKtTyLgoT8S8yMlD8XeYKHBuZWvPsMvxUtL5/Z84ewpEkQUSZxvjkOuu3Q 19Cw== 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=GxUUVkzyfzxekYFSXH9ZiF1N0xg6ECCmVx/5DgTypbo=; b=BRORNCQgeJzpCl+0Sq3KBohMloMNlgG2tJoq6zRxrfgRB1W/bR1mCFQTomfwPkm6vw S8zHQ2LyuM0wFTtghnAGuZI0GV0fCLaZEF/BkI3i6qH4fwv5g0ddnHWkTYCjnCppX6S+ iiJfwQM5QEMrCiLfVO8v0k0jTXDCabhDi2XT5bWyQgxqzgFTbI+mrMaCS7ypI73Qu+Cl YkpokB4RnrN5Vn3kjrf1RSvMoQYUYjozzBwWyiVzGlJ09PJ8tpt2v8j6ksYnWQCL2MIn CfdXAfzJkIFPe2p/yHnrmCrHPV0/KkvVS36p+NASPjdNuAKL2X/Tl6oY4lbjSz/zzGQO yitQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=selector1 header.b=OQmkT8x6; 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 s12-v6si375894pgv.271.2018.05.10.02.54.53; Thu, 10 May 2018 02:55: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=OQmkT8x6; 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 S935288AbeEJJyT (ORCPT + 99 others); Thu, 10 May 2018 05:54:19 -0400 Received: from mail-he1eur01on0108.outbound.protection.outlook.com ([104.47.0.108]:58276 "EHLO EUR01-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934661AbeEJJyP (ORCPT ); Thu, 10 May 2018 05:54:15 -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=GxUUVkzyfzxekYFSXH9ZiF1N0xg6ECCmVx/5DgTypbo=; b=OQmkT8x6zY9TXcNWIQTuS7Bq8uCnRjECcBD/nGETVzTuJse4lycX3a7+ZnNk58z+xM0lFubyGlkjNJo8NEjb4zsf4yLxNkwbeo4wL8R7MAbSzO1tDRMagNSfm+cduEaC7T6AiZRFpsXiUikhJ47C3cP5gd5TCMm8PKcbAdJ+cXA= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=ktkhai@virtuozzo.com; Received: from localhost.localdomain (195.214.232.6) by DB6PR0801MB1335.eurprd08.prod.outlook.com (2603:10a6:4:b::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.755.16; Thu, 10 May 2018 09:54:08 +0000 Subject: [PATCH v5 12/13] 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: Thu, 10 May 2018 12:54:04 +0300 Message-ID: <152594604464.22949.13100629516136544648.stgit@localhost.localdomain> In-Reply-To: <152594582808.22949.8353313986092337675.stgit@localhost.localdomain> References: <152594582808.22949.8353313986092337675.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: AM0PR07CA0016.eurprd07.prod.outlook.com (2603:10a6:208:ac::29) To DB6PR0801MB1335.eurprd08.prod.outlook.com (2603:10a6:4:b::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:DB6PR0801MB1335; X-Microsoft-Exchange-Diagnostics: 1;DB6PR0801MB1335;3:1of641lO+l5FWzIXvh9onfASEabATpWDMe+cH12Bev5abYynSzSC9sfsVbmRRMXvmNOi+2sWKjrqbzyAB2ru4nZRjvJuGpWJ7KpaIo9qGQ9N4oqN3EwVPBP1aCI4AeZ/WkFgH2D1gnB5f+yOWxEhbIZ0SiT5EZ5o+tYyz+XbBLEH5pWwhmkNO9lWKk93K9+Z+3F9VG15+n82shv2mUrCjUgIkd22j09bEVu8LGo8PykvVk29nWeuew0/h3R/19gg;25:+2YOmRQEOrFJ7i0BCt+eTLtkxT5oEnPOlaS9Hd/F8NMXWZOIe5VmQuLHRvMkhfoVPgGHJF+LANazaryiaU9Xq2cV8C9aQVEcOk/zalUJSw7rMqjUOVvtq7POd+x/pgiBAoc6/x1p0pXwJnCM1fNxwu+iZsWcnflV5+6+FBJarUGAXpE3K+Uxs1IVMh8XiWMV8C2c+req6xLwuX79lErF2HajP3x4kjovDYCaD248EH61wwCBiSr0/HlFo9RFs3tXKNSG90QFf+4XcCP+G7Z6V7MpEPHuk1AjhtVz1s6Lh8iMaVfHRi6mpzE1Jb8YDCjfOp5OTLSdXkIZbezSmZgmwQ==;31:sWOCauzrNYCrjcTcw8+9GE3Yw+T50IHfna8PSBqvXKHezGLWu+Ivy0D7XDkHphwOi/1x9jKVvusARiywK1ZdpdzY9G30drzwE4Wgf+p4cDRAS84GucVYTtt2zeZg40esYg+o8lD1hbIhie6P9ZWDR3MuWQXrr8Ph52PPMgE/jk3RpUpzLeqzXBS1WXUz54PnKuy8VHfWmVeQ7E8C5++SyoN4qcHnhm35qGiGSveqpr0= X-MS-TrafficTypeDiagnostic: DB6PR0801MB1335: X-Microsoft-Exchange-Diagnostics: 1;DB6PR0801MB1335;20:Ken5pJjXYZcjDADXpOyNOzk8UbXXBGFwicASVPv68K8FsoOcWOMzUPW4P5j4sNv9pz1w2JkeZ9XH7CMD75thMq0rfDqZOwPqfE/a8LZpP5y/1/80EGekM93hLBcSkWZc7BBS/qV95OWVMVcb/8LmasxR+XPVna8/LAs+VlwfmGuEdPUW4/dYguhdnXrARAKIbtwUHnCSaDE88egzzS/Wxq3TBVwpIBvHC7GvrYcw6Z/xdmn2PnX/2Rm97DP4fL4kDunA4YBMBZmxNljpp9lvaE0xzB/GsVaE+yK/WvGYbi9yf5qK7sQ8jf0ZPq38vzGwV61AGlTXB9SgjCfsdUrTturyudz2Q7KN4klHSt99noRJiNGpeK0WQCXGsH9zCmZ5erAyFwoqUpZHRQq0zk2q5Jgsq6Bxhv9meLcqMh3rzNNDEgLyUOgTsvE3vvsfgktmVFuUgQlZd1gGaDSjuDOkupnYmnaYWjxU5n5K/42NyLXGGEibY7YneiGdFv5EiOxT;4:uzbyIGx0DsMCHbRV0zlUBS1nmx9AIP4wh5H30evEeqbz10q9zQR94rrroWCxWvIr7p54jzbFDePR21YWSGYtdWbnYYeskVp5iD8e1ZKfunrY3BUB0qcv4o3n8gzM3JUPy6JCHGUHtUC9ltVkIf4Tanyf2EXkk8s6AxTm12TUQDduGOBAGc18qjTjr7MtuHmjVqpJiO+zC2rCkXxd42pVn2qvn4GS1DmwzD/SVNxvTGMYHVSpVj8ZCnQ1kypOaBcxvQgcxWqvCH3VTpCE/cx1jQ== 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)(5005006)(8121501046)(10201501046)(93006095)(93001095)(3231254)(944501410)(52105095)(3002001)(149027)(150027)(6041310)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123564045)(20161123558120)(6072148)(201708071742011);SRVR:DB6PR0801MB1335;BCL:0;PCL:0;RULEID:;SRVR:DB6PR0801MB1335; X-Forefront-PRVS: 066898046A X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(6069001)(366004)(39380400002)(376002)(396003)(39850400004)(346002)(199004)(189003)(105586002)(76176011)(186003)(16526019)(230700001)(55236004)(106356001)(26005)(7416002)(2906002)(11346002)(446003)(81166006)(8936002)(50466002)(33896004)(486006)(476003)(103116003)(305945005)(7736002)(316002)(956004)(59450400001)(6506007)(8676002)(386003)(58126008)(81156014)(61506002)(68736007)(6666003)(6636002)(9686003)(39060400002)(97736004)(478600001)(25786009)(7696005)(66066001)(55016002)(47776003)(575784001)(86362001)(53936002)(52116002)(6116002)(5660300001)(2486003)(23676004)(3846002)(921003)(1121003);DIR:OUT;SFP:1102;SCL:1;SRVR:DB6PR0801MB1335;H:localhost.localdomain;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; Received-SPF: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtEQjZQUjA4MDFNQjEzMzU7MjM6YWFDL0UzdFREZGw0TnVBTEN1YVFBUVg4?= =?utf-8?B?SmdrUlBQc1hzbGtQUjZneG9kRk9ZZ3ZSZ1NOUGNZNkNPTVJNQ0Yzc1E4dmha?= =?utf-8?B?VnNDOTFHTS9iNWlwVXBVZUpZQzA1VW43UDhCTkZ6elI5cHhnbkZpWlkrQXVH?= =?utf-8?B?Mnpqc1FnREFnK1Iya1lwcXJlQTNPVFlkbWRvUkZxSE5CWlpFU0hXTG1BV1Mv?= =?utf-8?B?UkQrYmJxRmhCa1ViNFlhT1pZZW9EK0ljUlJkUlhpTU42TFc0Z0tJRUFNT2RM?= =?utf-8?B?NWJZWTRUY3dXd0xQQ2tKQlR5SmdwSlIvOHdOQlJvOU9OVzRBWDJaUUIxYWU0?= =?utf-8?B?L2dHK05oSklsejd4MjJJNml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u/Zyr4+FjBr4d7d1cfCjw62VqyK17Kot7eEWhN4BpR/tdZLP+8Q2zNfxO2BJD7bcqJm6Nb5HHs/ISRbpbI1QwgFxKO0yFaV1hE= X-MS-Office365-Filtering-Correlation-Id: 83377715-e519-4727-8256-08d5b65bfa37 X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 May 2018 09:54:08.1200 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 83377715-e519-4727-8256-08d5b65bfa37 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0801MB1335 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 dfa85e725e45..3cad04644329 100644 --- a/fs/super.c +++ b/fs/super.c @@ -134,6 +134,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 d8f3fc833e6e..82ea5012dfa0 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 a2e38e05adb5..7b0075612d73 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -446,8 +446,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 @@ -586,6 +586,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)) { @@ -633,6 +635,7 @@ static unsigned long shrink_slab(gfp_t gfp_mask, int nid, { struct shrinker *shrinker; unsigned long freed = 0; + int ret; if (memcg && memcg != root_mem_cgroup) return shrink_slab_memcg(gfp_mask, nid, memcg, priority); @@ -653,7 +656,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 da720f3b0a0a..e731e21a9fca 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;