Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp1659584pxy; Thu, 6 May 2021 12:34:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwym3ty/D4ZZCRi8+8XuMP9r5+LbKQSPpiCbH+ur+ti0FmMFoLF0hzZ2FnHUfX9RrBJwkSn X-Received: by 2002:a62:6481:0:b029:249:ecee:a05d with SMTP id y123-20020a6264810000b0290249eceea05dmr6453529pfb.9.1620329656780; Thu, 06 May 2021 12:34:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620329656; cv=none; d=google.com; s=arc-20160816; b=lSPRmBY++YE89AvrBwlEtxW5R4+8cn/pz4lMJif3R/8lNymNvhdyHqoOlWMscgP7q3 gZwVhD0N6Mlqj7AegWjSbhuBytU9M36XR14Ogh4GGm4Pmcnjz34A1Y/TPEynTNIpUVbE 3XYtWnJc8+tTztR3QNhkclxQq3eM5rcnU02EfJMLPO/NpZixkwx7zTmNhvY8XjWqLikX vHbKnYSOaJr2MTsd70FpGZYmOo0maKSTyyteLgpILvrFzwxWeTjKX2LkEFNeJbnfUoYf 3C1mdzGeGFfA2/T+Zv+01cfIoHaXV3KiGIZ0mTNTAt+qcYygkmjPQM0lHnYZ7La9L1TS i57A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=XbNbTYhWlyoDtNSU4EYWeOdiTYQsNVH6dzvu0tRpvT4=; b=sCvdEJcYwKmFZXcSxRITij0OW42xKJDknjOj3AuLyWs5C+ajgDtd3Ynj8mxck/C8ht G2TkM+vRKwo/mlDowJQw56KTrcIFL57ub5knDTh0hE+WwYEn8Dov/C68bkppXFO3laG3 k2+UhyCiKMs5ALKP9KWD9bv5LksaU86Pk9mO5G/LU2WbABJPbFFiOKzGdLx/mp8IpvOR 48F8LNjQntzSU1cM4N/GkFTwcISEt143cbHPco+DEtbZAgi/JVUL79Ly5uAG0JhuMoMS rV5AWbrg939tVtTVl2PRWs2cvvrL3FM86YgMrsG1kywe/SHmXnx5OCIWiS4IIq4LeH6e Ov/Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l9si4094244pjc.108.2021.05.06.12.33.55; Thu, 06 May 2021 12:34:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235668AbhEFQDq (ORCPT + 99 others); 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; > } > > /* >