Message ID | 20231102032330.1036151-10-chengming.zhou@linux.dev |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp101896vqu; Wed, 1 Nov 2023 20:26:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHxtoumDXPX3nq/Cz5YZ/uuzhCpJVINSzOFie1bLLSQkwXy5qQeGlBM0wp11rOEq3qNfK2q X-Received: by 2002:a17:90a:e516:b0:280:1dca:f699 with SMTP id t22-20020a17090ae51600b002801dcaf699mr10787245pjy.42.1698895603436; Wed, 01 Nov 2023 20:26:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698895603; cv=none; d=google.com; s=arc-20160816; b=k5YjzoazaRYKBjxnEZK4ne7BWawFNG56hC77EkvfSlkCkJN7p2YUUA8eh0xka21cJm gwYKjWUrnx6Tj9mYPJuR5b6PAVEyZJeT+FV/GGxLXTvVfpfdJqf+392aXHeTTGTLGNox pwMp2nUPLO9cJQXbtv7W2Obyn3qZ4aQ3gEcPQpvb4lemNrCwredisfEH5pXM0tvlV7FB JDWgZkIZnAWnRTPgv8od+1lSCImlQf8R6XmojJz9R7oYFOQ8Y8bhp1OVNOfk4usHm7Zj mOrpRwSemNtSKx6xe2y2XQawwHEHhncNPgLdl3u537PtWqxl7fVeiWEBbvEfv57WVH2Z mCfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=gJd616cEH+YooKkPi26MjXWgnIGEXuyIPk1hxd0FhTk=; fh=Dd5ryTbz4gXtDU9jzXqg2hD87XusQgPqunF08GDmhnA=; b=qTqaGI/cEjsDiaRdzhV6/BqXbwl7vjDO2f1ap1RsZHo++HDaAQBQu/mQi5mmM9h9+L P5sV3/wdO0H50nY8MybCIhT5STYbMKsy6XDubtESl0Zi+pGOIeP54GM/EN770Reeo0rK 7vjVoFQFhgreeXHvV5E1Yvt3/EOiThZqBA6JTRbLADnwGpT4pSpwGrLuroRlsUodmK8H oIE4e7Ci6TcYY40bdLJW4gIJOUr4N3NjVPbFezoJ11i37atKytv3oJqx5Twh6D/AHQwD cwEm+77KUQLEtsaQ6m4DL39goOiGrBJcOTXIVlH49KWNq+eyfaOkSuvS/R/zm57RX7a9 e9TQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=nDjeGraa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id w89-20020a17090a6be200b00280571bb749si2010926pjj.150.2023.11.01.20.26.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 20:26:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=nDjeGraa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 001CD80A9930; Wed, 1 Nov 2023 20:26:00 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348415AbjKBDZt (ORCPT <rfc822;heyuhang3455@gmail.com> + 35 others); Wed, 1 Nov 2023 23:25:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348419AbjKBDZk (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 1 Nov 2023 23:25:40 -0400 Received: from out-179.mta1.migadu.com (out-179.mta1.migadu.com [95.215.58.179]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDB87119 for <linux-kernel@vger.kernel.org>; Wed, 1 Nov 2023 20:25:33 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1698895532; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gJd616cEH+YooKkPi26MjXWgnIGEXuyIPk1hxd0FhTk=; b=nDjeGraaC0yMn15FP6J1O98CFrfWFi/efFlDQyWlgTKRBWcIkb3Bueh3V63chVaCnBjh/z aT+DJ4liAnoOXN6AjPz5ujQz9YSWQl2pq1MhhIZ8NmN0T3o3AMQcWG/ZORLSwwjhMGbr7d UKvLJzRg/tomBOgosqWMv4T+MnQQ2Cg= From: chengming.zhou@linux.dev To: vbabka@suse.cz, cl@linux.com, penberg@kernel.org Cc: rientjes@google.com, iamjoonsoo.kim@lge.com, akpm@linux-foundation.org, roman.gushchin@linux.dev, 42.hyeyoo@gmail.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, chengming.zhou@linux.dev, Chengming Zhou <zhouchengming@bytedance.com> Subject: [PATCH v5 9/9] slub: Update frozen slabs documentations in the source Date: Thu, 2 Nov 2023 03:23:30 +0000 Message-Id: <20231102032330.1036151-10-chengming.zhou@linux.dev> In-Reply-To: <20231102032330.1036151-1-chengming.zhou@linux.dev> References: <20231102032330.1036151-1-chengming.zhou@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 01 Nov 2023 20:26:01 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781421156484605234 X-GMAIL-MSGID: 1781421156484605234 |
Series |
slub: Delay freezing of CPU partial slabs
|
|
Commit Message
Chengming Zhou
Nov. 2, 2023, 3:23 a.m. UTC
From: Chengming Zhou <zhouchengming@bytedance.com> The current updated scheme (which this series implemented) is: - node partial slabs: PG_Workingset && !frozen - cpu partial slabs: !PG_Workingset && !frozen - cpu slabs: !PG_Workingset && frozen - full slabs: !PG_Workingset && !frozen The most important change is that "frozen" bit is not set for the cpu partial slabs anymore, __slab_free() will grab node list_lock then check by !PG_Workingset that it's not on a node partial list. And the "frozen" bit is still kept for the cpu slabs for performance, since we don't need to grab node list_lock to check whether the PG_Workingset is set or not if the "frozen" bit is set in __slab_free(). Update related documentations and comments in the source. Signed-off-by: Chengming Zhou <zhouchengming@bytedance.com> Tested-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- mm/slub.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
Comments
On Thu, Nov 2, 2023 at 12:25 PM <chengming.zhou@linux.dev> wrote: > > From: Chengming Zhou <zhouchengming@bytedance.com> > > The current updated scheme (which this series implemented) is: > - node partial slabs: PG_Workingset && !frozen > - cpu partial slabs: !PG_Workingset && !frozen > - cpu slabs: !PG_Workingset && frozen > - full slabs: !PG_Workingset && !frozen > > The most important change is that "frozen" bit is not set for the > cpu partial slabs anymore, __slab_free() will grab node list_lock > then check by !PG_Workingset that it's not on a node partial list. > > And the "frozen" bit is still kept for the cpu slabs for performance, > since we don't need to grab node list_lock to check whether the > PG_Workingset is set or not if the "frozen" bit is set in __slab_free(). > > Update related documentations and comments in the source. > > Signed-off-by: Chengming Zhou <zhouchengming@bytedance.com> > Tested-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> > --- > mm/slub.c | 16 ++++++++++++---- > 1 file changed, 12 insertions(+), 4 deletions(-) > > diff --git a/mm/slub.c b/mm/slub.c > index c20bdf5dab0f..a307d319e82c 100644 > --- a/mm/slub.c > +++ b/mm/slub.c > @@ -76,13 +76,22 @@ > * > * Frozen slabs > * > - * If a slab is frozen then it is exempt from list management. It is not > - * on any list except per cpu partial list. The processor that froze the > + * If a slab is frozen then it is exempt from list management. It is > + * the cpu slab which is actively allocated from by the processor that > + * froze it and it is not on any list. The processor that froze the > * slab is the one who can perform list operations on the slab. Other > * processors may put objects onto the freelist but the processor that > * froze the slab is the only one that can retrieve the objects from the > * slab's freelist. > * > + * CPU partial slabs > + * > + * The partially empty slabs cached on the CPU partial list are used > + * for performance reasons, which speeds up the allocation process. > + * These slabs are not frozen, but are also exempt from list management, > + * by clearing the PG_workingset flag when moving out of the node > + * partial list. Please see __slab_free() for more details. > + * > * list_lock > * > * The list_lock protects the partial and full list on each node and > @@ -2617,8 +2626,7 @@ static void put_partials_cpu(struct kmem_cache *s, > } > > /* > - * Put a slab that was just frozen (in __slab_free|get_partial_node) into a > - * partial slab slot if available. > + * Put a slab into a partial slab slot if available. > * > * If we did not find a slot then simply move all the partials to the > * per node partial list. > -- Looks good to me, Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Thanks! > 2.20.1 >
On Thu, 2 Nov 2023, chengming.zhou@linux.dev wrote: > From: Chengming Zhou <zhouchengming@bytedance.com> > > The current updated scheme (which this series implemented) is: > - node partial slabs: PG_Workingset && !frozen > - cpu partial slabs: !PG_Workingset && !frozen > - cpu slabs: !PG_Workingset && frozen > - full slabs: !PG_Workingset && !frozen The above would be good to include in the comments. Acked-by: Christoph Lameter (Ampere) <cl@linux.com>
On 2023/12/5 05:41, Christoph Lameter (Ampere) wrote: > On Thu, 2 Nov 2023, chengming.zhou@linux.dev wrote: > >> From: Chengming Zhou <zhouchengming@bytedance.com> >> >> The current updated scheme (which this series implemented) is: >> - node partial slabs: PG_Workingset && !frozen >> - cpu partial slabs: !PG_Workingset && !frozen >> - cpu slabs: !PG_Workingset && frozen >> - full slabs: !PG_Workingset && !frozen > > The above would be good to include in the comments. > > Acked-by: Christoph Lameter (Ampere) <cl@linux.com> > Thanks for your review and suggestion! Maybe something like this: diff --git a/mm/slub.c b/mm/slub.c index 623c17a4cdd6..21f88bd9c16b 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -93,6 +93,12 @@ * by clearing the PG_workingset flag when moving out of the node * partial list. Please see __slab_free() for more details. * + * To sum up, the current scheme is: + * - node partial slab: PG_Workingset && !frozen + * - cpu partial slab: !PG_Workingset && !frozen + * - cpu slab: !PG_Workingset && frozen + * - full slab: !PG_Workingset && !frozen + * * list_lock * * The list_lock protects the partial and full list on each node and
On 12/5/23 07:06, Chengming Zhou wrote: > On 2023/12/5 05:41, Christoph Lameter (Ampere) wrote: >> On Thu, 2 Nov 2023, chengming.zhou@linux.dev wrote: >> >>> From: Chengming Zhou <zhouchengming@bytedance.com> >>> >>> The current updated scheme (which this series implemented) is: >>> - node partial slabs: PG_Workingset && !frozen >>> - cpu partial slabs: !PG_Workingset && !frozen >>> - cpu slabs: !PG_Workingset && frozen >>> - full slabs: !PG_Workingset && !frozen >> >> The above would be good to include in the comments. >> >> Acked-by: Christoph Lameter (Ampere) <cl@linux.com> >> > > Thanks for your review and suggestion! > > Maybe something like this: Thanks, added. > diff --git a/mm/slub.c b/mm/slub.c > index 623c17a4cdd6..21f88bd9c16b 100644 > --- a/mm/slub.c > +++ b/mm/slub.c > @@ -93,6 +93,12 @@ > * by clearing the PG_workingset flag when moving out of the node > * partial list. Please see __slab_free() for more details. > * > + * To sum up, the current scheme is: > + * - node partial slab: PG_Workingset && !frozen > + * - cpu partial slab: !PG_Workingset && !frozen > + * - cpu slab: !PG_Workingset && frozen > + * - full slab: !PG_Workingset && !frozen > + * > * list_lock > * > * The list_lock protects the partial and full list on each node and
diff --git a/mm/slub.c b/mm/slub.c index c20bdf5dab0f..a307d319e82c 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -76,13 +76,22 @@ * * Frozen slabs * - * If a slab is frozen then it is exempt from list management. It is not - * on any list except per cpu partial list. The processor that froze the + * If a slab is frozen then it is exempt from list management. It is + * the cpu slab which is actively allocated from by the processor that + * froze it and it is not on any list. The processor that froze the * slab is the one who can perform list operations on the slab. Other * processors may put objects onto the freelist but the processor that * froze the slab is the only one that can retrieve the objects from the * slab's freelist. * + * CPU partial slabs + * + * The partially empty slabs cached on the CPU partial list are used + * for performance reasons, which speeds up the allocation process. + * These slabs are not frozen, but are also exempt from list management, + * by clearing the PG_workingset flag when moving out of the node + * partial list. Please see __slab_free() for more details. + * * list_lock * * The list_lock protects the partial and full list on each node and @@ -2617,8 +2626,7 @@ static void put_partials_cpu(struct kmem_cache *s, } /* - * Put a slab that was just frozen (in __slab_free|get_partial_node) into a - * partial slab slot if available. + * Put a slab into a partial slab slot if available. * * If we did not find a slot then simply move all the partials to the * per node partial list.