From patchwork Mon Dec 23 14:15:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaixiong Yu X-Patchwork-Id: 13918978 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 999EAE7718D for ; Mon, 23 Dec 2024 14:21:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 283406B00E3; Mon, 23 Dec 2024 09:21:06 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1E6A96B00E5; Mon, 23 Dec 2024 09:21:06 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 05FA76B00E4; Mon, 23 Dec 2024 09:21:05 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id D884E6B00E2 for ; Mon, 23 Dec 2024 09:21:05 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 85B32C1844 for ; Mon, 23 Dec 2024 14:21:05 +0000 (UTC) X-FDA: 82926434556.24.B0E01DC Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf10.hostedemail.com (Postfix) with ESMTP id 7F61FC0014 for ; Mon, 23 Dec 2024 14:20:46 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf10.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=1734963620; 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=lFV4TZuzKfmEqWZlRKbwRB7QlRY/a4rMjAjpjEnJNvznGOHok5ERFi2QwjARpvJ91xn/7g TGHfeR63ymi0nvYGSF6XiTvjfd3qEnRPWsKHDmTLWg42iprhvftnP6neMdkChdr1RFiRGi 1pDNQs5QQUt/GU6i0F0qJDNjyJ/uqJ8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734963620; a=rsa-sha256; cv=none; b=mx85351uL78f2OaINIDwF+cIUjTjtI3P0QD6Des0gDEp0DukecNKOg+BcNdzCZVqflZtc7 VE4PxPb1MYfavWUL0IDSTYNMgHah71EYMEwO4GdIT3L0pChFnRdMbWbEbybUlaAClKzGZj nu1WDhyHr/pHUFWhTeMiZrP6W8+idY8= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf10.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com Received: from mail.maildlp.com (unknown [172.19.88.105]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4YH0Vk2nWGzhZTh; Mon, 23 Dec 2024 22:18:22 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id 168EC140257; Mon, 23 Dec 2024 22:21:00 +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:56 +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:45 +0800 Message-ID: <20241223141550.638616-27-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-Queue-Id: 7F61FC0014 X-Rspam-User: X-Rspamd-Server: rspam07 X-Stat-Signature: pg5of7yj5ws3op7pnz7m9w35kcbtbd5i X-HE-Tag: 1734963646-90842 X-HE-Meta: U2FsdGVkX1+DylP4TD6VZ4loRvicBGSOES+LVtKPW7mQ72rNHL6LcXRfyLNMbmnMRc67eoIginReaUk2eMXjBjVA0eqTZ1gQRe+ZFqB6PApnnMvWSeJNoivn7tceTHs2nuJuID+4BHfGK3J5Du87vLjIo7BJ5JHbktPrcXe/39Hi+IsjwUZ1G7oCQZrbncPM2WLYo3ZOacRaaluAibpwRJE+XMZVM5689+D54JlZYllahUTUT8AjylhFMwMoAEbKT99OnUXn9BY7CpXrJ2iNGt0h8pLlkmD9JLGjfFqxtCwsBfni5vC8jtbmKFIP5ryD9wX3Ndi5G0mO9XG76us2V2dG9QLEU1JcgodY6r9TkUJIEPMmMkjxAelUJ+HSVdWKqclu++fz56eXKMH9RiQZjj+9FfJjxEYjpVcXgMr5ZUqyFrSjO74TAPb/1oCwgl3kYyIZeGaAkvvkQfrdaNUhyNmshLqGA19jEGXxCZO6ADnu97f5wTl2MEl4BSKwqvw7K6b3aazBdlbngauXWy+akUMsWLyKqwuSShJTTGv7if/59eUbIRJ0bYZksIJjBLtRtqmX3m5b0LD31gbNeR0QfkrBQjiahFYZAGXZ3dVhF+d6ysMlE6CyKYQNCa22rzsvBdcf0PJTWj3G67b2nZsPUREECBWwTuz111vZU9wHUIDNJT0s9pSajaAwetYzo3OtV0vbdqAp18LjIKm4djGIigqFsyxxw6Z/RuBp8++/DSQhqUvkhlbSeNzBsn5IaIg5AQvRb/fhxvGCFg11KxJH1KTFg0W2P23TMwjD2/McoRcmLL/HNQ2nKZZuGPj26TPS/p8FyLYI72WBrob00Iavvzf7poWQ4xNQu4FfAJuPbPv302ou+j3yR6shCWsXghT6xV3x0yBYg9At7q5WtkH0EaZ0RtT3paTX0FMgMdgRdtTz3rfMz2oqgQcOTqVPa5iRQx/W4Gh3WP7AnaWlWdW Owv67e6l 9X8wLfUzmNa1eGp26F08JiN+OZJU/4+yqfllxu4Xya1Y+cWRfk/5T7993xql9cqYCXysVAE3iB2Fzh3o/AlPDt//ym6++QpqpYzt0rJq9Ygg+79kWM12l+Q8kQEpLzpppxdrMN0mckUJ1v5kXCAsJ9wjnkGI+V2icZe4Hw+M8FtI/7EhV+uLcS48O9tOqOAu0TbGs+9wKK1r/zujVqEQOPQg8/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,