From patchwork Thu Nov 2 03:23:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengming Zhou X-Patchwork-Id: 13443357 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 0845FC4332F for ; Thu, 2 Nov 2023 03:25:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9BA298E001E; Wed, 1 Nov 2023 23:25:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 942F08E0009; Wed, 1 Nov 2023 23:25:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7E3EF8E001E; Wed, 1 Nov 2023 23:25:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 6D9BC8E0009 for ; Wed, 1 Nov 2023 23:25:35 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 4F90DA0E93 for ; Thu, 2 Nov 2023 03:25:35 +0000 (UTC) X-FDA: 81411574230.07.57D8C58 Received: from out-173.mta1.migadu.com (out-173.mta1.migadu.com [95.215.58.173]) by imf08.hostedemail.com (Postfix) with ESMTP id 8D7BC160021 for ; Thu, 2 Nov 2023 03:25:33 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=nDjeGraa; spf=pass (imf08.hostedemail.com: domain of chengming.zhou@linux.dev designates 95.215.58.173 as permitted sender) smtp.mailfrom=chengming.zhou@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1698895533; 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=gJd616cEH+YooKkPi26MjXWgnIGEXuyIPk1hxd0FhTk=; b=FmV0w4MigEBUPOglogwafec2StwpTH3Xl+Q5X+0xkE6wKpQpxP1KWtUfVSuv0dewn0xmyC mX475fJ5/Gg4yxuGxVspkf+tl6x1L2uCtbtZwjmUhU88avG4cvWZfINUPZWGUp5ZiU/kKC YmBVjlUGIls9gZodfG5CPhb9lRhiYNs= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=nDjeGraa; spf=pass (imf08.hostedemail.com: domain of chengming.zhou@linux.dev designates 95.215.58.173 as permitted sender) smtp.mailfrom=chengming.zhou@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1698895533; a=rsa-sha256; cv=none; b=rZPzYPNeFutNdn5V4Nb540ii2Ls9v/T5fNU0dqWFujOagUaxLliX6Q+Dpqfi/SdIpyoKKc TDF8IFRU91d6ziTIru9gE7uYhOTYACMWSly6/8/VArfA4t29bXfPh8fvHbNY5aBw1ti5A6 huyY8Tr4+EnEoP4jtezzCTsvSikjq8w= 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 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 X-Migadu-Flow: FLOW_OUT X-Rspamd-Queue-Id: 8D7BC160021 X-Rspam-User: X-Stat-Signature: nky4asfdbyq7ppzc8f1ficobhs4qys7e X-Rspamd-Server: rspam01 X-HE-Tag: 1698895533-867760 X-HE-Meta: U2FsdGVkX1+VdKpadSlWGpNqeB4NVFxQB0NHYv9w4aCapQXuZ24pv/JaTVCrjisUAwZCGGAsPuiPcXjLCLpZAaB6bOHN23wRYCoaPar8Xn4Ex0zqDWdqw7zHN2FQv9ZxY7W6Gg0xDfA878YgnjZfWSDMvn5P/epT9tkGTKh47qGd4DFRZKODGskM6Ncds75JSyegIgDcv1AK/5T8RjDoTp4MmGv9Ir7XE1G7d/aYx1BY0v5N/hvUqLfyvrVNkMLs9Vjs8g8UzkRTKCbusTKBMmHXLKZfF0LIKzXofQqWoFrAYYuMhc0rktuBetXj/8rJbB6njI8eaTL4D5krH3rYpRbRPPrcAX2LcXqbbXrXn+EFN5ju2ak9JF6J07g4ued+So+kiy/coSnXujb/1gCBBSxaU18NTHMn0T6kWUmQcLC+xOli5pKgZ4H2ccufVopZSHmNkOhddy1Fj7GggpByWFMjXwjGJFXD/fXvdp8AWFaMlwob8QbUsOqzjihuzoOVHCjdPZTwPq0TuEhanETjyhXeQT7FKijvcX1hf+SKt8jl7T1ni8ObbwvA8xQtseuHjcc3PICbWNVCuE3JEaQh2ooeax7A+KsCgTm06Ld64DRW/PsH1Xz4MDwwfQkW4U7hub3kbUpqhzKSNXEn/ODGI3gdm09n8GFZ0BqIC0MvAWtTeyZJ7dSIJVERU5Nh0AZnowwxBxTWn7LmAZycY73WrQArHrnRLFcyypWSxeOBr4kuMI+EasEfR97wzf/Va3+1N4CdV5WcdP3eZXBsMY4Kr96BiVFFWbXSMcJnOBP/zyNc1FT5g/80SFRFKTwqwPliSdGS5CMDPy2vq2N35zZ3hFd/i1WFj/aTSrBWFcuDCxXcvYlB7M+q6jsnkT5wMIAbqL9NmLwOrs0Dz5UYMdXWm1e1GPtirc345gARrMo+AV0+pAR7apSuyIs+nnJ700xTCYcIfhgxv5iINRKlgYg 6zMmWRB3 Ira4WdTPHhJXGZgB2Yzog0mSDGZkOpvVNt1omTVDMG5Of5NfKx+wdieRu762MSfHehkcpA4XcoTQNj/gykJ+Pl6xJCObDrv1kIt4F5+3KxO24r197NIxmWrVAbm2TGTzxAPE/btvm5XpCrXFx0zaCEMwQEJBA6NqwKHC2G8KguOKcja/Rah8bif7uDV1Q+Qy9/QFLpeMBANe64+C0JcJgPKVhsbf0byq5/kXNdkoO07F796k= 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 Tested-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Acked-by: Christoph Lameter (Ampere) --- 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.