From patchwork Wed Oct 9 03:54:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Leizhen (ThunderTown)" X-Patchwork-Id: 13827519 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 37FBBCF043B for ; Wed, 9 Oct 2024 03:55:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9C5B26B00CA; Tue, 8 Oct 2024 23:55:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 975E96B00CB; Tue, 8 Oct 2024 23:55:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 83C066B00D4; Tue, 8 Oct 2024 23:55:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 628896B00CA for ; Tue, 8 Oct 2024 23:55:56 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 6C284C0F5F for ; Wed, 9 Oct 2024 03:55:53 +0000 (UTC) X-FDA: 82652700270.05.7B178E8 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf15.hostedemail.com (Postfix) with ESMTP id 5F025A0004 for ; Wed, 9 Oct 2024 03:55:51 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf15.hostedemail.com: domain of thunder.leizhen@huawei.com designates 45.249.212.188 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=1728446018; 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=Ryp7Jp18B3NJwXCroxQedvpOvV763pZ8HxchbRuc35k=; b=QRnkcVdxawrgZvJ4c3umRX3GmauIlccKOuRISsN1APGEPeGJ5NVFFlTJ+nZ0Znm6mzy33d jeHIZdxGXica199l4GdfcRzTrtwdlIbec69nYE6og+jy7HqX9bC++m8Bx+MsCjQu8OSsSh pmdUofCsklZLvOfuN9vnKLy9fGSe8+A= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728446018; a=rsa-sha256; cv=none; b=payvG2+GfFrQ60JncjfaKNx/2mlZZWvQf7aCx/OHJproyu3ZKpPOJwYjQ2U7PAXs0wofSL qm3N2zizkUCylIdwxTfLzuScfhAd5ZIcQO9eZk+XuUqy7Ao11qJlVQFr0BU0L+iWSezpkO 5MCQFtZxwaejZ5VNUICFIlCU31XC344= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf15.hostedemail.com: domain of thunder.leizhen@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=thunder.leizhen@huawei.com Received: from mail.maildlp.com (unknown [172.19.163.48]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4XNfBh03lYzpWGw; Wed, 9 Oct 2024 11:53:48 +0800 (CST) Received: from dggpemf100006.china.huawei.com (unknown [7.185.36.228]) by mail.maildlp.com (Postfix) with ESMTPS id D731E18006C; Wed, 9 Oct 2024 11:55:47 +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, 9 Oct 2024 11:55:47 +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 v2 1/1] mm/slab: remove duplicate check in create_cache() Date: Wed, 9 Oct 2024 11:54:55 +0800 Message-ID: <20241009035455.616-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: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemf100006.china.huawei.com (7.185.36.228) X-Rspamd-Queue-Id: 5F025A0004 X-Stat-Signature: 98ipc7s149zawadzf9tsfkn5pbubp4au X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1728446151-892164 X-HE-Meta: U2FsdGVkX1+D+W3yb6Q1QRzUQsI3qKP8Jmzp7R6+CfYbyFVgSpP1f7FEP6vGiDxTuxAb3hhITb5AjbihFf3dXUR5WC/nj8BSAp1UuHRoTeWYypdbHAdNRjjRZxJb7AFMrNjzY41sCpJyDEx+EhKp1EA2gD+UpFoHFM8XO5WG9DIjpajQ9dMdfT90EvXRx4OUoXEDcE6Q3EQQsHL1y5PfbfVIBJ+WL9MpjCU1C8KvZ7OuOOPtTa9JiEq+7tHK4Z8Z9lQiAUs4GfbX/s6d0g9w9iFlrcJ6mBdktlrzIJ2lQG/fK+EV7Zzsveaa8xutVQCdcYOOdoVFyoUPHMgES5ow4wQ8TeHRoaYBQ0kFCUt9rQ16Q2h+yOeMfqLMDivdAfvSRxa517hOpEQ8QIxSm10+K5T9dDOoKq/pTCXOfje4/OuVOBD8f6NyrhH8+yeNgtiiVtIg7BIVJgZ/FaIgi7otWo68Y83j24JHf9keel8WZtehZAtZgF8uzS2d96hfttmnPTFN+NKdD7MS9t8FF6wy6Vj3EVTDGzjJnXxINXWiWfmi8Vn+fAGPzYYzv2xB92Sd96N5r0Er4HAcXETq0sN54F80L7M92Exs6Xrb/6N9x4rBUUF4ee7x/fMhRkNJarmg9yQ853EeyhIcGnnDeIORjfpmd5tIQ7+D5jvf1S0OBvpg2CLRZwt/8KJTg1S/XWTHw88RsoydI9845Q5O7HBhB3T6+MbekwBWex+QTLey86oYBaGzranp0R4eI6/KdOuAuJ8FZNhtPg3vxSDdqViRRr5jt2tmXTsy4nUfy1qRMCK5etLY6UlwTRVxBACRibmt4VtnIObFi2nJiJGoytBZ+i3YkgaZhx5HLOCer1cAKe6ylTjKIkr5nxSMuPrN9o9siOrpIRrol3aqCoXwmHoK+3p+QXgH9xBDFgx+Jlkp3PbV1sOp/YTW8Cb/hotd8Onj3Sj4/y4dUP97Lm+xxcj 3HFx2sJn SfkDnX9CEeN6yq6iAlexsqRSkI2SIBaVOYsU3RTXDZD/kqhPkMTzF63i+A8NhV5OKH/QoedswmsuY0/7XOChsf60mIRgapeO5XqWbfiY+YvLZHcuUbS3YIcXJB0nOi1dVhHbgvqgb5+X00CqJo0McEvpHxdIRg2sMnHYyfFyhrrhqg0VPUaDx40mufkhw7LGZNJVbR4WUK82bqb2/JqhtD3ahAOZXcRIycWnOyzCKod8lTKU0HM3SJj111ssXb7eQPESXmsnW+lzcsO8= 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_args() before calling it. if (... || WARN_ON(... || object_size - args->usersize < args->useroffset)) args->usersize = args->useroffset = 0; ... s = create_cache(cache_name, object_size, args, flags); 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(-) v1 --> v2: Updates based on the latest v6.12-rc2. diff --git a/mm/slab_common.c b/mm/slab_common.c index 3d26c257ed8b57c..88aa64fc8cd2742 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -222,9 +222,6 @@ static struct kmem_cache *create_cache(const char *name, struct kmem_cache *s; int err; - if (WARN_ON(args->useroffset + args->usersize > object_size)) - args->useroffset = args->usersize = 0; - /* If a custom freelist pointer is requested make sure it's sane. */ err = -EINVAL; if (args->use_freeptr_offset &&