Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp4268885rwd; Tue, 23 May 2023 05:44:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ71YqSF6WFRazmq149QHcE1T2FwOgNjb+dDOUUmaPdO1iVmU1B2FMTePRTwxghPWtBeWWpo X-Received: by 2002:a17:902:7848:b0:1af:a2a4:8374 with SMTP id e8-20020a170902784800b001afa2a48374mr6720422pln.21.1684845882305; Tue, 23 May 2023 05:44:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684845882; cv=none; d=google.com; s=arc-20160816; b=j3qYN6AQ9FQL2pjY3QVg+3A98B/zFPuUcpmPPAzObpKL1BSM/xgKcU/rl5vzOuhpIk nHcyCGK7iHNm48SqYIm6WrsTWFhbBMTSyNB23rufR4mqe62xYpcoMGnOYo/SiUlnOCJr IsOdsZ0Kz4SEB/Ym4VWrUWOlGb5dVSF3FkPukKETGE3d7z5K+Qxwif7zubNWKWomeDGE pIBH4tHa8KBpMXQ10ljsttOyr8dBGt8smYbhGLHr6qOunJ03kpPGqdDrgn7eGRZPguxR BetDG6e6SAQ7so0HBo2R57vpg2saBcIQHKni8q5/gWFzZUTfKh0BfzXcrNwIGcKxXkVG az2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:cms-type:content-transfer-encoding :mime-version:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=XgkbRo19UlgdrEJvMNy7N2uFh3oWcAT22mim1ypDjVs=; b=tnANq37Za0v5/5Qk9MW+L55/u1avdGoTIuTowHZ2qZR6eIL7NX+x8qNbHvQRERxvFq AJLmEUmCyxHWNUWKsLHFRUS3xfdyX8l+07mMtx+K+xlKDk3dipKAV25dB1q1BViqc3vp fBPiGYy94uQ7RKiBQhpRhxZuCTVJiv4/7n8iFwgFn/UM9v4I9t0yfUQuEg3nMy/shdTG sEQ+SpRvW8VrWfYuHlCcZnMaRp6V1Y93lpUVIBtHpRghLEXG08pZbVRc850zZJB9Rz3y tOIeHCMPbUwW3WsZCh1nzLvDaD1+BMCEBM4YzQA+IdJVDEDy+5YKVJOPyqal/qoZXfHq 5nVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=a7ofdDb0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p2-20020a170902eac200b001add2ba445asi6188310pld.259.2023.05.23.05.44.27; Tue, 23 May 2023 05:44:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=a7ofdDb0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236910AbjEWMXH (ORCPT + 99 others); Tue, 23 May 2023 08:23:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236669AbjEWMWv (ORCPT ); Tue, 23 May 2023 08:22:51 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C3A5129 for ; Tue, 23 May 2023 05:22:38 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20230523122237euoutp01cb60457403713d4888f24f759b9c44a5~hxTK73nJB1779417794euoutp01H for ; Tue, 23 May 2023 12:22:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20230523122237euoutp01cb60457403713d4888f24f759b9c44a5~hxTK73nJB1779417794euoutp01H DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1684844557; bh=XgkbRo19UlgdrEJvMNy7N2uFh3oWcAT22mim1ypDjVs=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=a7ofdDb0csT5TBo0Gzshl+6CUFh30TL9pPvEOnlhE6xMgVkSE3kBMG2NACXoLQTH6 /TJ1zo7CRwfPnz3YwOl946TcDGJ11Yy01ufCe3cgHyHhpyeUsRg0XQa4rWWSHp3HkU 0eWOoLat1PCacffKWDc3wO4y3qMaHksUMvNgacr0= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20230523122236eucas1p1836bfa829d041455149d950379d7752d~hxTKoiG5j1843818438eucas1p1y; Tue, 23 May 2023 12:22:36 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 7F.16.11320.C00BC646; Tue, 23 May 2023 13:22:36 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20230523122236eucas1p17639bfdbfb30c9d751e0a8fc85fe2fd3~hxTKUg2Ds1843818438eucas1p1x; Tue, 23 May 2023 12:22:36 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230523122236eusmtrp2a28f795e5ac8c29f6d0a98a61d1d61ea~hxTKT6T3Q0682206822eusmtrp2Z; Tue, 23 May 2023 12:22:36 +0000 (GMT) X-AuditID: cbfec7f4-993ff70000022c38-ad-646cb00c97bd Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 1A.81.14344.C00BC646; Tue, 23 May 2023 13:22:36 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230523122236eusmtip28b71ff19fdedac7014bc085feb7047cf~hxTKHgzmo2661526615eusmtip2W; Tue, 23 May 2023 12:22:36 +0000 (GMT) Received: from localhost (106.210.248.82) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 23 May 2023 13:22:35 +0100 From: Joel Granados To: CC: Christian Brauner , Kees Cook , Joel Granados , , , Iurii Zaikin , Alexander Viro , Sudip Mukherjee Subject: [PATCH v4 7/8] sysctl: Refactor base paths registrations Date: Tue, 23 May 2023 14:22:19 +0200 Message-ID: <20230523122220.1610825-8-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230523122220.1610825-1-j.granados@samsung.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [106.210.248.82] X-ClientProxiedBy: CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) To CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprNKsWRmVeSWpSXmKPExsWy7djPc7o8G3JSDGZOtbB4ffgTo8WZ7lyL PXtPslhc3jWHzeLGhKeMFgdOT2G2OP/3OKvFsp1+DhwesxsusnjsnHWX3WPBplKPTas62Tw+ b5Lz2PTkLVMAWxSXTUpqTmZZapG+XQJXxtHONWwFD9Uq1rd9Zmpg/CnbxcjJISFgIjHz1ge2 LkYuDiGBFYwSi3cfYwJJCAl8YZRovyYCkfjMKHFxzmcmmI5D+29AdSxnlJj65RgrXNX8A3+g MlsYJRZOOsUO0sImoCNx/s0dZhBbREBc4s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mpg/CnbxcjJISFgInFo/w22LkYuDiGBpYwSWzfsY4dIyEhs /HKVFcIWlvhzrYsNxBYS+MgosXyxLETDFkaJ8zPvMIIk2AR0JM6/ucMMYosIiEucOL2ZEaSI WWA7k8SEv7uAujk4hAUcJbbOrgapYRFQldh1azkTiM0rYCvxvfc9G8QyeYm269PBZnIK2Ekc eraPFWKxrUTrq02sEPWCEidnPmEBsZmB6pu3zmaGsCUkDr54wQwxR0liddcfqJm1Ep//PmOc wCgyC0n7LCTts5C0L2BkXsUoklpanJueW2ykV5yYW1yal66XnJ+7iREYm9uO/dyyg3Hlq496 hxiZOBgPMUpwMCuJ8J4oz04R4k1JrKxKLcqPLyrNSS0+xGgK9OdEZinR5HxgcsgriTc0MzA1 NDGzNDC1NDNWEuf1LOhIFBJITyxJzU5NLUgtgulj4uCUamCyeXGmminUaX22y/Lnr632mIsv OKB7wbdFQkLS8NGa5793VF2eU3DwUN/Lj9v7hQV3ifzZJrp2Kf9V+y9Fs8LteScp2GjaTbAz +OnWYSmYFvVw/nb5Bvn78T9fX7iiEVnplPz5d9oy7sMafdXnUyd8bi6u/njjl83soosMH0zP qpv9z/6/VfDIviXZmgVrWKym5zyb+Of20lDDyY+2nZ4bWr3yzNrmvTssWtgV1HMLZ0vvbLXz n8Xr/ly7kX9Br+Bpo5NFcxUSCv+KclT6nXryMJS1R+6AQFqpXgd3R2rHy6OrZzy6tK/348zo rxuaJ22o9JhzVT878vttpawXBq9WmO1Y47X38bTOAP44J4dGJZbijERDLeai4kQA9yom8FYD AAA= X-CMS-MailID: 20230523122236eucas1p17639bfdbfb30c9d751e0a8fc85fe2fd3 X-Msg-Generator: CA X-RootMTR: 20230523122236eucas1p17639bfdbfb30c9d751e0a8fc85fe2fd3 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230523122236eucas1p17639bfdbfb30c9d751e0a8fc85fe2fd3 References: <20230523122220.1610825-1-j.granados@samsung.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is part of the general push to deprecate register_sysctl_paths and register_sysctl_table. The old way of doing this through register_sysctl_base and DECLARE_SYSCTL_BASE macro is replaced with a call to register_sysctl_init. The 5 base paths affected are: "kernel", "vm", "debug", "dev" and "fs". We remove the register_sysctl_base function and the DECLARE_SYSCTL_BASE macro since they are no longer needed. In order to quickly acertain that the paths did not actually change I executed `find /proc/sys/ | sha1sum` and made sure that the sha was the same before and after the commit. We end up saving 563 bytes with this change: ./scripts/bloat-o-meter vmlinux.0.base vmlinux.1.refactor-base-paths add/remove: 0/5 grow/shrink: 2/0 up/down: 77/-640 (-563) Function old new delta sysctl_init_bases 55 111 +56 init_fs_sysctls 12 33 +21 vm_base_table 128 - -128 kernel_base_table 128 - -128 fs_base_table 128 - -128 dev_base_table 128 - -128 debug_base_table 128 - -128 Total: Before=21258215, After=21257652, chg -0.00% Signed-off-by: Joel Granados [mcgrof: modified to use register_sysctl_init() over register_sysctl() and add bloat-o-meter stats] Signed-off-by: Luis Chamberlain Tested-by: Stephen Rothwell --- fs/sysctls.c | 5 ++--- include/linux/sysctl.h | 23 ----------------------- kernel/sysctl.c | 30 +++++++++--------------------- 3 files changed, 11 insertions(+), 47 deletions(-) diff --git a/fs/sysctls.c b/fs/sysctls.c index c701273c9432..76a0aee8c229 100644 --- a/fs/sysctls.c +++ b/fs/sysctls.c @@ -29,11 +29,10 @@ static struct ctl_table fs_shared_sysctls[] = { { } }; -DECLARE_SYSCTL_BASE(fs, fs_shared_sysctls); - static int __init init_fs_sysctls(void) { - return register_sysctl_base(fs); + register_sysctl_init("fs", fs_shared_sysctls); + return 0; } early_initcall(init_fs_sysctls); diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h index 218e56a26fb0..653b66c762b1 100644 --- a/include/linux/sysctl.h +++ b/include/linux/sysctl.h @@ -197,20 +197,6 @@ struct ctl_path { #ifdef CONFIG_SYSCTL -#define DECLARE_SYSCTL_BASE(_name, _table) \ -static struct ctl_table _name##_base_table[] = { \ - { \ - .procname = #_name, \ - .mode = 0555, \ - .child = _table, \ - }, \ - { }, \ -} - -extern int __register_sysctl_base(struct ctl_table *base_table); - -#define register_sysctl_base(_name) __register_sysctl_base(_name##_base_table) - void proc_sys_poll_notify(struct ctl_table_poll *poll); extern void setup_sysctl_set(struct ctl_table_set *p, @@ -247,15 +233,6 @@ extern struct ctl_table sysctl_mount_point[]; #else /* CONFIG_SYSCTL */ -#define DECLARE_SYSCTL_BASE(_name, _table) - -static inline int __register_sysctl_base(struct ctl_table *base_table) -{ - return 0; -} - -#define register_sysctl_base(table) __register_sysctl_base(table) - static inline void register_sysctl_init(const char *path, struct ctl_table *table) { } diff --git a/kernel/sysctl.c b/kernel/sysctl.c index bfe53e835524..73fa9cf7ee11 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -1782,11 +1782,6 @@ static struct ctl_table kern_table[] = { .mode = 0644, .proc_handler = sysctl_max_threads, }, - { - .procname = "usermodehelper", - .mode = 0555, - .child = usermodehelper_table, - }, { .procname = "overflowuid", .data = &overflowuid, @@ -1962,13 +1957,6 @@ static struct ctl_table kern_table[] = { .proc_handler = proc_dointvec, }, #endif -#ifdef CONFIG_KEYS - { - .procname = "keys", - .mode = 0555, - .child = key_sysctls, - }, -#endif #ifdef CONFIG_PERF_EVENTS /* * User-space scripts rely on the existence of this file @@ -2348,17 +2336,17 @@ static struct ctl_table dev_table[] = { { } }; -DECLARE_SYSCTL_BASE(kernel, kern_table); -DECLARE_SYSCTL_BASE(vm, vm_table); -DECLARE_SYSCTL_BASE(debug, debug_table); -DECLARE_SYSCTL_BASE(dev, dev_table); - int __init sysctl_init_bases(void) { - register_sysctl_base(kernel); - register_sysctl_base(vm); - register_sysctl_base(debug); - register_sysctl_base(dev); + register_sysctl_init("kernel", kern_table); + register_sysctl_init("kernel/usermodehelper", usermodehelper_table); +#ifdef CONFIG_KEYS + register_sysctl_init("kernel/keys", key_sysctls); +#endif + + register_sysctl_init("vm", vm_table); + register_sysctl_init("debug", debug_table); + register_sysctl_init("dev", dev_table); return 0; } -- 2.30.2