From patchwork Fri Apr 19 17:56:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jianfeng Wang X-Patchwork-Id: 13636703 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 C64E1C4345F for ; Fri, 19 Apr 2024 17:56:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 662A66B0089; Fri, 19 Apr 2024 13:56:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5EB676B008A; Fri, 19 Apr 2024 13:56:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 352C06B0095; Fri, 19 Apr 2024 13:56:21 -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 0BD6E6B0089 for ; Fri, 19 Apr 2024 13:56:21 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id AE529C156F for ; Fri, 19 Apr 2024 17:56:20 +0000 (UTC) X-FDA: 82027035720.23.268179A Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf26.hostedemail.com (Postfix) with ESMTP id C613F140002 for ; Fri, 19 Apr 2024 17:56:18 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=O7EnkUAx; spf=pass (imf26.hostedemail.com: domain of jianfeng.w.wang@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=jianfeng.w.wang@oracle.com; dmarc=pass (policy=quarantine) header.from=oracle.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1713549378; 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=E4ycvTEE8d8tsFa3XEXhTzxsb88jl02QoN97F8t0DMs=; b=4dhUhGYeSRd2xP2cM1ObdeMiQLdBQVxH5BZf7ec0VsBNEtuKVgL7FkdwAtyoyMsxioca+j IEA2LsOOLj5cpZUhE6zwjJYHQggpNx2siVr+4lNYvKCUoz89qIo7lyI/RGqsVb0K8rgN1K BU/a+LT92JPXA8gsPpg9f+pFoYi9J9M= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1713549378; a=rsa-sha256; cv=none; b=T+y0INNvV8P3JIX2EUkW/iwQe+VXom2jRHsJnjsdCouPq3+5Xy7jU+TOBqYdt0Wtz6BNDc KxVmOJvF8Z/N0Wv98irvQJ5BoAv5zktV/peb6hBwDmau3gWQOQGr7TbZiAn5skTkvVxWS9 WpqIMVSUyRSutWG/ulFCd0hJd8+9FYc= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=O7EnkUAx; spf=pass (imf26.hostedemail.com: domain of jianfeng.w.wang@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=jianfeng.w.wang@oracle.com; dmarc=pass (policy=quarantine) header.from=oracle.com Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 43JGi3x6030352; Fri, 19 Apr 2024 17:56:14 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2023-11-20; bh=E4ycvTEE8d8tsFa3XEXhTzxsb88jl02QoN97F8t0DMs=; b=O7EnkUAxu6+JwaIdG+XQWmPC3YXCmvTnio0EzM4WV/mouFcJw9MuEmhRi5Qp6qfnpOEc 9yALSY1fs8//YcBqvY9edw4JF0qaraCgKUFcxP1L6weQIm+MuNytl4Nd2uOLVu2gMb7o 430vMzcnBL/esbGeQpyjCPiY3mjraiXpZSFWNSjPigQBfEVI4YpBfbzR9K+iJRyO24t+ yVEmrSldDymURZlYUa1I+2oC+F+uKPLaSC2IA2embb9543K23EBI6DHP6liIzuK6BRAD WR3RDIiVfyJ/h8he3+QcEm8Dl9VpLMVwkC1xnB5p7sn8enV+FOwBHigZ/cK4fP9NcqYo FQ== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3xfgujwjm5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 19 Apr 2024 17:56:14 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 43JH48SJ005568; Fri, 19 Apr 2024 17:56:13 GMT Received: from jfwang-mac.us.oracle.com (dhcp-10-159-230-131.vpn.oracle.com [10.159.230.131]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3xkc7xd76r-3; Fri, 19 Apr 2024 17:56:13 +0000 From: Jianfeng Wang To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: vbabka@suse.cz, cl@linux.com, akpm@linux-foundation.org, penberg@kernel.org, rientjes@google.com Subject: [PATCH v3 2/2] slub: use count_partial_free_approx() in slab_out_of_memory() Date: Fri, 19 Apr 2024 10:56:11 -0700 Message-ID: <20240419175611.47413-3-jianfeng.w.wang@oracle.com> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20240419175611.47413-1-jianfeng.w.wang@oracle.com> References: <20240419175611.47413-1-jianfeng.w.wang@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-04-19_13,2024-04-19_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 bulkscore=0 malwarescore=0 suspectscore=0 spamscore=0 adultscore=0 phishscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404190137 X-Proofpoint-ORIG-GUID: etvbRzFUFWO99kOfRwSYzVdQlvEBJIX2 X-Proofpoint-GUID: etvbRzFUFWO99kOfRwSYzVdQlvEBJIX2 X-Stat-Signature: kkum16tukc4zeq1jjp61zpb87fgc7xnw X-Rspamd-Queue-Id: C613F140002 X-Rspamd-Server: rspam06 X-Rspam-User: X-HE-Tag: 1713549378-551599 X-HE-Meta: U2FsdGVkX19XWb90JHuYtBQ2UKXw18ztjPawsXpLgAgi7rA9jNcvdwWFHGRm6+DqFQBDc4kxN8UsmC2o5tH+S7qQZdqOGO/ilpKMzvK9NIMsXBoTOdZ6pjPKGNIIP8LMj7Uz8U1at/OHo8C6g+kpX+TmVLx/RjaFAA9EzdAZ+bVpSo6JQMD289Si0lavlwvK4AvBUVfkvBcqCTxxST06oNKKBw9s7x0lIrxTHmiPyJYUVWUGF66TWoniFqUhtHaHi8llnZWaqNQ7lAaD+q5lqagyzHaOGnG1QtY533SlsiZwtZ22EhFS1M2/nGTVQTBb676DRhEw7u2pSl5EZPplkTT/2o5dg+/vxlyg7U9leuyhQdoEp2eQsdYubbqZaAJvsQAVYRkwRibbkgqNUuYvmgGdum0x8QTQjj8erObZdpDDTfkZdBL1J4uV57ig4cedB0mJMV0AuuYuFE9nSd/XE3mAbTTvR2nAT+44qoe2oJhQtPpbBpsFPv1tVr1XM7JOyODc1TLbhyoVRR1EMUY6MwYMhCiC24CaDwsQz6hjrIriDpLzGHpQjClNtO41NasleVFEkvRBpy6ilbcfwyvPlfQGPhx1tgUbXZmWbWo0dbm/JSHDJ/0yxm0HFPs8U7TqOHAbx7jVzOw+23mirFqx0xTbpQBqfHzKPQn+LNPqJlOzr9W1BpQGmjhUoHC5l1q73jgxegbqGmcRPS4wjh7BLwGPP0+xz3Gq1KgXjVoUAspsAdQIyCKuAeXPupIs7hZrtTfTtAUcfAqoB5R0NOlhu9lJrL8upuVHGVQPcmhViaIVQSpZe2T+sUOculQzbLcHH1c5i6ieTNQiUf2EBHBCoHs2i/BXywueknqWl/0fUA0a4idAw4tJ/LkXrIaYbStOoSHFx8SVPL+ZjVTZch2feHyzkUZxRMA5T7J6axBm0lbQfOAVQeT0psOj8hbhvwjYsIWEbu3izWp5zxCVYqB J8Oybrz+ baRszcWniHPQErY7Y+Ukrbtp44Tt11KRWenWEaYDAsgeJTgondzeuqwGJzV1j8m3/Z9U/LEwLx9T1LFfPowqplbXq7lQosNawd6J+nWIKfB8IsTiTzZVMEX2GJeszrVOXmNHNJmmCwT+GW5Z9uPSPKRYaBlE/ZQWxm5KJC9JtT/TnJvs88ilXfiPdVSF4G/lWwo4pb5c4527hc2co2IoplIeXhbh/eDjTkGkEf43FU3hGFe1nxaFlH02ZSJuf8qDniZUn/z4U5jv+HVcck01iB9qJcQ== 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: slab_out_of_memory() uses count_partial() to get the exact count of free objects for each node. As it may get called in the slab allocation path, count_partial_free_approx() can be used to avoid the risk and overhead of traversing a long partial slab list. At the same time, show_slab_objects() still uses count_partial(). Thus, slub users can still have the option to access the exact count of objects via sysfs if the overhead is acceptable to them. Signed-off-by: Jianfeng Wang Acked-by: David Rientjes --- mm/slub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/slub.c b/mm/slub.c index 993cbbdd2b6c..fa55699aa21a 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -3292,7 +3292,7 @@ slab_out_of_memory(struct kmem_cache *s, gfp_t gfpflags, int nid) unsigned long nr_objs; unsigned long nr_free; - nr_free = count_partial(n, count_free); + nr_free = count_partial_free_approx(n); nr_slabs = node_nr_slabs(n); nr_objs = node_nr_objs(n);