From patchwork Tue Oct 31 14:07:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengming Zhou X-Patchwork-Id: 160132 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b90f:0:b0:403:3b70:6f57 with SMTP id t15csp267864vqg; Tue, 31 Oct 2023 07:10:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFCkMSrYm4EKd8AttynTNvPiLeelm9EvvAPNm2S3UZ0usPSk1pM1k1DBwt83Rt2xeIfWKpm X-Received: by 2002:a17:902:f9ce:b0:1ca:a07b:36d with SMTP id kz14-20020a170902f9ce00b001caa07b036dmr10185317plb.48.1698761400541; Tue, 31 Oct 2023 07:10:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698761400; cv=none; d=google.com; s=arc-20160816; b=uxY6BJq4KkkoWbJQwB1New62W+G1J7EHIdDyuA5PJZMSsQtWiWHqTr4RbfCEDvgfFO M4uvs+hjL5H4G5kmLn3M1oLFxTryXNIH7WXDC5jiLhyanRzV878ethAVShY5dYQUA2U3 0FrzXcMaZN85sGqLsynWJlEKdN6vmUCHDXeVxJ0d6lKYV8m4K2UjNgcsJdZhyDqFtOdm nagcAg4MWkyAlOb2poPWJlzMyBVaPBs4RKX1b5YTet7XNrTVd2rqNfd2h3/Kf5iyEI0x Gdm6M7YMHB9HFObUEWxOWrA+AkveZHhwXMLd47uZ/rKGHzXL6BKqD8z4IcmV4KguXh2T GGAQ== 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=1rWlR4h5g4eDWf2XTzUlOrJLNxfEOq6mT+00ilTz0G0=; fh=1GJaSiew/4nhYvae+yJYXPcARWi0PNZhXd1mB5ASXRg=; b=qwVGt+T70LcpVz5TnfVK+XUcgK/QZz+Is8PuaosTIqltEXvg2E52KtXg4+zQI2sffX KFwyU3LWd96Q0WYNbyyWDkHZFRHjr9aAPSQHLbC08IzKOpT7CLtS0DxCHdIsO7eKNxvm Xu11HNC2Gu3yppz8uV0ATDXeZImfopCWZ0qSdS251HMAwt+jKe4Yspwb6+OOTKxWhR1+ 9GnWso2G3f0i+6Z4Ao7NPINSQH4sFDrL3Lo6WxxAfj89jGAZH7gNMDfNkxjSdXXjhbri f2iwr3S0lsIaLDYaBVH8x13l7gfJpOXOdA7NuOwH6OE0DGmhcavylMfiQkUIltzqv54N 4SSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=Y0fRMVJb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id j1-20020a170902da8100b001c60636e426si1063701plx.432.2023.10.31.07.09.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 07:10:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=Y0fRMVJb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id 003D68037AA3; Tue, 31 Oct 2023 07:09:57 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236130AbjJaOJp (ORCPT + 33 others); Tue, 31 Oct 2023 10:09:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235747AbjJaOJb (ORCPT ); Tue, 31 Oct 2023 10:09:31 -0400 Received: from out-181.mta1.migadu.com (out-181.mta1.migadu.com [IPv6:2001:41d0:203:375::b5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26E4019E for ; Tue, 31 Oct 2023 07:09:25 -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=1698761363; 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=1rWlR4h5g4eDWf2XTzUlOrJLNxfEOq6mT+00ilTz0G0=; b=Y0fRMVJblxItnO7fa29gryhY0OuDSuYpX3u9Ss3dhqwRf1OZ/GJBzbFxGqASfXa3ZkcDEd llhl/Boestl6/Pzbcckw30/f5cm8ZIVtqAPveVEahzHWy0Mm0D45/0Br2r/TLM+w+opTst LbLFwmWZyebAWLmuYs8XzdN4+enFRJY= From: chengming.zhou@linux.dev To: vbabka@suse.cz, cl@linux.com, penberg@kernel.org, willy@infradead.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 Subject: [RFC PATCH v4 9/9] slub: Update frozen slabs documentations in the source Date: Tue, 31 Oct 2023 14:07:41 +0000 Message-Id: <20231031140741.79387-10-chengming.zhou@linux.dev> In-Reply-To: <20231031140741.79387-1-chengming.zhou@linux.dev> References: <20231031140741.79387-1-chengming.zhou@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, 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 agentk.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 (agentk.vger.email [0.0.0.0]); Tue, 31 Oct 2023 07:09:58 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781280434110941845 X-GMAIL-MSGID: 1781280434110941845 From: Chengming Zhou 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 --- mm/slub.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index bb7368047103..89d3f7a18a73 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 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 @@ -2620,8 +2629,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.