From patchwork Sat Jan 22 06:12:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12720500 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 59F93C433EF for ; Sat, 22 Jan 2022 06:12:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E06D66B00AB; Sat, 22 Jan 2022 01:12:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DB5B06B00AD; Sat, 22 Jan 2022 01:12:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C55E86B00AC; Sat, 22 Jan 2022 01:12:22 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0161.hostedemail.com [216.40.44.161]) by kanga.kvack.org (Postfix) with ESMTP id B63116B00A9 for ; Sat, 22 Jan 2022 01:12:22 -0500 (EST) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 853B093D61 for ; Sat, 22 Jan 2022 06:12:22 +0000 (UTC) X-FDA: 79056903324.04.3472726 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf19.hostedemail.com (Postfix) with ESMTP id D153C1A0009; Sat, 22 Jan 2022 06:12:21 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 42AF460C52; Sat, 22 Jan 2022 06:12:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3EFBCC004E1; Sat, 22 Jan 2022 06:12:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1642831940; bh=4f34QbniaFP5T1em3aVmWIhw1dgLoXC5f3T8QcX/sHk=; h=Date:From:To:Subject:In-Reply-To:From; b=rqMVwLb/4vjAcIFnTseyJP/o9qiTrmGviC804w5fz41C8g/tA16MmH7Nl3f6wRJKN HEB4O+A9ptSeyDY8McWXB3eUPXM0C6jq71Zyk1N4T7wSImdBsZfeBkfafrWXX+rmKs 4NrMEnLCAt0tpd+dxhMCiTrJWQUevDrQHSsyiHQQ= Date: Fri, 21 Jan 2022 22:12:18 -0800 From: Andrew Morton To: airlied@linux.ie, akpm@linux-foundation.org, amir73il@gmail.com, andriy.shevchenko@linux.intel.com, arnd@arndb.de, bcrl@kvack.org, benh@kernel.crashing.org, clemens@ladisch.de, crope@iki.fi, dgilbert@interlog.com, ebiederm@xmission.com, gregkh@linuxfoundation.org, jack@suse.cz, jani.nikula@intel.com, jani.nikula@linux.intel.com, jejb@linux.ibm.com, jlbec@evilplan.org, john.ogness@linutronix.de, joonas.lahtinen@linux.intel.com, joseph.qi@linux.alibaba.com, julia.lawall@inria.fr, keescook@chromium.org, kernel@tuxforce.de, linux-mm@kvack.org, mark@fasheh.com, martin.petersen@oracle.com, mcgrof@kernel.org, mm-commits@vger.kernel.org, nixiaoming@huawei.com, penguin-kernel@I-love.SAKURA.ne.jp, peterz@infradead.org, phil@philpotter.co.uk, pjt@google.com, pmladek@suse.com, rafael@kernel.org, rodrigo.vivi@intel.com, rostedt@goodmis.org, senozhatsky@chromium.org, sre@kernel.org, steve@sk2.org, surenb@google.com, torvalds@linux-foundation.org, tytso@mit.edu, viro@zeniv.linux.org.uk, wangqing@vivo.com, yzaikin@google.com Subject: [patch 20/69] random: move the random sysctl declarations to its own file Message-ID: <20220122061218.N1-ElDxfn%akpm@linux-foundation.org> In-Reply-To: <20220121221021.60533b009c357d660791476e@linux-foundation.org> User-Agent: s-nail v14.8.16 Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b="rqMVwLb/"; dmarc=none; spf=pass (imf19.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org X-Stat-Signature: 3jwzc66a67drqhgq8e37731j1sga991t X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: D153C1A0009 X-HE-Tag: 1642831941-698376 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: Xiaoming Ni Subject: random: move the random sysctl declarations to its own file kernel/sysctl.c is a kitchen sink where everyone leaves their dirty dishes, this makes it very difficult to maintain. To help with this maintenance let's start by moving sysctls to places where they actually belong. The proc sysctl maintainers do not want to know what sysctl knobs you wish to add for your own piece of code, we just care about the core logic. So move the random sysctls to their own file and use register_sysctl_init(). [mcgrof@kernel.org: commit log update to justify the move] Link: https://lkml.kernel.org/r/20211124231435.1445213-3-mcgrof@kernel.org Signed-off-by: Xiaoming Ni Signed-off-by: Luis Chamberlain Cc: Al Viro Cc: Amir Goldstein Cc: Andy Shevchenko Cc: Antti Palosaari Cc: Arnd Bergmann Cc: Benjamin Herrenschmidt Cc: Benjamin LaHaise Cc: Clemens Ladisch Cc: David Airlie Cc: Douglas Gilbert Cc: Eric Biederman Cc: Greg Kroah-Hartman Cc: Iurii Zaikin Cc: James E.J. Bottomley Cc: Jani Nikula Cc: Jani Nikula Cc: Jan Kara Cc: Joel Becker Cc: John Ogness Cc: Joonas Lahtinen Cc: Joseph Qi Cc: Julia Lawall Cc: Kees Cook Cc: Lukas Middendorf Cc: Mark Fasheh Cc: Martin K. Petersen Cc: Paul Turner Cc: Peter Zijlstra Cc: Petr Mladek Cc: Phillip Potter Cc: Qing Wang Cc: "Rafael J. Wysocki" Cc: Rodrigo Vivi Cc: Sebastian Reichel Cc: Sergey Senozhatsky Cc: Stephen Kitt Cc: Steven Rostedt (VMware) Cc: Suren Baghdasaryan Cc: Tetsuo Handa Cc: "Theodore Ts'o" Signed-off-by: Andrew Morton --- drivers/char/random.c | 14 ++++++++++++-- include/linux/sysctl.h | 1 - kernel/sysctl.c | 5 ----- 3 files changed, 12 insertions(+), 8 deletions(-) --- a/drivers/char/random.c~random-move-the-random-sysctl-declarations-to-its-own-file +++ a/drivers/char/random.c @@ -1992,8 +1992,7 @@ static int proc_do_entropy(struct ctl_ta } static int sysctl_poolsize = POOL_BITS; -extern struct ctl_table random_table[]; -struct ctl_table random_table[] = { +static struct ctl_table random_table[] = { { .procname = "poolsize", .data = &sysctl_poolsize, @@ -2055,6 +2054,17 @@ struct ctl_table random_table[] = { #endif { } }; + +/* + * rand_initialize() is called before sysctl_init(), + * so we cannot call register_sysctl_init() in rand_initialize() + */ +static int __init random_sysctls_init(void) +{ + register_sysctl_init("kernel/random", random_table); + return 0; +} +device_initcall(random_sysctls_init); #endif /* CONFIG_SYSCTL */ struct batched_entropy { --- a/include/linux/sysctl.h~random-move-the-random-sysctl-declarations-to-its-own-file +++ a/include/linux/sysctl.h @@ -217,7 +217,6 @@ extern int unaligned_dump_stack; extern int no_unaligned_warning; extern struct ctl_table sysctl_mount_point[]; -extern struct ctl_table random_table[]; #else /* CONFIG_SYSCTL */ static inline struct ctl_table_header *register_sysctl_table(struct ctl_table * table) --- a/kernel/sysctl.c~random-move-the-random-sysctl-declarations-to-its-own-file +++ a/kernel/sysctl.c @@ -2145,11 +2145,6 @@ static struct ctl_table kern_table[] = { .proc_handler = sysctl_max_threads, }, { - .procname = "random", - .mode = 0555, - .child = random_table, - }, - { .procname = "usermodehelper", .mode = 0555, .child = usermodehelper_table,