Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp317017ybm; Fri, 29 May 2020 00:31:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyUMqKMQ8Q88NUzR2iS6LV/oWbx4hy+CPj3ucw+FmusB833Cr+DuasUo1ajJFzDBzpJEy1z X-Received: by 2002:aa7:c758:: with SMTP id c24mr6713539eds.290.1590737518041; Fri, 29 May 2020 00:31:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590737518; cv=none; d=google.com; s=arc-20160816; b=wXFZJYdzl1Em/voaX4j0qeME60kZ0uW16gbECgC/Iaa2GJZ/AZRe9bi0jEp3emu455 D/qjUlecWmeBBZxpfx6J6+fM35co2WQlmIvP1/CKN6NShPO/9iHLVt6TfEn8YiNngG8x fRRodDIvE38yDvNq7rbiG1PDOWkrmqx9D8QpkIxKr1ll4xLBXsTmGSSEWEos0MS7lZG3 goeU50qsbDt7WYxiPdjfVjCNar4vKZxS4ToVfZEQCvIg0Dwgvcuxzu5VsJB9S+/xILkK t72OkLTGiwa5RtAomGfSXmP5K0/3tWtljUYnas7GXs0+wfj8chAAPBfR9iCbQAU6t5JF lWMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=TPv6vGGiPD/jUBGg8QoDaCS77XjCgUDaUEzUBUkqxK8=; b=NJXKJH1HHIgtcFqFmegs63RYYaqvAOkFpUAFB5JCwi9Wf5VHOPE7QrkA5UU/1/Yd2U polDs7I+NLyhZT7rcZAEMw1eRaaZkG0YTvziTx5YHaHb6kpedmjOnOKpaOU+WzZxGty0 S1kmW5ZkdO04cfG4y41DjOec2w2KWPU02YOEDUL89Jn689az2JXcTnpgQcB8KwdRcqJF whNl40rPBVRCxT0pHPo9IayJv8GD2DCHCiLPtHP/85UDtq/04RwmckSYInPhiAx/brK4 uPZu71QrOKH13SJF1QxhEdItbaurNqZK1Vy1eHvM95t1V0tcMDMjtmQqjrlc5MykahOR i1yg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p1si4736940edb.406.2020.05.29.00.31.34; Fri, 29 May 2020 00:31:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725936AbgE2H1f (ORCPT + 99 others); Fri, 29 May 2020 03:27:35 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:5308 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725355AbgE2H1f (ORCPT ); Fri, 29 May 2020 03:27:35 -0400 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 4C47CEE2736375FBA807; Fri, 29 May 2020 15:27:33 +0800 (CST) Received: from [127.0.0.1] (10.67.102.197) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.487.0; Fri, 29 May 2020 15:27:22 +0800 Subject: Re: [PATCH v4 1/4] sysctl: Add register_sysctl_init() interface To: Luis Chamberlain CC: , , , , , , , , , , , , , , , , , , , , , References: <1589859071-25898-1-git-send-email-nixiaoming@huawei.com> <1589859071-25898-2-git-send-email-nixiaoming@huawei.com> <20200529070903.GV11244@42.do-not-panic.com> From: Xiaoming Ni Message-ID: <3d2d4b2e-db9e-aa91-dd29-e15d24028964@huawei.com> Date: Fri, 29 May 2020 15:27:22 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.1.2 MIME-Version: 1.0 In-Reply-To: <20200529070903.GV11244@42.do-not-panic.com> Content-Type: text/plain; charset="gbk"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.67.102.197] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020/5/29 15:09, Luis Chamberlain wrote: > On Tue, May 19, 2020 at 11:31:08AM +0800, Xiaoming Ni wrote: >> --- a/kernel/sysctl.c >> +++ b/kernel/sysctl.c >> @@ -3358,6 +3358,25 @@ int __init sysctl_init(void) >> kmemleak_not_leak(hdr); >> return 0; >> } >> + >> +/* >> + * The sysctl interface is used to modify the interface value, >> + * but the feature interface has default values. Even if register_sysctl fails, >> + * the feature body function can also run. At the same time, malloc small >> + * fragment of memory during the system initialization phase, almost does >> + * not fail. Therefore, the function return is designed as void >> + */ > > Let's use kdoc while at it. Can you convert this to proper kdoc? > Sorry, I do n??t know the format requirements of Kdoc, can you give me some tips for writing? >> +void __init register_sysctl_init(const char *path, struct ctl_table *table, >> + const char *table_name) >> +{ >> + struct ctl_table_header *hdr = register_sysctl(path, table); >> + >> + if (unlikely(!hdr)) { >> + pr_err("failed when register_sysctl %s to %s\n", table_name, path); >> + return; > > table_name is only used for this, however we can easily just make > another _register_sysctl_init() helper first, and then use a macro > which will concatenate this to something useful if you want to print > a string. I see no point in the description for this, specially since > the way it was used was not to be descriptive, but instead just a name > followed by some underscore and something else. > Good idea, I will fix and send the patch to you as soon as possible >> + } >> + kmemleak_not_leak(hdr); > > Is it *wrong* to run kmemleak_not_leak() when hdr was not allocated? > If so, can you fix the sysctl __init call itself? I don't understand here, do you mean that register_sysctl_init () does not need to call kmemleak_not_leak (hdr), or does it mean to add check hdr before calling kmemleak_not_leak (hdr) in sysctl_init ()? > PS. Since you have given me your series, feel free to send me a patch > as a follow up to this in privae and I can integrate it into my tree. > > Luis > Thanks Xiaoming Ni