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=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,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 CC632C43462 for ; Thu, 6 May 2021 16:02:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 93D1761104 for ; Thu, 6 May 2021 16:02:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235715AbhEFQDq (ORCPT ); Thu, 6 May 2021 12:03:46 -0400 Received: from mx2.suse.de ([195.135.220.15]:60230 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235176AbhEFQDp (ORCPT ); Thu, 6 May 2021 12:03:45 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 2E60BB1DE; Thu, 6 May 2021 16:02:46 +0000 (UTC) Subject: Re: [PATCH v4 3/3] mm: memcg/slab: Disable cache merging for KMALLOC_NORMAL caches To: Waiman Long , Johannes Weiner , Michal Hocko , Vladimir Davydov , Andrew Morton , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Roman Gushchin , Shakeel Butt Cc: linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org References: <20210505200610.13943-1-longman@redhat.com> <20210505200610.13943-4-longman@redhat.com> From: Vlastimil Babka Message-ID: <83135334-f85e-b587-82fe-1875de602f53@suse.cz> Date: Thu, 6 May 2021 18:02:45 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 In-Reply-To: <20210505200610.13943-4-longman@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/5/21 10:06 PM, Waiman Long wrote: > The KMALLOC_NORMAL (kmalloc-) caches are for unaccounted objects only > when CONFIG_MEMCG_KMEM is enabled. To make sure that this condition > remains true, we will have to prevent KMALOC_NORMAL caches to merge > with other kmem caches. This is now done by setting its refcount to -1 > right after its creation. > > Suggested-by: Roman Gushchin > Signed-off-by: Waiman Long Reviewed-by: Vlastimil Babka (outside of scope of this patch/series, we should later replace this refcount ugliness with a proper slab flag) > --- > mm/slab_common.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/mm/slab_common.c b/mm/slab_common.c > index bbaf41a7c77e..a0ff8e1d8b67 100644 > --- a/mm/slab_common.c > +++ b/mm/slab_common.c > @@ -841,6 +841,13 @@ new_kmalloc_cache(int idx, enum kmalloc_cache_type type, slab_flags_t flags) > kmalloc_info[idx].name[type], > kmalloc_info[idx].size, flags, 0, > kmalloc_info[idx].size); > + > + /* > + * If CONFIG_MEMCG_KMEM is enabled, disable cache merging for > + * KMALLOC_NORMAL caches. > + */ > + if (IS_ENABLED(CONFIG_MEMCG_KMEM) && (type == KMALLOC_NORMAL)) > + kmalloc_caches[type][idx]->refcount = -1; > } > > /* > From mboxrd@z Thu Jan 1 00:00:00 1970 From: Vlastimil Babka Subject: Re: [PATCH v4 3/3] mm: memcg/slab: Disable cache merging for KMALLOC_NORMAL caches Date: Thu, 6 May 2021 18:02:45 +0200 Message-ID: <83135334-f85e-b587-82fe-1875de602f53@suse.cz> References: <20210505200610.13943-1-longman@redhat.com> <20210505200610.13943-4-longman@redhat.com> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20210505200610.13943-4-longman-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> Content-Language: en-US List-ID: Content-Type: text/plain; charset="us-ascii" To: Waiman Long , Johannes Weiner , Michal Hocko , Vladimir Davydov , Andrew Morton , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Roman Gushchin , Shakeel Butt Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org On 5/5/21 10:06 PM, Waiman Long wrote: > The KMALLOC_NORMAL (kmalloc-) caches are for unaccounted objects only > when CONFIG_MEMCG_KMEM is enabled. To make sure that this condition > remains true, we will have to prevent KMALOC_NORMAL caches to merge > with other kmem caches. This is now done by setting its refcount to -1 > right after its creation. > > Suggested-by: Roman Gushchin > Signed-off-by: Waiman Long Reviewed-by: Vlastimil Babka (outside of scope of this patch/series, we should later replace this refcount ugliness with a proper slab flag) > --- > mm/slab_common.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/mm/slab_common.c b/mm/slab_common.c > index bbaf41a7c77e..a0ff8e1d8b67 100644 > --- a/mm/slab_common.c > +++ b/mm/slab_common.c > @@ -841,6 +841,13 @@ new_kmalloc_cache(int idx, enum kmalloc_cache_type type, slab_flags_t flags) > kmalloc_info[idx].name[type], > kmalloc_info[idx].size, flags, 0, > kmalloc_info[idx].size); > + > + /* > + * If CONFIG_MEMCG_KMEM is enabled, disable cache merging for > + * KMALLOC_NORMAL caches. > + */ > + if (IS_ENABLED(CONFIG_MEMCG_KMEM) && (type == KMALLOC_NORMAL)) > + kmalloc_caches[type][idx]->refcount = -1; > } > > /* >