From patchwork Sat Jan 11 07:07:45 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaixiong Yu X-Patchwork-Id: 13935841 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 0127AE7719A for ; Sat, 11 Jan 2025 07:13:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8F7E06B00AE; Sat, 11 Jan 2025 02:13:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 880B26B00AF; Sat, 11 Jan 2025 02:13:00 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6FA516B00B0; Sat, 11 Jan 2025 02:13:00 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 492316B00AE for ; Sat, 11 Jan 2025 02:13:00 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id C29D3C112D for ; Sat, 11 Jan 2025 07:12:59 +0000 (UTC) X-FDA: 82994304078.24.AE33200 Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) by imf29.hostedemail.com (Postfix) with ESMTP id 4C848120004 for ; Sat, 11 Jan 2025 07:12:56 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf29.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.35 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736579578; a=rsa-sha256; cv=none; b=kD95/3DrgQd3rzqDnP0xTIqLz1d1yTnt2YTDQopLNRmCxiOKSYk2oT+dlKoujuv3AZ+0Jw ufcyB51Ip6T6zF1epybjudLumB1B4TxwpLChRIXhx8++dBQxI3glV+Q5SYn6FGRlAACpVx t3BTYWSbmSORdnVEM0SCEfhjijVsmWU= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf29.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=1736579578; 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=WreX7GUmbJjdCEp+I36e8/ZNrB4xEScOoakrMlLbvIs=; b=KLtICE+1g8LaDEfLuVhXm163ZlTKiWENTPELotGali2/nV8blVGNiacdbNhe6/PUQ3muFT A6B1NGS/LQjEyCwQgba8d03nO5v7r1UHeoO08nq9x1msAmcj51mC2Wfepi845GiICv71FW AIuXQEipuOauv9C8qKNrE16UL3SI5QI= Received: from mail.maildlp.com (unknown [172.19.88.163]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4YVV5S14prz1V4Py; Sat, 11 Jan 2025 15:09:48 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id BEA0A180043; Sat, 11 Jan 2025 15:12:53 +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, 11 Jan 2025 15:12:50 +0800 From: Kaixiong Yu To: , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v5 -next 10/16] fs: drop_caches: move sysctl to fs/drop_caches.c Date: Sat, 11 Jan 2025 15:07:45 +0800 Message-ID: <20250111070751.2588654-11-yukaixiong@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250111070751.2588654-1-yukaixiong@huawei.com> References: <20250111070751.2588654-1-yukaixiong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemh100016.china.huawei.com (7.202.181.102) X-Stat-Signature: hpms3nr91bpwwkn1n1c3o56xkaokt6gk X-Rspam-User: X-Rspamd-Queue-Id: 4C848120004 X-Rspamd-Server: rspam08 X-HE-Tag: 1736579576-562716 X-HE-Meta: U2FsdGVkX1/gl17/wAQ8gnnGwQLfKtEXcaGpRnAiNmb7qxcaUyQlwgEkw4ddIUHFPJshbtXOvVFP1wflHgHk40MAk//ve1PU56adjgt6CN18Y1LZKyhYT0JgWevg7E86oCVPtghjZMh23qNnIx8bmFPPMNu3IuKlU75C2S6e4+086eBLKiVz+hppBZHOWXAXXBDeNJvYZDulWWXz3fI+WElIBIrQVp7HsG3eqNDJ49ZgctOn/QgstQ2zTxAvOCmqSSVp5ZktI3Ve+pdIDXIxGLrRGCxAR8fiCRu5GmuAvet3phxNVJxwRPdiKQgETe7fIS2kyro92np2mUMfXUI4WC7IZ+o4PATUQ/C+DJf1c7fAEa9/q+RXFpRV+zjlRxlI8/cvVSdjxCxRxnA6pAIA/kyI2WfMprIKU6F7euShimmuK3n74fA+/wkKbRwJW578IyjpaP+BjJF4Vux7B7IPuQbvbJd+lE+ND+J852PbP7lm7COFdZ9ivJzXWqbGZPjFMwbbz3FrrH41R+OLs6U4GEBpz3e0nToP7IHbjtHYI7aIgmeYBmSXPXnskp8cLnXTM36QwCL2DeSBnqPNSoNph5jqbx10zm6nQrxCCEGjz2YVNm/1RV6pla4dQkLiBgmYWnbSiPrTh937TUwZbFwd0Bubn5WB3xMRL8gz4y9DB4fvUrRrO8tZ1eYsq2gR3p85Vw2qXd8Bgg0sp6sTrCZE9bk0mVve49JI7Dh09Q3jqy8sR8WwBbhUXYSWPQXrz50yP5Lbql1RChT1Qb6SGlBbllV9qQAjLrVChVtjO4qB8ptOui3I9tmXg0Sl0787tvDS4+k78t3yZYH2uYt0DCSY53/mY6BAp/iQeJK0g7z8uhNYfy/FCyymo6ew/bO2rPyF3qVvYcgWeC7Um7RH1uKU4rLIuviI3P40EbnISJxVAKzD50cBJCkPzJR2OAvzatTKvppeIUAsmBaaix6DqF2 ppG3PfrY UN1O9MSQde9EjJ5WZ/YCKhNEK4xh/x3F8wPTb78ylJLuxEFz/x9vcwISbkZtCat9rV/UXHPWAq/mQUYMe6QLJdwKfYOrLi+YgUwyFNoPmXiTE7DHEX5J7IJ+mgoI9b1qIHYIHeWDjz9dN4N0DzaUv18dTB0ssvcO7h2DgLXyZ4uUqvH4cVhbSzonaxMURBAJ/qT64kRjRLGvfe9aYxRAh/wfer+QvbDb6bDmh1HB2Fm9ewA8qXoghWXeX9yEfs+T10wrQZGl7ZhJWpJVG4E3G8zFnpT9pgMorITFBkfjW6mz+/kzCF3RE4vbU6QOBfoCFA/l2/5j3+661Nx2/rvhvg1PtChz6djzENRe4bi1/iXt7u7I= 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 98654abef3b8..3ed6f2600abd 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3873,12 +3873,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,