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=unavailable 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 C827FC43461 for ; Thu, 6 May 2021 16:02:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4046161078 for ; Thu, 6 May 2021 16:02:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4046161078 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 57C306B006E; Thu, 6 May 2021 12:02:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 52D006B0070; Thu, 6 May 2021 12:02:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3CDD96B0072; Thu, 6 May 2021 12:02:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 226B46B006E for ; Thu, 6 May 2021 12:02:48 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id D13E2181AEF1D for ; Thu, 6 May 2021 16:02:47 +0000 (UTC) X-FDA: 78111274374.17.AAF59DC Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf17.hostedemail.com (Postfix) with ESMTP id 86294407F8FE for ; Thu, 6 May 2021 16:02:42 +0000 (UTC) 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 Authentication-Results: imf17.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf17.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.15 as permitted sender) smtp.mailfrom=vbabka@suse.cz X-Stat-Signature: hpf5rw1959jj7ushuiz78yhjmtzbxwh7 X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 86294407F8FE Received-SPF: none (suse.cz>: No applicable sender policy available) receiver=imf17; identity=mailfrom; envelope-from=""; helo=mx2.suse.de; client-ip=195.135.220.15 X-HE-DKIM-Result: none/none X-HE-Tag: 1620316962-714453 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 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; > } > > /* >