From patchwork Wed Aug 21 03:26:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Leizhen (ThunderTown)" X-Patchwork-Id: 13770757 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 27DCFC5320E for ; Wed, 21 Aug 2024 03:36:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1EE6E6B0093; Tue, 20 Aug 2024 23:36:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 19C3B6B0096; Tue, 20 Aug 2024 23:36:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 064A36B0095; Tue, 20 Aug 2024 23:36:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id DDC8A6B0083 for ; Tue, 20 Aug 2024 23:35:59 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 3590A1A07C9 for ; Wed, 21 Aug 2024 03:35:59 +0000 (UTC) X-FDA: 82474838838.14.A252131 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf18.hostedemail.com (Postfix) with ESMTP id 298DD1C0010 for ; Wed, 21 Aug 2024 03:35:55 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf18.hostedemail.com: domain of thunder.leizhen@huawei.com designates 45.249.212.190 as permitted sender) smtp.mailfrom=thunder.leizhen@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724211299; a=rsa-sha256; cv=none; b=kDk5we+CDaMW49yKL58a/+rxyoaicc8vDbIZKQ+5diNHkwcnk8O42OvKocYnRNqScysghR coBQ4fT4e7B3R80bhIvmJSkMG00RsWn3k+tADuR7Li3U+PknhCHNKh1Av6NpRJBXH1dwKU EXnh/7AYELqEChIv5ZWXHIyvBmXPszA= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf18.hostedemail.com: domain of thunder.leizhen@huawei.com designates 45.249.212.190 as permitted sender) smtp.mailfrom=thunder.leizhen@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724211299; 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: references; bh=PpbFDrzSWl37dHRDXSGbhWHMRgqHUSKlC7M8V3qYNKc=; b=Gi+sl+GEsQwyHipL5hleV0anqtvsaaTTAmk05FNiJeB9u8X4vgd4vDbkUZ35DyzzAfsBrs pngsfWCWOkegwLzxQ2y99RnUzBQn3DOWpeyp0MgCXX/ZcTu9MmpC8jx1RkfYDU0WzSRGyw 97Z2M2A0Wh83ykS79P5irz61htYEPjg= Received: from mail.maildlp.com (unknown [172.19.88.214]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4WpX6X1tHYz2Cn5k; Wed, 21 Aug 2024 11:35:48 +0800 (CST) Received: from dggpemf100006.china.huawei.com (unknown [7.185.36.228]) by mail.maildlp.com (Postfix) with ESMTPS id 330C71A016C; Wed, 21 Aug 2024 11:35:50 +0800 (CST) Received: from thunder-town.china.huawei.com (10.174.178.55) by dggpemf100006.china.huawei.com (7.185.36.228) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Wed, 21 Aug 2024 11:35:49 +0800 From: Zhen Lei To: Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Vlastimil Babka , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com>, , CC: Zhen Lei Subject: [PATCH 1/1] mm/slab: remove duplicate check in create_cache() Date: Wed, 21 Aug 2024 11:26:37 +0800 Message-ID: <20240821032637.1930-1-thunder.leizhen@huawei.com> X-Mailer: git-send-email 2.37.3.windows.1 MIME-Version: 1.0 X-Originating-IP: [10.174.178.55] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemf100006.china.huawei.com (7.185.36.228) X-Rspamd-Queue-Id: 298DD1C0010 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 1fc8hcn76734e5orttt3oh69jxwwwr4g X-HE-Tag: 1724211355-271344 X-HE-Meta: U2FsdGVkX19ifb82UewBm4O81SgkN0uD7RZ83iFm6SKFti++WzzgdqYZBD+r/d8/3mM7TQ1RNx8iva74FbFVAJ0WsYanYP7kmco3Vfu+U7/QFlL3D0hL4r7MOxHHJ2T80OigjcDKD0tJe/jWUEpin99afu88SmIN+1I0e/zyewX2exgnbXqPbZf49Nqs6RCLl8/pO8rrUI2n7dNnI9zON0QjlWoibqJired8j2Vfdet98Tzuq3s+vpX362XTuAlxGZkkDau5X/wKjyKnptZTGIFN7Gq6fDp4jnLI5bByk+Ulza/RrnixO6fa1BgLX09sLXuxO52KeqmKoLTHWLxC6Ey2IUwXeIT39NvZzEXAF636luRn34QPvAtNTxWi0PiFnRpodZTn7wX76OmgzAxFV8fXUFagMhHr7ox2FNK/+GnGWUeqyB2wH7HtA/FhxeaGWv8Leoz9pB33C9uH2V69Z5vyzWOuOj6/4XtEaxWrocs8YNEsyHNFe4XbiRj/r74/lygLlmQH30Xzy+gitQ8qFmG8QTpbtEPbrRqyk+O3wopZiUWtbAzhEpXTpcCPYlXUKOFWPIgn72vuz95mluzV44/3wpo2y9gGMgjV1WqkUh7ybJ+av1pTpyH4X8HNDLV/9qlvCWhURoyJ47LJiCcNz2XTkUMtD9xC7zCOwZCXeVYeslnAajnGpR1CnmtBfubgkUyX5JZYugeKAg/1Wk5zV6tguktuZCeC3lWv5WFdmv7lJ6oyDSqtYIYigv8Z8zNVfk6dy391G/6/b/pMeeGSWaDWBHOr3KjgQxXQ1K1dusxIwSvTz44ndEXI8UJrdwlRYFbhAnZ11C/BiJ45ltdOVFm2OPBu4+h0p1x68Vgm7YdJsdcWozhjpOdbFmJp+M8ubkBN51ekSQ8yLVtEmuXTliIzvfwbR2naHJFvuu44tdsetrapDL4RFkiLcUwYrBVTzEXj96weKdTyjGQp6aW Tae/JPLA h/G2TJY8mBs+GVNZ2mwFhntgZlVHNglllFn8url0Bpn9t69a5C//him7DkIXZuoqKXGyuVjEqopRWitb2DHqGJbcFeR2ZrpOroAitW482g52LJBOn4vCLQ47M82/gTQdWUZ8brdA7cRhW2/KQO+Tw4gXUA7zrB2RwOUiA1OuwculYzFot6QjMhku4G/XrRD11SDN60WU+76rZiAEXy/Ixuim6HoZxVdaNcA6XRyS8RHS8M1JxSUs9dcFLvCKEJcIYhe/qQjW/PDFhzKc= 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: The WARN_ON() check in static function create_cache() is done by its only parent kmem_cache_create_usercopy() before calling it. if (... WARN_ON(size < usersize || size - usersize < useroffset)) usersize = useroffset = 0; ... s = create_cache(..., size, ..., useroffset, usersize, ...); Therefore, the WARN_ON() check in create_cache() can be safely removed. Signed-off-by: Zhen Lei --- mm/slab_common.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/mm/slab_common.c b/mm/slab_common.c index 40b582a014b8f2f..3069c9095523484 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -210,9 +210,6 @@ static struct kmem_cache *create_cache(const char *name, struct kmem_cache *s; int err; - if (WARN_ON(useroffset + usersize > object_size)) - useroffset = usersize = 0; - err = -ENOMEM; s = kmem_cache_zalloc(kmem_cache, GFP_KERNEL); if (!s)