From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 802FDC433F5 for ; Wed, 13 Apr 2022 08:45:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234070AbiDMIsI (ORCPT ); Wed, 13 Apr 2022 04:48:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234311AbiDMIr4 (ORCPT ); Wed, 13 Apr 2022 04:47:56 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9CBA13CCE for ; Wed, 13 Apr 2022 01:45:35 -0700 (PDT) Received: from dggpemm500020.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4KdbhX6y4vzFpqt; Wed, 13 Apr 2022 16:43:08 +0800 (CST) Received: from dggpemm500001.china.huawei.com (7.185.36.107) by dggpemm500020.china.huawei.com (7.185.36.49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 13 Apr 2022 16:45:31 +0800 Received: from [10.174.177.243] (10.174.177.243) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2375.24; Wed, 13 Apr 2022 16:45:30 +0800 Message-ID: Date: Wed, 13 Apr 2022 16:45:30 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.5.1 Subject: Re: [PATCH v3 3/4] hugetlb: Fix return value of __setup handlers Content-Language: en-US To: Muchun Song , "liupeng (DM)" CC: , , , , , , , References: <20220413032915.251254-1-liupeng256@huawei.com> <20220413032915.251254-4-liupeng256@huawei.com> <5bbf45e7-1d92-f543-5cfc-bc0141999d46@huawei.com> From: Kefeng Wang In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.177.243] X-ClientProxiedBy: dggeme701-chm.china.huawei.com (10.1.199.97) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022/4/13 16:21, Muchun Song wrote: > On Wed, Apr 13, 2022 at 04:16:11PM +0800, liupeng (DM) wrote: >> On 2022/4/13 15:55, Muchun Song wrote: >>> On Wed, Apr 13, 2022 at 03:29:14AM +0000, Peng Liu wrote: >>>> When __setup() return '0', using invalid option values causes the >>>> entire kernel boot option string to be reported as Unknown. Hugetlb >>>> calls __setup() and will return '0' when set invalid parameter >>>> string. >>>> >>>> The following phenomenon is observed: >>>> cmdline: >>>> hugepagesz=1Y hugepages=1 >>>> dmesg: >>>> HugeTLB: unsupported hugepagesz=1Y >>>> HugeTLB: hugepages=1 does not follow a valid hugepagesz, ignoring >>>> Unknown kernel command line parameters "hugepagesz=1Y hugepages=1" >>>> >>>> Since hugetlb will print warning/error information before return for >>>> invalid parameter string, just use return '1' to avoid print again. >>>> >>> Can't return -EINVAL? It is weird to return 1 on failure. >>> >>> Thanks. >>> >>> . >> Not against "return -EINVAL", but consistent with: >> 1d02b444b8d1 ("tracing: Fix return value of __setup handlers") > I think it is better not return 1. I don't think it's a good habit we > should follow. /*  * NOTE: __setup functions return values:  * @fn returns 1 (or non-zero) if the option argument is "handled"  * and returns 0 if the option argument is "not handled".  */ #define __setup(str, fn)               \        __setup_param(str, fn, fn, 0) 1 or -EINVAL should ok, and  most __setup return 1 for know ;) > Thanks. > > Thanks. > > .