From patchwork Mon Aug 26 12:04:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yukaixiong X-Patchwork-Id: 13777718 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 D29FBC5321E for ; Mon, 26 Aug 2024 12:06:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6355F6B009D; Mon, 26 Aug 2024 08:06:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 32AFE6B00D1; Mon, 26 Aug 2024 08:06:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0BCAB6B0098; Mon, 26 Aug 2024 08:06:03 -0400 (EDT) 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 B45826B04D3 for ; Mon, 26 Aug 2024 08:06:03 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 70FA4410A5 for ; Mon, 26 Aug 2024 12:06:03 +0000 (UTC) X-FDA: 82494268206.19.8C4618A Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) by imf21.hostedemail.com (Postfix) with ESMTP id 0D35A1C0018 for ; Mon, 26 Aug 2024 12:06:00 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=none; spf=pass (imf21.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.35 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724673848; 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=sOkIIcnEqEzuEUJOqXnIARzH0REOuidbOyffr1zGOCU=; b=ErYne5mAMit/N5CcUMjonJ9KSSAWEcMG7zXKBAA7TrWaAg9iduJiMq0XGxybRyWy1CHH1C /faL9CsdFc+/CtGgLgZGG27WvUxz1BenP/4Yngawye+3+r3Ni6mIFjfkGRzS7BZZWtiq9D nM53q1Sqyi+kesJOX+rJpzEe5UJHFpU= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=none; spf=pass (imf21.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.35 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724673848; a=rsa-sha256; cv=none; b=0kSepxXzPFhOvm1S7VVovQrNtlbjq2JK6ymuNL/NrBkIHMto56p+XlLKYBMpTztlL8H5qm whseIlKhLL0MZXZtaKD7eVWA3a6j0UeVQHzgWQ//6PErqChz/tPTt1Fz8KpN46aLMn6xbB eIXp3nTsCbI5RVCX3LccoQg+fUSsVYE= Received: from mail.maildlp.com (unknown [172.19.163.17]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4WsqBQ4qLNz1S913; Mon, 26 Aug 2024 20:05:34 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id 0E97B1A0188; Mon, 26 Aug 2024 20:05:44 +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, 26 Aug 2024 20:05:41 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH -next 10/15] fs: drop_caches: move sysctl to its own file Date: Mon, 26 Aug 2024 20:04:44 +0800 Message-ID: <20240826120449.1666461-11-yukaixiong@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240826120449.1666461-1-yukaixiong@huawei.com> References: <20240826120449.1666461-1-yukaixiong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemh100016.china.huawei.com (7.202.181.102) X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 0D35A1C0018 X-Stat-Signature: bdc7oaps43zw5ft78jzkq89hn4tkxigi X-Rspam-User: X-HE-Tag: 1724673960-827326 X-HE-Meta: U2FsdGVkX18mMBLsk7tYU4CpxPt1yGsJzF5ymFMBJi/zmvadETcJ9taW4DmaOqQLkGMNRsdwiRimg8lH17Z/g5Ym0aCHlWP1c3+yiqQ2WWMeANuokAov9XgJBRdQvYsPyfZjQBZ7gBZ+m6ZzWjAyeuiU6aKyghw9cP7c5C4qe9x25DQxHVK8yJN0kN5CAn0G3EJM7Lu3+4Yf2dCjexQxaFZtfksoOxgYBT9O9EyzU4JkzfH+HhTIfyLtF8+yUff/LJwO9AvXDp+iOKbhbFz+V6D2/hHZc2B0HM88YKiCBJj84/MZp3pKC06Se7kQ8NcGWOyfoZXborvgMU/OQN0P34FTwok7unE8u4Lu52/RE8f3Ggjn0vSGj/zxXuIL0xi3K+UGCDH7MIdyjO4xNeHOQ/ioZuXUHy++RGRbi2DpPmeuax2qXVdrVnF2RXseOox8VGioh0QOjUxLn8mZTyGzTQ7RCCYFNcm8tsIaALYX+vbbdTFTH0IpzDq6n6BEQSnNgxLWUn1BVtDSGvYeDIM2Or9l+OR10L5lJf2zhwF8ZC3OZ/B5ZKW3YvsNl3gFeSfSjOXkco3x3kXdYbxpOHjAHKsgHIMcFD9p9B/XPNoa/ZGKYCg3n5vDBOAbRdFQK09GZaR7JMIWfHTEk7X0JGRHc5xZ4l02uvGxcwyXUJhZCu/7AwKth7gO9K+CkOWREjedtW/SrilQDf3gir6cHs/gq2VHuAHwb//if6wBvbO1Bp3S4fhQIrT11JvLswaYGKslVgbVGPlj6fQ8dTG5L9gO/3AqjBHST2YFxD0L6VFd8vQVeE+5iigsuOsH8KIAupRl+vHRzI8wlnTRoNarG5e6BbhRZ3Z8Z9J27N3uSV9vjPJ+VywUd2prvVy4UBSxb8RCVloYEjZz/pl/Rl9W06X1BJQ5BTUl/ndvvuZM6hUdPljalgzDDQHG4lu/Bcz3iptvYY7VqxtvyNtnRPSKWdD CQTZvvjl T4n+UNov4l//CP6cbk68WenkKesACP1bov1UhveubKs4ZoPECsCr2M0zvSguoVLdlwdKu3K1t254tqas3jS+Yqz4fUoOGFjjPlGf0uABt6ybu/1cz4sXGtqRiRAMLkfgmwuuyEsnF3lfRDgLSrqzU+t5BghSNHMATZn3RF5GC2lTZC5uOIRWmYiu3tysNv2mfva09 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 into its own file from /kernel/sysctl.c. And remove the useless extern variable declaration from include/linux/mm.h Signed-off-by: Kaixiong Yu --- 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..f2551ace800f 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 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 9e37d46fa666..a297a298542c 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3693,12 +3693,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 373e018b950c..d638a1bac9af 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2024,15 +2024,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,