From patchwork Sat Dec 28 14:57:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yukaixiong X-Patchwork-Id: 13922372 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 B584CE77188 for ; Sat, 28 Dec 2024 15:02:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4D45F6B00A0; Sat, 28 Dec 2024 10:02:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 45C776B00A1; Sat, 28 Dec 2024 10:02:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3249B6B00A2; Sat, 28 Dec 2024 10:02:23 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 1577A6B00A0 for ; Sat, 28 Dec 2024 10:02:23 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id BD15BA17C9 for ; Sat, 28 Dec 2024 15:02:22 +0000 (UTC) X-FDA: 82944682422.24.F615DE3 Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) by imf04.hostedemail.com (Postfix) with ESMTP id 6427D40018 for ; Sat, 28 Dec 2024 15:01:33 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf04.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.35 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1735398121; 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:in-reply-to:references:references; bh=t1Coy0cpaf42368gn+/HEcB4evuE9OzA1O1eQ3WKeRA=; b=j1X8yr1CKjfCtRD7Cr41xVAQUkYAdJNrtV973VhCgGCzNyLr29/+yqu/EyKxOJQyQNhkbp iMyNLHKX8+diuUuKYjjKJ5X2yJ+JuDl+T8rMs0YQMcXLaq2UEfqhzzG66jXl17/SyQkpRz CvMMoigEM1RMJXXSBnIxZeYl4+wKAVM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1735398121; a=rsa-sha256; cv=none; b=zkELPysUw8QzKDhTZwgwifPlznTQuKu4IxfDToKoe0Xcss6PzctVoi0LkPbnxSTeIUk5YU u0I5wmoakzoipjvwB0jjCqVym6qrMEJQLLqeSotTxEqresGLCS9soab6bb6UsMhea6/S+H aQ3cx17Miro8yXfFXWKBSqFcDkQbFlk= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf04.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.35 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com Received: from mail.maildlp.com (unknown [172.19.88.163]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4YL59r1bPRz1T7Z7; Sat, 28 Dec 2024 22:59:28 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id 6AA71180042; Sat, 28 Dec 2024 23:02:16 +0800 (CST) Received: from huawei.com (10.175.113.32) by kwepemh100016.china.huawei.com (7.202.181.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Sat, 28 Dec 2024 23:02:12 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v4 -next 10/15] fs: drop_caches: move sysctl to fs/drop_caches.c Date: Sat, 28 Dec 2024 22:57:41 +0800 Message-ID: <20241228145746.2783627-11-yukaixiong@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241228145746.2783627-1-yukaixiong@huawei.com> References: <20241228145746.2783627-1-yukaixiong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemh100016.china.huawei.com (7.202.181.102) X-Stat-Signature: 8ru6nch8m9g3unfqox84srmbjfweb1fm X-Rspamd-Queue-Id: 6427D40018 X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1735398093-348011 X-HE-Meta: U2FsdGVkX1/2WvqQF10f4UCIXHOIP+jdcdp9u/N2p3st8Na2qhbaOy/29VkvfLl1BgNICu8+vaVhb8rvvs2taBqx6WZBufG3EKcb6CWu+RUpWU0/72PumkghwiosxusbLuldvJ4/9bPTDPgfTpQmfbcT/gIc3JSPlZW6Rpmf+ri49LGw+Q4+GUDY+Y2UNQAc+WLPRZAQ1liKvfxT8UeAWqPoF8bn2eW8uwwQej7yuuYK1rIkLPvwkGQAjfvnPO4D/PbmGjtyNRIA7qymyRX+quygpQ5XycRU+0GRIogB1SYuLvieYgfKhKxE0OYOeW6EYEmXXexghHBtsQZ5Ce/NRsaAVjM7fUVDYf3DdjNyomw0/dVpGUUVRCIj2dNP3syKeB+hWCHaJmNc27SyeqDEVVZVsTLNWEEB2sry7n14fuFlJkfnQi6rmSOFFHrD9jWTb0rmRXGWTWOilGor9MWTD4JDYz4I3TKuA7f7FIjhML9KGiZL5dfdeC4v00MEBjgB5qDaVLGDtAiIgZik2VZBkSPrMksPPP/r6KDyjoJoRcOZXklTt0R0JXhpA9JhcOediG+/eWHoJDuIuvHXKGjgIyi5tI0LixDbk4Jyay5R/Rtb41t0uPgdkzPM6LgPiufT+BHAWQu7Eaauhsv2+MofIsZairdUAkpl9k9XJDoPcJox7wKPrqeDNBWKzcIGEVlFuioiNU5nzOk0lhbG3I11zAq8EhpTdwNN+YVxuJbq0c6zRRdp0O8FRwrhVcnobIMiA+vX7ewzDwj91MHO+L4zdgOcYY3J74LPlrq3eM78DbBqivtCYvTX2ASMCf3b7OSSUpP3/gj11L5Y6FxBWAGmThfYww9KhM7C1DI15yvCIhhaX0sbJ0wYqTzyRZvqcxACYWx5BZ0td7fJoNVe7LMdBypVifLWbB6pYBe4XNqQcVtBJfcxx5PFALG0vXvowwB/o6C7+v9b2Tf4wbRmZcL dntlec59 J8zQoPLoLloPBk5BzssrE0d/6PU+hWaRxxm/JgHqLuWBLB0e8nQjVdfFPdDKZKGHhTps+kpVFcfoxmpg92iPeavuNrd3Ir2vBhD7WfFUbdpQkCRlWR0N4ezJCO7godJVnf/TjZ5h2CbdAzFU4SN5+nORFZakijaqiF+p7I20/4Vw4D1hk4LK6wJ6EahLLz9rPNGMPxKGK6Ino7JW6Ar+frns7La7hqiPwxE7LD5zX1oK7iyPsJm1CAOMCLZnyV0ZYHA7vyLcnZOfL3eEX/EAHTZLbtf4dqnFdbtn0TrOzC8IKe1Yr+Eo7WtWMLSrH3LcPnlRNbXhSz3vn7L3N2vUTNUZN7dyuROsAT6CEElqzpKZATNY= 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 sysctl_drop_caches to fs/drop_caches.c, move it to fs/drop_caches.c from /kernel/sysctl.c. And remove the useless extern variable declaration from include/linux/mm.h Signed-off-by: Kaixiong Yu Reviewed-by: Kees Cook Reviewed-by: Jan Kara Reviewed-by: Christian Brauner --- v4: - const qualify struct ctl_table drop_caches_table v3: - change the title --- --- fs/drop_caches.c | 23 +++++++++++++++++++++-- include/linux/mm.h | 6 ------ kernel/sysctl.c | 9 --------- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/fs/drop_caches.c b/fs/drop_caches.c index d45ef541d848..019a8b4eaaf9 100644 --- a/fs/drop_caches.c +++ b/fs/drop_caches.c @@ -14,7 +14,7 @@ #include "internal.h" /* A global variable is a bit ugly, but it keeps the code simple */ -int sysctl_drop_caches; +static int sysctl_drop_caches; static void drop_pagecache_sb(struct super_block *sb, void *unused) { @@ -48,7 +48,7 @@ static void drop_pagecache_sb(struct super_block *sb, void *unused) iput(toput_inode); } -int drop_caches_sysctl_handler(const struct ctl_table *table, int write, +static int drop_caches_sysctl_handler(const struct ctl_table *table, int write, void *buffer, size_t *length, loff_t *ppos) { int ret; @@ -77,3 +77,22 @@ int drop_caches_sysctl_handler(const struct ctl_table *table, int write, } return 0; } + +static const struct ctl_table drop_caches_table[] = { + { + .procname = "drop_caches", + .data = &sysctl_drop_caches, + .maxlen = sizeof(int), + .mode = 0200, + .proc_handler = drop_caches_sysctl_handler, + .extra1 = SYSCTL_ONE, + .extra2 = SYSCTL_FOUR, + }, +}; + +static int __init init_vm_drop_caches_sysctls(void) +{ + register_sysctl_init("vm", drop_caches_table); + return 0; +} +fs_initcall(init_vm_drop_caches_sysctls); diff --git a/include/linux/mm.h b/include/linux/mm.h index 9813b5b9c093..387f579a6c18 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3803,12 +3803,6 @@ static inline int in_gate_area(struct mm_struct *mm, unsigned long addr) extern bool process_shares_mm(struct task_struct *p, struct mm_struct *mm); -#ifdef CONFIG_SYSCTL -extern int sysctl_drop_caches; -int drop_caches_sysctl_handler(const struct ctl_table *, int, void *, size_t *, - loff_t *); -#endif - void drop_slab(void); #ifndef CONFIG_MMU diff --git a/kernel/sysctl.c b/kernel/sysctl.c index c5527f59e3f2..7fb77cbcc24d 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2014,15 +2014,6 @@ static struct ctl_table kern_table[] = { }; static struct ctl_table vm_table[] = { - { - .procname = "drop_caches", - .data = &sysctl_drop_caches, - .maxlen = sizeof(int), - .mode = 0200, - .proc_handler = drop_caches_sysctl_handler, - .extra1 = SYSCTL_ONE, - .extra2 = SYSCTL_FOUR, - }, { .procname = "vfs_cache_pressure", .data = &sysctl_vfs_cache_pressure,