From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5AE1EC2BD09 for ; Thu, 5 Dec 2019 10:11:28 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 24DEC2464D for ; Thu, 5 Dec 2019 10:11:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 24DEC2464D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C13616B0F9E; Thu, 5 Dec 2019 05:11:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B76B26B0F9F; Thu, 5 Dec 2019 05:11:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A3ECC6B0FA0; Thu, 5 Dec 2019 05:11:27 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0206.hostedemail.com [216.40.44.206]) by kanga.kvack.org (Postfix) with ESMTP id 8B40A6B0F9E for ; Thu, 5 Dec 2019 05:11:27 -0500 (EST) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id 2ACC8181AEF31 for ; Thu, 5 Dec 2019 10:11:27 +0000 (UTC) X-FDA: 76230670614.05.boy25_63ea937db9a44 X-HE-Tag: boy25_63ea937db9a44 X-Filterd-Recvd-Size: 4199 Received: from relay.sw.ru (relay.sw.ru [185.231.240.75]) by imf14.hostedemail.com (Postfix) with ESMTP for ; Thu, 5 Dec 2019 10:11:26 +0000 (UTC) Received: from dhcp-172-16-24-104.sw.ru ([172.16.24.104]) by relay.sw.ru with esmtp (Exim 4.92.3) (envelope-from ) id 1ico6R-0005qE-In; Thu, 05 Dec 2019 13:11:19 +0300 Subject: Re: [PATCH] mm: vmscan: protect shrinker idr replace with CONFIG_MEMCG From: Kirill Tkhai To: Michal Hocko Cc: Yang Shi , hannes@cmpxchg.org, shakeelb@google.com, guro@fb.com, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <1575486978-45249-1-git-send-email-yang.shi@linux.alibaba.com> <20191205094341.GC28317@dhcp22.suse.cz> <894b9951-449d-6d7e-84aa-a1c510417710@virtuozzo.com> Message-ID: <80918583-da44-71f0-8c94-224a3268577c@virtuozzo.com> Date: Thu, 5 Dec 2019 13:11:19 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <894b9951-449d-6d7e-84aa-a1c510417710@virtuozzo.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 05.12.2019 13:00, Kirill Tkhai wrote: > On 05.12.2019 12:43, Michal Hocko wrote: >> On Thu 05-12-19 11:23:28, Kirill Tkhai wrote: >>> On 04.12.2019 22:16, Yang Shi wrote: >>>> Since commit 0a432dcbeb32edcd211a5d8f7847d0da7642a8b4 ("mm: shrinker: >>>> make shrinker not depend on memcg kmem"), shrinkers' idr is protected by >>>> CONFIG_MEMCG instead of CONFIG_MEMCG_KMEM, so it makes no sense to >>>> protect shrinker idr replace with CONFIG_MEMCG_KMEM. >>>> >>>> Cc: Kirill Tkhai >>>> Cc: Johannes Weiner >>>> Cc: Michal Hocko >>>> Cc: Shakeel Butt >>>> Cc: Roman Gushchin >>>> Signed-off-by: Yang Shi >>> >>> It looks like that in CONFIG_SLOB case we do not even call some shrinkers >>> for subordinate mem cgroups (i.e., we don't call deferred_split_shrinker), >>> since they never become completely registered. >>> >>> Fixes: 0a432dcbeb32edcd211a5d8f7847d0da7642a8b4 ("mm: shrinker: make shrinker not depend on memcg kmem") >> >> I am confused. Why the Fixes tag? Nothing should be really broken with >> KMEM config guard right? > > idr_replace() is disabled in CONFIG_MEMCG && CONFIG_SLOB case, and this is > wrong. > > 0a432dcbeb32edcd211a5d8f7847d0da7642a8b4 goes in the series, which enables > shrinker_idr infrastructure for huge_memory.c's deferred_split_shrinker > in CONFIG_MEMCG case. Previously, all SHRINKER_MEMCG_AWARE shrinkers were > based on LRUs, and they remain to base of CONFIG_MEMCG_KMEM. > But deferred_split_shrinker is an exception. > > In CONFIG_MEMCG && CONFIG_SLOB case, shrinker_idr contains only shrinker, > and it is deferred_split_shrinker. But it is never actually called, since > idr_replace() is never compiled. deferred_split_shrinker all the time is > staying in half-registered state, and it's never called for subordinate > mem cgroups. > > So, this is a BUG, and this should go to stable. The visible effect is that deferred_split_shrinker is never called from shrink_slab() for subordinate mem cgroups. It's called only for root_mem_cgroup. >> This is a mere clean up AFAICS. >> >>> Reviewed-by: Kirill Tkhai >>> >>>> --- >>>> mm/vmscan.c | 2 +- >>>> 1 file changed, 1 insertion(+), 1 deletion(-) >>>> >>>> diff --git a/mm/vmscan.c b/mm/vmscan.c >>>> index ee4eecc..e7f10c4 100644 >>>> --- a/mm/vmscan.c >>>> +++ b/mm/vmscan.c >>>> @@ -422,7 +422,7 @@ void register_shrinker_prepared(struct shrinker *shrinker) >>>> { >>>> down_write(&shrinker_rwsem); >>>> list_add_tail(&shrinker->list, &shrinker_list); >>>> -#ifdef CONFIG_MEMCG_KMEM >>>> +#ifdef CONFIG_MEMCG >>>> if (shrinker->flags & SHRINKER_MEMCG_AWARE) >>>> idr_replace(&shrinker_idr, shrinker, shrinker->id); >>>> #endif >>>> >> >