Received: by 10.213.65.68 with SMTP id h4csp1496977imn; Mon, 26 Mar 2018 08:38:50 -0700 (PDT) X-Google-Smtp-Source: AG47ELsVMCn5z4vsTVtT/GVdDO5L7w3MGNpK/yrcqOj2vTRYf7MwwpvFs6VC1knf8fySkSv1PT8P X-Received: by 10.98.66.203 with SMTP id h72mr30129874pfd.156.1522078730549; Mon, 26 Mar 2018 08:38:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522078730; cv=none; d=google.com; s=arc-20160816; b=tOl+0rabVO11JpaLhpHnJlxybvSzyeUApAhnKX/eoSPK1QLilGW9l8PGbb0sCqgyrg Pz4uW9XwFxkEwe4s3pvYgKAEGTkjTTvVE6sRk9rXj9g1lhhcc1Sx05i52ESuUocRdT3O zNyM0qtmHSxHfDBotzJDPilhzRfQxDAprlvxzQYb52KIDrbwg5G9oVpAbmDSmjCRm6Na ECszn6IVzuShLlK+vyKFZ6Vp6e2pcjvXm4ikHmXJWQ7zitJYqo5B8IRSr+C3U7PQrMic 8p9M/PioYK6zcIbVNhbTjP4np58bnbCTTIqIfugpWpSaA2emnxtDNmxH5Bx0GdxoqBDT bl4w== 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=T9yndd6qmkqR/pooiR/3toMCA5ee3IrOQJ414u1ToiM=; b=DC+ByEN4E7/3NwDnvd72gzl6HhKRW7EpmKH6dGMB9sA6XMNJ57pFlcZbyTJm8yEbaA tza0hBx8ADPzxzvmagAS7uPAnuVu35sarb4lr+hZ9QcNdn3kC5L4Fz3i6qnPSFMn9qra Hb6EmkTzhruMRcM1w8wD0N+00AUWnxUPdGG0Og+XkfkkuoSmfXXtXtWYG8aVq0fTVLA3 j0Gg2HuYC9daZMn2XD008pEG2OJvhZKytlYDUsivwZBEgqnZ0j1O/oht/oRciF4KQph7 PRN6W/BwOP7KDC4bkS25hCsA8m8hzgf1wfLAQpiXFD+CEpW38NStc31xDVA8NHV/nusi bn7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=selector1 header.b=gFORPWwu; 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 w16-v6si8600023plp.165.2018.03.26.08.38.35; Mon, 26 Mar 2018 08:38:50 -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=gFORPWwu; 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 S1752496AbeCZPh2 (ORCPT + 99 others); Mon, 26 Mar 2018 11:37:28 -0400 Received: from mail-ve1eur01on0133.outbound.protection.outlook.com ([104.47.1.133]:45412 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752082AbeCZPhW (ORCPT ); Mon, 26 Mar 2018 11:37:22 -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=T9yndd6qmkqR/pooiR/3toMCA5ee3IrOQJ414u1ToiM=; b=gFORPWwu/dYll9Ca9QcY+95+mnSDIeAsVN+cDs+j3TudWiwdZX9uXrAVR0Soq4z0t8DFnvKeYTue65c6eu8M1C7acUllERS1vv7/T5rglp6bVoE+eZEO+AVU5K/+P1bK8xPY5FbOVuM3wRrNm1qCOkpwkMG+fxG3Ykd43wZC0pI= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=ktkhai@virtuozzo.com; Received: from [172.16.25.196] (195.214.232.6) by VI1PR0801MB1343.eurprd08.prod.outlook.com (2603:10a6:800:3b::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.609.10; Mon, 26 Mar 2018 15:37:16 +0000 Subject: Re: [PATCH 10/10] mm: Clear shrinker bit if there are no objects related to memcg To: Vladimir Davydov Cc: viro@zeniv.linux.org.uk, hannes@cmpxchg.org, mhocko@kernel.org, akpm@linux-foundation.org, 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, shakeelb@google.com, jbacik@fb.com, linux@roeck-us.net, linux-kernel@vger.kernel.org, linux-mm@kvack.org, willy@infradead.org References: <152163840790.21546.980703278415599202.stgit@localhost.localdomain> <152163858159.21546.2876185232270486710.stgit@localhost.localdomain> <20180324203312.b2whjgadm7gwby3v@esperanza> From: Kirill Tkhai Message-ID: Date: Mon, 26 Mar 2018 18:37:13 +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: <20180324203312.b2whjgadm7gwby3v@esperanza> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [195.214.232.6] X-ClientProxiedBy: HE1PR0402CA0045.eurprd04.prod.outlook.com (2603:10a6:7:7c::34) To VI1PR0801MB1343.eurprd08.prod.outlook.com (2603:10a6:800:3b::7) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1465741a-2b1a-41d5-708f-08d5932f757a X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(5600026)(4604075)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020);SRVR:VI1PR0801MB1343; X-Microsoft-Exchange-Diagnostics: 1;VI1PR0801MB1343;3:9Xp28+7mFnzucxeNTd6xlSZji+JUu3XJkd4tkZNSGGMJB+mF28tx4FzVJ/mf+WrOMjq49AaRrty43QRUuGDj8gc8Fl/NAN/wBhwfmSU6h6647snlxRFQNP3qqsEQ2ZUvYVRdhgfalWobgKoCEn8CMfjvuRj1Jqj8AX2v8xVaW/I00gJD6JBs4XOZiKuq8Wm0tyPBxYiRXUkE/VmL2j3ZBULwhX0NDQVykZaxFBqhdNwUWwl2YQxSAVa+DfA5bEC1;25:amYvWmhAfd/+nA2jWw8qa4lBbUynwt2WOmDjZjYFhb/bh1eqiInOXvJIlbYrYE9m9LvaXLHFKMs+eBIAkJjjO4K7e15xNQL6cJCjPgeJiNJfRMiI134axhJF6ov+mVxh/TCgz5YYoTcSXon2VNN+hF7NIbQduG3y/AEUseo/OPqN3xUPKH0VWKwKNb5RcrvVuU+5bNK6LV3jSW3WP3AMmaDuObzSPOy19Ru5wzwsONl+xaaX4G5q/qkYhoLkX+n1LAD83tZaEZQrZWJPbQp9eJ+zWhBpe3f7YSlA/Q3apuJMITcE8ibprckswH8mgj6mNyqPbFR6vg8W+oVyr/1R0Q==;31:fsxXFnsGudpJQPXKVsFwK/SwSNsg1jcWiq4DJTQjbQ1Dwmq9liix5FyCXg6egQk6zv9MIr18X1VGaEplLXFjyNnRLCsCeKWKBWd4pKhCiKqN97hBlOuYJs5vE4JBIp/xoZrQSla78HszGf3jaTRbSld7eLtVeBOpJKU5o2kW9SxIMVx4T4IBlPAw4LUeKSiwgQRxZJUsKgS5AO2B034d0GmR/IvyIf9d2nEmznvUQeA= X-MS-TrafficTypeDiagnostic: VI1PR0801MB1343: X-Microsoft-Exchange-Diagnostics: 1;VI1PR0801MB1343;20:KDMAlQ9Bpm1/1+EjXukNpgYKrWuLiND68XTncnqWS9eRVFiH5EZqMAbCW1EB6tFQLD+tWpo2LBrsnU0ERaCKGxZl9tgrVtsYNNmq90fnotj6r2jF6HVn4qSLXC3rdc6mRW0BjqeYFCJLpamILcAS4tzTbBRVI15YiRGYs/liVefAI6/RvjF9UHienxt9/1a9fS33DnzBkawedvGfxe8mG62FLtMVvWvQq2Cdgn16hU/r/bDT3I/aBaXkt39Foghe7IleaJQ5EqMHeHoRaBD+ivZUEZ+hro2zouuPPHJKZRguQDiHFyt2j4an9kEw8nm9GmH+rFtZvnVcMUjgaUTT3wON9tIpTDHRJQH1+Y2lnfInygzckN/5f/AazeT3ND/2GSbbkyIj8ERtpmxLBqdSsz46qZK4G64r8reNDaBJrZJQQLQqUBA7f1zJEf04iL0iulL6jlCmyiqE5H4xDS9XTtL6GVwamJVR3qW+dDQR2ND+QbjJVxUXf9DxQMTGfE/f;4:FSWjyFYys/ikqmJI37PLssk0Z04g0TsqGuujVhgSezjpT90b01lq9s31oqOSheujDGmTB+uWd33mEEjAj88N9EqbnWNpJAJv6p7gZS7egLqaU1kgLcqauP89tkqxPdzfvreTFp/aHRZ7iT/35XJSUuF+rfOEH0C94CrfdYROA/4SvTcIf36/LQVOETubaUA5SnpoSdaUDIGyKFH8JnF8hSEJuHjEa0qlEsaI5KMZj2S9CTMvNRfK3MhDoYl8r2IwrOWJCbb7fJiIUYUyTfK4Jw== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040522)(2401047)(8121501046)(5005006)(3231221)(944501327)(52105095)(93006095)(93001095)(3002001)(10201501046)(6041310)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(20161123564045)(6072148)(201708071742011);SRVR:VI1PR0801MB1343;BCL:0;PCL:0;RULEID:;SRVR:VI1PR0801MB1343; X-Forefront-PRVS: 06237E4555 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(6049001)(376002)(39380400002)(396003)(346002)(366004)(39850400004)(199004)(189003)(52314003)(11346002)(6666003)(4326008)(25786009)(2616005)(446003)(956004)(7736002)(305945005)(58126008)(39060400002)(6246003)(36756003)(16526019)(105586002)(478600001)(7416002)(486005)(486005)(47776003)(53936002)(6916009)(230700001)(50466002)(2906002)(66066001)(65956001)(31696002)(316002)(81156014)(59450400001)(81166006)(8936002)(64126003)(76176011)(52116002)(65806001)(86362001)(65826007)(106356001)(55236004)(2486003)(52146003)(97736004)(26005)(5660300001)(6486002)(186003)(386003)(77096007)(53546011)(31686004)(68736007)(8676002)(16576012)(23676004)(229853002)(6116002)(3846002)(476003);DIR:OUT;SFP:1102;SCL:1;SRVR:VI1PR0801MB1343;H:[172.16.25.196];FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; Received-SPF: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtWSTFQUjA4MDFNQjEzNDM7MjM6NEJHQVkwSWNaVW9zUmF0RGVnL1l0bGpX?= =?utf-8?B?bGFxUythd0FYSFpMZXNnY0ZwbXp2NlQ0MFRYWFJOVXllQ2EzMC9JOVRvYVJI?= =?utf-8?B?aXNyMlY5T204VUdvNFhVTG9kdDZpZVhzS1ZISGg2bmpteW5palVxTkVBWnZs?= =?utf-8?B?MUc0cktsZTlpTy9kVXUvYU8xNXp2NTRKRlBUUCtBVE1mbllTQ3FWMUZvQmx4?= =?utf-8?B?R0FDNHlTTG9zcFRySHRuQjVUZ2t6NTQvY3phNXhxbkpHaGRpQ0pZOHd2VDlN?= =?utf-8?B?R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99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;VI1PR0801MB1343;7:XLJarluV16y9aVslf+BN1TgEswijpAmVQhBKIt4IFodpkrccnyzje8CqAWKS75wy8Y8UVDu2XzmjkmIiokqNgccfvfy/td14HqFFIZPMj2IhBPYcz2MBxmculiuhTNC4w5AM//3dZPctOFTHgzCo6R5Yyz6axCdiPq6M0uTako2DJsmzAaroDo4+DtOkDfvwsCNqTMq4SilHPhMZIZGiyrmMVNnXrFrhgEumonNm3Q2ULMMbB5BgoZXmYIGn3q1H;20:1gFLvpRZuRu7OhwiJvIv9ISFA1QWddg2J3LEMbAIIDvUefqjzNoxAH3zZ0tlk6JGYBtCZozy4WJBA0KSl3SLzAngNIpKsKT33T9vAr8Ret15pSxC+1pRqESIEjL97jI5GMHAmtTVaNROULTCIukpleZn0VFq0sAQ0IEaxWk8bbc= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Mar 2018 15:37:16.7274 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1465741a-2b1a-41d5-708f-08d5932f757a X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0801MB1343 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 24.03.2018 23:33, Vladimir Davydov wrote: > On Wed, Mar 21, 2018 at 04:23:01PM +0300, Kirill Tkhai wrote: >> To avoid further unneed calls of do_shrink_slab() >> for shrinkers, which already do not have any charged >> objects in a memcg, their bits have to be cleared. >> >> This patch introduces new return value SHRINK_EMPTY, >> which will be used in case of there is no charged >> objects in shrinker. We can't use 0 instead of that, >> as a shrinker may return 0, when it has very small >> amount of objects. >> >> To prevent race with parallel list lru add, we call >> do_shrink_slab() once again, after the bit is cleared. >> So, if there is a new object, we never miss it, and >> the bit will be restored again. >> >> The below test shows significant performance growths >> after using the patchset: >> >> $echo 1 > /sys/fs/cgroup/memory/memory.use_hierarchy >> $mkdir /sys/fs/cgroup/memory/ct >> $echo 4000M > /sys/fs/cgroup/memory/ct/memory.kmem.limit_in_bytes >> $for i in `seq 0 4000`; do mkdir /sys/fs/cgroup/memory/ct/$i; echo $$ > /sys/fs/cgroup/memory/ct/$i/cgroup.procs; mkdir -p s/$i; mount -t tmpfs $i s/$i; touch s/$i/file; done >> >> Then 4 drop_caches: >> $time echo 3 > /proc/sys/vm/drop_caches >> >> Times of drop_caches: >> >> *Before (4 iterations)* >> 0.00user 6.80system 0:06.82elapsed 99%CPU >> 0.00user 4.61system 0:04.62elapsed 99%CPU >> 0.00user 4.61system 0:04.61elapsed 99%CPU >> 0.00user 4.61system 0:04.61elapsed 99%CPU >> >> *After (4 iterations)* >> 0.00user 0.93system 0:00.94elapsed 99%CPU >> 0.00user 0.00system 0:00.01elapsed 80%CPU >> 0.00user 0.00system 0:00.01elapsed 80%CPU >> 0.00user 0.00system 0:00.01elapsed 81%CPU >> >> 4.61s/0.01s = 461 times faster. >> >> Signed-off-by: Kirill Tkhai >> --- >> fs/super.c | 3 +++ >> include/linux/shrinker.h | 1 + >> mm/vmscan.c | 21 ++++++++++++++++++--- >> mm/workingset.c | 3 +++ >> 4 files changed, 25 insertions(+), 3 deletions(-) >> >> diff --git a/include/linux/shrinker.h b/include/linux/shrinker.h >> index 24aeed1bc332..b23180deb928 100644 >> --- a/include/linux/shrinker.h >> +++ b/include/linux/shrinker.h >> @@ -34,6 +34,7 @@ struct shrink_control { >> }; >> >> #define SHRINK_STOP (~0UL) >> +#define SHRINK_EMPTY (~0UL - 1) > > Please update the comment below accordingly. Ok >> /* >> * A callback you can register to apply pressure to ageable caches. >> * >> diff --git a/mm/vmscan.c b/mm/vmscan.c >> index e1fd16bc7a9b..1fc05e8bde04 100644 >> --- a/mm/vmscan.c >> +++ b/mm/vmscan.c >> @@ -387,6 +387,7 @@ void set_shrinker_bit(struct mem_cgroup *memcg, int nid, int nr) >> { >> struct shrinkers_map *map = SHRINKERS_MAP(memcg); >> >> + smp_mb__before_atomic(); /* Pairs with mb in shrink_slab() */ > > I don't understand the purpose of this barrier. Please add a comment > explaining why you need it. Ok >> set_bit(nr, map->map[nid]); >> } >> #else /* CONFIG_MEMCG && !CONFIG_SLOB */ >> @@ -568,8 +569,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 >> @@ -708,6 +709,7 @@ static unsigned long shrink_slab(gfp_t gfp_mask, int nid, >> #if defined(CONFIG_MEMCG) && !defined(CONFIG_SLOB) >> if (!memcg_kmem_enabled() || memcg) { >> struct shrinkers_map *map; >> + unsigned long ret; >> int i; >> >> map = rcu_dereference_protected(SHRINKERS_MAP(memcg), true); >> @@ -724,7 +726,20 @@ static unsigned long shrink_slab(gfp_t gfp_mask, int nid, >> clear_bit(i, map->map[nid]); >> continue; >> } >> - freed += do_shrink_slab(&sc, shrinker, priority); >> + if (!(shrinker->flags & SHRINKER_NUMA_AWARE)) >> + sc.nid = 0; > > Hmm, if my memory doesn't fail, in the previous patch you added a BUG_ON > ensuring that a memcg-aware shrinker must also be numa-aware while here > you still check it. Please remove the BUG_ON or remove this check. > Better remove the BUG_ON, because a memcg-aware shrinker doesn't have to > be numa-aware. Really, we do not introduce new limitations, so it's need to just remove the BUG_ON. Will do in v2. > >> + ret = do_shrink_slab(&sc, shrinker, priority); >> + if (ret == SHRINK_EMPTY) { > > do_shrink_slab() is also called for memcg-unaware shrinkers, you should > probably handle SHRINK_EMPTY there as well. Ok, it looks like we just need to return 0 instead of SHRINK_EMPTY in such cases. >> + clear_bit(i, map->map[nid]); >> + /* pairs with mb in set_shrinker_bit() */ >> + smp_mb__after_atomic(); >> + ret = do_shrink_slab(&sc, shrinker, priority); >> + if (ret == SHRINK_EMPTY) >> + ret = 0; >> + else >> + set_bit(i, map->map[nid]); > > Well, that's definitely a tricky part and hence needs a good comment. > > Anyway, it would be great if we could simplify this part somehow. Ok, I'll add some cleanup preparations for that. >> + } >> + freed += ret; >> >> if (rwsem_is_contended(&shrinker_rwsem)) { >> freed = freed ? : 1; Thanks, Kirill