Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp310643imm; Tue, 15 May 2018 01:56:50 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrZhhsJ+B+fgXFAAy6yAhYpGQ9MzSR1zzjzGXuyixLYk233g3sI/J3RzbcqDLmBTlq+1+hi X-Received: by 2002:a62:f20d:: with SMTP id m13-v6mr14279118pfh.170.1526374610556; Tue, 15 May 2018 01:56:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526374610; cv=none; d=google.com; s=arc-20160816; b=0y8f82N26FEDAM/QL+tMIG0bqJD9BewWA8cpczSfi8chvRBuoc5nIWuJYmWg7KEOfw z2lFmD/UGk0yMQ3DvStUEgoN02ThQnC59bIwhNNaVgYtO8rlvB9cWY21zDbTXiyuI2mq k+V9sDIpMh7SLNxnVb/AFQWVxdOmuAJZgYBnFK6k6CcgGGzPpD5/Ghwg+FE78oBS4Zbt BQFWQIKaxfxhxCXghmwJ+7ve8Y1xl6in+O6bNrIaNiDRDRdBsM4e2YHeIpKcckbPrwHz eEuAFvXJ9NOf8dYsFzv0f0WEIzTUk8Ijg+CgIBlyTuBuRXi0N+NsuxK/3yekrIdma9nH WhGg== 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=66Q0aknQ4S6ml1i8YaeKf+yl+bVU4pWqOzta8d/g7+I=; b=NoG6tN08TfciXpXG9m6qcCWLn4QZhYpXc/4qgx08QuKSwQf5BHjL/n8iPtBeL7p4EG BXcUP3tz+NdnRtiJWv66dB1BT8tYECMjpJYDLHDqvDCP+VJy2dGZKnKUxuOHHzw2+O1W W4cXo1Xw2RzmhWLmpsQBTQB+91z04owgnpG3nrR9NFlgNfkEDDwQuMAuDxMKgapn7PEx 19nRT0iA1t/CXfa66F9DNgEp9BKcVPpq2q/2Af+CAUh7Fm3VGho4YK/Vkr5rMe0nu7sS zJgNsj3Z6qoxGGkkj51ZZD9hN0RstaEI6jFDbclUr1LvKrA4bfI6BijkEAcVHv6Hz63f bkxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=selector1 header.b=Mdv+gLy6; 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 n2-v6si6021368pgv.618.2018.05.15.01.56.35; Tue, 15 May 2018 01:56: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=Mdv+gLy6; 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 S1752576AbeEOIzS (ORCPT + 99 others); Tue, 15 May 2018 04:55:18 -0400 Received: from mail-he1eur01on0094.outbound.protection.outlook.com ([104.47.0.94]:63943 "EHLO EUR01-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752547AbeEOIzM (ORCPT ); Tue, 15 May 2018 04:55:12 -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=66Q0aknQ4S6ml1i8YaeKf+yl+bVU4pWqOzta8d/g7+I=; b=Mdv+gLy6+L6cUrnnftWYEpwUEodOJ43gAm9xVjeqTyYyqO5+UGbd8LWsTTOA2G4Iz5FuAAN1e3C3pPA/NIfqP/iDZgBIQDT1nso3KC9EJMvq9WBZCGjBgr23+UY7J1Vw2/6v5ykPlW/pExRydReKnmYBl6WgdI3N6301YZhM0iA= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=ktkhai@virtuozzo.com; Received: from [172.16.25.5] (195.214.232.6) by HE1PR0801MB1337.eurprd08.prod.outlook.com (2603:10a6:3:39::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.755.16; Tue, 15 May 2018 08:55:07 +0000 Subject: Re: [PATCH v5 13/13] mm: Clear shrinker bit if there are no objects related to memcg To: Vladimir Davydov Cc: akpm@linux-foundation.org, shakeelb@google.com, viro@zeniv.linux.org.uk, hannes@cmpxchg.org, mhocko@kernel.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, 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 References: <152594582808.22949.8353313986092337675.stgit@localhost.localdomain> <152594605549.22949.16491037134168999424.stgit@localhost.localdomain> <20180515055913.alk3pau43e3jps3y@esperanza> From: Kirill Tkhai Message-ID: <1e31235c-f4e3-1046-57c8-741de095e616@virtuozzo.com> Date: Tue, 15 May 2018 11:55:04 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180515055913.alk3pau43e3jps3y@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: AM0PR06CA0058.eurprd06.prod.outlook.com (2603:10a6:208:aa::35) To HE1PR0801MB1337.eurprd08.prod.outlook.com (2603:10a6:3:39::27) X-MS-PublicTrafficType: Email X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(5600026)(2017052603328)(7153060)(7193020);SRVR:HE1PR0801MB1337; X-Microsoft-Exchange-Diagnostics: 1;HE1PR0801MB1337;3:Uuw9lrnlvR81PKxYmEEcWbxgWWxfzhmsByNV6R4jmYeHeyztf8cVmME/ImWbq3aKMheAROGMzOoa4tpYwZL7zF9hf7+fpAiA73Dp4422L7oT3BQ7qmwq4UGrHKIl8rbsF89mlywxwM3t95uVKPmbQIJm+om6ynE8vk4nftktwP5DPG3gnYRmWDRc3fPQVNDTn75WvqtAF6RIj1XpYsJ8o1qHtFj+0l3+LR69Kj0YepsvzH+aw5ZlJp+TrUh+K1E7;25:H5CsmB5PVkMyw7EQ2N7P8BQQSwvfBoO28Ic9YuQFTBxwGfyIGaE0WaUhFtXGC3PicViNiYjhjZeqZ3JgKUEQsbAqwXJ7fO5pKck8RMkKSXxsl3xbDiDNR5TflNcanw8e1dljRMa/5dSkauLR++9WK2FHtXwL6YBd/w71XLwLkJ/jgdU8m9sh26qczk+PQ3OQ2HitNsOSQlyiqA1hp3/4YQngf4PVVQCfCrrwHr5hL4uU2Em101JYbMrW7lZ1RJT2SvlqLp5Ym6GHzODPuhVVcbJM1GVHxfny2JLfDpMkLD78SHWnfN0hdsf2suPBQbD6awB4GCmDxOJ2oka3RuUMaw==;31:2DzLBJipUBM9Fkjkz0PlCVRQ0MmX2Y3PD6QBQAT1g8DE2IjWUDJgKSdHopSn1c6QjZ8tAz6U3KpdIkP/LXyYt3vYe8qi6RZOevMDWVH1edT21MNMPMLVNImdIbSZyz2+zofHX2mgFJOUY2Uxu1P+Qg+q/rkIUD5Rjj7MvuTGbAVHRBlmQ+XUnwfjNWB81f72HzLO997dEqcfWyzYmNWu7ZIhB752V2d41J+99s4Cask= X-MS-TrafficTypeDiagnostic: HE1PR0801MB1337: X-Microsoft-Exchange-Diagnostics: 1;HE1PR0801MB1337;20:C0cCAFPu5kSJPlS+EaAcRXJJi8263FvM8zW76mnZsifScgD0WAcy14Z4zUqQGS/gq0WYnRnBdvLggnoE8zoZF0ZKX7ag9hAgXo89/cvBb6ZtgNFMMcDvqYmBmAlQfBdLNpNTbVinsWcpvg73qq7FQKfusDq5p6mxJoXN78pQiF1MUUc3er73P9sM0VzrHA1SFl2MhnnIoB30yHjtlfw+Qftt4QJk6s6rJo+a0GaNOHcOKD4Cfurei4OtW1gmuYM+LMErVtRn6nojb1vSiCOpfGLuIBINLSI9arEVWsTcicFOsfMdD/tBlSQPoFffCGJih8DytFZ7sxwvo5yOgvrRsMIUxJOxXYQ+FIqVVz0YT8hkBuc6tNuWB4lLejXdjtmbFE6ntsWlQkZspF/m9/S9a5UKOXL+8dvLTIb0dSRgUQ5HfbqaVrtrTWOSnFfzyfTpIcTa17Gln6h8czQtpOygQIdUmioVwz8z+LHtLUCF+MDF/7jf6fAgEWWEQIXEy7jm;4:UeQ89AZ+B95ov3Q7XAAq3hKS0zIagB109ScbAGg6ub32w3BfsjWeEnuNPN4IcPbzXheJooZ8CYQwsnRTziDCtKMbHX5/D/a2ASNH+F+Ry3gEO58WbbvxXl1dOLdsmioOen92j+wDQfGgkBFRZx5aVRELINQfmsEYRdmHdUMWV6WJkQrncIlv1C7o8qaCvNp19LWlhsPaHCZHSJ5ys/jics8VXA5xmdaUsWjmGf9XrkFrWs+iW6Zr+Lsr3eO8lt8CPqLf0VrkbuKoSZQkLLahwA== 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)(3002001)(10201501046)(93006095)(93001095)(3231254)(944501410)(52105095)(149027)(150027)(6041310)(20161123560045)(20161123558120)(20161123564045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:HE1PR0801MB1337;BCL:0;PCL:0;RULEID:;SRVR:HE1PR0801MB1337; X-Forefront-PRVS: 0673F5BE31 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(6049001)(39850400004)(346002)(376002)(366004)(39380400002)(396003)(189003)(199004)(53936002)(478600001)(16576012)(305945005)(39060400002)(4326008)(107886003)(3846002)(50466002)(229853002)(6246003)(6116002)(5660300001)(64126003)(956004)(97736004)(36756003)(476003)(81156014)(65826007)(81166006)(53546011)(8936002)(230700001)(11346002)(16526019)(2616005)(7736002)(6666003)(386003)(68736007)(26005)(58126008)(2906002)(65956001)(65806001)(31686004)(59450400001)(6486002)(8676002)(6916009)(575784001)(86362001)(52116002)(446003)(106356001)(31696002)(66066001)(77096007)(7416002)(2486003)(316002)(486006)(23676004)(76176011)(47776003)(105586002)(25786009)(52146003);DIR:OUT;SFP:1102;SCL:1;SRVR:HE1PR0801MB1337;H:[172.16.25.5];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?MTtIRTFQUjA4MDFNQjEzMzc7MjM6S0libzh4RGFaa1lERlN3c3orQ0lWTCtS?= =?utf-8?B?SXJFbWpqMmEyYUJ6SERmVHcwN05abUZkeVVmcFJ6TmJXQnZTdDhOK3E2S0xi?= =?utf-8?B?b0ZPV2ZqTzA2cVpSN0V3RFRVdUtLZ2U1Wldta1NMRk5ZYWF1cDVNWUxKWkI0?= =?utf-8?B?cEk3dXAydGJQVGJMOEhYbWFwR0JOK1VJOCt5NDJWTSswREJKek5qQnhuQlFL?= =?utf-8?B?aEJjN04zdFAvell2N21MYUEyZU9Eai9GRFhkbUZHWStI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oft-Antispam-Message-Info: oY27gh6Md58bMeRjgn2SAeXwLAg9F+pAH9oo/2Sg2F96USkktElgBw5SBeNNm9UxMvFoJEiU5IsSrrCpmts1OeRD/V5ftV4GZzyPbWb/TbHHGyc0d1t1D6faTA46FRPwC/u3xV2hMJrdHHYHYusQvSDYs//fkS/9lnq6BZoNrStRkxrcUqBf36xUM016UGyt X-Microsoft-Exchange-Diagnostics: 1;HE1PR0801MB1337;6:thWdRoNk2vCNew4xp0BEUyqTFxUsi9Ugn9nn4DxR247tvKy/3ne7J+nNfmR3JQIEqJzgW+Wv4HAvRj2R100EwQI5h+ELfUIdJipUivAz/PwsA34gCfUthqz89HUuUoW5E8O3ech3i/hmjdSfxEuC2nty5tks3z2qxKCYm6U1D8pHKL14fSbXFzbFmhzyfUyepV5zwvbNUv8aF9jKLiOlIs0Bd+r7qWdHF2RWz4DcZCLh4oVZ/cFQ5yvJXbo8vpn2TkkdfFduuOrJMR3PcuCBn3nxAKGpUYb0iT3nJHj6Qf8h3GT7ZKfKy8Wyat8kn/pRF1unAKR6uXJAAh33h9VVTmdFX+9Gp35zFfyp69W47MLfuQGykwEmMnmcQb06rouRY7IyZ29w8wv1PbWj5Dm9SwOHXvsQ1GsjMcn1lbuYn+I47GkaJHbtL510YsZ8lXLmBVv6zhFIPIdkht/2ddR9lw==;5:yhNVIBaH5uvg6HrQiTvzJtebmyIM4QsN9bMz1z0DD+cR6eibx0mY7H6ZP+ZNxPVFThWWe09T+HrNQb3JxUJ6AMsipVnFEQTIxLaFAuEnPAcJe2U9J+EjzY5CXp8IQCf6ZSZX0k5gn2oJiDRJc0HPXWiaUJztwNaFBQ0zuUQ424o=;24:yDMRHsmj+hWb9Nw838WTsOQ36IUO97YWJzXdxgeKrM06ht7LkZ3oVNplwp7gUw2/uz/SJm+aLZ3CGmdBuifYfEzRpoxtBlFrcHRyl3dNgao= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;HE1PR0801MB1337;7:61gGsoeqgrlqjt8+Jetx5uQaPJD5jB1y8w9jipv/MKAtpq4X9YO+/bye2NwLAON+Mchuz0k4LUDW3djbwe3XccZ6yGIRtXiAkv+i5FOtyemumh1+R2Kj+oHY/BxLzgYpvPiSXWArlUhbL+jOHf3tmKrP6i2Yh2mx5BGY95LsxogeJfSJYYOHJCPwzjTBTbKCdCboKBT5if632mhacwEcaw5nULLCE/P2n6kdVWQZPIcEXEcMonVDY6nV9mMdyDdW;20:/4q1eWkVa/VDrS9hTYUh/vE8Z5QjuQ7D2jVTTwxEH6Dp90SfGV9N6ZQ77F7728m+D2IXnlXb1wpoAIDaFhj+iXw2zPmPifKQGfHly3TDSVuv5Y7IhErHQ0OYPvUQhiP3WWSU03OYeSy6RhajRhIddswd3Eh0uCSnulgWVyPd+b4= X-MS-Office365-Filtering-Correlation-Id: fbe09e8d-aa88-4582-be66-08d5ba419017 X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2018 08:55:07.3251 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fbe09e8d-aa88-4582-be66-08d5ba419017 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0801MB1337 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 15.05.2018 08:59, Vladimir Davydov wrote: > On Thu, May 10, 2018 at 12:54:15PM +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 a lockless mechanism to do that >> without races without parallel list lru add. After >> do_shrink_slab() returns SHRINK_EMPTY the first time, >> we clear the bit and call it once again. Then we restore >> the bit, if the new return value is different. >> >> Note, that single smp_mb__after_atomic() in shrink_slab_memcg() >> covers two situations: >> >> 1)list_lru_add() shrink_slab_memcg >> list_add_tail() for_each_set_bit() <--- read bit >> do_shrink_slab() <--- missed list update (no barrier) >> >> set_bit() do_shrink_slab() <--- seen list update >> >> This situation, when the first do_shrink_slab() sees set bit, >> but it doesn't see list update (i.e., race with the first element >> queueing), is rare. So we don't add before the first call >> of do_shrink_slab() instead of this to do not slow down generic >> case. Also, it's need the second call as seen in below in (2). >> >> 2)list_lru_add() shrink_slab_memcg() >> list_add_tail() ... >> set_bit() ... >> ... for_each_set_bit() >> do_shrink_slab() do_shrink_slab() >> clear_bit() ... >> ... ... >> list_lru_add() ... >> list_add_tail() clear_bit() >> >> set_bit() do_shrink_slab() >> >> The barriers guarantees, the second do_shrink_slab() >> in the right side task sees list update if really >> cleared the bit. This case is drawn in the code comment. >> >> [Results/performance of the patchset] >> >> After the whole patchset applied the below test shows signify >> increase of performance: >> >> $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, 5 sequential calls of drop caches: >> $time echo 3 > /proc/sys/vm/drop_caches >> >> 1)Before: >> 0.00user 13.78system 0:13.78elapsed 99%CPU >> 0.00user 5.59system 0:05.60elapsed 99%CPU >> 0.00user 5.48system 0:05.48elapsed 99%CPU >> 0.00user 8.35system 0:08.35elapsed 99%CPU >> 0.00user 8.34system 0:08.35elapsed 99%CPU >> >> 2)After >> 0.00user 1.10system 0:01.10elapsed 99%CPU >> 0.00user 0.00system 0:00.01elapsed 64%CPU >> 0.00user 0.01system 0:00.01elapsed 82%CPU >> 0.00user 0.00system 0:00.01elapsed 64%CPU >> 0.00user 0.01system 0:00.01elapsed 82%CPU >> >> The results show the performance increases at least in 548 times. >> >> Signed-off-by: Kirill Tkhai >> --- >> include/linux/memcontrol.h | 2 ++ >> mm/vmscan.c | 19 +++++++++++++++++-- >> 2 files changed, 19 insertions(+), 2 deletions(-) >> >> diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h >> index 436691a66500..82c0bf2d0579 100644 >> --- a/include/linux/memcontrol.h >> +++ b/include/linux/memcontrol.h >> @@ -1283,6 +1283,8 @@ static inline void memcg_set_shrinker_bit(struct mem_cgroup *memcg, int nid, int >> >> rcu_read_lock(); >> map = MEMCG_SHRINKER_MAP(memcg, nid); >> + /* Pairs with smp mb in shrink_slab() */ >> + smp_mb__before_atomic(); >> set_bit(nr, map->map); >> rcu_read_unlock(); >> } >> diff --git a/mm/vmscan.c b/mm/vmscan.c >> index 7b0075612d73..189b163bef4a 100644 >> --- a/mm/vmscan.c >> +++ b/mm/vmscan.c >> @@ -586,8 +586,23 @@ 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; >> + if (ret == SHRINK_EMPTY) { >> + clear_bit(i, map->map); >> + /* >> + * Pairs with mb in memcg_set_shrinker_bit(): >> + * >> + * list_lru_add() shrink_slab_memcg() >> + * list_add_tail() clear_bit() >> + * >> + * set_bit() do_shrink_slab() >> + */ > > Please improve the comment so that it isn't just a diagram. Please, say, which comment you want to see here. >> + smp_mb__after_atomic(); >> + ret = do_shrink_slab(&sc, shrinker, priority); >> + if (ret == SHRINK_EMPTY) >> + ret = 0; >> + else >> + memcg_set_shrinker_bit(memcg, nid, i); >> + } >> freed += ret; >> >> if (rwsem_is_contended(&shrinker_rwsem)) { >>