Received: by 10.192.165.156 with SMTP id m28csp213712imm; Tue, 17 Apr 2018 08:57:36 -0700 (PDT) X-Google-Smtp-Source: AIpwx49rChqL2klW0o+j60FhJDQ9GhZ5CyUFM7aPfhW0MEgf+T1BzRBW/aliEpq+A4stUjo2Dzk0 X-Received: by 2002:a17:902:3e5:: with SMTP id d92-v6mr2652925pld.104.1523980656859; Tue, 17 Apr 2018 08:57:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523980656; cv=none; d=google.com; s=arc-20160816; b=WTFaKh8Q+1lEh6uuXp0/LSq8l3K81RP7YdoSdByOJ4/OLxnBplZBzSMnpwcN13ivnr zvJB9z040bCY1Mi5uI0NmrBdP1rmINEH4avKZ2focSGA5Z+0jwAO7N6duCO/Y4/AvYHL Y/CMA/IGV/FByWp2frcuvjFXHL6GEmPqM88AC9l7EWJiK9Sgd18bhyKgIu7DJYKW4/J8 P53LakqFI/HNHl+dLHp20wkCS9Ug+DGEi2FM9kcRYfGY8bxFMJlcRYWukAYVmN7ltioG svGeF/00VoKEtLFPo2DpKQ5rHb/ZModRQCD7ZZXmjxn4AyT/3mwCWDcLwopUKUNM/Gjb YAsQ== 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=d2NzK/f1wbT68LZoS7Uc6KHvxCaF6CCFNp1YwzGxjI0=; b=PMvmRT7cIT2sammN1jVQMdEd67WpXi6KTF6ZvocThxRnTdnnQhN3+5EvjlN9qr26GI sTcOjZuCpTPC+sMQmk0J9x/ynh9dXJIenUnBf9sYV7fHVHC8718R7R1d57hN/G4RAJZi fhgyeYqZbdXHZ+Y7gheZ7/7YowH8g9HKGz+xsMVhT0RSMgVPwGo4AG4Wm6qgNR+gxv5+ iLZRnKnrRiey9o00LW5FV3H+xVsryjYIKZ0EQqmA5yUFcZ8GNQ+Vs3hBB3ZfmzHgoiAF LgU+OYHAeeTtpsXG1/mdPVUp75+Tqeir5kT+HC69LgLy37a52ehBooYz7oPtisaWAoVP 0r1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=selector1 header.b=JfMjP4b+; 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 k7si12021035pgq.286.2018.04.17.08.57.22; Tue, 17 Apr 2018 08:57:36 -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=JfMjP4b+; 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 S1753443AbeDQPzC (ORCPT + 99 others); Tue, 17 Apr 2018 11:55:02 -0400 Received: from mail-db5eur01on0127.outbound.protection.outlook.com ([104.47.2.127]:61798 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752743AbeDQPyz (ORCPT ); Tue, 17 Apr 2018 11:54:55 -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=d2NzK/f1wbT68LZoS7Uc6KHvxCaF6CCFNp1YwzGxjI0=; b=JfMjP4b+Vz4MuisE1BQ6aa63buMfQAankX2qcsN6yLFa0r1Ku9X0yCWAeRbg9QcONOIeFspF+qicS8uqKSWPklyXw6x4T2aD1+KbJZCQLCrRfupum5FfJpWQSnoWSE9dgnYmh2MEteiINskEK8q9zmXOrb4E6JYMn6+qD4s1DFo= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=ktkhai@virtuozzo.com; Received: from localhost.localdomain (195.214.232.6) by HE1PR0801MB1338.eurprd08.prod.outlook.com (2603:10a6:3:39::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.675.14; Tue, 17 Apr 2018 15:54:52 +0000 Subject: [PATCH v2 11/12] 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, hillf.zj@alibaba-inc.com, 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: Tue, 17 Apr 2018 21:54:43 +0300 Message-ID: <152399128393.3456.4036800434493129834.stgit@localhost.localdomain> In-Reply-To: <152397794111.3456.1281420602140818725.stgit@localhost.localdomain> References: <152397794111.3456.1281420602140818725.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: HE1PR0802CA0021.eurprd08.prod.outlook.com (2603:10a6:3:bd::31) To HE1PR0801MB1338.eurprd08.prod.outlook.com (2603:10a6:3:39::28) 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:HE1PR0801MB1338; X-Microsoft-Exchange-Diagnostics: 1;HE1PR0801MB1338;3:/PIPHEHJ2IhG/dI9hbzjeF499bTmnt7UmO2LGDRoLUGPU0QhOXEBRS12H5RbKJ5Ycx4+oFbQW+ptilmSlTJtKcJJqV05/9+a4cfIr1K3+9dv0NtRKro4SMM3Zm7kqkM5NSDVywbECtREfNcPKN6I5d2ImVFIq+h7ca8dEBv3tCLZ2byoHaPmmrT4+mR82hcCUN5DAOuhSohHnD2zLjIzJeJDzL8zZcfSYa0Llt3Xp0NqSyGy7cM2rQsPkHVHM+oe;25:2Afu65rOGHqmt+bH1LcUKe2Tn8OS93SE6BYT3WeOvjLNxEmg1gB96G+X9+dwdz6WlSbjJdPcyXPUAM47lCRxFwEClzaZcXnCAuz3dPN2W4swRRODMeezZGV8jgc7EfxZDjqjQdF+pICjY7Gmrqfnh8PwRNp9OI/1afhpffwkxoTIS8Iude/ku6HwI8SI8Wfe2ElIrvaOE3bmVmTNjr3rwo8jOdNdvoSb5J26LYe58qolA8e1x4eOtHvDdEiXpYqyD3d7+wtlZaEDms8+rcsQetQyBm7xE4zvWaz0GZ7YE9208lkWKmPwq32PR+O6GJ2Uycg+uscFWsecZXqY3WtWXg==;31:+jl6sYkM11LRqvKr/GK2u5453gUS46Mycu1KV/eXK2Ht8+ju+M2H0IKHcPukUWM2q2VJs1gknOVNYPGtbe7lGyHL04/95Sr0ToBz6D5XAMCpm8ZF7yUc7Ok4/+EQ/4J5POmwuEB9z+YgoJjtOjrjzIBGm7HCh5jtx2Dfjty/5B+5cxDsFqGYbiRH5+EyenI1aWtqxlO6Ptu8s5LX26iDfp6yMcxXbT6NQ7aax7IE0Q8= X-MS-TrafficTypeDiagnostic: HE1PR0801MB1338: X-Microsoft-Exchange-Diagnostics: 1;HE1PR0801MB1338;20:yQ5lV6+3CyMv2baeuq9EBlDdqCAGgROGAN364r10V/f5Tyr1g+atIXiH+8+o6yRKWM863kGiLlPXilVXhbwuhZMCpTIAc2FXXAtx3HdqiacjTCRaSrnQZ+30smmcYnIXNbgyDxFUU6yXqzpIVdKfg9xMir1EuhhrWYTiEb0p3IgEx9M0s+C6z2WNg+WduS2Ytm4Kp2SYNlKeMi+EgppeC4GT/i92WOOZei119UAKFFUS/SYWRvpEg7uYY74bkK+EUEyqOCAYmr2pbH4p904KVAUQax9rVR7+qaNENbnfVi8GBW79Ei6iA2j1wRauFZGP7Ug5ZGWXke4zOtAP1XKi1blffpZj7zZWHyr72yZnd4jGjPMr/TCCCi8KeeWbelk+9fg1bUyn44RPWV7HhD8WnBy9UkXud/P9pysEqkbVPFNRu3fRnluDrQJDjn7XJltF611oZ/k9dLpGgExYnLWrdSR35Oyy/NuQm3BeVaXc1j+2+BoGrY5nD9EoYFXHhHbc;4:E6FkOd4uUHdtwLEf6QbeWBXK6OebtqSsa0mUG2n6rfIN5SqcLwcTNQeYWL0NtbSsf1xrEAVm2HASV9gGFqTqegoq6toPSq92INMMslIRTB8jZk6OUmVXQabit4v/jqdJ5T9qerVTtW/zCsrVn72CvVXJQE/wbBA7+JMt8YrzGQ8jVcZZA0KDEERYq/Q/jifAbUabKqPp2sAxsjQ7RuA2pTHSxDtIgUvYhMMTAqvXKBmOXKJlpNgS4/Bp+vT29dGDAPZyShzxL6MG3vGNmcjBJA== 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)(93006095)(93001095)(3002001)(3231232)(944501327)(52105095)(10201501046)(6041310)(20161123558120)(20161123562045)(20161123560045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:HE1PR0801MB1338;BCL:0;PCL:0;RULEID:;SRVR:HE1PR0801MB1338; X-Forefront-PRVS: 0645BEB7AA X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(6069001)(376002)(366004)(396003)(346002)(39380400002)(39850400004)(199004)(189003)(47776003)(6636002)(7696005)(52116002)(23676004)(55236004)(7736002)(68736007)(7416002)(53936002)(2486003)(33896004)(76176011)(386003)(6666003)(59450400001)(6506007)(316002)(66066001)(305945005)(3846002)(478600001)(230700001)(86362001)(6116002)(25786009)(5660300001)(8676002)(55016002)(61506002)(16526019)(26005)(186003)(103116003)(97736004)(106356001)(105586002)(39060400002)(476003)(11346002)(58126008)(8936002)(486006)(9686003)(81156014)(2906002)(446003)(956004)(81166006)(50466002)(921003)(1121003);DIR:OUT;SFP:1102;SCL:1;SRVR:HE1PR0801MB1338;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?MTtIRTFQUjA4MDFNQjEzMzg7MjM6SlpWQ3QxbTNGdFBrVERJM2U2b2RoVlZv?= =?utf-8?B?eXUrUll4QVhoMHd4d01LdE1lVXFEdUJyd3hQelpjdXIwbUMzZ3B6VVgyZmph?= =?utf-8?B?STk0STVpeElFSVZyTEt4S1o0MmF0NWtmSXdQV2ovTUlydGdIR2xSa1daM01S?= =?utf-8?B?MnJiUDZSU2xIaDNwdlk3bmhDYTV6akk1SjdRZis3eklXaTF0a2Y0WHd3YVhw?= =?utf-8?B?aGMrOVBMZmJDWFhIMEtUM3Jmd1N3YmYvRDZnMlNYTE5rM3dKM2M2cDF2NWNm?= =?utf-8?B?SWx6QzEwQnhadGZmTEFHYzV3N3VyVEZxTFpIWldmdEVwWXFCV1FUcklqNmNp?= =?utf-8?B?cmdVcmgzeVcraGthWk1yS3g5T2duK0FIZTJqOF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UMh20SYcDSGWuSfiFD2QlbedtzfpHSd17AcumBrBQSbeqPMneU0qY69ELMLu0QBJNbb+NTc5ZqUetj5LBJhGZQh5FuSviywUvlQkpd0bAdIfoDmij3Z07YcNOskFwfinCptWwzCt5QY+EdgLAxbo4q++JUjfWRMdBLh0UehwdCi5kfyH9W/mqapUQbfJls6x3JaTrKEOcTGBPAA4AW0qYsIL8O91y3fKCaOsqv5e3+yEKc85kooHvFoK6JcCX3i31QHOAji++V510FSHvk/JzvefWn3KJp9zFgGZPHyxGSFyh42fBpUqE6bz2kc3ko17z2tihSfynPlLAA==;5:MBI3g9rqivYQtSFD680QiOr4ohD317a7d4lgOhRS6cylY60XzDj0YmOfdhPqB/SPzaUYBGEHhI2UDwSUA1FP+t+sLjjh9Q5IOTcBqfgJtFWWidA8l74rlgOva1dWvS9YjRqaTniQanXcxIma14XlgetgBfzwdH23rqpK3n50DFU=;24:5M5DzLokXcVpZo60SPFOFaWiTPingXP/R70LR5rHZL1SfSMqgVFHokyNs+dNNFQv8qosRuCMr8EChmJ+kd8BPDAbgoO2SbR8Y9z/KeZkgqc= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;HE1PR0801MB1338;7:9vuy5A2c9Ar3Vclibv8+LDZdjKsy3N2vI2dwOAQhcdQIlKB3+Z/2CQhVvKgIqia7Kz5kAWEhXeqiGutp1s4HQboOTBdeJpeaxLLdGq1Im9PO8MVzxfsrEJ7aogbW0bZpAcfTm8RIniNzZGW/LEU8eW5+HYQ/ieIkiqOv2dQh58KZDXnylBOVev/ZjiCBw+UOLavH4+nMQQibxCjxlAMli9cGoT5WN4X4YEix86WUpoSIHDT9CPNHfYbHzUVA1kRA;20:xdwkOIoNxgVxFedJ6nebxd60kCHDmEpXr7YAjNXGEzpzytjvNwucvuKsjSkOebqVE1mkonsrt+4IU5O1B8MHj1YeVoLlztgWHWixVBEVaCXPlyS7mUYD9JT0beoaLCSCtu/1c8Ad22xEq/MgCKB6C6IIm2pA+E96tSMUvXsh5u0= X-MS-Office365-Filtering-Correlation-Id: 5befc364-4f15-43b1-b4c5-08d5a47b8f21 X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Apr 2018 15:54:52.3482 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5befc364-4f15-43b1-b4c5-08d5a47b8f21 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0801MB1338 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 9bc5698c8c3c..06c87f81037c 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 22ee2996c480..973df501c335 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 b81b8a7727b5..3be9b4d81c13 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -443,8 +443,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 @@ -579,6 +579,8 @@ static unsigned long shrink_slab_memcg(gfp_t gfp_mask, int nid, } ret = do_shrink_slab(&sc, shrinker, priority); + if (ret == SHRINK_EMPTY) + ret = 0; freed += ret; if (rwsem_is_contended(&shrinker_rwsem)) { @@ -620,6 +622,7 @@ static unsigned long shrink_slab(gfp_t gfp_mask, int nid, { struct shrinker *shrinker; unsigned long freed = 0; + int ret; if (memcg && (!memcg_kmem_enabled() || !mem_cgroup_online(memcg))) return 0; @@ -642,7 +645,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 2e2555649d13..075b990e7c81 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;