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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id EE4B7C433EF for ; Wed, 15 Jun 2022 08:37:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8CC176B0072; Wed, 15 Jun 2022 04:37:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 87B376B0073; Wed, 15 Jun 2022 04:37:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 743526B0074; Wed, 15 Jun 2022 04:37:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 661316B0072 for ; Wed, 15 Jun 2022 04:37:03 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 34F56203CE for ; Wed, 15 Jun 2022 08:37:03 +0000 (UTC) X-FDA: 79579815126.18.2A5FE59 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf17.hostedemail.com (Postfix) with ESMTP id 8F25D40084 for ; Wed, 15 Jun 2022 08:37:02 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 130E81F9C1; Wed, 15 Jun 2022 08:37:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1655282221; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=343BjbVrfUTKzzHDVLHqseRRkhRTJ4iUhaXrlwxZiWE=; b=JwS6DDQX2RGdWgg0Cr+sejnqN8TPFxcewf3S4wQLVCY4BGU/41MNiYN2FCE6z18JOzilWD W45AYhEcyQrMsjs0fM/CMhjq7EH6I1mF+xZ/tK6bRmysCweEJUenLegEmxe6FL4YlcxJlH ZUlKLtTg1qFYTwTNaGYBW2MnZoXCn/U= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1655282221; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=343BjbVrfUTKzzHDVLHqseRRkhRTJ4iUhaXrlwxZiWE=; b=WK++0ZKoz4bR/QN29E/RMdgJnhuI7sQDFR6aJSRw5PlQuB+oWybsAOvl0tMPyjTzeIz+E3 O9n8exw0hoMEUlAw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id DAD2013A35; Wed, 15 Jun 2022 08:37:00 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id a3PQNCyaqWJRKQAAMHmgww (envelope-from ); Wed, 15 Jun 2022 08:37:00 +0000 Message-ID: Date: Wed, 15 Jun 2022 10:37:00 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: Re: [PATCH v2] mm/slub: Simplify __kmem_cache_alias() Content-Language: en-US To: Xiongwei Song , Hyeonggon Yoo <42.hyeyoo@gmail.com> Cc: Xiongwei Song , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Roman Gushchin , Muchun Song , "linux-mm @ kvack . org" , Linux Kernel Mailing List , Xiongwei Song References: <20220603143555.41914-1-sxwjean@me.com> From: Vlastimil Babka In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655282222; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=343BjbVrfUTKzzHDVLHqseRRkhRTJ4iUhaXrlwxZiWE=; b=t69oz8J4oi/3YQDVwI5y4oFECELnNhMFaesLilQNEOT+qVagjnyuwSvncpkhS35h5XqPHs qbO9qKDPQiMQ6+KnQiTzD7JiRaQzHzPex+uCyQODc+Q2H4f+a7wMDC7Rw/GfN1wk/qXDFS AFHSps2fS9YDdGyvxLdUj73Jf1SAFdY= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=JwS6DDQX; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=WK++0ZKo; spf=pass (imf17.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.29 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655282222; a=rsa-sha256; cv=none; b=eGCIlFteNvsI51Cmk2f/AfFYlBv4wye/EZg7I3D0yV/nYGTR26tfvYEfFndLlOJP91t0VK o6gO0cWStEiM8rxT1fyjx3eE8POL0+7MbT5Kc4UAuCK95m6eF0w/IQ2ljtDdWq5WSPTYmH V1uRkFY7tIeH1ocY6qRo9yufykdQTkM= X-Stat-Signature: cjs6tg78nwuizx94qjyxi36u179tmqqm X-Rspamd-Queue-Id: 8F25D40084 X-Rspamd-Server: rspam11 X-Rspam-User: Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=JwS6DDQX; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=WK++0ZKo; spf=pass (imf17.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.29 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none X-HE-Tag: 1655282222-349260 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 6/5/22 09:04, Xiongwei Song wrote: > On Sat, Jun 4, 2022 at 5:43 PM Hyeonggon Yoo <42.hyeyoo@gmail.com> wrote: >> >> On Fri, Jun 03, 2022 at 10:35:55PM +0800, sxwjean@me.com wrote: >> > From: Xiongwei Song >> > >> > There is no need to do anything if sysfs_slab_alias() return nonzero >> > value after getting a mergeable cache. >> > >> > Signed-off-by: Xiongwei Song >> > Reviewed-by: Muchun Song >> > --- >> > v2: Collect Reviewed-by tag from Muchun. Hmm I added v1 (with the Reviewed tag) before getting to the v2 thread. But I think it's fine, see below. >> > --- >> > mm/slub.c | 8 +++----- >> > 1 file changed, 3 insertions(+), 5 deletions(-) >> > >> > diff --git a/mm/slub.c b/mm/slub.c >> > index d8d5abf49f5f..9444277d669a 100644 >> > --- a/mm/slub.c >> > +++ b/mm/slub.c >> > @@ -4861,6 +4861,9 @@ __kmem_cache_alias(const char *name, unsigned int size, unsigned int align, >> > >> > s = find_mergeable(size, align, flags, name, ctor); >> > if (s) { >> > + if (sysfs_slab_alias(s, name)) >> > + return NULL; >> > + >> > s->refcount++; >> > >> >> I think we should not expose sysfs attributes before initializing >> what can be read via sysfs attribute (object_size). Hmm I don't think they are unitialized. They have an old value from the cache we are merging with, which is updated if the new aliased cache has a larger one. So yeah we might briefly during creation expose an alias that will have an incorrect value, but I doubt anything will break. The values are not stable anyway as new aliases are added, as we are bumping them for the 'root' cache and all aliases that share it already. >> > /* >> > @@ -4869,11 +4872,6 @@ __kmem_cache_alias(const char *name, unsigned int size, unsigned int align, >> > */ >> > s->object_size = max(s->object_size, size); >> >> this calculation should be done before sysfs_slab_alias(). > > Yeah, understood. Should we restore s->object_size and s->inuse if > sysfs_slab_alias() returns non zero value? And by bailing out early this patch effectively achieves that, so I'd say it's a better state than before the patch so I'll keep it unless proven otherwise. Thanks! > Regards, > Xiongwwei > >> >> Thanks, >> Hyeonggon >> >> > s->inuse = max(s->inuse, ALIGN(size, sizeof(void *))); >> > - >> > - if (sysfs_slab_alias(s, name)) { >> > - s->refcount--; >> > - s = NULL; >> > - } >> > } >> > >> > return s; >> > -- >> > 2.30.2 >> > >>