From patchwork Thu Apr 13 14:34:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiongwei Song X-Patchwork-Id: 13210356 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 DC388C77B6E for ; Thu, 13 Apr 2023 14:35:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 473356B0078; Thu, 13 Apr 2023 10:35:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 42270900003; Thu, 13 Apr 2023 10:35:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2EAA0900002; Thu, 13 Apr 2023 10:35:40 -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 1FF3C6B0078 for ; Thu, 13 Apr 2023 10:35:40 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id D4D81A023A for ; Thu, 13 Apr 2023 14:35:39 +0000 (UTC) X-FDA: 80676616398.08.1101B91 Received: from pv50p00im-ztdg10011301.me.com (pv50p00im-ztdg10011301.me.com [17.58.6.40]) by imf12.hostedemail.com (Postfix) with ESMTP id 109B04000E for ; Thu, 13 Apr 2023 14:35:37 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=me.com header.s=1a1hai header.b=OxAmEuHT; spf=pass (imf12.hostedemail.com: domain of sxwjean@me.com designates 17.58.6.40 as permitted sender) smtp.mailfrom=sxwjean@me.com; dmarc=pass (policy=quarantine) header.from=me.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1681396538; 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=rfau5OufM0BiNWhby4onOK71jyUiBVhrPZSigYK+sks=; b=e0/IGCb/u2pO7PyJyrrT7+H+xCIg+0BXMARLRq0NSUhkVzsVU9g3oS1PjuBMzBlwGf9Ao5 jwJEzgG5KdVSJYrykawxS24AS5lkM7GUC77RiizVf5W/nzvxPM2q8qwm5pDTQVdHhwk2gl 55b4HcfTHuNs7TyYm/cymKMJ6wKE79g= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=me.com header.s=1a1hai header.b=OxAmEuHT; spf=pass (imf12.hostedemail.com: domain of sxwjean@me.com designates 17.58.6.40 as permitted sender) smtp.mailfrom=sxwjean@me.com; dmarc=pass (policy=quarantine) header.from=me.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1681396538; a=rsa-sha256; cv=none; b=Q0TYp+Ovc/OwV4CPBDH6ymwbY0LWTnu9TxnXeQUcCMZAa4lYMfNZQFWK0LytfSPk4mfK5v fuA4ZoLzpNjpxddFvbDB/AsE507H960GUYwoNemDjoZg4MuxvHeN+EPJPI+r29AaCfQg/x n1jBY6Cnx19BQBpfReDL3cCxUY+OzA0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=me.com; s=1a1hai; t=1681396536; bh=rfau5OufM0BiNWhby4onOK71jyUiBVhrPZSigYK+sks=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=OxAmEuHTfbSVCKdAfkQv02ZaI1VeZo+oqjWjiC0NDnzKYZ3QYcB9qQyCqVjceU2ns rxhuI69vMigg8bi+XZKz1aHRqvd2Fh79cHKvc0lQ77ndsMQ05s7rXerNHiGe+prOm1 gOsnVWdqjcuh0XBYfv+WIC50Ias0u2u6N7+9OgmvK90VpGloW7Ibfedr8mrjBZ6jDz AowZ4/ypEnQjcdRWoM2TE4resLxelcNFFJZl/CWzbHUKZRTSPNDZ9ODt+1/nfQv6xg 6hLraqC7BpImr5CalHFlNHbXvDZAuL1MHtuYMiiJly2ZfZGeuwTLB36ChB3fqlHhkG RAmlX0Fi5l1hQ== Received: from xiongwei.. (pv50p00im-dlb-asmtp-mailmevip.me.com [17.56.9.10]) by pv50p00im-ztdg10011301.me.com (Postfix) with ESMTPSA id 540711805A0; Thu, 13 Apr 2023 14:35:30 +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 1/5] slub: Correct the error code when slab_kset is NULL Date: Thu, 13 Apr 2023 22:34:48 +0800 Message-Id: <20230413143452.211250-2-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: 51lpZUJemfRvfvuXf7GNT1NeHV8UTyvG X-Proofpoint-ORIG-GUID: 51lpZUJemfRvfvuXf7GNT1NeHV8UTyvG 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=989 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2304130130 X-Stat-Signature: 8hod51pj6qrapwmafgi67cygne73hwcr X-Rspam-User: X-Rspamd-Queue-Id: 109B04000E X-Rspamd-Server: rspam06 X-HE-Tag: 1681396537-346466 X-HE-Meta: U2FsdGVkX1/xW6qkxl8hjtnXWjCOJ3fB7MKtMYnAKBI8gjUD+tGfPS3T25aG/zsmZnzMn2qzkG+Ls3KzEKWbFU8cTAZMXq26hTOfmM9aiqatj9awu2YWYG3FJjrGVQqiHQVc3SDTNTMMw+77BpeXcyuYrpAcTXPGcALgvada4vknBbB0SlplcxikbHPIoQRwfnwM1EjffcNPJmMLgbixeYAXIyDeU6DK0flStpzgK5DmqgQ4iyTKZJw06yuBnIXtjjkgxzj9XZtwc6ZuNUzVcAjKbt7LcgqNNR3antRUMuq2tRPVVUrv6D61yZcQ5xQp8JHnuAXM3HdB03o9SibHTrGOIVdEtRXHWSWJEpVFYJJAtlAUp8gIQba+kl/Lnjk3W/KExDaHLJ5tYnntQNrqnegbop1zAOwgsZINy4jOzzuopv8TM3Vvgu2KqtPaNH6iTrkWu5vGc3MSEmcDNcokAd18/BdmQl02xq6QaSCuev3GlZTSk1cREpMb8CPPHnASVoRoRZ7ymjRQEwZXcLpUUsKUOR1Vxv5PTvbm2j3K1wGx011i2U5EuKX6MP0TJx6aQHjw9+EljcnKHqvahSqnN/dh12HO9T5vRVSmA2qfHe2W45CvriAPPGdOkDmWxx3tX1xNnnlhbg0X/QCBfGW1xCcUjMQliUFHTN4MezN7A7SfFjIhBgx12XdiMJSsPntFgEAeAGhcv897iNx5nqZt/0q8Rm/0Yp54zl2FKz/Sqc0/kAp0DEQKD1vfzE6/YMBgJFlUmVZBlhsgUtY5pKKDn3XnE+5WlgHbpO/dV5xjBdmZlOsQoZKHHAJjj5SdfTUSsKS8C0AMBO1vVWVbhX4gcjP/YutXei8gPlX5XMfmkk+MAtn1iomqCkZRtUGvd6YUu0qbkUjAXS2mePoSQn/UH8r6VBkWjoPYEmORyNEm5Q6rDmGbs97WiNpQPEUPFhf4iF1kShO+1QHH1Dex9lb jBU7ISxD PCBr5T9XniRrLDewXZdYuDXD0VRxxkHGnWjij4glsurShzZZUG1kNawotLlqXbZWb9vJnPhUQqs7dWymbWKX3f2eAXGXQKWbccLm9TiJzPaorKTUYhOHQyEuj/spjf+nN9Gl3Fr8C9P/PySByYiSD9c+ejKXnilB/MdSMxmTOdV5SFP4jrpgLdD1pe9ZWPEV1kI/n00FVHlLjl9HYaw3budtwsX4ZhZEdRJRENX0Rf8lEktmOTht/JsUb+fU4nbv9sfTt0+0cvvTyfbKuxg/4LizpSD/bHMjiDTw0APZSdbB1GY1eaCDZLTs9UtKsVHEaDRdFDqGCK8fTmeYcB5S8nTVLua6zCX5OTZLU+IJ5axQcIHLOZKTv1nW49VaCH/YBAL5Va1PCepMjfoLki0TUHBeFsg== 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 The -ENOSYS is inproper when kset_create_and_add call returns a NULL pointer, the failure more likely is because lacking memory, hence returning -ENOMEM is better. Signed-off-by: Xiongwei Song --- mm/slub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/slub.c b/mm/slub.c index 28ca576d988d..5cc56f780241 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -6225,7 +6225,7 @@ static int __init slab_sysfs_init(void) if (!slab_kset) { mutex_unlock(&slab_mutex); pr_err("Cannot register slab subsystem.\n"); - return -ENOSYS; + return -ENOMEM; } slab_state = FULL; From patchwork Thu Apr 13 14:34:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiongwei Song X-Patchwork-Id: 13210357 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 4E7B8C77B61 for ; Thu, 13 Apr 2023 14:35:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BECAD6B007B; Thu, 13 Apr 2023 10:35:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B9C52900003; Thu, 13 Apr 2023 10:35:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A8AD5900002; Thu, 13 Apr 2023 10:35:47 -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 9C08F6B007B for ; Thu, 13 Apr 2023 10:35:47 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 625441A0146 for ; Thu, 13 Apr 2023 14:35:46 +0000 (UTC) X-FDA: 80676616692.24.3939FB6 Received: from pv50p00im-ztdg10011301.me.com (pv50p00im-ztdg10011301.me.com [17.58.6.40]) by imf14.hostedemail.com (Postfix) with ESMTP id 623FA100021 for ; Thu, 13 Apr 2023 14:35:44 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=me.com header.s=1a1hai header.b=XcKoR5cL; spf=pass (imf14.hostedemail.com: domain of sxwjean@me.com designates 17.58.6.40 as permitted sender) smtp.mailfrom=sxwjean@me.com; dmarc=pass (policy=quarantine) header.from=me.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1681396544; 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=8jRYHdyOLx4stczwHdVkraZpDl6WNFY1n6xs2s88Ih4=; b=Gx/NSwJLsYxroK1OZcuzt+DLoMV3+qUP4uUM3eSSNuDXM7q8SJYkfQy5qyCf4yTdbVDSYp dNJ8bnmd7ggxB+BViElwtSE5/jTL9JKflsU2Ge9vgXF5gLqdrLLLlukQsArrhjE0HSGmVK /DmqzkZhptNOvJccDPmar3Qx4CowYpw= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=me.com header.s=1a1hai header.b=XcKoR5cL; spf=pass (imf14.hostedemail.com: domain of sxwjean@me.com designates 17.58.6.40 as permitted sender) smtp.mailfrom=sxwjean@me.com; dmarc=pass (policy=quarantine) header.from=me.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1681396544; a=rsa-sha256; cv=none; b=qIKwSVmnYcLkq8qUGw2fhVyG/fEKunXLMF11sDqNxrTmggyJ3M7n8nOsLOYn+C7GyYT6wO 3qoM2kiqEpITh+SapDu7WxroVVslUAuw/u1fYQvfF43qyEjoRTCgpZahxL/o+7E7sfOK+U hK9AwUqqKKXxToaUl1xPgzk4WNPU9NI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=me.com; s=1a1hai; t=1681396543; bh=8jRYHdyOLx4stczwHdVkraZpDl6WNFY1n6xs2s88Ih4=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=XcKoR5cL/+upnaXqW5vEFVtkOztLb/OPL22EeKcuRy5aCKbMwJbI0lmkNMOd97cF8 U4nWgm3EJLu3+KVDvf2gpegVHJId7BREhcCxvx0qgyQyLCBDTjraGch7/Mh+sNnUpG 92/s8k/7x+2YqeGtk54ynj7p2UiHQ7d14zQlskNXll1HQ2Y1ksAoVjU0kHOYzrYiPh O4AJHBWOs1x1gkwS9kM8kB0zDEJDbBt+ipH34112Kl8ECnMt0m7FFOWkdnvWUFNQsi BPcQeMwhwXLQhEceqI+c8OpkxVYB4WBRjjstjTcPZrynKlB+GOgOZrkIwuBvUOfAV7 O7Z4mjnAAXeZQ== Received: from xiongwei.. (pv50p00im-dlb-asmtp-mailmevip.me.com [17.56.9.10]) by pv50p00im-ztdg10011301.me.com (Postfix) with ESMTPSA id 95D4518043E; Thu, 13 Apr 2023 14:35:37 +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 2/5] slub: Put objects_show() into CONFIG_SLUB_DEBUG enabled block Date: Thu, 13 Apr 2023 22:34:49 +0800 Message-Id: <20230413143452.211250-3-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: QqH1Ghpj5ydBr4pmMZw4eIZhmrwWvj9d X-Proofpoint-ORIG-GUID: QqH1Ghpj5ydBr4pmMZw4eIZhmrwWvj9d 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-Server: rspam07 X-Rspamd-Queue-Id: 623FA100021 X-Rspam-User: X-Stat-Signature: q5acik3aa7eoymbn9b7s1nznbgis3xhg X-HE-Tag: 1681396544-475791 X-HE-Meta: U2FsdGVkX1+enmDlnTPBJLCknOMERZU+ukd4b57GmT8MI3tfgYc+c+gzQUOlnM4EWH+eZAx9ef8NGrOhZHpsszemZ9H7I4quBf3rLauCMxs74gkFTMGwo1DQGLyF0YYAgvo9iwyLBEZ6+B1KgNeQlZ89B31T5alabcH0YqBd51QWL9I9jIs/ZY1pnWRsexkQ8EHs7ALiO9HKK2lBphxvUJbyxHAHaY6NPfAGD8tRLXWrfs3G7Dp8nPTjpsfz9t2vrCIkWfAIfegeG33x1rQu5nQw8XqxYz5K4W9KVnSqJ0BuWRwIofv6p+xTj3mlSjpwbHXCFHSnyNZH3WyIQPR9itLek2EwbgrzUsJbj1NO6S/1NQxVE5Z+G6zh902oT9An6DaSJ+L6DheuC7EwbcmJoKmOcUMaRpwW8A3vEr17PSXfL7vFuDYy/5tN9lRqyPPmBucRuzyn09GXMPi5/bD1ArgWgaXgegxCcY0u2nBAzGcaCV4+BlRKj8zNj6NgZFpdya9u3yzdaKynlrmZyskI8BX4jCNZ7K9C/SXVyIdlPO06vGxUIdx+UFbcaglw/9hLve07f+Mjml+2h7unDdpJNcm5HKEKwefQKgUn2ElSycnK3bBKQGDFSmeFV8XGOtQ9SN3NEh9BogbfDJ+TcsdGyo+dAzkwCDSWx3B9jV+PpbMSDbcRGPANGVeZYIj9hJDEcpDgbEVvugfyacrTCXwnN5zWW9w1yt7WcdX6FiTlyRifO+hAE9sq0r0sfZFOJzXHjjYgPZg9ba13xA/R3C6sNkX2zF2d8ZtsHNJlTJJhSWu4hMQpisRnxc1UyY7UNYICKQ6aLS1250wbpl0vUIJwJAwQkBLdCY533iAmYomn0pEPDIVwRCOHK2axa4/o9MjQD/Nz6q3YWgcHOM5xhqt5ZbsjJ+78QnLKaYIHNRkZzBKK++wcG/zesuZuc5OFrnYmguAavRI1TZi8v9dsH7y riAeTAdL sguvTHt/mI95/QW9IHTgto+1aPsewkJ6TRySsVes/ZD95+fbrFe6SDTkJojljtwtxYuli81wsTdnAejAlN7X81GjisNC7nfdrIOQ+LyL8B7VCDfuZT1XVtmMaHdTkBY1wwoY+txLbGZ/nulu+Z/nyjl+4CvWFq2BXdXS3wuLHvqsyzmtDXBnL08udprtQO+g8MDlpIHfQkWG/1ubwZISEzOeZuVgTU1sfNQWylPQNMAvBeI1Wl2uMZnlZasgMHKJsk4eY9jx+eaMkOA4VxvNoYzW22Ems2SiQGy1i9d9DieP3aZynw4P6ZrTByLqLZypSTBniROQenX4eiCZesGuGeM1rf44yBaE5U4HzOoTrG6mSERHBx3uWXrFJFnUKsdtBxSOYWfMWOHnITb3zCNrfab6q8A== 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 The SO_ALL|SO_OBJECTS pair is only used when enabling CONFIG_SLUB_DEBUG option, so the objects_show() definition should be surrounded by CONFIG_SLUB_DEBUG too. Signed-off-by: Xiongwei Song --- mm/slub.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index 5cc56f780241..b8afe12ebba1 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -5613,12 +5613,6 @@ static ssize_t cpu_slabs_show(struct kmem_cache *s, char *buf) } SLAB_ATTR_RO(cpu_slabs); -static ssize_t objects_show(struct kmem_cache *s, char *buf) -{ - return show_slab_objects(s, buf, SO_ALL|SO_OBJECTS); -} -SLAB_ATTR_RO(objects); - static ssize_t objects_partial_show(struct kmem_cache *s, char *buf) { return show_slab_objects(s, buf, SO_PARTIAL|SO_OBJECTS); @@ -5713,6 +5707,12 @@ static ssize_t total_objects_show(struct kmem_cache *s, char *buf) } SLAB_ATTR_RO(total_objects); +static ssize_t objects_show(struct kmem_cache *s, char *buf) +{ + return show_slab_objects(s, buf, SO_ALL|SO_OBJECTS); +} +SLAB_ATTR_RO(objects); + static ssize_t sanity_checks_show(struct kmem_cache *s, char *buf) { return sysfs_emit(buf, "%d\n", !!(s->flags & SLAB_CONSISTENCY_CHECKS)); From patchwork Thu Apr 13 14:34:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiongwei Song X-Patchwork-Id: 13210358 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 49435C77B6E for ; Thu, 13 Apr 2023 14:35:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DC082900002; Thu, 13 Apr 2023 10:35:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D716B6B007E; Thu, 13 Apr 2023 10:35:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C38DB900002; Thu, 13 Apr 2023 10:35:53 -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 B40C16B007D for ; Thu, 13 Apr 2023 10:35:53 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 60FE21A027E for ; Thu, 13 Apr 2023 14:35:53 +0000 (UTC) X-FDA: 80676616986.01.EAC1E3D Received: from pv50p00im-ztdg10011301.me.com (pv50p00im-ztdg10011301.me.com [17.58.6.40]) by imf22.hostedemail.com (Postfix) with ESMTP id 52975C0025 for ; Thu, 13 Apr 2023 14:35:51 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=me.com header.s=1a1hai header.b="xO/T7yXe"; spf=pass (imf22.hostedemail.com: domain of sxwjean@me.com designates 17.58.6.40 as permitted sender) smtp.mailfrom=sxwjean@me.com; dmarc=pass (policy=quarantine) header.from=me.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1681396551; 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=JAgRIwnVPHjbTYshg0Cq1C5avnVLUoxXJ3pl2kvDPSY=; b=n/n3jXeT5wkpUifLVTqEHbxuijD3hvi77O0ulwmvDpa4VzB1oSd0k+lyvG7l3kkHHXQaUd 9ep1mXoIdtEz2xu+vZWHJUuaKi+o4XzVwNLMemCs4q6rhrWoJpO/Wkc5Z5t9Kh11dyXaOq YbwDck9yAbw+zOl/piql7EpcNmLzVTs= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=me.com header.s=1a1hai header.b="xO/T7yXe"; spf=pass (imf22.hostedemail.com: domain of sxwjean@me.com designates 17.58.6.40 as permitted sender) smtp.mailfrom=sxwjean@me.com; dmarc=pass (policy=quarantine) header.from=me.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1681396551; a=rsa-sha256; cv=none; b=54M7PZ87vbwhknSVdxnbq50vWb4Hajziu801zjK0fK9S/2AqJRSpRtPSXsbNcWKJN74HtJ aSguPhlZmMUvwVr76pv/w5KxEX7K9NlrxXALWzs5s5BImmgA0YMsii+mSg4A7ySjQjR4OH gQOO3WwxM7h0CXDm1W4k4AZ+eRODptM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=me.com; s=1a1hai; t=1681396550; bh=JAgRIwnVPHjbTYshg0Cq1C5avnVLUoxXJ3pl2kvDPSY=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=xO/T7yXeroPIvZvyiZbh8x1/X/oIWsBNuf3i2Jxqpee4hQabZaqIUSllys6W3vKOm fhBd5rqPfi0VHzmUG9xcCqs8YguaGRJxQfSBNX2RKZgR3Tlwc58xclavJ+aEuMUzDp e+MMrxFCGJH3sSBXM1INcprrw70wNtK4REsFYbv98wbX7EM8cHX+lQQUUVBqFY7Dq6 /ezTu0fwfSbI+qIgj5EbOxPknN9Z23QwKU4ckcDnydsfIrNH1Ov3I9Qa1QnevgbUFT /Y/EKM+m8TSExEgq4Ox2jjM0CBZTPFZL/jgPmrlbTSuScAJTlidSuIG7euqikTjLSx IuTLBj7bt7/LA== Received: from xiongwei.. (pv50p00im-dlb-asmtp-mailmevip.me.com [17.56.9.10]) by pv50p00im-ztdg10011301.me.com (Postfix) with ESMTPSA id BE746180985; Thu, 13 Apr 2023 14:35:43 +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 3/5] slub: Remove CONFIG_SMP defined check Date: Thu, 13 Apr 2023 22:34:50 +0800 Message-Id: <20230413143452.211250-4-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: Y1U1vCSTKtKD3BAtj30KeORsRiE5ZfNE X-Proofpoint-ORIG-GUID: Y1U1vCSTKtKD3BAtj30KeORsRiE5ZfNE 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=980 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2304130130 X-Stat-Signature: cpd4fyc9fg58xuctej87tq5f315fxr4u X-Rspam-User: X-Rspamd-Queue-Id: 52975C0025 X-Rspamd-Server: rspam06 X-HE-Tag: 1681396551-352849 X-HE-Meta: U2FsdGVkX1+CGTubmbEjuHQyw+JEnKxjQ4Yw8JmsyS4vHMDv5R7hH4hVFOKaurN0Pz6Gq/5qoW3zh1lNZYkWJa1lI48m+TDbHVJZCC61XmDFKw/APbBW1FkeHuY1c4mG0FIJYjGjmhrtW8FgL1udsXopveQD9tsQDIYIIO3sZWD2VkjjdEF3l/Khf+Y1Blp29DAJSqp3NiOeUj5KK2ywWBZOsMHr5Tc6pM9RwvNyY8QWYe40IapFvIhr3VHzj1mNwGeFiiG6ZzopAwr6nLgcbk9iwmAWR6e4jwrmiVo4Giwj3Yw7hRNvL6vCqPThryk1mH+Rmopwdw9myCJJ30cF/4ivBN0p9ggQtY60P/hbzLoKdVsi80nNuCUftTGErfkkkbeZ3Erq4ncpFzjnwbJ7fPFDKhfhIQqQ8RdlluRzC3ojGa88NOPwWZS0Z43dwi4vHwhyKQmsv0lknami+nis0RDJ2Y1ynb77ni4rAipGRGawbAe8wd3QIwtq5wdxGUa97PDC5MlDJlOVQAQ+gdmNn7LPglDnGT2NKR/Y7nYLx/v8lMKbPLdcueNkY1lLOPTezjYN3buXiZ0HDxiL4RzA4ODchqIEU1mzohN7NTBvxI6XdqEv7oAxqSUPv78yGwpzMr1//IHlsMDWowoo9m37Clst0W5nngZ9JG9BfSx0KuEiXnThgQ8CxTgKqNW6lVd3n3hcALaDML/pbwEJYQzOVQRPJ/CvAvZkn4cJSCAiPl5QrUc7WV4aMcyqgBkX3hwBiTwEMccehNksqv7o1TTGhuSPkWlAruog0XPkJNVFS+mXXoIohGymDncORBD5pASHDdvzbuJTRsT1Q11+mUhLt1qRnf1yu8crsClVOTg46mabyImPQ1X1KsKi05Q5yFuPseet8e7F7YxDvx9eOqnjWtMBQVXlnDLlzo6y7X2HvTGGXbZOwg9WnbpbuPqzkKPiG8XJBYh6hxxwjvUd/sn qZ62yyvf T6LN/2FST8Zs9YqFhDKej+a4H1e93aVhJTo/uM9AibUSCMOQ6fjkueS9OvN6H7B38+JQhhCfB/pOg+3uTDiUByH6iuao5dHkpOmf+M/ZIpI1Z67isIrTLH/KgwDueAXhtuJGQ9zq+7BhG8MaQ48C09v5vVaO7fQcvFKiBHtdlZdIkL9QI493eWWB8p+/jazbRkMXGpNI55WA4YGjhvFEdfO7kcGu2VjaQEQ2Ms6Q6n7LH0SlKrSDM6zyXwqLbrdu7MVAnBM7sXdZxJehAWKQD03e6uVSbKCJU13a10Tf6YRX0NKzcOAXyVeYA+Q58C3sh1H5BMl7TCw1MxNn/C/RL8Bb8o9634gjTqXhIB+6jlIVUt4hb8b1oqacAkO3eybTaLWpqOesWVi4Z1v9MwKpXx9LqvQ== 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 As CONFIG_SMP is one of dependencies of CONFIG_SLUB_CPU_PARTIAL, so if CONFIG_SLUB_CPU_PARTIAL is defined then CONFIG_SMP must be defined, no need to check CONFIG_SMP definition here. Signed-off-by: Xiongwei Song --- mm/slub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/slub.c b/mm/slub.c index b8afe12ebba1..d897df8fe7e7 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -5641,7 +5641,7 @@ static ssize_t slabs_cpu_partial_show(struct kmem_cache *s, char *buf) objects = (slabs * oo_objects(s->oo)) / 2; len += sysfs_emit_at(buf, len, "%d(%d)", objects, slabs); -#if defined(CONFIG_SLUB_CPU_PARTIAL) && defined(CONFIG_SMP) +#ifdef CONFIG_SLUB_CPU_PARTIAL for_each_online_cpu(cpu) { struct slab *slab; 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; } From patchwork Thu Apr 13 14:34:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiongwei Song X-Patchwork-Id: 13210360 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 847A8C77B61 for ; Thu, 13 Apr 2023 14:36:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 276E3900004; Thu, 13 Apr 2023 10:36:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 226166B007E; Thu, 13 Apr 2023 10:36:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 13C44900004; Thu, 13 Apr 2023 10:36:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 02A296B007D for ; Thu, 13 Apr 2023 10:36:07 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id CF241C0275 for ; Thu, 13 Apr 2023 14:36:06 +0000 (UTC) X-FDA: 80676617532.30.BF98B52 Received: from pv50p00im-ztdg10011301.me.com (pv50p00im-ztdg10011301.me.com [17.58.6.40]) by imf09.hostedemail.com (Postfix) with ESMTP id DA73A14000C for ; Thu, 13 Apr 2023 14:36:04 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=me.com header.s=1a1hai header.b=JvOgqw6h; 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=1681396565; 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=MbAmcnG2CXhNY1EHnQtPRAGFD2rG2vh6+CqnhkUIkDg=; b=L5qhWX2CMu1soLK62rbJakKaqMBiUeirzLQ0IP89KmUK/yRs1lClSjPQVJGqwrJWYRXjQd 1geyseWb1k36zuiKm4OMTKmcyw1V3WCdMTTIR8Sg/QKBtmZt7MmIN56vPHh/oDiYnMJeHd HZXcOZ4PHmCcuUnxSajZ8xWbVucZ6VY= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=me.com header.s=1a1hai header.b=JvOgqw6h; 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=1681396565; a=rsa-sha256; cv=none; b=YWaCbS5LosDElVSMyY85VThqHE5g6JfyO96EztHkTXBtCdlocrrzPd2X0WWhAJJ/CACsI1 sFqqwuUd+omsRUozBwF5UI4byUpHWDHOzvhucM6QyhO4oS0mur+lHCJKBHhG+ulW1iB1FA uCVWUWVqkHEJDr/9nmA+qmXybZCjmYM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=me.com; s=1a1hai; t=1681396563; bh=MbAmcnG2CXhNY1EHnQtPRAGFD2rG2vh6+CqnhkUIkDg=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=JvOgqw6hQO6n706BQdyO1B5LykXqDdOsxC0Bat5AR7nSJZ3p1SJ3qIl3wSiTXSFyO wVvA9qtPK016jKajDu3n+P0tiMWM4FMq28xZnd7xUYbY/MPwODpTNsD7xkcEblz6Et QrfwEr+Zf5Tv3QDroo6WkXUc2MqwJ9yYBfeltVVuofA1zyEk+trEPIDlD20sMFsc85 AQr3Gqz4B7MNDCJ6Ei4lch97oAxilcSTnaezMb9H7+j6jJXRdeUUbIn1geZQpfs9sS ul0O/SS2Xizt0f0davmFhyeq88cIzma7kCuo0S8OQaGOjCHbSQJMWN7k/80Na58tgj XJl+AQFv11KZw== Received: from xiongwei.. (pv50p00im-dlb-asmtp-mailmevip.me.com [17.56.9.10]) by pv50p00im-ztdg10011301.me.com (Postfix) with ESMTPSA id A6CC818099F; Thu, 13 Apr 2023 14:35:56 +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 5/5] slub: Don't read nr_slabs and total_objects directly Date: Thu, 13 Apr 2023 22:34:52 +0800 Message-Id: <20230413143452.211250-6-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: nAzode42SKfbD2lWdSEdjskVbXveXf7e X-Proofpoint-ORIG-GUID: nAzode42SKfbD2lWdSEdjskVbXveXf7e 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=683 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2304130130 X-Rspamd-Queue-Id: DA73A14000C X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: bywggqifrth5fxnm4s1i8hrg1wznbtfc X-HE-Tag: 1681396564-444023 X-HE-Meta: U2FsdGVkX1/JkEDo7UP9Dy1ki8f8pH67eXAOU1836VS2PTt4Iwz+JtwpYVzQ4iY8pCKIMLaC43/Sus/BdE66eqH9WK9jym6z2Bd4ms4vqaip89xfP32NnPrtpimCxqtSRFJW3NmOxS+gDZyfPvQM+mpKtxO72UuEc5SQUER/gYEs8+S/8CVawOdDP4m/10jx2eH5Ja0lu5luz8/GdqsGtHkUldx9p5QjkcLogb1C/6C2Xn41QYHyzWgiRNESg7SlwzuPbkRdrAiSSsPAvDTxFVqyJl9sbdi3s3JlJ9TxvZLY+5PU4vvkcspmD3VkqKELCkhnKY7rQK5pFIeVljGRM9KYurWQRMXi9wbbs4KhJz+o/Fkn/XXneBCUthSC9275YOGEv4baK6OlUsb0xwjHlNPvRMQ73+gzpyL55yHaAj7CzrWA4yjYFw+cT0Hkj/zE0xeINdERB0q/ti3DhkvJgZ/o+7jAAXJlyBYlw6ikTsMdg0Kfvyd5VkbdS62mJvF04IT1Cs/8EqVHk5KznW+FS1CNfPQt465JJhYBhr8Zfuz8+LIccN7YRJe6yanbq1SUT57ei2jo1J3D7IxCKU/T2SSsRuzDM9K6OOPgYiTinLZzhMxO9ycjyKADOUC5ZTx31ggpi5IcKdFmbkozLo4itOQ82gn7VlTgjqjZ3tG5sA6O3TyKDzHp0VymnxIpRNRgxn3qQOuX6CXpvwsnBqaiyjy1ZGCSQM2iIMmaqf47/iqHhrGEnhaZDlv0c+d1wTbEQ6eFRVADp8Wr+29JjnzAmdEoa6pWsZ/lWaAWEvTGtHcnMWLp+wylGoWovwdzREkUP8PGOG1jsdhk40UBgS/BeCfCCJgXal3JXdneidXHiF7oIwp37ixduaVSNkK9hvfpyXc0dSZkW4Xxmn/14pzBINLbDpjN8qMVunUbmz9Xn92FcYgNPpDG+OLoWMZFtH8GjQpClr8b3vzPLUyE0/s ZVu09E94 nq6S7DXnS8EwW5qT4d2pKB6XFTcr8vUyeyRmSsCPGEFY4qNXIx5LjMMbl5TR8nA7+bxDGzWncZfutPfOxBvV0/uH8XsEsfhA4xRiYGgy/eIX0UU9hK3vemSx0DomHZP5d5e+rypOW4085hgB91aHwfodjH3eTK070csQ+Vb3Kjfixa279qJQK+oBq6Wgk8GNixRg51w71XUu1aqsKFZM8VtM/LePKX4rJdm5afYS2Z/X7o1gU5Z/gtML1O/dYS8+oNYbIwplC6EXHtJ0LmaP5PEFGWfmurg+xOgUjBJTGfFP4mc2b2qn3FkdAvlJABXIu23HjXOemwgxuNtY/lLu9N6Q410YIOKk6irMk6V0BCPxPL+vxamfRkJWX2/QA6stcF/vSiekfCmzJsPM1wATRo6f97A== 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 We have node_nr_slabs() to read nr_slabs, node_nr_objs() to read total_objects in a kmem_cache_node, so no need to access the two members directly. Signed-off-by: Xiongwei Song --- mm/slub.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index 33b4fec6bc7a..2c3af399d9d6 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -5157,9 +5157,9 @@ static int validate_slab_node(struct kmem_cache *s, validate_slab(s, slab, obj_map); count++; } - if (count != atomic_long_read(&n->nr_slabs)) { + if (count != node_nr_slabs(n)) { pr_err("SLUB: %s %ld slabs counted but counter=%ld\n", - s->name, count, atomic_long_read(&n->nr_slabs)); + s->name, count, node_nr_slabs(n)); slab_add_kunit_errors(); } @@ -5443,12 +5443,11 @@ static ssize_t show_slab_objects(struct kmem_cache *s, for_each_kmem_cache_node(s, node, n) { if (flags & SO_TOTAL) - x = atomic_long_read(&n->total_objects); + x = node_nr_objs(n); else if (flags & SO_OBJECTS) - x = atomic_long_read(&n->total_objects) - - count_partial(n, count_free); + x = node_nr_objs(n) - count_partial(n, count_free); else - x = atomic_long_read(&n->nr_slabs); + x = node_nr_slabs(n); total += x; nodes[node] += x; } @@ -6387,7 +6386,7 @@ static int slab_debug_trace_open(struct inode *inode, struct file *filep) unsigned long flags; struct slab *slab; - if (!atomic_long_read(&n->nr_slabs)) + if (!node_nr_slabs(n)) continue; spin_lock_irqsave(&n->list_lock, flags);