From patchwork Thu Apr 13 14:34:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiongwei Song X-Patchwork-Id: 13210359 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 22327C77B6E for ; Thu, 13 Apr 2023 14:36:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 92D6D900003; Thu, 13 Apr 2023 10:35:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8DCEF6B007E; Thu, 13 Apr 2023 10:35:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7CC1F900003; Thu, 13 Apr 2023 10:35:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 6E37A6B007D for ; Thu, 13 Apr 2023 10:35:59 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 2DE3BA0255 for ; Thu, 13 Apr 2023 14:35:59 +0000 (UTC) X-FDA: 80676617238.22.F4C673B Received: from pv50p00im-ztdg10011301.me.com (pv50p00im-ztdg10011301.me.com [17.58.6.40]) by imf09.hostedemail.com (Postfix) with ESMTP id 462BE14000D for ; Thu, 13 Apr 2023 14:35:57 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=me.com header.s=1a1hai header.b=WOd2wAMW; dmarc=pass (policy=quarantine) header.from=me.com; spf=pass (imf09.hostedemail.com: domain of sxwjean@me.com designates 17.58.6.40 as permitted sender) smtp.mailfrom=sxwjean@me.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1681396557; 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=X9rNsbyg8P2zc9bEIgObTak89L4pwM16nNASnZu43Cs=; b=D/C+XwsrvfEPk4hZp09Zt/ccLeqix59TT2Hf5dT69FTWYgQhS94Dz8ZoIaPP4kBHB/htmw th8nIyL//7Vh9OC/qEhppRlDo1QCwIy2Ucq9EovBZqePfnRI2rp4wCk9GRqS22cwOcvQrI gy/gAoqZbImbPYISuT4n6difpZNUws8= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=me.com header.s=1a1hai header.b=WOd2wAMW; dmarc=pass (policy=quarantine) header.from=me.com; spf=pass (imf09.hostedemail.com: domain of sxwjean@me.com designates 17.58.6.40 as permitted sender) smtp.mailfrom=sxwjean@me.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1681396557; a=rsa-sha256; cv=none; b=A4wuMexDhucDogHEyfylAaPQbHMZ6XbSeqElPwN4biFjrL3D4epua41dsLqim9TDtjtX2z 2/TRdV4X0ZRnJoW+zAaitmZRIbwsCiswccrRua8sZ0du8SHBfkb50fgvX1t6+psiL6srvy SBEcSoCbXTUKrF9uDuF+b+MtbQk+z4k= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=me.com; s=1a1hai; t=1681396556; bh=X9rNsbyg8P2zc9bEIgObTak89L4pwM16nNASnZu43Cs=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=WOd2wAMW+qWyWk2cozpwKyj07x00lw52yUR5HaZdPGBbmkRAsTWGwqtV4xojlHTRU lrn2hlJ0NoQXTg/RXGrmpXYosF0+ezrHGt6IvOMYzpxxh0gWREg8Exc5Ll4cgJ6QpN WFuOLwbBjXRATVVksmR+4UgxmIFNurKRNZax42wcu13DClam0KAovkAc4dbIb7KIil 5evduAa7H3S4EyyGES25mPnXNjuR+FY6LJ8ALnPYP7zkmHkoswxvMea3Ln8HZsqRad WKV4ZpV7JX8ZnLUOwJg1kHzSuSNFoUeuPsyIi1ziiNT7RjrJR6CrMg+Fhcrcay2kYH V94yuCgc8bh/A== Received: from xiongwei.. (pv50p00im-dlb-asmtp-mailmevip.me.com [17.56.9.10]) by pv50p00im-ztdg10011301.me.com (Postfix) with ESMTPSA id 2010B18065F; Thu, 13 Apr 2023 14:35:50 +0000 (UTC) From: sxwjean@me.com To: cl@linux.com, penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, akpm@linux-foundation.org, vbabka@suse.cz, roman.gushchin@linux.dev, 42.hyeyoo@gmail.com, keescook@chromium.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, Xiongwei Song Subject: [PATCH 4/5] slub: Remove slabs_node() function Date: Thu, 13 Apr 2023 22:34:51 +0800 Message-Id: <20230413143452.211250-5-sxwjean@me.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230413143452.211250-1-sxwjean@me.com> References: <20230413143452.211250-1-sxwjean@me.com> MIME-Version: 1.0 X-Proofpoint-GUID: kXvLyGF-H8usFLhMixCBzmU7tdwWLDs3 X-Proofpoint-ORIG-GUID: kXvLyGF-H8usFLhMixCBzmU7tdwWLDs3 X-Proofpoint-Virus-Version: =?utf-8?q?vendor=3Dfsecure_engine=3D1=2E1=2E170-?= =?utf-8?q?22c6f66c430a71ce266a39bfe25bc2903e8d5c8f=3A6=2E0=2E517=2C18=2E0?= =?utf-8?q?=2E883=2C17=2E0=2E605=2E474=2E0000000_definitions=3D2022-06-21=5F?= =?utf-8?q?08=3A2022-06-21=5F01=2C2022-06-21=5F08=2C2020-01-23=5F02_signatur?= =?utf-8?q?es=3D0?= X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 clxscore=1015 bulkscore=0 malwarescore=0 adultscore=0 suspectscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2304130130 X-Rspamd-Queue-Id: 462BE14000D X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: rgcq5st4ks1t5s3bseib8bmqinitc5e3 X-HE-Tag: 1681396557-553837 X-HE-Meta: U2FsdGVkX1+s+BDmxDc/KIWUPftpJ2hhuHw1SYNCM36jKXmqrW4CR/LWU6c/PyLil1l28kN36qUtXB7HAlsHRpwzLV9mY/KApFQts7wg+WHbUiHre/wAED2VpVzsa8vC+MrU1Olvv5D/aOWzSctXNCdaBgs7oKTBBWykndT+p954o2jWXAOYyK0ffRSoxs1BE6O4F3Uxl92ZOtw4kIKGgaZWILrUM6wyO4r1jUje6VoMS8XoobUhin6DVKyMeEa2mKeTfhLtN+PuAVv8JznNyHxX9maQQrMtPayK0rAl0FBspaF3d0r/XnobHfC29Go4quxGMMKELqINkQlQzaG3I8J3/oHkPEfnEj+wz1p29CQdytlr5Kl/uLwyH8wiULvmR6DVHRindxXUaPR8duZHpAxLZcszR4l0qUHQRjyYLAPZeJdVN/gGpQqoouAg4iu9RT2sEApoaMDAdoStHHi9XyhwAWdVV7rj6SFRG6oHwEPqvGg+aD80AuNv3S/9dcpHlDEPQXZVNDZs720prDM6W/OUDkyCAV/VuNGKkKDFB+D0SEZolVMCI22hiutD7CxFYirqq1K5s2sclhuPszZb7aYW4l/6NAbduo4maWk9Pta/h0NenpDvgaI0KAUNlLM626jTtMYeQpNRlYvfqzDfb3FjEFwa24BrrTawjBDR/fp7dWtFLacjRBNzu5DNs7iEhmltLh4ZdDyBj0+qunQzJHrlpb2OF+Jf5Hz1KI+aV+ejhIjeOU2fHBzbQ3kdXJWb7Fa3W5sJsniD6n6PJkVcyxwdpTp47gmRXYKo7GNZ4LCBCDeNqqfsJmJeaeiRHWPoPUwF/R4DWyI+lEB5EjodfW2iVfI1+2qFaUM+a3WLhFEb8x2MLIB6qKIUW2PF09/dWCFzhhIenoawFFjWGR7WzcXKiqHUozCM18TfA4+bhGbYY0zef4qgVhKronyICS0keKSiZoXzkZ35P6K/xj6 UvcjQdVH wYJ3g7ZgTfrwkDgmHvPkZv5FTCATKEdgb3UlXkuWLSVHVr/66ialTF//9e/8hhaLrOqZRTpTlnIZNywhXPewoLp+6wFgoBXGyNiLJXGFy1f4HJvIXCdJrWxZOfa2ksQOkS+cgzY5T45+vda8d6BHb0GO3pm2PjBhKqIKBgtpE/bK4omkxsPr8daBw5BElLM2yqyS+YjKv8u4S6zANoPI3eSx8rMIQ4XiM9r1goURdfSld24QZdYN7B0whryVg2kZdK/zaCaJ9caUDb8LOHuXJtXZMO0fqCPqYrmJcOfzl7WOtG0WeFd4nvvDmx03QA50GYB9CQt0qr+0A29wK6JgNvHg/DjvxSM87543yoDoGL2CsaFbUdtZvZl6exyQ4MiOIxqMNldVWwJvgzIg+T6Y5mtnrJQ== 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: From: Xiongwei Song When traversing nodes one by one, the get_node() function called in for_each_kmem_cache_node macro, no need to call get_node() again in slabs_node(), just reading nr_slabs field should be enough. However, the node_nr_slabs() function can do this. Hence, the slabs_node() function is not needed anymore. Signed-off-by: Xiongwei Song --- mm/slub.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index d897df8fe7e7..33b4fec6bc7a 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -1344,14 +1344,6 @@ static void remove_full(struct kmem_cache *s, struct kmem_cache_node *n, struct list_del(&slab->slab_list); } -/* Tracking of the number of slabs for debugging purposes */ -static inline unsigned long slabs_node(struct kmem_cache *s, int node) -{ - struct kmem_cache_node *n = get_node(s, node); - - return atomic_long_read(&n->nr_slabs); -} - static inline unsigned long node_nr_slabs(struct kmem_cache_node *n) { return atomic_long_read(&n->nr_slabs); @@ -1722,8 +1714,6 @@ slab_flags_t kmem_cache_flags(unsigned int object_size, #define disable_higher_order_debug 0 -static inline unsigned long slabs_node(struct kmem_cache *s, int node) - { return 0; } static inline unsigned long node_nr_slabs(struct kmem_cache_node *n) { return 0; } static inline void inc_slabs_node(struct kmem_cache *s, int node, @@ -4599,7 +4589,7 @@ bool __kmem_cache_empty(struct kmem_cache *s) struct kmem_cache_node *n; for_each_kmem_cache_node(s, node, n) - if (n->nr_partial || slabs_node(s, node)) + if (n->nr_partial || node_nr_slabs(n)) return false; return true; } @@ -4616,7 +4606,7 @@ int __kmem_cache_shutdown(struct kmem_cache *s) /* Attempt to free all objects */ for_each_kmem_cache_node(s, node, n) { free_partial(s, n); - if (n->nr_partial || slabs_node(s, node)) + if (n->nr_partial || node_nr_slabs(n)) return 1; } return 0; @@ -4829,7 +4819,7 @@ static int __kmem_cache_do_shrink(struct kmem_cache *s) list_for_each_entry_safe(slab, t, &discard, slab_list) free_slab(s, slab); - if (slabs_node(s, node)) + if (node_nr_slabs(n)) ret = 1; }