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: 13441583 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D8F6FC4167B for ; Tue, 31 Oct 2023 14:09:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 96E256B0310; Tue, 31 Oct 2023 10:09:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8F45B6B0312; Tue, 31 Oct 2023 10:09:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7A48F6B0314; Tue, 31 Oct 2023 10:09:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 634896B0310 for ; Tue, 31 Oct 2023 10:09:27 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 1E569C07F5 for ; Tue, 31 Oct 2023 14:09:27 +0000 (UTC) X-FDA: 81405939174.18.5E8AD8F Received: from out-172.mta1.migadu.com (out-172.mta1.migadu.com [95.215.58.172]) by imf06.hostedemail.com (Postfix) with ESMTP id 413E418002A for ; Tue, 31 Oct 2023 14:09:24 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=Y0fRMVJb; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf06.hostedemail.com: domain of chengming.zhou@linux.dev designates 95.215.58.172 as permitted sender) smtp.mailfrom=chengming.zhou@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1698761365; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=1rWlR4h5g4eDWf2XTzUlOrJLNxfEOq6mT+00ilTz0G0=; b=FoEJQCbi42k909KZaK35H2VInIZxVl6CYMA5WJKkdFF9bOyRqcP19lQkMN+Nu7VGfNA5vw DdOPUuElepPiTS9b50Z99N0LbeUAXZdH1GTyjvTDWNp8pIFoTF5sHuWmrMMl61Et3IolYY 7U+ZVe21lTyRv2f9HrQLsRHfQ8ms6fk= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=Y0fRMVJb; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf06.hostedemail.com: domain of chengming.zhou@linux.dev designates 95.215.58.172 as permitted sender) smtp.mailfrom=chengming.zhou@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1698761365; a=rsa-sha256; cv=none; b=Xx31Bh9d45IUEF/YpugW/aZzBjE0uIJUQUmdts3qTL4X6FEMgs0DkpR+1ZOyi85t9+zqL/ 4wN68A5JBhTX0HthcuMYNHChIZq5WGMJK5D4b1zFeTXUKIAPq56fsldgundhqFJAmJ4IqK CRdaaI1F/TFOkWw1LSGB1+eP3DNA1r4= 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-Rspam-User: X-Stat-Signature: 55pzqq3gb61ckzoba7ymq8stfxpn39py X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 413E418002A X-HE-Tag: 1698761364-539673 X-HE-Meta: U2FsdGVkX1/EMnZcjQdjuAxMLz7q22EtvmcH524J2fFmxnZDResnAAbOx9BOIYB+Jzc6r1liCaiTBN3pYf1AkPAK+UtGQDIAnU2dBgMiQFbD7AaVTw3c7/hQKVOFDhr890qumRrmbSV7Re9hGnkx7vcwH/IHh6fQkDdMhUYm7adKXC+zlx7wUpcED1LS5GBwxlp/lDIiR1sNADWmEXc6gHFBPDLBDgCgRMkjHkZN0Ca3cWxvCzMJ+p5vbylIhPE4z605O7HI0Q5hdNhmpvTIvzVTFxyOnvSsnRQTLaF7mXG/stSuig1XBH9nMlv+1qbWbcRqFd/IJquAMk4WbJ937eaqFZPyh4NsyzdOkScnLFjFTAEe0A0kJGtsY46jQDpTvXRJVvBkJ2BUlL2W8JLRBZeTpOtOdEJvgCteSQlHg3e/zZT32WKn0lm//yjVduqNRZKBNSteUi4pMBnIOH/kHL4tmM2IgO6iuwcFERXYcjd8FJNOLEycHcmDU9iau1ETC0K0fGivqckLss3VaGypVZxLbYwfCO1TBPqzlbaBgeclUqoo47E6FO6r3VS2bWB0xaAOP6zN7hmVnkoPtpKXFt17Zl7jFnbqPM5IVQjufp8N6e68AXfdrYzN++QrKAbx9TgL6zu107NZ1tu14joB1NUWjYOzguNYFL9ISmA6nSl5ZqKmEvvJEdJVFZaiChZLGT2nX54NVh7Ad+OUOTYKZ5nymXRVfqNONyoZfvHi8y3T9lCKDw48KBMvCaIhhiour2+NzI7sYQ+PRsYZCR3uNdf30ztBKoiB8pFdLcZfPv/ciRIoeDIbzs+0FnqI6ChDp81Z/j+mnLVxylNRYyhmZuvw7e3OVf2Dt24zgY0STnWrz6R2mEbdeaUk0bA7F6AmkhtyL2pnnJ0RJSDR9hNK/1tT1x1rlgNPvEakog2DkcW7U/bIkhpyoMKAtNsyywZWzIrGEkagqXt7T+8CAZc 2IlK1vqT In9jGWmnk0tooV2Ue4xfqOM6cLUYxzUjX4Co8HSk+UKlwrQshC63Rc/y1IPcWXMrxP3yuuwcMSNxfWN4Cc7FpDT8CePKztw9f9KhPKQDptpCzfMSLIcY2SnOZIqIYGO6Oa8YReHJMzn85vBLcUqaXuXNyhYHh+2ct4ybINbEgLBRINKHNi0xXBMaODNGLppGLRexLvzJOIyNhE9o= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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.