From mboxrd@z Thu Jan 1 00:00:00 1970 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 1D86ECD1288 for ; Thu, 4 Apr 2024 05:59:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A72BD6B0088; Thu, 4 Apr 2024 01:59:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A225C6B0089; Thu, 4 Apr 2024 01:59:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8E9626B008A; Thu, 4 Apr 2024 01:59:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 6E29F6B0088 for ; Thu, 4 Apr 2024 01:59:08 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id DF1A1120E60 for ; Thu, 4 Apr 2024 05:59:07 +0000 (UTC) X-FDA: 81970796334.03.3A382DC Received: from mx0b-0064b401.pphosted.com (mx0b-0064b401.pphosted.com [205.220.178.238]) by imf15.hostedemail.com (Postfix) with ESMTP id E1BC8A0003 for ; Thu, 4 Apr 2024 05:59:05 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=windriver.com header.s=PPS06212021 header.b=DK16AvjF; dmarc=pass (policy=reject) header.from=windriver.com; spf=pass (imf15.hostedemail.com: domain of "prvs=482462f78f=xiongwei.song@windriver.com" designates 205.220.178.238 as permitted sender) smtp.mailfrom="prvs=482462f78f=xiongwei.song@windriver.com" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712210346; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=/rH/4dIIFl0tP0DZ8KBYwKtVJ20Qari0JGnwd0w4aJA=; b=2rPe6vhKMpJCNc8cK4+ewNrvMaSctI+AWUccPdBCXqJ6f8LjPjvGf4m9ZjnlpEfnRMy+K2 /oO2SN5Qb1Ft39S6ZtOZcPYcxth+M1CGyqhK0DCoZXxsUTE3Vsr403t8PDQyXbDqfsYddJ j2BAWJjYCUf4Rt/L6+rsaHYALI858UQ= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=windriver.com header.s=PPS06212021 header.b=DK16AvjF; dmarc=pass (policy=reject) header.from=windriver.com; spf=pass (imf15.hostedemail.com: domain of "prvs=482462f78f=xiongwei.song@windriver.com" designates 205.220.178.238 as permitted sender) smtp.mailfrom="prvs=482462f78f=xiongwei.song@windriver.com" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712210346; a=rsa-sha256; cv=none; b=rvDsgzTVx5bM/H9GY4NMaxaVF8NMytASp0UILIuVR4u0QxaVf8FuI2wJCCEL/fIY0fBPWA UAQrxWhXCw9FQDDl9SMUspZVkxCANTtWTe5nNjXyWiAicC/NcDD+g1hRju4Aes7Wm2hPJS EtRicwzyquKcTqXElsDwMPXNw6eHU7w= Received: from pps.filterd (m0250811.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4344vEJ5006418; Thu, 4 Apr 2024 05:58:55 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriver.com; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= PPS06212021; bh=/rH/4dIIFl0tP0DZ8KBYwKtVJ20Qari0JGnwd0w4aJA=; b= DK16AvjFscZbHJfWB3SOOHjr7Yax33Mv64mMZqqHthRLfqi02cOn086ofAxfuDAv BHRa9/64buMKJWrGm1zJoZHegHBh7Mq7cuSORoXIwpHBfBKJgpGyrsrVrKsl3JKb u6DQOric5Bi+s73hvdxWAr/eVix587befoksPj11jEukxowZ54Oqde+aOfeZDWTu dmVdHSKZclKirlZxPa2s9gag/m+3BxTpmmMWFPEExYtMjFjDwepl1u07wX74x7lF ZV23UNuae87o013Qfgjap/9jqcytoj7dsVImzdcmXNxVa6uowkPDijafP/lr8cRs tlur3KKB9SIAo6CruK5ybQ== Received: from ala-exchng01.corp.ad.wrs.com (ala-exchng01.wrs.com [147.11.82.252]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3x9epk89h3-13 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Thu, 04 Apr 2024 05:58:55 +0000 (GMT) Received: from ALA-EXCHNG02.corp.ad.wrs.com (147.11.82.254) by ala-exchng01.corp.ad.wrs.com (147.11.82.252) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.37; Wed, 3 Apr 2024 22:58:46 -0700 Received: from pek-lpd-ccm5.wrs.com (147.11.1.11) by ALA-EXCHNG02.corp.ad.wrs.com (147.11.82.254) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.37 via Frontend Transport; Wed, 3 Apr 2024 22:58:43 -0700 From: To: , , , , , , , <42.hyeyoo@gmail.com> CC: , , Subject: [PATCH v2 3/3] mm/slub: simplify get_partial_node() Date: Thu, 4 Apr 2024 13:58:26 +0800 Message-ID: <20240404055826.1469415-4-xiongwei.song@windriver.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240404055826.1469415-1-xiongwei.song@windriver.com> References: <20240404055826.1469415-1-xiongwei.song@windriver.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: iScp0TsPV-TMjLRsoPJ93q7ds1TOZWuW X-Proofpoint-ORIG-GUID: iScp0TsPV-TMjLRsoPJ93q7ds1TOZWuW X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-04-04_02,2024-04-03_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 adultscore=0 priorityscore=1501 impostorscore=0 lowpriorityscore=0 phishscore=0 mlxscore=0 clxscore=1015 spamscore=0 suspectscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2404010003 definitions=main-2404040036 X-Rspamd-Queue-Id: E1BC8A0003 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: 7gjwrscqpa1hifg1nib3sqic8pzdurxo X-HE-Tag: 1712210345-94932 X-HE-Meta: U2FsdGVkX182BIwcSbKxEhlfLGK0LLnpDyXbINmB5M13+WX9Y8Ywh4VzsYmlSOHt7JzGNOKlas4LCsULOyGzAvrSo/vWUVNE77wYn0p1LRFFFbYGIvsdAXL/09GxD+DHr1Jd1PipqTgK2KHC1e/0XXfOATajJfuFwZUqnjxLezIM+i/IzLQ/ThFkOkfNqasCidmDC2WITzPnAiuog4G1PofiZ4L3UFtVOXgysYDX3nBH8N2X8gDYHVilV24aYLgcahgmLObC10cxcDa4v1ykaeFw2Q3PRm57WVntFQwPELv5JcVPYlgqRUUrZp0ILjftT30uxVEXZc03QRkeFigHdxJTFURyUxd3nc1Eit+W5UJqLKlmShxHhryb8WqdClZTekpNyrALBHqlZ7DY2pVPoI2F7p7cg7BPrHXLL6qYLVLItlwXud0eudnOZ4lfvzxXeceocB+9xpYKFs7+I5Nsdbre0FQZsE/aP8+Izkcyxf3j9UAi4878Q/fnY6ZD0hCTytlcK5tIg6C5ZXBkcEaOiVTiLsZDMoQahg7XflLmBqUTKuwr8aYL5RMhKuDQqe8UAII6+3o3s61KxfZpqzUqe7pIDxRU8hCevxTCCL1efGt0arFt7hrlTDtYl/bDJPLk86szcPrcZvs72g4gWVj9Gtm8Fr3JX+MCgS1iSY75w4GwQVSlS9MFkz3brtzjFHAmx8iu3ve01LVOJYYsyGE6WDjuXE+IB5DXQ65nScE3WkI/AdwEUIebkizEqOhBS6wrnuFRVaWzFRHwLsPXEymA25rb5aqozSqQCWTUezOAfujOhkax4b0mmWxVEtNgi9DhZtE/SmKfI6paQEsdFwZmuawGhWePImSJndJbuTD+V7WboqyqcHlIFpyaeKAPTpc4h4z09t5PUO7pLMUhLas2gmLJY6IuIfBGLsXFSEU2VFwqndRiU1eNJBK8dBfPfhGQahNSRStjJ5SzP7+eXq4 FNwmuowi P78BPK0C2TyRGCKAyPGYLDlizn/o6r8zv2jusJ0q6dKY88KZI7UXczs9/J2n/VaPAEHahLqgcDMQbMqOx/XKM38sqKFZkyubYNk3yET0lZCbZUvKTF9jZ0jgMp3wcQ0kmYbxh8OjB4ercTIpstFO18CKlRp5FaHHdZEGmcp8XdJNK0lhlwPxAy0fHUqqNk6HLV8mttobGG+Dg61wwXrnGYo1keehS+0uTy9nc4m/jd+JGpHQjDpudd0GckuJ47b/Tb1gAOrO77XRFQ8AJpuiWCxhtTel0fl5ZIbCjdJqt67UNoOCVBfOu8Nz5K40dftcq1zy6VW/6Nv2yeUTRlZBTshsDKzwp/Hx0mV9kIVDfU8nqvWTQfYTa7e22UROechccTRMUApYnreekEXtGxLLx5abh7TX8rIh//gfeBW6sUUG6EPUOilFZDkPZbuntsc1RvTSjn9TyVntSNIhyDSkQsZBCxEs73/WhOc95X+TbVmcUIM4PesEh9Iyhp+nBUxv3Habr 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: Xiongwei Song The break conditions for filling cpu partial can be more readable and simple. If slub_get_cpu_partial() returns 0, we can confirm that we don't need to fill cpu partial, then we should break from the loop. On the other hand, we also should break from the loop if we have added enough cpu partial slabs. Meanwhile, the logic above gets rid of the #ifdef and also fixes a weird corner case that if we set cpu_partial_slabs to 0 from sysfs, we still allocate at least one here. Signed-off-by: Xiongwei Song --- The measurement below is to compare the performance effects when checking if we need to break from the filling cpu partial loop with the following either-or condition: Condition 1: When the count of added cpu slabs is greater than cpu_partial_slabs/2: (partial_slabs > slub_get_cpu_partial(s) / 2) Condition 2: When the count of added cpu slabs is greater than or equal to cpu_partial_slabs/2: (partial_slabs >= slub_get_cpu_partial(s) / 2) The change of breaking condition can effect how many cpu partial slabs would be put on the cpu partial list. Run the test with a "Intel(R) Core(TM) i7-10700 CPU @ 2.90GHz" cpu with 16 cores. The OS is Ubuntu 22.04. hackbench-process-pipes 6.9-rc2(with ">") 6.9.0-rc2(with ">=") Amean 1 0.0373 ( 0.00%) 0.0356 * 4.60%* Amean 4 0.0984 ( 0.00%) 0.1014 * -3.05%* Amean 7 0.1803 ( 0.00%) 0.1851 * -2.69%* Amean 12 0.2947 ( 0.00%) 0.3141 * -6.59%* Amean 21 0.4577 ( 0.00%) 0.4927 * -7.65%* Amean 30 0.6326 ( 0.00%) 0.6649 * -5.10%* Amean 48 0.9396 ( 0.00%) 0.9884 * -5.20%* Amean 64 1.2321 ( 0.00%) 1.3004 * -5.54%* hackbench-process-sockets 6.9-rc2(with ">") 6.9.0-rc2(with ">=") Amean 1 0.0609 ( 0.00%) 0.0623 * -2.35%* Amean 4 0.2107 ( 0.00%) 0.2140 * -1.56%* Amean 7 0.3754 ( 0.00%) 0.3966 * -5.63%* Amean 12 0.6456 ( 0.00%) 0.6734 * -4.32%* Amean 21 1.1440 ( 0.00%) 1.1769 * -2.87%* Amean 30 1.6629 ( 0.00%) 1.7031 * -2.42%* Amean 48 2.7321 ( 0.00%) 2.7897 * -2.11%* Amean 64 3.7397 ( 0.00%) 3.7640 * -0.65%* It seems there is a bit performance penalty when using ">=" to break up the loop. Hence, we should still use ">" here. --- mm/slub.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index 590cc953895d..6beff3b1e22c 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -2619,13 +2619,10 @@ static struct slab *get_partial_node(struct kmem_cache *s, stat(s, CPU_PARTIAL_NODE); partial_slabs++; } -#ifdef CONFIG_SLUB_CPU_PARTIAL - if (partial_slabs > s->cpu_partial_slabs / 2) - break; -#else - break; -#endif + if ((slub_get_cpu_partial(s) == 0) || + (partial_slabs > slub_get_cpu_partial(s) / 2)) + break; } spin_unlock_irqrestore(&n->list_lock, flags); return partial; -- 2.34.1