From patchwork Mon Dec 23 14:15:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaixiong Yu X-Patchwork-Id: 13918963 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 429B7E7718D for ; Mon, 23 Dec 2024 14:20:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DF4C66B00C4; Mon, 23 Dec 2024 09:20:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DCA876B00C5; Mon, 23 Dec 2024 09:20:12 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C45096B00C6; Mon, 23 Dec 2024 09:20:12 -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 A35A36B00C4 for ; Mon, 23 Dec 2024 09:20:12 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 63732120DE0 for ; Mon, 23 Dec 2024 14:20:12 +0000 (UTC) X-FDA: 82926432708.04.FEF9DB4 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf21.hostedemail.com (Postfix) with ESMTP id D30C01C001F for ; Mon, 23 Dec 2024 14:18:56 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf21.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734963574; a=rsa-sha256; cv=none; b=ZziOkADeDm6lqlGf2/XBfIY/A76zpkUVy8rNymhMvOUKasrCSRBj5e5YBPvFvm/Z4kByNm c7Nu6hHMd3gWplUPxdf526mROs6rYMTtT0wh8ZyEH32kZuiKGqD1A6zI0V85/WVjTKMwic j/WM4rduFpQSQRn0rld1Dn51M6LrMMM= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf21.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.187 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=1734963574; 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=OC0pkVuTdJHHRptJtelft/rmUsy+30g5GtnTLWjTEN7v87vw7dzJbvpIdOxbQbXeWNBsVh PMiAaCRiIAKv+JVESez0oY1gjzXL/wKOXZ50fkZ2XThnAve9o3AxB7ghOtsO+FnZOaKGlu 19PR6+mZ/zNvBmIIOF9UKqQfgWVVghQ= Received: from mail.maildlp.com (unknown [172.19.163.174]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4YH0Ss0jx3z11NJh; Mon, 23 Dec 2024 22:16:45 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id A9EB8140391; Mon, 23 Dec 2024 22:20:06 +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; Mon, 23 Dec 2024 22:20:03 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v4 -next 10/15] fs: drop_caches: move sysctl to fs/drop_caches.c Date: Mon, 23 Dec 2024 22:15:29 +0800 Message-ID: <20241223141550.638616-11-yukaixiong@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241223141550.638616-1-yukaixiong@huawei.com> References: <20241223141550.638616-1-yukaixiong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemh100016.china.huawei.com (7.202.181.102) X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: D30C01C001F X-Stat-Signature: pg5of7yj5ws3op7pnz7m9w35kcbtbd5i X-Rspam-User: X-HE-Tag: 1734963536-435621 X-HE-Meta: U2FsdGVkX18xe00wZ/MNR5QK8kds/nD5jRrJKick4A/nrRjsqczLcE5erdKZJGfEzuN0ivUiV71UqV7pqMmBNi154kN12VRoIBMzXyoyaHLEbU658/ZDZErI4i8Ae1/+AKx11nBcfTXixWh8X/bN0ny7KZMRO7A9dd8vH8tHCYMG6BNOYWUDXKtxJqk7xARe0aZIqz1/IqJilGZHmd9dchOfPty9q4unm8HNIPW0avaak5MSVGG2TCK+monkOvhQMHzdEIOLLbUqkgi1FIBGBeCgxjR3X9lF8tBI8wnjOWti0B/1KoTmDLaO6fnloMUG6Ur11PcUSKn2khTWuuW9hN4DRSkW39Ce2OUZbedz1c5m/NrTYmLeV9I5G7jVkyf9+WXxRg1JofCkjEsT3WkdDt4TZksvwqGViaYxa0kDlBJ8Im+OS7ypx/FqSOlCwjguPHb02cSQhZG0yJwCNzVbo10lPknS05z+amUFEBnKAUT+RvyTlKnpMUULKNVu0+1EkOVPSwupxlvU27vHrs20bLsWDPDfFS1q38h/R0th/Jr+lFlt+y6hwmYVeIDgEeGCOZgYKdH0KhSJbrvTfxckmL1Lqm0smS6AJZYl3FKJE1IYK/lJr2f2sM17FIqR9OYIz79pH1pbPyve9ljYrP3hCHVplwMjwgCYliYu882H99RdnaxZm5LC+SDZDgmhwFJhaP4ynE7VOKAzzJvWAHUlCfsT1n+T2j8HONuf9nNKaDobbEVLuPL25aN4E1EkxUgVBcUiFIYVuSMFf0vj9FHFNRKVlR2XqvfNnF+jCRcV+zHpAiAGZFdSqCXv0yZY9x7QmCBgUaTjL+yytwPj0Cf1M+D29DdOxlqqoH1/CmmnbKe4BeQXglXHGONe88VSpH94DsUeXjZiUsK2SOMpvNeyCMzAzZcjGbndui1b/1cyB72u5/zi7bjVO9TeOMOL5AjMG4CfE8b17B5tnm5LWR2 q+ivN5+K 4eDDVSrqeYV3aupN7G14JhNldhaqV8d1pbc0H+A4QSL1HC7cNzq7mHUVUwFQoMZ+lGc9Eo3DcNWyxcelCsBvGmMDbMYh8Wqx72xeHaF2zT62D2Qnwcb6CeXp567dlCud13b/fg9yD466Fvs6xkFfG51+Ib+qS0dioiaLB+by0s7M2xZ3ZhUZPZQVG3B/2w7iXziw/A0CrmQ0WvRKG43q3AEvC+Q== 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,