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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 265F1C43334 for ; Wed, 15 Jun 2022 08:37:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245420AbiFOIhM (ORCPT ); Wed, 15 Jun 2022 04:37:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245041AbiFOIhI (ORCPT ); Wed, 15 Jun 2022 04:37:08 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6437530569 for ; Wed, 15 Jun 2022 01:37:02 -0700 (PDT) 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 >> > >>