Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2843322rdb; Mon, 4 Dec 2023 08:58:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IGZclrX2exWu5gjr+MHeqH/t2OZEcgjFtwu+jpACnEbE+1XtbTHJzXKXAibOs1C/IoMu8OF X-Received: by 2002:a05:6a21:3293:b0:18c:f9a7:6f75 with SMTP id yt19-20020a056a21329300b0018cf9a76f75mr2896574pzb.3.1701709102883; Mon, 04 Dec 2023 08:58:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701709102; cv=none; d=google.com; s=arc-20160816; b=trNa9zgJhCymm8yqQkSyNSfmW7Xx4MWvEWxvTSEZTrKFzQwI32MnoA5TlAElZMaES3 PQYWjbg3j+KoHCZGdB8YXDSlPdqkcFr+7IQI4SUd0cHRTeBOuonx9dZQeLt5Ee+hagpZ OAB2bfhfW7CXETaXUJ6L8b2eX1z30ia6mAxJK3EiAXXbL0fAj+GQHjHLCV3pZ7JDJW2J sU3IrmULh5sYNrOgimz2CHC0M7PeLI+5aBjvp4DeexcxmHhMkMW1zcMqt7AjN95S5YGS hrsPa8v+R8PoqCUvIA2QLxZBUFB5ddHUMK7p+UjLar2DNpLXtaBJtRpyiCWYg9gxNGnF E+zQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=CdoD3EJkYKwdKUzvgkGIFhcvDWIbPAe6anPnyxcLEEQ=; fh=Llwo1Tx068h3ofDo78sxM3awDiiMHkQud7SY7oRoja8=; b=Q7rO4WjvKlJ8ZStHcmhttu/lBBpxrtjCdhgCWw5hX+l0IFOpUuKDgc5lTFJeNXBO1/ 3JoRFuf6pQkJkHS63HApPqNBJDK+iRgrQ1QRzwijHoVcw7sjr2ce8jvz9nzWw/VBHzc1 1pIh+oILOSHYDJSiF6teq00SS5OffR9layaXFWh5PKicib1r9ke24dcm7DwgSpTIEK9k b1eyf+9c0gl8jom82L07/0rKlB4cXZQu0EvYMem/O5cgj/t9kCKBwcJorsEYz63dWyZ7 6ejpXHZJ+nrEE9sm84PYWakFL2zG0Rd1jpCpKA3IFC/Alf1x+37PqpRKHQz6gVW1fBSf gk9g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id w189-20020a6362c6000000b005c65c11ad09si4259335pgb.768.2023.12.04.08.58.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 08:58:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 4BF9380AEB0A; Mon, 4 Dec 2023 08:58:20 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230283AbjLDQ6G (ORCPT + 99 others); Mon, 4 Dec 2023 11:58:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229561AbjLDQ6E (ORCPT ); Mon, 4 Dec 2023 11:58:04 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2a07:de40:b251:101:10:150:64:2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8576CB9 for ; Mon, 4 Dec 2023 08:58:10 -0800 (PST) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id D5CE11F894; Mon, 4 Dec 2023 16:58:08 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id BC0D01398A; Mon, 4 Dec 2023 16:58:08 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id WmKLLSAFbmU2eAAAD6G6ig (envelope-from ); Mon, 04 Dec 2023 16:58:08 +0000 Message-ID: <7cd33b23-64f5-a736-ea69-b29e40d42e78@suse.cz> Date: Mon, 4 Dec 2023 17:58:08 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH v5 6/9] slub: Delay freezing of partial slabs Content-Language: en-US To: Chengming Zhou , Hyeonggon Yoo <42.hyeyoo@gmail.com> Cc: cl@linux.com, penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, akpm@linux-foundation.org, roman.gushchin@linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Chengming Zhou References: <20231102032330.1036151-1-chengming.zhou@linux.dev> <20231102032330.1036151-7-chengming.zhou@linux.dev> <98763097-d05e-40cd-afe0-4df65083d104@linux.dev> From: Vlastimil Babka In-Reply-To: <98763097-d05e-40cd-afe0-4df65083d104@linux.dev> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spamd-Bar: +++++ Authentication-Results: smtp-out2.suse.de; dkim=none; dmarc=none; spf=softfail (smtp-out2.suse.de: 2a07:de40:b281:104:10:150:64:97 is neither permitted nor denied by domain of vbabka@suse.cz) smtp.mailfrom=vbabka@suse.cz X-Rspamd-Server: rspamd2 X-Spamd-Result: default: False [5.39 / 50.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; TAGGED_RCPT(0.00)[]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(1.20)[suse.cz]; R_SPF_SOFTFAIL(4.60)[~all]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; RCVD_COUNT_THREE(0.00)[3]; MX_GOOD(-0.01)[]; RCPT_COUNT_SEVEN(0.00)[11]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.cz:email]; FREEMAIL_TO(0.00)[linux.dev,gmail.com]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(2.20)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; SUSPICIOUS_RECIPS(1.50)[] X-Spam-Score: 5.39 X-Rspamd-Queue-Id: D5CE11F894 X-Spam-Status: No, score=-4.9 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Mon, 04 Dec 2023 08:58:20 -0800 (PST) On 12/3/23 11:15, Chengming Zhou wrote: > On 2023/12/3 14:53, Hyeonggon Yoo wrote: >> On Thu, Nov 2, 2023 at 12:25 PM wrote: >>> >>> From: Chengming Zhou >>> >>> Now we will freeze slabs when moving them out of node partial list to >>> cpu partial list, this method needs two cmpxchg_double operations: >>> >>> 1. freeze slab (acquire_slab()) under the node list_lock >>> 2. get_freelist() when pick used in ___slab_alloc() >>> >>> Actually we don't need to freeze when moving slabs out of node partial >>> list, we can delay freezing to when use slab freelist in ___slab_alloc(), >>> so we can save one cmpxchg_double(). >>> >>> And there are other good points: >>> - The moving of slabs between node partial list and cpu partial list >>> becomes simpler, since we don't need to freeze or unfreeze at all. >>> >>> - The node list_lock contention would be less, since we don't need to >>> freeze any slab under the node list_lock. >>> >>> We can achieve this because there is no concurrent path would manipulate >>> the partial slab list except the __slab_free() path, which is now >>> serialized by slab_test_node_partial() under the list_lock. >>> >>> Since the slab returned by get_partial() interfaces is not frozen anymore >>> and no freelist is returned in the partial_context, so we need to use the >>> introduced freeze_slab() to freeze it and get its freelist. >>> >>> Similarly, the slabs on the CPU partial list are not frozen anymore, >>> we need to freeze_slab() on it before use. >>> >>> We can now delete acquire_slab() as it became unused. >>> >>> Signed-off-by: Chengming Zhou >>> Reviewed-by: Vlastimil Babka >>> Tested-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> >>> --- >>> mm/slub.c | 113 +++++++++++------------------------------------------- >>> 1 file changed, 23 insertions(+), 90 deletions(-) >>> >>> diff --git a/mm/slub.c b/mm/slub.c >>> index edf567971679..bcb5b2c4e213 100644 >>> --- a/mm/slub.c >>> +++ b/mm/slub.c >>> @@ -2234,51 +2234,6 @@ static void *alloc_single_from_new_slab(struct kmem_cache *s, >>> return object; >>> } >>> >>> -/* >>> - * Remove slab from the partial list, freeze it and >>> - * return the pointer to the freelist. >>> - * >>> - * Returns a list of objects or NULL if it fails. >>> - */ >>> -static inline void *acquire_slab(struct kmem_cache *s, >>> - struct kmem_cache_node *n, struct slab *slab, >>> - int mode) >> >> Nit: alloc_single_from_partial()'s comment still refers to acquire_slab(). >> > > Ah, right! It should be changed to remove_partial(). > > diff --git a/mm/slub.c b/mm/slub.c > index 437485a2408d..623c17a4cdd6 100644 > --- a/mm/slub.c > +++ b/mm/slub.c > @@ -2463,7 +2463,7 @@ static inline void remove_partial(struct kmem_cache_node *n, > } > > /* > - * Called only for kmem_cache_debug() caches instead of acquire_slab(), with a > + * Called only for kmem_cache_debug() caches instead of remove_partial(), with a > * slab from the n->partial list. Remove only a single object from the slab, do > * the alloc_debug_processing() checks and leave the slab on the list, or move > * it to full list if it was the last free object. > > Hi Vlastimil, could you please help to fold it? Done, thanks.