Received: by 2002:a05:7412:f589:b0:e2:908c:2ebd with SMTP id eh9csp271122rdb; Tue, 31 Oct 2023 07:10:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFUFIoRWZ+jQayzZ7SpDlB3LTk3yHuDKR0CjWnHQo03xT+xcs9vMyS0ZNDXU1OWbsj9bxUt X-Received: by 2002:a05:6a20:e687:b0:13c:988c:e885 with SMTP id mz7-20020a056a20e68700b0013c988ce885mr10470136pzb.56.1698761405906; Tue, 31 Oct 2023 07:10:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698761405; cv=none; d=google.com; s=arc-20160816; b=RLzR8Oxu1YOBwrrr4bH13zf1B/w8ro008IK7yfrnbQmCWeIXFoNGzxA0mqe8bWtdV/ 0kX09FC2wOmpZ0GggDbTOYScAOsgkZsi9hhQ0PaZD/NqOwHh9iD41P8KhWgnJB7PViTt XEXuS1HFMsYSXBk+hNPm8JzhFnlYivKbK1gjTQXPIKDqHc689jQV8s7A80Mj65X+/ksz X36uVdzZZrTwcuYm5/GW/0oIa4rOVNY/CjiqY4rxDPKybMv3LtvKdpaQOSPMsWFC8uV3 4HqS5Kg6F8SxIN1L6cw8qZIy5WC6kxSyEtUC0bKrqWAgf+/OlxwvY+VDAUyCqjFInWMS xGZw== 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 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id w184-20020a6362c1000000b005b930e0b604si1103304pgb.549.2023.10.31.07.10.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 07:10:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; 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 23.128.96.32 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 25E238037AA6; Tue, 31 Oct 2023 07:10:03 -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 S235751AbjJaOJp (ORCPT + 99 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 Content-Transfer-Encoding: 8bit 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:10:03 -0700 (PDT) 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. -- 2.20.1