From patchwork Thu Oct 10 15:22:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yukaixiong X-Patchwork-Id: 13830192 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 11997CF11F8 for ; Thu, 10 Oct 2024 14:11:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B35726B0083; Thu, 10 Oct 2024 10:11:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AE5646B0085; Thu, 10 Oct 2024 10:11:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 95E396B0088; Thu, 10 Oct 2024 10:11:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 794A36B0083 for ; Thu, 10 Oct 2024 10:11:41 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 788EAC0601 for ; Thu, 10 Oct 2024 14:11:37 +0000 (UTC) X-FDA: 82657880802.22.AA0A31A Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) by imf22.hostedemail.com (Postfix) with ESMTP id 5BB25C0005 for ; Thu, 10 Oct 2024 14:11:36 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf22.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=1728569398; a=rsa-sha256; cv=none; b=Cwke6QpkcIJfrzO68VKl1tcA6dDGmlNgoP60WMFO74Swzw1qwm5Jb8rEXbGtrE4D+YvL5L 6wvnGN4+bj0InMAU+ggphvaMKltNmE8LYcFlRizVXQPAGVeiyG8xQFjdfDcWIdwJIoxFEB 8pQ4BNwNZx52sMaoZE6sPBCCi7k80pY= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf22.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=1728569398; 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=UWSPkCwxF9UmlURoYddi8wAGqtTYIkzJtcpFUjpOoK4=; b=xaGPTd6J52d2WjNTxl5L77+whmsg/KNSPHpRGFdgmwj7KM/yXPD/euv4ddjrVSJVpnirbL P5AYl9f9dRxO36zPv1JFfLsOp3WzTyFhcOQZsWXO6f36ZpDfOk7Ioh+uTXZNPFJMrZuoV3 N+zCHBR6WRYlQb0xC1EK6s+lnE/qewA= Received: from mail.maildlp.com (unknown [172.19.163.17]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4XPWqk51SGz1SCPQ; Thu, 10 Oct 2024 22:10:26 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id F2A901A0188; Thu, 10 Oct 2024 22:11:33 +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; Thu, 10 Oct 2024 22:11:30 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v3 -next 01/15] mm: vmstat: move sysctls to mm/vmstat.c Date: Thu, 10 Oct 2024 23:22:01 +0800 Message-ID: <20241010152215.3025842-2-yukaixiong@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241010152215.3025842-1-yukaixiong@huawei.com> References: <20241010152215.3025842-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-Rspamd-Queue-Id: 5BB25C0005 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 5eyhe4qipgdptffpzejci84r8tn349q8 X-HE-Tag: 1728569496-288144 X-HE-Meta: U2FsdGVkX18cOFCgGqNtV9MAesRXBaetZzDFchnCAZ0Grd4Nivm9Q65rj7IH8PoK+mXRrIjmr0o2nLsqYD8Vuy51R45TdIErxZ2eOGurqav4Hv2387bI4tuMoQPFH9o29i/k3J3GhUZfdaxHY7z2GG+jleNteRwIsOAF71SWfK0Zws0cfrdQ6xbrrTwUJIQTqica7QnpSwUUNJCzyRi6vRGysjUQbCUgCaTT/VatHQPP/gcul/ZN1cARBQPGnlUwUu18XL6eqQpWAr1U6ciw+PIYMWN7EyTPUKDBNxK8EPod5Ae5ofKO9l9AFZkM6y70uYUiLyNm3n1BaQQQxNZriVZiy5eYGAQ0bBPZyb4n2khRf7+CckUoentK4ErHYsNOR0nQScsK+aNIxMVWBRXxLReKXrC2pcGwe2JNPkc6arKByU5fMPKHNDKM2ldVSZEuFYPK306pXJ6BjUD56GeU+1KpLypJ8YQcwgxcVBaFSxgFADQfBX+Y8bGdvRDCiCd3sZcbdwU/W/sXmfthSzXHryk5pse9R+l2FvdyPVcO7QaeF9pjObnpGPKc1EduDED8+aCfprxCVFyUi+xlsKFDzSy2b9V8pLm6sc6Hg2EqHyxk2N6WYReE/TI55dGxn48E7vfPgEr+LC3F46RO8LmWJEdD/YCsZLmAghXnTVhIthBAHH/TIrQqvfwsNV7DTlOVdTK9r9d82gON2VYJhQR29UdJB6vDxs/NCaVmpkeZTgxvnWmfDq28qDOLpgKLpoFCXy8L4yKpXIIJi9wpfe9mqo9jdYJdui8nofdsv3I1fBARLfpn0YEa9p90eDWEUvuqPAZml8hvEct4Ldk5WrxQbPbj+fTC5ci06gcSO+K2n7PK39DwHWJl6afSUsD9S9c1FKiM7JvcmleE9gbqjffvsE/e/GhXxghi9gCXnS88aE00QNqnfEDwfLSwX0GMQ0ORy2CS1UkQ/OH1hjPwd7j 9eAYJRzB tykTiHWwDt35hdzB3+gWxe/ylbXE0RfMQqx9EgUF5JivRRZ8cY1JJ4W0pfYGUK8Vcpf6y6qvKCXGl9RajE23F+Vbix4Zpah5A+UfdgIpoaBgiYhCFEZfjd3Gvf5vxMrnc77KbL+6Bv8rFWlbLv8Pl8ZjhvJfUkWvBS4Py 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: This moves all vmstat related sysctls to its own file, removes useless extern variable declarations, and do some related clean-ups. To avoid compiler warnings when CONFIG_PROC_FS is not defined, add the macro definition CONFIG_PROC_FS ahead CONFIG_NUMA in vmstat.c. Signed-off-by: Kaixiong Yu Reviewed-by: Kees Cook --- v3: - change the title - change sysctl_stat_interval to static type --- include/linux/vmstat.h | 11 ----------- kernel/sysctl.c | 28 --------------------------- mm/vmstat.c | 44 ++++++++++++++++++++++++++++++++++++++---- 3 files changed, 40 insertions(+), 43 deletions(-) diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h index d2761bf8ff32..b2ccb6845595 100644 --- a/include/linux/vmstat.h +++ b/include/linux/vmstat.h @@ -10,15 +10,8 @@ #include #include -extern int sysctl_stat_interval; - #ifdef CONFIG_NUMA -#define ENABLE_NUMA_STAT 1 -#define DISABLE_NUMA_STAT 0 -extern int sysctl_vm_numa_stat; DECLARE_STATIC_KEY_TRUE(vm_numa_stat_key); -int sysctl_vm_numa_stat_handler(const struct ctl_table *table, int write, - void *buffer, size_t *length, loff_t *ppos); #endif struct reclaim_stat { @@ -304,10 +297,6 @@ void quiet_vmstat(void); void cpu_vm_stats_fold(int cpu); void refresh_zone_stat_thresholds(void); -struct ctl_table; -int vmstat_refresh(const struct ctl_table *, int write, void *buffer, size_t *lenp, - loff_t *ppos); - void drain_zonestat(struct zone *zone, struct per_cpu_zonestat *); int calculate_pressure_threshold(struct zone *zone); diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 79e6cb1d5c48..726b866af57b 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -49,7 +49,6 @@ #include #include #include -#include #include #include #include @@ -2081,17 +2080,6 @@ static struct ctl_table vm_table[] = { .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_TWO_HUNDRED, }, -#ifdef CONFIG_NUMA - { - .procname = "numa_stat", - .data = &sysctl_vm_numa_stat, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = sysctl_vm_numa_stat_handler, - .extra1 = SYSCTL_ZERO, - .extra2 = SYSCTL_ONE, - }, -#endif { .procname = "drop_caches", .data = &sysctl_drop_caches, @@ -2157,22 +2145,6 @@ static struct ctl_table vm_table[] = { .extra1 = SYSCTL_ZERO, }, #endif -#ifdef CONFIG_SMP - { - .procname = "stat_interval", - .data = &sysctl_stat_interval, - .maxlen = sizeof(sysctl_stat_interval), - .mode = 0644, - .proc_handler = proc_dointvec_jiffies, - }, - { - .procname = "stat_refresh", - .data = NULL, - .maxlen = 0, - .mode = 0600, - .proc_handler = vmstat_refresh, - }, -#endif #ifdef CONFIG_MMU { .procname = "mmap_min_addr", diff --git a/mm/vmstat.c b/mm/vmstat.c index bb081ae4d0ae..25cb31545bc0 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -31,8 +31,10 @@ #include "internal.h" +#ifdef CONFIG_PROC_FS #ifdef CONFIG_NUMA -int sysctl_vm_numa_stat = ENABLE_NUMA_STAT; +#define ENABLE_NUMA_STAT 1 +static int sysctl_vm_numa_stat = ENABLE_NUMA_STAT; /* zero numa counters within a zone */ static void zero_zone_numa_counters(struct zone *zone) @@ -74,7 +76,7 @@ static void invalid_numa_statistics(void) static DEFINE_MUTEX(vm_numa_stat_lock); -int sysctl_vm_numa_stat_handler(const struct ctl_table *table, int write, +static int sysctl_vm_numa_stat_handler(const struct ctl_table *table, int write, void *buffer, size_t *length, loff_t *ppos) { int ret, oldval; @@ -102,6 +104,7 @@ int sysctl_vm_numa_stat_handler(const struct ctl_table *table, int write, return ret; } #endif +#endif /* CONFIG_PROC_FS */ #ifdef CONFIG_VM_EVENT_COUNTERS DEFINE_PER_CPU(struct vm_event_state, vm_event_states) = {{0}}; @@ -1928,7 +1931,7 @@ static const struct seq_operations vmstat_op = { #ifdef CONFIG_SMP static DEFINE_PER_CPU(struct delayed_work, vmstat_work); -int sysctl_stat_interval __read_mostly = HZ; +static int sysctl_stat_interval __read_mostly = HZ; static int vmstat_late_init_done; #ifdef CONFIG_PROC_FS @@ -1937,7 +1940,7 @@ static void refresh_vm_stats(struct work_struct *work) refresh_cpu_vm_stats(true); } -int vmstat_refresh(const struct ctl_table *table, int write, +static int vmstat_refresh(const struct ctl_table *table, int write, void *buffer, size_t *lenp, loff_t *ppos) { long val; @@ -2175,6 +2178,38 @@ static int __init vmstat_late_init(void) late_initcall(vmstat_late_init); #endif +#ifdef CONFIG_PROC_FS +static struct ctl_table vmstat_table[] = { +#ifdef CONFIG_SMP + { + .procname = "stat_interval", + .data = &sysctl_stat_interval, + .maxlen = sizeof(sysctl_stat_interval), + .mode = 0644, + .proc_handler = proc_dointvec_jiffies, + }, + { + .procname = "stat_refresh", + .data = NULL, + .maxlen = 0, + .mode = 0600, + .proc_handler = vmstat_refresh, + }, +#endif +#ifdef CONFIG_NUMA + { + .procname = "numa_stat", + .data = &sysctl_vm_numa_stat, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = sysctl_vm_numa_stat_handler, + .extra1 = SYSCTL_ZERO, + .extra2 = SYSCTL_ONE, + }, +#endif +}; +#endif + struct workqueue_struct *mm_percpu_wq; void __init init_mm_internals(void) @@ -2206,6 +2241,7 @@ void __init init_mm_internals(void) proc_create_seq("pagetypeinfo", 0400, NULL, &pagetypeinfo_op); proc_create_seq("vmstat", 0444, NULL, &vmstat_op); proc_create_seq("zoneinfo", 0444, NULL, &zoneinfo_op); + register_sysctl_init("vm", vmstat_table); #endif } From patchwork Thu Oct 10 15:22:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yukaixiong X-Patchwork-Id: 13830193 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 ADEB3CF11F5 for ; Thu, 10 Oct 2024 14:11:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A73836B0085; Thu, 10 Oct 2024 10:11:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9D6746B0088; Thu, 10 Oct 2024 10:11:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 800436B0089; Thu, 10 Oct 2024 10:11:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 659156B0085 for ; Thu, 10 Oct 2024 10:11:44 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 60D6EC05FA for ; Thu, 10 Oct 2024 14:11:40 +0000 (UTC) X-FDA: 82657880928.23.CB021B4 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf08.hostedemail.com (Postfix) with ESMTP id 42EE2160017 for ; Thu, 10 Oct 2024 14:11:39 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=none; spf=pass (imf08.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.189 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=1728569457; 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=ejyIAcThZCfKnFMXQWKWyGAETZRqYgziZ+0ookqNxBA=; b=2XfjtJM2Z2DuVdCaOSoauhmpuBsAdH7LpB1jpqVXW+gE8jr9wcF3qRvqlpS3UCB2fQTle3 XxWzojtIkFefCmAuwJMWgxxoCkt5uWneb2peG9k6lNkdT1ds7o6zJvApEIXB//rV2pzd8T Q9y3BerQP6V1QODTAJhly0UGqD2Lq1Y= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=none; spf=pass (imf08.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.189 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=1728569457; a=rsa-sha256; cv=none; b=692tTlzgwnT8GgIbwnXM2Bjegd/LIa4DIIPfjKJfw0gucHOlWBoc/fHaRzpGK64pKcXGI9 AiJukcQYLFOtvrTwjg22vjgbGpxphkmseluZxCLKjQciGlJc28dUNXR9kfq90ZbGA+XRtN ByrML+AffTJyeyKsaAYafSj0auAv76A= Received: from mail.maildlp.com (unknown [172.19.162.254]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4XPWrM1ZmgzCsrx; Thu, 10 Oct 2024 22:10:59 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id 2FB1E180105; Thu, 10 Oct 2024 22:11:37 +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; Thu, 10 Oct 2024 22:11:33 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v3 -next 02/15] mm: filemap: move sysctl to mm/filemap.c Date: Thu, 10 Oct 2024 23:22:02 +0800 Message-ID: <20241010152215.3025842-3-yukaixiong@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241010152215.3025842-1-yukaixiong@huawei.com> References: <20241010152215.3025842-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-Rspam-User: X-Stat-Signature: mskpp86pnwh7zfdkcme6313yieuoequ7 X-Rspamd-Queue-Id: 42EE2160017 X-Rspamd-Server: rspam11 X-HE-Tag: 1728569499-763697 X-HE-Meta: U2FsdGVkX1/c7s37H+KyydJmwoFAXVKnSzppiUFcxEqPjdGGhWhy7pwtl5rlGhjnybKSf/C5OlMvoT/dlqwhjyMyFAaM+Vf/nXuZ4VIpqQby+QxSD32f5zg26THSH7nozaPIYy4/Yb4f55eNGhu73ZHrJPgO/HiJdpXosps+ToBoOfm0DRKWllGzpqrl7lIY/WnIVCm4Hs0ji3A1PCtZEbAM78/5v6C5wdoO/MLUDgfa3VxBeENzLcrIH88sKuQ5MMiBBj1qMHEV8+ck233RRfuxkubCMtBrmTpcrxDG5v0mT2kcOqHlBoS7zW6AQ3gDhcMbh4QIFSzv8OCcc/87uvNCxplcQNdlc15EADf2q95tOVHemSqFe9mGkSVX50f4TOzFhLOPPBuP7qThLdQBXT3Y+/LoYapQYPCFHBzYovI0QCtf376VaZmSukhnmI+q/JUdOEQS+aNRpz4GfRUXwVtnZdah5qhLPeqhD4x5sKX1uFpzKiznZJ1EgO2ZIxrU33BLw9toP50Sow5A/Dfh37mye9WNv5BrU6zblHb3oMfwebQqy+4cHoRMyESEujimYBWHyDMOMjhQW1s6t+//tBwYSJwCWgh8DfNpGZelZeAhcIQF4kq2FBrllOp9K6+wzMozN3H37BwfNn5qGcVdG/ELnGtHXAqzsxRUsnHGjfUH462sznAad/FXJov2ANK7tfmMTQ69lasAfggKlaj6TzI4VhICVvtzBlTBK65xhi3DHE7YVPG8EtASH9rF8bxZsEJWT3T2Sjkf/fzzlUwZEB702MRH/MG+exluJ6QjDahwVrlshXKPEyDpvXQnwV2y6bPZXc35EYdyq5Bk/lupre2v0nl3/VvdfJ07sM+OgvwtNVa7LbdGixSKvEoASpOCVofROM8TBab8VZGnKwwJyAUwUtI9Uido5ZqfZ2PbeU/vpw2xYlmJVFe5rvF+68GysWsf8kMC5cal7ZlcsW3 J+lcHBmu FqLiE8TnQE0rTACeT2Yi5h0LJGpMeE5vPNfRP4m9tnhQxDOdqu80b7pNXDVKbLqXSKzhOQZIBKKaGOOkyepNKldpRJdIrYCbptXPl8rSwhygmUXDHxmm4Abik2J4eqHBpy9sIkkcduRKYRICbGfYW1vt4Uam2uuj8nZShjwgnnCLgIlU= 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: This moves the filemap related sysctl to mm/filemap.c, and removes the redundant external variable declaration. Signed-off-by: Kaixiong Yu Reviewed-by: Kees Cook --- v3: - change the title --- include/linux/mm.h | 2 -- kernel/sysctl.c | 8 -------- mm/filemap.c | 18 +++++++++++++++--- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index df0a5eac66b7..a3c3a7d64407 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -39,8 +39,6 @@ struct user_struct; struct pt_regs; struct folio_batch; -extern int sysctl_page_lock_unfairness; - void mm_core_init(void); void init_mm_internals(void); diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 726b866af57b..2a875b739054 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2089,14 +2089,6 @@ static struct ctl_table vm_table[] = { .extra1 = SYSCTL_ONE, .extra2 = SYSCTL_FOUR, }, - { - .procname = "page_lock_unfairness", - .data = &sysctl_page_lock_unfairness, - .maxlen = sizeof(sysctl_page_lock_unfairness), - .mode = 0644, - .proc_handler = proc_dointvec_minmax, - .extra1 = SYSCTL_ZERO, - }, #ifdef CONFIG_MMU { .procname = "max_map_count", diff --git a/mm/filemap.c b/mm/filemap.c index 429895f1a564..0d4adf8068ca 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include "internal.h" @@ -1069,6 +1070,19 @@ static wait_queue_head_t *folio_waitqueue(struct folio *folio) return &folio_wait_table[hash_ptr(folio, PAGE_WAIT_TABLE_BITS)]; } +/* How many times do we accept lock stealing from under a waiter? */ +static int sysctl_page_lock_unfairness = 5; +static struct ctl_table filemap_sysctl_table[] = { + { + .procname = "page_lock_unfairness", + .data = &sysctl_page_lock_unfairness, + .maxlen = sizeof(sysctl_page_lock_unfairness), + .mode = 0644, + .proc_handler = proc_dointvec_minmax, + .extra1 = SYSCTL_ZERO, + } +}; + void __init pagecache_init(void) { int i; @@ -1077,6 +1091,7 @@ void __init pagecache_init(void) init_waitqueue_head(&folio_wait_table[i]); page_writeback_init(); + register_sysctl_init("vm", filemap_sysctl_table); } /* @@ -1224,9 +1239,6 @@ static inline bool folio_trylock_flag(struct folio *folio, int bit_nr, return true; } -/* How many times do we accept lock stealing from under a waiter? */ -int sysctl_page_lock_unfairness = 5; - static inline int folio_wait_bit_common(struct folio *folio, int bit_nr, int state, enum behavior behavior) { From patchwork Thu Oct 10 15:22:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yukaixiong X-Patchwork-Id: 13830194 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 2004ECF11F8 for ; Thu, 10 Oct 2024 14:11:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AE78F6B0089; Thu, 10 Oct 2024 10:11:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A70646B008A; Thu, 10 Oct 2024 10:11:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8EB016B008C; Thu, 10 Oct 2024 10:11:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 707746B0089 for ; Thu, 10 Oct 2024 10:11:49 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 68F6E40682 for ; Thu, 10 Oct 2024 14:11:46 +0000 (UTC) X-FDA: 82657881096.18.C020249 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf21.hostedemail.com (Postfix) with ESMTP id 9B05A1C0018 for ; Thu, 10 Oct 2024 14:11:43 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=none; spf=pass (imf21.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.190 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=1728569437; 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=cxy8UHV1XeChHvv+QQZ0+LM90KKX8jwmk3+kNPJFrGM=; b=H2LnS+LzDN4UvoL9wIaVU4JC0Hu7Xi2H7pL2R+SvOoEL3PcMhN19SMykyjErMgmQt9727O deiQie1I5HBfZuXzhq31SPzizyx0HdspcT2hJ2B38T6QRe0pFU4gGPZl9KseNLryOP7g9N kVxS3UnBTM7Z0qANMXrr1ms0PZlvWdU= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=none; spf=pass (imf21.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.190 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=1728569437; a=rsa-sha256; cv=none; b=BRrbo0qZJwo/ChS58jZ64ZOyKiAUbva0c/EzV8KPCt8pSWWdYVRfUOekY8p6j8aaH/A7Ae NEU3mvi3EvHcYqzpehI2aBFe+vyJnUszlPIzkFzaKk9Xg+npiAxt9dMyptDJSRnM0AjYmY tzt9GZxYZSocAxM0FoN/peXLqhIqiSU= Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4XPWqs4mTgz2DdD3; Thu, 10 Oct 2024 22:10:33 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id 5C4C61400DC; Thu, 10 Oct 2024 22:11:40 +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; Thu, 10 Oct 2024 22:11:37 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v3 -next 03/15] mm: swap: move sysctl to mm/swap.c Date: Thu, 10 Oct 2024 23:22:03 +0800 Message-ID: <20241010152215.3025842-4-yukaixiong@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241010152215.3025842-1-yukaixiong@huawei.com> References: <20241010152215.3025842-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-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 9B05A1C0018 X-Stat-Signature: 3k3zqzkdee3ucsgme9i51h1pcxe78m48 X-HE-Tag: 1728569503-397648 X-HE-Meta: U2FsdGVkX19755B4LJvX9sK2wtaoc7Cei8kV4agw4CAmc6lbYImZuHj92ysCX7T8cdhkf7F+EdRuyQd338Uo1r8BFr+vUMzg0ErETO5owdsR03TfjQJIxg072Rv1nkXxV1R9sqcwr1sebg+QAcYcTtULk5DI02IBgXKb0fPXlxxNfaikb2dsG9v0DmrlNfrx+FXoRZoRP7rt3kXihgpXxMDv+Y/XYI/trsl3itC2BPll1YqHxmIimbn78Eq7KDEHDWFqqtph77rr316EVkHY+hYmorcqMEqPtpT+d4/zHhlkkpmHeZo0xWNoI/+mF96DprtudnxCH9YISlEjpIRm2ZSajazEyFQLVpf3CYaAhrT5QC7d9jnhI+ks6fWTFEYd61MKDongMSpj3D6WyT+yNm1nwHRZTJ+13MvjIvJDFRNzPo3G62G1afFE+b8A66pY/qUHUSfSxheYFSENieTk7WhMvcmpbAMdY/FYpp3omJV+OnpkpTWYp4H4cgWLySfbcOx9fqbtbYRaEo+/jylxwyrnu4uH0Qwy1THuf6L2/7ILZ8SsSxQ/9P84ls6lRinlEzKII9U46BpH4zAY1DRnOqKh/MZldz6RsBGubFscEDx4xRLiN4l3flohkVjOs6khEZNe82I7ixD43M8b7WKKv+w9fg0hNjOiHdsYF0c17/vujQqm+yjwvcrcstuWLXZtgPM3MNq/S3F9vzSGeU0NXtoVCgCoOBOWfflPT3RbLN1IasOcjGU3MuZLfM+g+g9LY1ZeNQPRJUcy43ZLC+RVzNBoD3qcONcEWG/9Xbzk3yrkWy59hfsWnPCSXA9c3VgfpY5zg7chiNasPYGGKdECtrYFjW8ZdF6mF27aO5xfblHMaJWFID2pQNod/YhlAMsTGbKZGbNKXYuvYxvl5Jt9OK9KFe4ZJKhqjZ2HFn8BWl0dsuGXgF6hQhHb7gyOcvRUrGRzalzaKeT8jKPKOfn k/xtwZiQ 36W+wWp/xDKg7/BE1p0FDMSOJHaIWsn5m6MKiDeyooYpTloT5Sk8iojEwsoXnhvSdYpx9xIlC7J02dpEfm9PwJiQEQ+hWwg4DmqTiTpxp3IzoYbYQVBfEzwYZoN2ACpONF3ZZw6EC2KGo/HN5fMpHsYULl6KkkD98xFPM4zW8vwmGPsI= 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 page-cluster belongs to mm/swap.c, move it to mm/swap.c . Removes the redundant external variable declaration and unneeded include(linux/swap.h). Signed-off-by: Kaixiong Yu Reviewed-by: Kees Cook --- v3: - change the title --- include/linux/mm.h | 2 -- kernel/sysctl.c | 10 ---------- mm/swap.c | 16 +++++++++++++++- mm/swap.h | 1 + 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index a3c3a7d64407..7c46de4290da 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -75,8 +75,6 @@ static inline void totalram_pages_add(long count) } extern void * high_memory; -extern int page_cluster; -extern const int page_cluster_max; #ifdef CONFIG_SYSCTL extern int sysctl_legacy_va_layout; diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 2a875b739054..9fad501311a1 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -21,7 +21,6 @@ #include #include -#include #include #include #include @@ -2054,15 +2053,6 @@ static struct ctl_table vm_table[] = { .mode = 0644, .proc_handler = overcommit_kbytes_handler, }, - { - .procname = "page-cluster", - .data = &page_cluster, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = proc_dointvec_minmax, - .extra1 = SYSCTL_ZERO, - .extra2 = (void *)&page_cluster_max, - }, { .procname = "dirtytime_expire_seconds", .data = &dirtytime_expire_interval, diff --git a/mm/swap.c b/mm/swap.c index 835bdf324b76..2f7d415e66a3 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -45,7 +45,7 @@ /* How many pages do we try to swap or page in/out together? As a power of 2 */ int page_cluster; -const int page_cluster_max = 31; +static const int page_cluster_max = 31; struct cpu_fbatches { /* @@ -1089,6 +1089,18 @@ void folio_batch_remove_exceptionals(struct folio_batch *fbatch) fbatch->nr = j; } +static struct ctl_table swap_sysctl_table[] = { + { + .procname = "page-cluster", + .data = &page_cluster, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = proc_dointvec_minmax, + .extra1 = SYSCTL_ZERO, + .extra2 = (void *)&page_cluster_max, + } +}; + /* * Perform any setup for the swap system */ @@ -1105,4 +1117,6 @@ void __init swap_setup(void) * Right now other parts of the system means that we * _really_ don't want to cluster much more */ + + register_sysctl_init("vm", swap_sysctl_table); } diff --git a/mm/swap.h b/mm/swap.h index ad2f121de970..274dcc6219a0 100644 --- a/mm/swap.h +++ b/mm/swap.h @@ -3,6 +3,7 @@ #define _MM_SWAP_H struct mempolicy; +extern int page_cluster; #ifdef CONFIG_SWAP #include /* for swp_offset */ From patchwork Thu Oct 10 15:22:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yukaixiong X-Patchwork-Id: 13830195 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 92800CF11F5 for ; Thu, 10 Oct 2024 14:11:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 397FD6B008A; Thu, 10 Oct 2024 10:11:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 31D916B008C; Thu, 10 Oct 2024 10:11:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 149606B0092; Thu, 10 Oct 2024 10:11:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id EC9AD6B008A for ; Thu, 10 Oct 2024 10:11:49 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 86E76120140 for ; Thu, 10 Oct 2024 14:11:46 +0000 (UTC) X-FDA: 82657881138.30.64E20A7 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf20.hostedemail.com (Postfix) with ESMTP id CF8D51C0025 for ; Thu, 10 Oct 2024 14:11:45 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=none; spf=pass (imf20.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.191 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=1728569369; 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=yW/O80OCskqq9OCT7qIQ/2hREsg1DGEceF3YaqJVfrM=; b=IrUTlJnYSLwqDkAxl+J3FsFkJARTATHx4XmbUMlmEe5e33tNdiaY7Wp7eAQIG76d5mnDyW t7pEJ0Q0pgVnHZ+VrL06AuG8zrI/CPcYkWArRPJ1iXCR04emRoa6HXUxvGGLodOXt7Ibwb PEg5/9x4bPZUrv7oMUkB2oQxP0gtlyU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728569369; a=rsa-sha256; cv=none; b=L8YSIWvZfcmVRS65pSwIZqbrCh5PlpkBNN+39o1XWNMLaxgNE0WVhzX8jolQAzvhbtpk9A 69hCQw96IUmk/lyZqW3t3ZLjZPqOpFgFOuU0JWF/AMwqQlKxsNDGnE9IZgQXOZmmk7orX9 bMk8PImSMV+AYY2Gsgw37Lb5dEXIylg= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=none; spf=pass (imf20.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4XPWmS55yMz1HKl3; Thu, 10 Oct 2024 22:07:36 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id A35011400DC; Thu, 10 Oct 2024 22:11:43 +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; Thu, 10 Oct 2024 22:11:40 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v3 -next 04/15] mm: vmscan: move vmscan sysctls to mm/vmscan.c Date: Thu, 10 Oct 2024 23:22:04 +0800 Message-ID: <20241010152215.3025842-5-yukaixiong@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241010152215.3025842-1-yukaixiong@huawei.com> References: <20241010152215.3025842-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: ouek8yhxafeo77g44r451u63rad3xh1i X-Rspamd-Queue-Id: CF8D51C0025 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1728569505-920086 X-HE-Meta: U2FsdGVkX18vSKAIYTGe6eSBo6ydsBR1gMQKgCKzYbp4b2FlwxTV4rYGSiPofgNu2ncn4vzWyGhUIrAvXPY5X+lOSlfmMiDwZiafcM/KqDSk1SecFDG7pbe1/TYQ70jfiHRio5M/oMl3o/4XC+MVpjpZezIhEUzNtH0r2CG7ZEwaOveh0HOiCsEWddkDh7DioQa3G2kgCw4wRIKINwt884e/QDNqzuTWE7spcPKaTqmf3wHiio+BkNeTKqMFRJZfVxR4cpri7pMRGSZWMdxLME0PZUaDYuBinQM9j48bFDabrOo//yxza7sAv98QvXuDSKoAtqIg/5YpqgnuOpwYVk8XLQ97I3BUNjKIYaUjQ5cmZ+B2kNh2ZROo+Inx+l5u2RIfRoymGdfegFhTM119Mt8me/bcInYFpOd2vOdBFbuXaWlLXPELRi9dzsYTzkCNeL0Pr2HNjqj/dsTPlo+evhSsIgiTlSfntukWmyPMyzrdUZSN1PjxVDBLtzQDavtlnpAogNO1ZLHPYy6KNBec50lozqTjI0ufu3OOKNPnhUvk7FsOuHbtkDGw2/v0/7/AC+7Oa0FtLpmQTRcLXe6KZcj+BWYXMTcTO0RcyO5eA/4MV/Kb6DdeO3Vm2MBOMpNOcGUS9+Lz9+O36O/dZpVod2FPxAoz252d12SfeVfRMWr3IZZt2FFwdv927cUbsyL1e37ajlpBc5CIRzTjh6tte4/EGi5QlZvhyyJSdcqI+5e4Ahyr12SE274JUvglFqEFVtX884V+ByTG5uF21ejAMmIOYhGG2sP9Dw2/iB+rK40xPe7OV/I2FZJb1Iv674aUURj1g5ZHETtq6RLcAgF7fe/aVDtFLCXJbE+Yb2cNs5OO4odds9r/+FKyFN0hZfxyZ8hAvmh/l3PxL5jnqxhtnNnBZZe6oP5igj5dVJiX6CGa7MzoxM54/pvgcea6xBs/5AhkDkuCCwaOZHMF2eP +k/VseoY D77+zOOzn4D/qKxpsfQRj3x1dp30FFKlGJGvkBuG1qB+SPaF64cVLdVkB1rZcFWiEf7KQATxYurKgkHoh3PlyCDdSIAbowoED4ZKEdv/aNzodP1kf5aDE8bkcxiF0RSzz+Fvu1AxErxqmMwpWM3T+QapZDLLLViyxwKc9xXWOd/+7bOk= 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: This moves vm_swappiness and zone_reclaim_mode to mm/vmscan.c, as part of the kernel/sysctl.c cleaning, also moves some external variable declarations and function declarations from include/linux/swap.h into mm/internal.h. Signed-off-by: Kaixiong Yu Reviewed-by: Kees Cook --- v3: - change the title --- include/linux/swap.h | 9 --------- kernel/sysctl.c | 19 ------------------- mm/internal.h | 10 ++++++++++ mm/vmscan.c | 23 +++++++++++++++++++++++ 4 files changed, 33 insertions(+), 28 deletions(-) diff --git a/include/linux/swap.h b/include/linux/swap.h index ca533b478c21..c95fb8d87b05 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h @@ -425,19 +425,10 @@ extern int vm_swappiness; long remove_mapping(struct address_space *mapping, struct folio *folio); #ifdef CONFIG_NUMA -extern int node_reclaim_mode; extern int sysctl_min_unmapped_ratio; extern int sysctl_min_slab_ratio; -#else -#define node_reclaim_mode 0 #endif -static inline bool node_reclaim_enabled(void) -{ - /* Is any node_reclaim_mode bit set? */ - return node_reclaim_mode & (RECLAIM_ZONE|RECLAIM_WRITE|RECLAIM_UNMAP); -} - void check_move_unevictable_folios(struct folio_batch *fbatch); extern void __meminit kswapd_run(int nid); diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 9fad501311a1..184d39944e16 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2061,15 +2061,6 @@ static struct ctl_table vm_table[] = { .proc_handler = dirtytime_interval_handler, .extra1 = SYSCTL_ZERO, }, - { - .procname = "swappiness", - .data = &vm_swappiness, - .maxlen = sizeof(vm_swappiness), - .mode = 0644, - .proc_handler = proc_dointvec_minmax, - .extra1 = SYSCTL_ZERO, - .extra2 = SYSCTL_TWO_HUNDRED, - }, { .procname = "drop_caches", .data = &sysctl_drop_caches, @@ -2117,16 +2108,6 @@ static struct ctl_table vm_table[] = { .extra1 = SYSCTL_ZERO, }, #endif -#ifdef CONFIG_NUMA - { - .procname = "zone_reclaim_mode", - .data = &node_reclaim_mode, - .maxlen = sizeof(node_reclaim_mode), - .mode = 0644, - .proc_handler = proc_dointvec_minmax, - .extra1 = SYSCTL_ZERO, - }, -#endif #ifdef CONFIG_MMU { .procname = "mmap_min_addr", diff --git a/mm/internal.h b/mm/internal.h index 906da6280c2d..84c46fe6a07c 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -1038,9 +1038,13 @@ static inline void mminit_verify_zonelist(void) #define NODE_RECLAIM_SUCCESS 1 #ifdef CONFIG_NUMA +extern int node_reclaim_mode; + extern int node_reclaim(struct pglist_data *, gfp_t, unsigned int); extern int find_next_best_node(int node, nodemask_t *used_node_mask); #else +#define node_reclaim_mode 0 + static inline int node_reclaim(struct pglist_data *pgdat, gfp_t mask, unsigned int order) { @@ -1052,6 +1056,12 @@ static inline int find_next_best_node(int node, nodemask_t *used_node_mask) } #endif +static inline bool node_reclaim_enabled(void) +{ + /* Is any node_reclaim_mode bit set? */ + return node_reclaim_mode & (RECLAIM_ZONE|RECLAIM_WRITE|RECLAIM_UNMAP); +} + /* * mm/memory-failure.c */ diff --git a/mm/vmscan.c b/mm/vmscan.c index f9919b522c01..1188978e46d5 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -7384,6 +7384,28 @@ void __meminit kswapd_stop(int nid) pgdat_kswapd_unlock(pgdat); } +static struct ctl_table vmscan_sysctl_table[] = { + { + .procname = "swappiness", + .data = &vm_swappiness, + .maxlen = sizeof(vm_swappiness), + .mode = 0644, + .proc_handler = proc_dointvec_minmax, + .extra1 = SYSCTL_ZERO, + .extra2 = SYSCTL_TWO_HUNDRED, + }, +#ifdef CONFIG_NUMA + { + .procname = "zone_reclaim_mode", + .data = &node_reclaim_mode, + .maxlen = sizeof(node_reclaim_mode), + .mode = 0644, + .proc_handler = proc_dointvec_minmax, + .extra1 = SYSCTL_ZERO, + } +#endif +}; + static int __init kswapd_init(void) { int nid; @@ -7391,6 +7413,7 @@ static int __init kswapd_init(void) swap_setup(); for_each_node_state(nid, N_MEMORY) kswapd_run(nid); + register_sysctl_init("vm", vmscan_sysctl_table); return 0; } From patchwork Thu Oct 10 15:22:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yukaixiong X-Patchwork-Id: 13830196 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 53EFFCF11F5 for ; Thu, 10 Oct 2024 14:11:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B84786B0093; Thu, 10 Oct 2024 10:11:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B34B06B0095; Thu, 10 Oct 2024 10:11:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9B1D16B0096; Thu, 10 Oct 2024 10:11:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 6FC7B6B0093 for ; Thu, 10 Oct 2024 10:11:53 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 44805ABED9 for ; Thu, 10 Oct 2024 14:11:46 +0000 (UTC) X-FDA: 82657881306.27.21ECFC2 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf20.hostedemail.com (Postfix) with ESMTP id 3EB1B1C0008 for ; Thu, 10 Oct 2024 14:11:48 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf20.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.188 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=1728569359; 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=4g5npcGMjrxR7dKjkJ+VwsQ/8xMhxDYDk22gcM7vC7U=; b=cqw2pB4tIhxb5jnGTat3cTBAE5wcVxVLKZ/gx81qTYF0XudshvaHiyqGJFUx3MUAk2fttH esKsCeJs+LjSYagZ4LbyaKFSSPn0pETspcy4tavt3HqRC7b+Xn/QZs8uWo1jMR+l1Z0zbN 79HeZHg0mZRWPZm/yEUgILgGcXy7BDU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728569359; a=rsa-sha256; cv=none; b=IFuhAUlpRQpq9w4gjKAjRguVyzvSZ2QU7r0C2hu2Bhy3w1ZMigLHnziB4ykMC4SjLgWgHs N2KY79jcrFT8+TI1F60QrphmEEcjnvlBeacHH/WZ+PLiquvhSuMXGUIsnAJOEV3DuAyJ+S MZ51QsHyqKxuXQG8OjtFl+gLb0LXJfg= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf20.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com Received: from mail.maildlp.com (unknown [172.19.162.254]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4XPWpV3pGKzfdB3; Thu, 10 Oct 2024 22:09:22 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id C5727180105; Thu, 10 Oct 2024 22:11:46 +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; Thu, 10 Oct 2024 22:11:43 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v3 -next 05/15] mm: util: move sysctls to mm/util.c Date: Thu, 10 Oct 2024 23:22:05 +0800 Message-ID: <20241010152215.3025842-6-yukaixiong@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241010152215.3025842-1-yukaixiong@huawei.com> References: <20241010152215.3025842-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-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 3EB1B1C0008 X-Stat-Signature: b7pti9j9co6n5dka98e494kordau3y6j X-Rspam-User: X-HE-Tag: 1728569508-7404 X-HE-Meta: U2FsdGVkX196Ew78ADvbAkEhYEhzGQN7L7rhj3UwxNQmEUT3XvViuvKBkxEv29bRCiihwnX0kBhfmJTcI/Lr6qg3qXIrKTHGVuvk8OE6LjkjDZB3gRCq3KzoBMlTRcS6Ag5/ajRUeb8U0UJ1Z2ccGcXB6bfO/0I+J0I3D5DOCO74ROYLnr3MxfGPTXT/i0D+ovXtw+3ZoR+08Y/y2wJtHVLeVWX8TLEFGdldvVls6kPDhwBjM7ECj/iy9bS0NMtrrI3BQlLqUbGTnHyacxWw490Xp+aR0UhCIShGl6Fg1xj+1yeC21DyKo5ud1hLeMeQ4gkMdYDfUa8ZExeo7BiT15A3KVuTQ3QghZEAS+YJiUw9PRcDfLbySoIqT5TxHhPmzlmH90IBr5kdA3NdsFhHuYiNZE0askF5oZ4UrACeilfqk5KSkJnH1iPhZXecgvfpNfrRWVqIhRX3nLhDFHJv/cUkmKSJ88vUB6knTZM2Frx1dbR4VY0JLF9n8iKamwyLTcWNva1gSzLCMFGcX/twLssRK4nCTgsql6Jr2xRpy7/1AQoFaI9VXeWf4FmE3Ncyc4WKMtVynWqtNTLXv6O4QW8U+S2ZIsWVppSZs+zovNTm3uIo3xMcIh2cR+VV6AY/PA9tDv9CIG6mxJjDckvVV2uRjw2qBpb8EWDEejeQoNIZpnv8dohN0BVt3Xep/j7JmcjoLEOWcMq2BEBNNhlzcZXsGoOs1QT20NTuUxpZ0i+m5ydCPDbg7OfFKvOX6SdHYgGuSxmnDqQzW1+qtg4eDhM2qjXbB6VCwk8gYtyXYLRrez2+l/CzugCC45BhurZ8FaIGBIYCv5bqQid3cGSircXiNtlYdTrBA5jgTVCaohLbSt6F2RawuwdIgr4QX/QewEdCk6tJ/SgGjkFQNzjP6O1enr52vSKmHDWCLbUugjtiHKrdnI0JnHFH2na6PvBTEcz1Putv/gGAjEea0Ov RB9pcZpq 29nVN8MU48eheACGxOm5Z1xdPomlpr1+cDEKPyOFKON9ZYEqSHfi+SbGCepqbwk8Vmp6idhg5OlO5TFeeeAX/edoXCh4/g8sEGSoASWkrsz+PXHc5bnxq6Wx8cXk7A98bDEL5iFRS/Z2ghKLyNIFvL/7+GDAhJsclF6pyQy9V4zLj+gk= 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: This moves all util related sysctls to mm/util.c, as part of the kernel/sysctl.c cleaning, also removes redundant external variable declarations and function declarations. Signed-off-by: Kaixiong Yu Reviewed-by: Kees Cook --- v3: - change the title --- include/linux/mm.h | 11 -------- include/linux/mman.h | 2 -- kernel/sysctl.c | 37 ------------------------ mm/util.c | 67 ++++++++++++++++++++++++++++++++++++++------ 4 files changed, 59 insertions(+), 58 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 7c46de4290da..50f0069280f4 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -204,17 +204,6 @@ extern int sysctl_max_map_count; extern unsigned long sysctl_user_reserve_kbytes; extern unsigned long sysctl_admin_reserve_kbytes; -extern int sysctl_overcommit_memory; -extern int sysctl_overcommit_ratio; -extern unsigned long sysctl_overcommit_kbytes; - -int overcommit_ratio_handler(const struct ctl_table *, int, void *, size_t *, - loff_t *); -int overcommit_kbytes_handler(const struct ctl_table *, int, void *, size_t *, - loff_t *); -int overcommit_policy_handler(const struct ctl_table *, int, void *, size_t *, - loff_t *); - #if defined(CONFIG_SPARSEMEM) && !defined(CONFIG_SPARSEMEM_VMEMMAP) #define nth_page(page,n) pfn_to_page(page_to_pfn((page)) + (n)) #define folio_page_idx(folio, p) (page_to_pfn(p) - folio_pfn(folio)) diff --git a/include/linux/mman.h b/include/linux/mman.h index bcb201ab7a41..e62ef272d140 100644 --- a/include/linux/mman.h +++ b/include/linux/mman.h @@ -58,8 +58,6 @@ | MAP_HUGE_1GB) extern int sysctl_overcommit_memory; -extern int sysctl_overcommit_ratio; -extern unsigned long sysctl_overcommit_kbytes; extern struct percpu_counter vm_committed_as; #ifdef CONFIG_SMP diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 184d39944e16..ad3ac6f6c808 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2030,29 +2030,6 @@ static struct ctl_table kern_table[] = { }; static struct ctl_table vm_table[] = { - { - .procname = "overcommit_memory", - .data = &sysctl_overcommit_memory, - .maxlen = sizeof(sysctl_overcommit_memory), - .mode = 0644, - .proc_handler = overcommit_policy_handler, - .extra1 = SYSCTL_ZERO, - .extra2 = SYSCTL_TWO, - }, - { - .procname = "overcommit_ratio", - .data = &sysctl_overcommit_ratio, - .maxlen = sizeof(sysctl_overcommit_ratio), - .mode = 0644, - .proc_handler = overcommit_ratio_handler, - }, - { - .procname = "overcommit_kbytes", - .data = &sysctl_overcommit_kbytes, - .maxlen = sizeof(sysctl_overcommit_kbytes), - .mode = 0644, - .proc_handler = overcommit_kbytes_handler, - }, { .procname = "dirtytime_expire_seconds", .data = &dirtytime_expire_interval, @@ -2133,20 +2110,6 @@ static struct ctl_table vm_table[] = { .extra1 = SYSCTL_ZERO, }, #endif - { - .procname = "user_reserve_kbytes", - .data = &sysctl_user_reserve_kbytes, - .maxlen = sizeof(sysctl_user_reserve_kbytes), - .mode = 0644, - .proc_handler = proc_doulongvec_minmax, - }, - { - .procname = "admin_reserve_kbytes", - .data = &sysctl_admin_reserve_kbytes, - .maxlen = sizeof(sysctl_admin_reserve_kbytes), - .mode = 0644, - .proc_handler = proc_doulongvec_minmax, - }, #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS { .procname = "mmap_rnd_bits", diff --git a/mm/util.c b/mm/util.c index c1c3b06ab4f9..d0c5f5110aa1 100644 --- a/mm/util.c +++ b/mm/util.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -894,14 +895,16 @@ int folio_mc_copy(struct folio *dst, struct folio *src) EXPORT_SYMBOL(folio_mc_copy); int sysctl_overcommit_memory __read_mostly = OVERCOMMIT_GUESS; -int sysctl_overcommit_ratio __read_mostly = 50; -unsigned long sysctl_overcommit_kbytes __read_mostly; +static int sysctl_overcommit_ratio __read_mostly = 50; +static unsigned long sysctl_overcommit_kbytes __read_mostly; int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT; unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */ unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */ -int overcommit_ratio_handler(const struct ctl_table *table, int write, void *buffer, - size_t *lenp, loff_t *ppos) +#ifdef CONFIG_SYSCTL + +static int overcommit_ratio_handler(const struct ctl_table *table, int write, + void *buffer, size_t *lenp, loff_t *ppos) { int ret; @@ -916,8 +919,8 @@ static void sync_overcommit_as(struct work_struct *dummy) percpu_counter_sync(&vm_committed_as); } -int overcommit_policy_handler(const struct ctl_table *table, int write, void *buffer, - size_t *lenp, loff_t *ppos) +static int overcommit_policy_handler(const struct ctl_table *table, int write, + void *buffer, size_t *lenp, loff_t *ppos) { struct ctl_table t; int new_policy = -1; @@ -952,8 +955,8 @@ int overcommit_policy_handler(const struct ctl_table *table, int write, void *bu return ret; } -int overcommit_kbytes_handler(const struct ctl_table *table, int write, void *buffer, - size_t *lenp, loff_t *ppos) +static int overcommit_kbytes_handler(const struct ctl_table *table, int write, + void *buffer, size_t *lenp, loff_t *ppos) { int ret; @@ -963,6 +966,54 @@ int overcommit_kbytes_handler(const struct ctl_table *table, int write, void *bu return ret; } +static struct ctl_table util_sysctl_table[] = { + { + .procname = "overcommit_memory", + .data = &sysctl_overcommit_memory, + .maxlen = sizeof(sysctl_overcommit_memory), + .mode = 0644, + .proc_handler = overcommit_policy_handler, + .extra1 = SYSCTL_ZERO, + .extra2 = SYSCTL_TWO, + }, + { + .procname = "overcommit_ratio", + .data = &sysctl_overcommit_ratio, + .maxlen = sizeof(sysctl_overcommit_ratio), + .mode = 0644, + .proc_handler = overcommit_ratio_handler, + }, + { + .procname = "overcommit_kbytes", + .data = &sysctl_overcommit_kbytes, + .maxlen = sizeof(sysctl_overcommit_kbytes), + .mode = 0644, + .proc_handler = overcommit_kbytes_handler, + }, + { + .procname = "user_reserve_kbytes", + .data = &sysctl_user_reserve_kbytes, + .maxlen = sizeof(sysctl_user_reserve_kbytes), + .mode = 0644, + .proc_handler = proc_doulongvec_minmax, + }, + { + .procname = "admin_reserve_kbytes", + .data = &sysctl_admin_reserve_kbytes, + .maxlen = sizeof(sysctl_admin_reserve_kbytes), + .mode = 0644, + .proc_handler = proc_doulongvec_minmax, + }, +}; + +static int __init init_vm_util_sysctls(void) +{ + register_sysctl_init("vm", util_sysctl_table); + return 0; +} +subsys_initcall(init_vm_util_sysctls); +#endif /* CONFIG_SYSCTL */ + /* * Committed memory limit enforced when OVERCOMMIT_NEVER policy is used */ From patchwork Thu Oct 10 15:22:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yukaixiong X-Patchwork-Id: 13830197 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 3AE15CF11F8 for ; Thu, 10 Oct 2024 14:11:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BAC0D6B0095; Thu, 10 Oct 2024 10:11:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B5CA56B0096; Thu, 10 Oct 2024 10:11:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9D53D6B0098; Thu, 10 Oct 2024 10:11:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 834BC6B0095 for ; Thu, 10 Oct 2024 10:11:56 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 549631A05F4 for ; Thu, 10 Oct 2024 14:11:50 +0000 (UTC) X-FDA: 82657881432.22.832D80B Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf18.hostedemail.com (Postfix) with ESMTP id 5AF221C0021 for ; Thu, 10 Oct 2024 14:11:52 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=none; spf=pass (imf18.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.255 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=1728569444; a=rsa-sha256; cv=none; b=VocZ4yKakUi1U9K6dpErQApalJ1fbf8jNQwm28NyqhqgIgVj2nBSVBZDvuAPeI2xnMZEO7 ta72g2KBeNE98F9K5iTMDChK+uPmSqHIE7PAk/px2UO5wc/HTmp9mFNEUQHv9Jl3nNX69w tliixr938qziI2qFpg0jDbP9PaB/emo= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=none; spf=pass (imf18.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.255 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=1728569444; 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=s2ros0uLr2eOPAZap4eBocjo7MYyEJpnKahV/mA/ubk=; b=NsD0jw6BCKLxAH5EuBKN4rHxe2Ex1X8798QCdMxKBwtZArdk1hxjqwJskVQ5yfsl2bcsSK mssdr3PlAE1GqE4KTTyiVjudL7EmH8dKEyumHL+Obim68Cfeul2X0k/gZJCLILT9yTTKhy EY/J8C9Ul8Bzts6yxhe/lo1BdEZoIjg= Received: from mail.maildlp.com (unknown [172.19.88.194]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4XPWqK1kbpz1T8N3; Thu, 10 Oct 2024 22:10:05 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id 09BCF1401E9; Thu, 10 Oct 2024 22:11:50 +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; Thu, 10 Oct 2024 22:11:46 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v3 -next 06/15] mm: mmap: move sysctl to mm/mmap.c Date: Thu, 10 Oct 2024 23:22:06 +0800 Message-ID: <20241010152215.3025842-7-yukaixiong@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241010152215.3025842-1-yukaixiong@huawei.com> References: <20241010152215.3025842-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: s1phw5ssibs77aarnz9qbqy5cx7ogsk5 X-Rspamd-Queue-Id: 5AF221C0021 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1728569512-891353 X-HE-Meta: U2FsdGVkX19/IscJXlMjqWBLBMsXnwKVe2amlIHrgKu59Ou90ctuip1MtdQw8w7cotp/3Ta7mc+Kz0QVSSDshcSwTAbYOXHEV9yJE5T6eCVkstBdDu1DeDwMhUHdFHu2quWpecvQLuxkyxMbbU0tzNsFQ7J3u+KfONTymAivOHfrXdpzQEJRuQp2NFKsYGF5rcUkE2xXW0iG0mHF8gVsFYb3tLu6BayMKokxooxr6FGNKH525lT8CwIQSZraWv+AyWfjlVcgCSFHDvFPSrlsWtVu2DgTLlMjbOS8yrzAr2pqmojom5OVxmjf8Y5MeKiWHUAaY7wti2OslDpxTrknexlYhV62ErgsgaE2Eu2rGfntiIdi0cMTqDBCmEGwQhD6T6qEiyvYIh97N82uu183Aqq6+GAxqXD6qBE87OBieU2O/DYOHgnhJCXFCUdelsNBUNkw9Iep+p02x+k2DxkrJymvTqIH3zYzXYCfoAwmXRny9YX5kYsydtqIeGx0n2VrJf3kprcbcRSwCuJ6NNToO7oRePsCv2Egv/HskcnnGwugPzzWt+zz4T7rf/9uWAhgVW5Bf0D/n4yUKPE6yipo8gm21Mh9ftvTWxHiXpdEJcl4BS0HFsTRGBsi8N9OF1q8KUC4kMPhs/aUQ60k+/VjHSiz4TUDLG41IliVyzj7zygASAjORAH8hIzgT9Q46kQfhhK2SY40IRguUWzSA5yKfw2fX+OISvvcAn0j+RX/MSyD/sVhP/B3D+yrz08oBnpli9OSMQ/XSz9k3heNzG08xCdNeskR3N9UnMnvhnJLaLIn1Kz1rQeQOtgjPly3i5PXecJoLNEhga2PkU03GQXzB0c1Z4Ur6rr6T5MVPM4qM9e1HKXZOLQ6ifXQpCXyCKwuOQdk4qrsgTNNc21HD212YA7NeJH8QqrblrtEsBLoVW4b71uo+ETUQewcqs2eeR9R3Bul3BhoGnon911feot DyXDUIXK DHIq809o+b9qy0VHWD9FEJWOjD2lMKB5yXi1BHUuT3MLG63QwTaqlPgelavKKjdF9l10XBl85TepI4z9gpTIMQxvGcJkMlqbQke+cx7dR+EWT+xxbaYueQSt4Tysx5ZRid3DRrzO8uKkk4KkZam3Ccp21G10GdvEKAfw2 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: This moves all mmap related sysctls to mm/mmap.c, as part of the kernel/sysctl.c cleaning, also move the variable declaration from kernel/sysctl.c into mm/mmap.c. Signed-off-by: Kaixiong Yu Reviewed-by: Kees Cook --- v3: - change the title v2: - fix sysctl_max_map_count undeclared issue in mm/nommu.c --- kernel/sysctl.c | 50 +-------------------------------------------- mm/mmap.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 49 deletions(-) diff --git a/kernel/sysctl.c b/kernel/sysctl.c index ad3ac6f6c808..41d4afc978e6 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -127,12 +127,6 @@ enum sysctl_writes_mode { static enum sysctl_writes_mode sysctl_writes_strict = SYSCTL_WRITES_STRICT; #endif /* CONFIG_PROC_SYSCTL */ - -#if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \ - defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT) -int sysctl_legacy_va_layout; -#endif - #endif /* CONFIG_SYSCTL */ /* @@ -2047,16 +2041,7 @@ static struct ctl_table vm_table[] = { .extra1 = SYSCTL_ONE, .extra2 = SYSCTL_FOUR, }, -#ifdef CONFIG_MMU - { - .procname = "max_map_count", - .data = &sysctl_max_map_count, - .maxlen = sizeof(sysctl_max_map_count), - .mode = 0644, - .proc_handler = proc_dointvec_minmax, - .extra1 = SYSCTL_ZERO, - }, -#else +#ifndef CONFIG_MMU { .procname = "nr_trim_pages", .data = &sysctl_nr_trim_pages, @@ -2074,17 +2059,6 @@ static struct ctl_table vm_table[] = { .proc_handler = proc_dointvec_minmax, .extra1 = SYSCTL_ZERO, }, -#if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \ - defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT) - { - .procname = "legacy_va_layout", - .data = &sysctl_legacy_va_layout, - .maxlen = sizeof(sysctl_legacy_va_layout), - .mode = 0644, - .proc_handler = proc_dointvec_minmax, - .extra1 = SYSCTL_ZERO, - }, -#endif #ifdef CONFIG_MMU { .procname = "mmap_min_addr", @@ -2110,28 +2084,6 @@ static struct ctl_table vm_table[] = { .extra1 = SYSCTL_ZERO, }, #endif -#ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS - { - .procname = "mmap_rnd_bits", - .data = &mmap_rnd_bits, - .maxlen = sizeof(mmap_rnd_bits), - .mode = 0600, - .proc_handler = proc_dointvec_minmax, - .extra1 = (void *)&mmap_rnd_bits_min, - .extra2 = (void *)&mmap_rnd_bits_max, - }, -#endif -#ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS - { - .procname = "mmap_rnd_compat_bits", - .data = &mmap_rnd_compat_bits, - .maxlen = sizeof(mmap_rnd_compat_bits), - .mode = 0600, - .proc_handler = proc_dointvec_minmax, - .extra1 = (void *)&mmap_rnd_compat_bits_min, - .extra2 = (void *)&mmap_rnd_compat_bits_max, - }, -#endif }; int __init sysctl_init_bases(void) diff --git a/mm/mmap.c b/mm/mmap.c index 4ef58ad80a33..6d584e67d045 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2176,6 +2176,57 @@ struct vm_area_struct *_install_special_mapping( &special_mapping_vmops); } +#ifdef CONFIG_SYSCTL +#if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \ + defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT) +int sysctl_legacy_va_layout; +#endif + +static struct ctl_table mmap_table[] = { + { + .procname = "max_map_count", + .data = &sysctl_max_map_count, + .maxlen = sizeof(sysctl_max_map_count), + .mode = 0644, + .proc_handler = proc_dointvec_minmax, + .extra1 = SYSCTL_ZERO, + }, +#if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \ + defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT) + { + .procname = "legacy_va_layout", + .data = &sysctl_legacy_va_layout, + .maxlen = sizeof(sysctl_legacy_va_layout), + .mode = 0644, + .proc_handler = proc_dointvec_minmax, + .extra1 = SYSCTL_ZERO, + }, +#endif +#ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS + { + .procname = "mmap_rnd_bits", + .data = &mmap_rnd_bits, + .maxlen = sizeof(mmap_rnd_bits), + .mode = 0600, + .proc_handler = proc_dointvec_minmax, + .extra1 = (void *)&mmap_rnd_bits_min, + .extra2 = (void *)&mmap_rnd_bits_max, + }, +#endif +#ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS + { + .procname = "mmap_rnd_compat_bits", + .data = &mmap_rnd_compat_bits, + .maxlen = sizeof(mmap_rnd_compat_bits), + .mode = 0600, + .proc_handler = proc_dointvec_minmax, + .extra1 = (void *)&mmap_rnd_compat_bits_min, + .extra2 = (void *)&mmap_rnd_compat_bits_max, + }, +#endif +}; +#endif /* CONFIG_SYSCTL */ + /* * initialise the percpu counter for VM */ @@ -2185,6 +2236,9 @@ void __init mmap_init(void) ret = percpu_counter_init(&vm_committed_as, 0, GFP_KERNEL); VM_BUG_ON(ret); +#ifdef CONFIG_SYSCTL + register_sysctl_init("vm", mmap_table); +#endif } /* From patchwork Thu Oct 10 15:22:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yukaixiong X-Patchwork-Id: 13830198 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 1C614CF11F5 for ; Thu, 10 Oct 2024 14:12:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A24616B0098; Thu, 10 Oct 2024 10:11:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9AF956B0099; Thu, 10 Oct 2024 10:11:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 875486B009A; Thu, 10 Oct 2024 10:11:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 667616B0098 for ; Thu, 10 Oct 2024 10:11:59 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id A567840675 for ; Thu, 10 Oct 2024 14:11:56 +0000 (UTC) X-FDA: 82657881558.04.D33B66F Received: from szxga06-in.huawei.com (szxga06-in.huawei.com [45.249.212.32]) by imf14.hostedemail.com (Postfix) with ESMTP id 196F410000C for ; Thu, 10 Oct 2024 14:11:54 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf14.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.32 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=1728569366; 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=Bx6aKZiFe76ydKrYGeXzEnl862q0yF//lZgdUVUUJU4=; b=pudBzYWbpNg6CTjnZphAeskrGfuomdzMcylmcOOjOiDVNabcdHNx4Sk8AjXM/jdsZlVwT4 LJIwNbkA8jL10r1JnTWwwRBXilZkWiR0MODpgCjqOvAKqrWvBEQheQeEm82byV5COg2L8K OHPbW9Luj0Tgvbny8i3EHfr049mbPoo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728569366; a=rsa-sha256; cv=none; b=aBEy0yw6hZxqlwBg3ufJW8Q7OV2wrEnBKzhATNUiqBZeWRiY3/yg7UQr5YTxY+1Ox/BlbV zV1J2ByYoeDlA9C+jtydPbTYL8+eM1N8cTdU0w33AvHH+FhnO+iaERxUaGiU3DGJbKBCvy BAJFoUnnFYZrD9vmriftkr3pq6KNKxk= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf14.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.32 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com Received: from mail.maildlp.com (unknown [172.19.88.214]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4XPWsT6mQjz2KXx6; Thu, 10 Oct 2024 22:11:57 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id 3D1631A016C; Thu, 10 Oct 2024 22:11: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; Thu, 10 Oct 2024 22:11:49 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v3 -next 07/15] security: min_addr: move sysctl to security/min_addr.c Date: Thu, 10 Oct 2024 23:22:07 +0800 Message-ID: <20241010152215.3025842-8-yukaixiong@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241010152215.3025842-1-yukaixiong@huawei.com> References: <20241010152215.3025842-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-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 196F410000C X-Stat-Signature: hzx7syr9rd4echsmuosb9yu5d1yjex9t X-Rspam-User: X-HE-Tag: 1728569514-732414 X-HE-Meta: U2FsdGVkX180Xb6Y366q3AXjuXO1aOjG5kZx6rDQUmzxujhSOj43cZzEtfFpJq5qvnEGWM5uSZEUY8OWcR31+ikJsgaFVJK/CglZ9hpctH+84jUXNklIWmsQ421rvgtQDsP563hBbGWvlL0tETkR0ncPCWg/JBocPN+Qw2VGZTX3LwS+W9HVL7+j+i382UAz3aPOKITciqjIsJ9nZwHjule21YvTtXCHLMLUcSxIjdOK/2FlmbrzzePLBInin1GaVhlnq/vhtyNXqIEnp0KGUUcFrytLzMAEb7p25SyarRyS3/zhGffFoa+DY4pjfvfLNv9m4gu/zJ8roANwzb1zteP47vDA9Kr+4VY07gaOfT1GqxD+Hx1gZ+J2alXXM+PG8awTUkLeUZF+QkZ0W1jcTdxt/l29sqjfVLInUMuMPsPflfWGxQBGgMrlwBmh9YCn4xBzkeKD6UuC0PpfdKWV1wkaLmD+HyAG2A5AUvxkizYUOlP7aC2F2/bc/PFvVu43p5XMold9U3C03w03DuUJrXey7Kw0T3NZl3u4iv6ZqTZfDnZvaFS3i3JYR7VLU97EX2nBvo5NoIzJWGbXDapze0H7WBIqmCvF4PbrMMMBLq4UyekOG7IxJNIpbkORvF21XO0tX7H+RBwaoqWLbhY7q1NIjCRtqAWP5S3tUpogXfjQ0xgglGNfbGwMIjj1syjkcsyIJTUmNn38kJp36YRZfEReE77Fe9D89fCsrH3wSyY/VaqHvQ0dcJM2AcAqVbP4Os792gB/Exbu6gPYQufPtZGUHWpSg/dkqOelTJrbf3/tNODuOrBMNdTfUOz0xJFTn9qTpy4CAd7g6X0q4YqeYRQprbHxMDLk/QZyR4xVHzzVtgLJH9wg0nppuKLpR7ON2ohVPSoA1DIdYMeiS1GE/Ui+kjq2FviJTFv//5D2QAAlu4W247u1QGUbeUXLLFHPaG/f+EBNrTWZUngYg/U spnbvTvg Yz98TD3y20W7k9CWVnqMDUXWKSrBuxYh4oSzYTvEixdrhEdMrym4kQ3HZ/jN0E7hOH9hMzDL0BgnGcdPlr4moS+cGkj4aZZ8wPrWRIJ3yo5HLUdvWxswmHpfH97eP/ensuC95dj8DSQhRB0/4vlPmxMHLvBAVz6jWgdfOHpAUVd96lh30ZmDyuPkGRA16/t0avlfLSZe1CCyKP8tSIXKnP49LvYwjIvZbLYaoJPgDABowqhtBEvA5P0E7iomVlT2QpVNLiOXXpmHYpfY= 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 dac_mmap_min_addr belongs to min_addr.c, move it to min_addr.c from /kernel/sysctl.c. In the previous Linux kernel boot process, sysctl_init_bases needs to be executed before init_mmap_min_addr, So, register_sysctl_init should be executed before update_mmap_min_addr in init_mmap_min_addr. And according to the compilation condition in security/Makefile: obj-$(CONFIG_MMU) += min_addr.o if CONFIG_MMU is not defined, min_addr.c would not be included in the compilation process. So, drop the CONFIG_MMU check. Signed-off-by: Kaixiong Yu Reviewed-by: Kees Cook Acked-by: Paul Moore --- v3: - change the title v2: - update the changelog to explain why drop CONFIG_MMU check. --- kernel/sysctl.c | 9 --------- security/min_addr.c | 11 +++++++++++ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 41d4afc978e6..0c0bab3dad7d 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2059,15 +2059,6 @@ static struct ctl_table vm_table[] = { .proc_handler = proc_dointvec_minmax, .extra1 = SYSCTL_ZERO, }, -#ifdef CONFIG_MMU - { - .procname = "mmap_min_addr", - .data = &dac_mmap_min_addr, - .maxlen = sizeof(unsigned long), - .mode = 0644, - .proc_handler = mmap_min_addr_handler, - }, -#endif #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \ (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL)) { diff --git a/security/min_addr.c b/security/min_addr.c index 0ce267c041ab..b2f61649e110 100644 --- a/security/min_addr.c +++ b/security/min_addr.c @@ -44,8 +44,19 @@ int mmap_min_addr_handler(const struct ctl_table *table, int write, return ret; } +static struct ctl_table min_addr_sysctl_table[] = { + { + .procname = "mmap_min_addr", + .data = &dac_mmap_min_addr, + .maxlen = sizeof(unsigned long), + .mode = 0644, + .proc_handler = mmap_min_addr_handler, + }, +}; + static int __init init_mmap_min_addr(void) { + register_sysctl_init("vm", min_addr_sysctl_table); update_mmap_min_addr(); return 0; From patchwork Thu Oct 10 15:22:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yukaixiong X-Patchwork-Id: 13830199 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 28FD9CF11F5 for ; Thu, 10 Oct 2024 14:12:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9B0106B009D; Thu, 10 Oct 2024 10:12:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 938F06B009E; Thu, 10 Oct 2024 10:12:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7D8B66B009F; Thu, 10 Oct 2024 10:12:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 58E986B009D for ; Thu, 10 Oct 2024 10:12:04 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 39942AB863 for ; Thu, 10 Oct 2024 14:11:57 +0000 (UTC) X-FDA: 82657881768.22.91B9A8E Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf23.hostedemail.com (Postfix) with ESMTP id 03D76140012 for ; Thu, 10 Oct 2024 14:12:00 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf23.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.188 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=1728569371; 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=8kQPIq4t81iBD7A+vL+4I0G39xoDgt4bSm/7VHQ/2+E=; b=06ByXv3TZH6uUVZS+Iec9ftA/X/++0rnA2KPC6vcFm0VeqY1yMa4bZ9HfD3de1z9le1lRW r1O1lHSiUJGM2mQ19/kIJlIy3xy91P3CDk6EdJcBtlAnjB67sD6Tzfp3DK661thW2vQJl8 DE5TR0zKEpJYeMx7oCHAiNCjfV/Ov6Q= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728569371; a=rsa-sha256; cv=none; b=GiHWMZ/3lZufarJEhcCiaTDN7Y2+tBwmFIxd6g8ILono6d8HR2uNQrRMYAaOsSbmSdgJlg qES9rr2PE+ZDM6Qv+uLCo6xO0mNtkfFB77TMGPJ2TvnPVcocnJ31yknv9ENQOjmU5SqCqp pcMzAH9A/TezM0Y5P4CrRLPmMgHcQgY= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf23.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com Received: from mail.maildlp.com (unknown [172.19.163.174]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4XPWph1BJGzfdCv; Thu, 10 Oct 2024 22:09:32 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id 6BB25140157; Thu, 10 Oct 2024 22:11:56 +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; Thu, 10 Oct 2024 22:11:53 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v3 -next 08/15] mm: nommu: move sysctl to mm/nommu.c Date: Thu, 10 Oct 2024 23:22:08 +0800 Message-ID: <20241010152215.3025842-9-yukaixiong@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241010152215.3025842-1-yukaixiong@huawei.com> References: <20241010152215.3025842-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-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 03D76140012 X-Stat-Signature: owu8h7cabbg85oco8dun9s1jugwcaz9a X-Rspam-User: X-HE-Tag: 1728569520-92454 X-HE-Meta: U2FsdGVkX1+K/px9Tht+UKyu++HknGPlTIA6d8wILSL4zKEK135iKYfG/95oyRvcs2G/SL9kE2ZGJcEzJ0dXrj++viO5T0pXjHijqs8GdXC5CW954/ppaxD5zi13iw/LNoyEot0uRHPBmtZTKxy3gE7w+yJk4aq8iO4OMrjUYQnxIWBvAOzLb2QEYe62BxuoOy2lAyAwqdf333y2J6aTt3vCpZ5nZkSdujlyYvrMpOL+lvndoTWCM6JnaJDsqF1mznv8z/eAuO4zbA8Xi8HqesMo76BFhbdpOeW0Mi64Oi9izCQnxHdwNYhKFJkLFMMny4KCo3oZx1JY9qELykTNM67zwYE4Pb5OiTC8zAX/7AxUazuTI39dpFlz5I2JWT+DM+Bmvh3VGXFPRk+/IIJ8Mrhy5gugM5LLEIajMwz6i8Y4RyuGZ2/+VgRsaxGctD1U8v5Zu9R2qc9Ce9K4vtAuURHSMyWmMX6GwKbfOsDHsOHUVTJUShcKqguU6/TCc1WOEg4DaEKuyDHQfKexXZberZi/xm7H2S8N/4FxrY7x6sYkqS4boWWLOGYlae4PVB/ayp+PghBiTuXe7XvCDH2Hy3trysPc4+aFyM4iD1MazPhl1FzBnMNku5X74GtMTRm5Eoey6C+yk620vkNb8YxwQZdDNdBuukKdmvg1GOscBLON/bikIOUc0Pn1XMWYiyq/edxQX7Bnt13R6xu6g43uTmD7Knh/OrhpsiZHuQGpVK3mHrAI99Bd1h2vwSc0f3PtF/LrcD3y2VDzrMFW2FML8PyumpsTEkJWsvJbB+Z98pQ0kuAZ7c3fK5VAM1vIi9VyyCu/tbO/s+tQXsO3i4oEFKQ2E7GIMvpgWZlENP/AnYV553CHIggYCJOieDyIp0KoBCoq535RemGbBn6XOmtvWM3yqJtxppoMsPLUVPHukAOWF9jKTVzCubNjSjY2zDqD3NCl/Rebks/w6yTSoQQ 84achFhW HCH/XPQ/DGo6N975YKNDKu7657+Padsi4hnQp7moqkGV4M1SwTSg4PlWzf6rXydekiHRVPxIBXPVf9IWEHUIHBJ5N3BIthNBAgaeO1iF72RokwQAwHwxZOhdRqgJdquEa+ZXt8Z4HiGsiyZKjEEbfJdvcpA== 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_nr_trim_pages belongs to nommu.c, move it to mm/nommu.c from /kernel/sysctl.c. And remove the useless extern variable declaration from include/linux/mm.h Signed-off-by: Kaixiong Yu --- v3: - change the title v2: - fix the build error: expected ';' after top level declarator - fix the build error: call to undeclared function 'register_syscall_init', use 'register_sysctl_init' to replace it. --- include/linux/mm.h | 2 -- kernel/sysctl.c | 10 ---------- mm/nommu.c | 15 ++++++++++++++- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 50f0069280f4..c7f73bf32024 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -4070,8 +4070,6 @@ unsigned long wp_shared_mapping_range(struct address_space *mapping, pgoff_t first_index, pgoff_t nr); #endif -extern int sysctl_nr_trim_pages; - #ifdef CONFIG_PRINTK void mem_dump_obj(void *object); #else diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 0c0bab3dad7d..d3de31ec74bf 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2041,16 +2041,6 @@ static struct ctl_table vm_table[] = { .extra1 = SYSCTL_ONE, .extra2 = SYSCTL_FOUR, }, -#ifndef CONFIG_MMU - { - .procname = "nr_trim_pages", - .data = &sysctl_nr_trim_pages, - .maxlen = sizeof(sysctl_nr_trim_pages), - .mode = 0644, - .proc_handler = proc_dointvec_minmax, - .extra1 = SYSCTL_ZERO, - }, -#endif { .procname = "vfs_cache_pressure", .data = &sysctl_vfs_cache_pressure, diff --git a/mm/nommu.c b/mm/nommu.c index 385b0c15add8..48b2812f492a 100644 --- a/mm/nommu.c +++ b/mm/nommu.c @@ -48,7 +48,6 @@ struct page *mem_map; unsigned long max_mapnr; EXPORT_SYMBOL(max_mapnr); unsigned long highest_memmap_pfn; -int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS; int heap_stack_gap = 0; atomic_long_t mmap_pages_allocated; @@ -392,6 +391,19 @@ SYSCALL_DEFINE1(brk, unsigned long, brk) return mm->brk = brk; } +static int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS; + +static struct ctl_table nommu_table[] = { + { + .procname = "nr_trim_pages", + .data = &sysctl_nr_trim_pages, + .maxlen = sizeof(sysctl_nr_trim_pages), + .mode = 0644, + .proc_handler = proc_dointvec_minmax, + .extra1 = SYSCTL_ZERO, + }, +}; + /* * initialise the percpu counter for VM and region record slabs */ @@ -402,6 +414,7 @@ void __init mmap_init(void) ret = percpu_counter_init(&vm_committed_as, 0, GFP_KERNEL); VM_BUG_ON(ret); vm_region_jar = KMEM_CACHE(vm_region, SLAB_PANIC|SLAB_ACCOUNT); + register_sysctl_init("vm", nommu_table); } /* From patchwork Thu Oct 10 15:22:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yukaixiong X-Patchwork-Id: 13830200 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 24E26CF11F9 for ; Thu, 10 Oct 2024 14:12:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D842C6B00A0; Thu, 10 Oct 2024 10:12:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D2FF96B009F; Thu, 10 Oct 2024 10:12:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BAA686B00A0; Thu, 10 Oct 2024 10:12:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 9F3ED6B009E for ; Thu, 10 Oct 2024 10:12:05 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id D5A0AA0280 for ; Thu, 10 Oct 2024 14:11:58 +0000 (UTC) X-FDA: 82657881810.28.9F409EA Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf29.hostedemail.com (Postfix) with ESMTP id 3FD73120022 for ; Thu, 10 Oct 2024 14:12:00 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=none; spf=pass (imf29.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.191 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=1728569453; 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=tKrT3z68GpyU14ZsW9Udy/3EKw4RLNtJqOq3GBJQh/k=; b=itiOi6sB3VHyhpO2IMJ54qCaXHZa/YlNZfm8YkDXXaEYYScHbxnoVLdsFwuc55GaxXZB9Y L7erKccXRTtJSs2f5JmSl89uhz4CuA9fOiN7m0z+bu/6E3Y/JWaLpqqqCnq/AyQsm6oHaQ hZZNxslh9LGjWAJxwpICqEKQjrWxgEU= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=none; spf=pass (imf29.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.191 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=1728569453; a=rsa-sha256; cv=none; b=eHMXFL/YMz5l31FnClBhS1cyFmiFiHujGeRSTzsC14FUa+UPp8vdb4tTt/xiRXhWVFjtky ssAysFdK8oXw0CFYTjpXL4a0BmdUXgVzoXyquLO/aJoT6mXX407ekTu5bx3qBFDvslYwOK SFf3Um49CT4lrtu4HnW9FKy+bwilA68= Received: from mail.maildlp.com (unknown [172.19.88.163]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4XPWmm4zJFz1HKkx; Thu, 10 Oct 2024 22:07:52 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id 9D41D18001B; Thu, 10 Oct 2024 22:11:59 +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; Thu, 10 Oct 2024 22:11:56 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v3 -next 09/15] fs: fs-writeback: move sysctl to fs/fs-writeback.c Date: Thu, 10 Oct 2024 23:22:09 +0800 Message-ID: <20241010152215.3025842-10-yukaixiong@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241010152215.3025842-1-yukaixiong@huawei.com> References: <20241010152215.3025842-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-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 3FD73120022 X-Stat-Signature: yesncgb5fsdp9fg53a9h4x5pbteimkhk X-HE-Tag: 1728569520-76612 X-HE-Meta: U2FsdGVkX18i7UamNwik0AcY1s8Md9MJC1a8rs6hOFeUiyNVANYpaPqJMb57yLPev9uS/ZJWfKCKvAEslL44oLQtp/mDaFggc83FYcZbGy75fcU6C6QweSmS2y9/zhaxiBkKGJ4hMlSKMeTwR4ax2Us1CZKB93efrjz5Of0QcEjKO/eZfJwZgjmuRRAcihQLbYKGyN2rJiM1qOH+QCJkOvCkN4zGU5Odh5yQ/F/63h7cEzcU1hJOSTAH1MhI2t49sYnL+SFF5pylS6olzXOf5cG89S/hbF24HAS13UD8W9/y1COkNiwrc8f1r4llVPgikn3gcFjOqS2fPqMUlIlC7LIf7K2ZQ4fAxpI2rdSOuRDMxhF58MaeI/zmhEv1g1MlYNMAM6ufqtsuj/OWwKboEvWOuX0ZCRqlHn/suzzzQVA2gyLoMIyM9UusKXvjgFgViZXY/siVGK+EWUcuCn3t6U6fS8+Lt+2a5xmBCQV03fBwnPazhY8D9BPk4hi8mDIL73QHUfQiUkaomgYHIDXcmuFGkDNMff4VoK6Wfy+xtnB9T2o6bXHB4RTKu8912nJI8ewZCX8zER2mF1bXoJg7WyeMuPtsNBmlb0gQzTU3SHLeJfyVxXYhBd7uHH03jmbKjIRxnB5kEP/flbqvL6Tas/9qdM71niexEUdWlFIYxACDOMe5fDcnMtWurl6aH9UyfDo2ZeoRq2AphZS9/vgQZYVfuqhvtImQkoJVSH6ErJB3f39o/t1gnYg/7XbYwIAPIUX7VPFZV8j+2CuPH3T/qmueFp2xbrjNC9HWaL1XpKDsyFPlOCCXIuhR7O3239KRnfjogbEtJPht5PKKfGgAEKxgE7KzF+o+rWzvgycwyLzAs7YGwUQiPlOWKqtodRVSvSm8B0vH92rnHiPuqXnjfAPjeXXVY8P13Ji2vEF6ajHujYNzAQksdiMtYtGJKWCcmtA3B/7hE4O9uM5vKGR kMgpdk9B 5veiT4K1jLW9eQJujsfjTq1eVw0cTX+pHXV+EgRtaxpOnKFGa8A1uGtKC5tdiEP6RwYSUh8e5+N7jsKzsZU7MrTEw/ESRIx6K7qCBFBpEQALptkEadOFb9M7fejUdHbY6nBKc9YEACN9uiqjCnC1rnLQSSj88uKTz9bMP 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 dirtytime_expire_interval belongs to fs/fs-writeback.c, move it to fs/fs-writeback.c from /kernel/sysctl.c. And remove the useless extern variable declaration and the function declaration from include/linux/writeback.h Signed-off-by: Kaixiong Yu Reviewed-by: Kees Cook Reviewed-by: Jan Kara --- v3: - change dirtytime_expire_interval to static type - change the title --- fs/fs-writeback.c | 30 +++++++++++++++++++++--------- include/linux/writeback.h | 4 ---- kernel/sysctl.c | 8 -------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index d8bec3c1bb1f..4fedefdb8e15 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c @@ -65,7 +65,7 @@ struct wb_writeback_work { * timestamps written to disk after 12 hours, but in the worst case a * few inodes might not their timestamps updated for 24 hours. */ -unsigned int dirtytime_expire_interval = 12 * 60 * 60; +static unsigned int dirtytime_expire_interval = 12 * 60 * 60; static inline struct inode *wb_inode(struct list_head *head) { @@ -2413,14 +2413,7 @@ static void wakeup_dirtytime_writeback(struct work_struct *w) schedule_delayed_work(&dirtytime_work, dirtytime_expire_interval * HZ); } -static int __init start_dirtytime_writeback(void) -{ - schedule_delayed_work(&dirtytime_work, dirtytime_expire_interval * HZ); - return 0; -} -__initcall(start_dirtytime_writeback); - -int dirtytime_interval_handler(const struct ctl_table *table, int write, +static int dirtytime_interval_handler(const struct ctl_table *table, int write, void *buffer, size_t *lenp, loff_t *ppos) { int ret; @@ -2431,6 +2424,25 @@ int dirtytime_interval_handler(const struct ctl_table *table, int write, return ret; } +static struct ctl_table vm_fs_writeback_table[] = { + { + .procname = "dirtytime_expire_seconds", + .data = &dirtytime_expire_interval, + .maxlen = sizeof(dirtytime_expire_interval), + .mode = 0644, + .proc_handler = dirtytime_interval_handler, + .extra1 = SYSCTL_ZERO, + }, +}; + +static int __init start_dirtytime_writeback(void) +{ + schedule_delayed_work(&dirtytime_work, dirtytime_expire_interval * HZ); + register_sysctl_init("vm", vm_fs_writeback_table); + return 0; +} +__initcall(start_dirtytime_writeback); + /** * __mark_inode_dirty - internal function to mark an inode dirty * diff --git a/include/linux/writeback.h b/include/linux/writeback.h index d6db822e4bb3..5f35b24aff7b 100644 --- a/include/linux/writeback.h +++ b/include/linux/writeback.h @@ -351,12 +351,8 @@ extern struct wb_domain global_wb_domain; /* These are exported to sysctl. */ extern unsigned int dirty_writeback_interval; extern unsigned int dirty_expire_interval; -extern unsigned int dirtytime_expire_interval; extern int laptop_mode; -int dirtytime_interval_handler(const struct ctl_table *table, int write, - void *buffer, size_t *lenp, loff_t *ppos); - void global_dirty_limits(unsigned long *pbackground, unsigned long *pdirty); unsigned long wb_calc_thresh(struct bdi_writeback *wb, unsigned long thresh); unsigned long cgwb_calc_thresh(struct bdi_writeback *wb); diff --git a/kernel/sysctl.c b/kernel/sysctl.c index d3de31ec74bf..373e018b950c 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2024,14 +2024,6 @@ static struct ctl_table kern_table[] = { }; static struct ctl_table vm_table[] = { - { - .procname = "dirtytime_expire_seconds", - .data = &dirtytime_expire_interval, - .maxlen = sizeof(dirtytime_expire_interval), - .mode = 0644, - .proc_handler = dirtytime_interval_handler, - .extra1 = SYSCTL_ZERO, - }, { .procname = "drop_caches", .data = &sysctl_drop_caches, From patchwork Thu Oct 10 15:22:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yukaixiong X-Patchwork-Id: 13830201 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 2E205CF11F8 for ; Thu, 10 Oct 2024 14:12:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AE82B6B009E; Thu, 10 Oct 2024 10:12:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A72696B009F; Thu, 10 Oct 2024 10:12:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8EA786B00A1; Thu, 10 Oct 2024 10:12:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 6D58E6B009E for ; Thu, 10 Oct 2024 10:12:09 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id CC22B120140 for ; Thu, 10 Oct 2024 14:12:05 +0000 (UTC) X-FDA: 82657881936.11.88A4F97 Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) by imf10.hostedemail.com (Postfix) with ESMTP id BE72AC001C for ; Thu, 10 Oct 2024 14:12:05 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=none; spf=pass (imf10.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=1728569483; 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=lCQrL2I1/DxYS61YKTMcXplK++j12MCPMTYeBUKqYUE=; b=S2AZ43xtCi7qFDaleeJ8CxPGRdhtRxfSd17qaC64/7hICK2GBIcaOqA+kwACfpgWW8ucZV iO2F/veomL/7SonTNil1+j5BLtSbW33lJKrh7DScbAw2jpEwf8s3KUG1ZypNHyTGT/nVWE d3UGgO5HFb7V1IZugsZ6kbP9rnpjvvI= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=none; spf=pass (imf10.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=1728569483; a=rsa-sha256; cv=none; b=ifjDOY9qvcuihLG5kdNZqZIt7jL8+A3aKkenpSCk1lVS7qirOOt6YI4qghnLxU/XM68CW4 mLdP7zuJDvAThtJ0wk3Bu5laet65RQdAup6xNOeOFbvonDwmojHe1+p5tt6v69t+uoxAi2 vfjLBGMEepxcxQk3YT/nhpH+RBN4UyM= Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4XPWrH3jK8z1SCPP; Thu, 10 Oct 2024 22:10:55 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id C68131400DC; Thu, 10 Oct 2024 22:12:02 +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; Thu, 10 Oct 2024 22:11:59 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v3 -next 10/15] fs: drop_caches: move sysctl to fs/drop_caches.c Date: Thu, 10 Oct 2024 23:22:10 +0800 Message-ID: <20241010152215.3025842-11-yukaixiong@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241010152215.3025842-1-yukaixiong@huawei.com> References: <20241010152215.3025842-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-Rspam-User: X-Stat-Signature: b4xfejno3dy6dg9rnrdf1bp5ht46d3np X-Rspamd-Queue-Id: BE72AC001C X-Rspamd-Server: rspam11 X-HE-Tag: 1728569525-558072 X-HE-Meta: U2FsdGVkX1/ZbbMMARe/4Z8i725mGEXZV3Xom2kzd/ANAoAaYJTedWT7pcGHyO/tSeHEbEUqVeBmbEAU1XMidLvxbrzUu+22w2qxVeYhMdd5HdsAVUqr9CB16hOfolQWUwBE4vGz2SjiYr2Cez6EFpUNG4pqDBauAnwpKFnM8RlVd56wOrKXHF5Hjjwn6guQxBTPpyuSVk9t6RRXtLYRmpmrtXC31DQcp5I+sAgzBZfaQR/FvitDL6kKzQzjeNi7Pi9ylvrfrkj74YvAxV0yXqWKNuHhJQ7XzPR8gPTAniWxpFQ4+AabXARht8tJAe6FlJIU9valnf0CKmaACRAYPi7Lm76q4lPFtilS7j36OVJjNRYrXC4dgfuXopRG2iRN/VXXWRkfXftrIludZIerfyKtrROYgaDZfc8hvyqN6I99CaGfW/tz9QvxoDgGuZmg3TC7s+d9+4EfhctPjgJwlcxJLFI8kRxa/gjhail/Jsd4xhFnAr01zn/X47aJsqo47zGSkFFPiJr9lW8aItFrJs6xdnZQKbn0Bhnv4SZ8uVZUjGXCZMUv8440rfU6sY8M0P0NJLdRBZWPCGJd220ylI1aUX1ibVZPofgc3IEZJxclEfl2DnMi1gFEOvS4DvStdHTqxLDXGXVkgDE4jb7RmAX0IqjcNOnOzUGeHE0kr4HFDZZMxD8FyZbG+WnrfDsqqkpjo5vujmFs9M6y8PJoKHAg3MtBgrVBDU3p24tH9VPacHup3WelwOrKMUSuAJ2rIjXHZJbViBNMUcd3En1ZbLrRlnbUBcuz2QTudblk5TLoj1A4xAjqYb04G1p/0c9Ldfjkc/MQIKQqb4+yTsoBL59KdDGdZX++VYOGiHq+CDmcNyFkue9H909wNsj+JN6XdNrhm37C+mU9J8NSp4VZCu2CGEGTtdVrDIZknBXmwlXDNjbJ8HK1uVfyO+UspdxmBOcXdG3CSnIHHRwSKlZ 4x2n8oX9 w1Smc4BwOn0bfN/86sZKqJZ8S1/7ccLsqzD0dyPy82ZR/JYrFnIODHyWvTKsJh09TfBhUdkf8fFHHQXaXRPC07p2MDd5/izYhYe6VIw0N6VTxDdCWSkaEW56ByFUsKwNgxevsrO5M7wXeDihc48/FBr8dQUo3u7Tw8OkYkHR3R1FcNFWmTX7dtc0L8XMNUy4UFBMPB1pEH+jqWijleUnnaoWuOg== 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 --- 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..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 c7f73bf32024..ed2e7425c838 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3791,12 +3791,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, From patchwork Thu Oct 10 15:22:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yukaixiong X-Patchwork-Id: 13830202 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 2046BCF11F9 for ; Thu, 10 Oct 2024 14:12:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A03376B00A1; Thu, 10 Oct 2024 10:12:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 960B86B00A2; Thu, 10 Oct 2024 10:12:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 78CD16B00A3; Thu, 10 Oct 2024 10:12:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 56B0D6B00A1 for ; Thu, 10 Oct 2024 10:12:12 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id DA5361C41A0 for ; Thu, 10 Oct 2024 14:12:07 +0000 (UTC) X-FDA: 82657882062.18.DBF7A60 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf18.hostedemail.com (Postfix) with ESMTP id B76531C0014 for ; Thu, 10 Oct 2024 14:12:08 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=none; spf=pass (imf18.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.188 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=1728569459; a=rsa-sha256; cv=none; b=bkgVbghyeAoRH6CfWcahgO8mIKQKWI7El0h2JxXbi+RgiPSu7rgcQ5hVWi2d0an6wczEjK 0wViVectNnLEupDaXp7LBCjnHOTz8bApsoy6nQrIAPvI3qZl395bK5WLLTffqqV9nhZjTl 3hqFLksRIxyIdOBRJFmQHzvu78OiYQE= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=none; spf=pass (imf18.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.188 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=1728569459; 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=qcFabJnSAPGDVVxpb7DwCXKyqXrGxesN6Jv4YQDways=; b=ZwpjhhZqv4oF6V5k6s/R7T9MydqoKzqFF/fnzeuhWxGizc96ET4PauMwAnT1Y0lEyO+0iT 8wQgBZ13/HDH0/obOcoIIA2gkNAZLX6rSERsmn31+mnbBnlb4/G+3sDSm5WPo2jHw4K2Df EusJ+CK+GMtxJVKSz/tU/nojh5t3lf0= Received: from mail.maildlp.com (unknown [172.19.163.174]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4XPWps55PlzfcvP; Thu, 10 Oct 2024 22:09:41 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id F30D8140157; Thu, 10 Oct 2024 22:12:05 +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; Thu, 10 Oct 2024 22:12:02 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v3 -next 11/15] sunrpc: use vfs_pressure_ratio() helper Date: Thu, 10 Oct 2024 23:22:11 +0800 Message-ID: <20241010152215.3025842-12-yukaixiong@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241010152215.3025842-1-yukaixiong@huawei.com> References: <20241010152215.3025842-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: tx3wt6wcyew9iyb4ruzx3mo1up9ob613 X-Rspamd-Queue-Id: B76531C0014 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1728569528-393664 X-HE-Meta: U2FsdGVkX1+GeFKFYCb37yHziUGctnf4/uSvpLzY++UA8b/La1yAoMLdhrzEXYTLJieWHW5VAqUTfbik2ZKggm/bqplGSkHgkTT5yG/sJRl50CONQnnnmzq79Ewlpi6byiETLA9BW6cU9hds2N5L6v2k/GJ607EI9OIwsdIUPMR/Ueeaj5JcdmjA6NuUqu/kbMQujHWwK+FIW/gNt/EVbVlgrEkfeNGXISP5JEpQJh8LHEREeKXbj1hZAD1pbxtPfwzRyvacZe+mOd6aEWZyxXOvDL30FQBOALTBlnxqF2RFH4g81Pu0K4G6w1pvwIVRoCVGdX7cM7rmQ15w4mGL3ofa0rMe/27f9B+y2CFQocrfZGz7bH6MMi1wZmZoGpXmW6jE8w7YBTi4mnwj7LjWtZalSCApc0tM68CwiY5Zpv/ImsFTppu3UBQxI29J1lxONXTBDwBRqwAABx5TH25j9FpG2aN/zHhlE6NG7OrZuvvOoZKLUPWCWLo55/O48oPccPTyFNnsbiF7lGCn7rpRgRKhABjDXX+/0x9KK6Rd4g5wxUbxsv/ShGF/FtWDycBGCA8Wt6l2Z1k2y5R1UzspDSk2Zecobqh9ZxS2dk074HeYr7b4HZcSjzM+to5Z1dHeM/Xrnp9CAWRZce3p32GO3ipPzkHKvl2FHqoKMQchQNqwVD6uBfAvReR+wK9v8ctH+WVQnpl1Zrp73iVqvy/VnHAdwv2K2QWgLBStvn/3lXJfYQAU1fFlfpIDvrn9IoCCA8TCOUeHkYx03/YE9AQBbC8Ts0oyk+WT5IaQpHeFUcIRyuxm9757uAC6O2gvflZa4uHBFCwP4BDvxFJ6g+UJyyAjAcTaiwJB4tNxqqaGLaQSPeftBbSerbsAZigwCE4LgO09mLwJfYJoou9OgDPjvt/Pj7zXFCX8ZVRn/rn4fOSZqojNxdEctlSJo/XgRkxvnpJexoXclRBSzM6ILpQ Icc4zh1V 4WAUtWxjGZBjBO5EV8KJpDsRsCl677JvDGjhOYMfLqwL1aI1APYeKcGcGtFpI/PcgGBj5iVx03ebdUO/QHx1xn7bIVclMjSuUx9ngRMwCtq6Hov1tvC6r2K1FzVONyiXHgjVmAnuls8EQR2Lsfl9pNZK0t1hZmb8+TDNuTv5xKnwMPkOsQepgpBVzfzfe8/zeP1NPWvRquxsrzXYA9v6pHW4mhEetafbQU8S1+RA5AwM80eQ= 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: Use vfs_pressure_ratio() to simplify code. Signed-off-by: Kaixiong Yu Reviewed-by: Kees Cook Acked-by: Anna Schumaker Acked-by: Jeff Layton --- net/sunrpc/auth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/sunrpc/auth.c b/net/sunrpc/auth.c index 04534ea537c8..3d2b51d7e934 100644 --- a/net/sunrpc/auth.c +++ b/net/sunrpc/auth.c @@ -489,7 +489,7 @@ static unsigned long rpcauth_cache_shrink_count(struct shrinker *shrink, struct shrink_control *sc) { - return number_cred_unused * sysctl_vfs_cache_pressure / 100; + return vfs_pressure_ratio(number_cred_unused); } static void From patchwork Thu Oct 10 15:22:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: yukaixiong X-Patchwork-Id: 13830203 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 12474CF11F8 for ; Thu, 10 Oct 2024 14:12:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 918086B00A4; Thu, 10 Oct 2024 10:12:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 89CF06B00A5; Thu, 10 Oct 2024 10:12:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6A13F6B00A6; Thu, 10 Oct 2024 10:12:15 -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 451EB6B00A4 for ; Thu, 10 Oct 2024 10:12:15 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 830271604AF for ; Thu, 10 Oct 2024 14:12:11 +0000 (UTC) X-FDA: 82657882188.02.1285C79 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf23.hostedemail.com (Postfix) with ESMTP id C503A140006 for ; Thu, 10 Oct 2024 14:12:11 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf23.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.188 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=1728569381; 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=m+aqCBGqG1LLcsWoa/sFnsKwtSGT9ES7SdGk4tfUnsk=; b=F5/WmJQy5JC2P4HVEBJz88SZRzN61R4TYSL2QARbBLXbo31x9i7+bExGQOjhp9YxXxmnIZ M4ydVcUaaX/N0/JzQh5F+jm2hZneN6WyMeUUMCN8XKK9b2OJZ7cqaR/ILZkKB1GlQcfH5p dSR8Mt51GKQWi/l6joOmP+I7E3lUDh0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728569381; a=rsa-sha256; cv=none; b=dB16iGH7SJEzEyi8z8WHhqZ719lBRrp4EWUIDnncpXUhnmQtquE11Dg8PhnNsUPvRJA1uk RWBTSmsdzv7491KQ7mm+UqY70M0G5sgF28Jg2gQuJqmcX4wh2/0ACZ50mZaCEdS3BEkQOB 4p3qvqkcJu+jgZRQjA+HuPagqc99Hbg= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf23.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com Received: from mail.maildlp.com (unknown [172.19.88.105]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4XPWqP4l4qzpWhQ; Thu, 10 Oct 2024 22:10:09 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id 342941402CA; Thu, 10 Oct 2024 22:12:09 +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; Thu, 10 Oct 2024 22:12:05 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v3 -next 12/15] fs: dcache: move the sysctl to fs/dcache.c Date: Thu, 10 Oct 2024 23:22:12 +0800 Message-ID: <20241010152215.3025842-13-yukaixiong@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241010152215.3025842-1-yukaixiong@huawei.com> References: <20241010152215.3025842-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-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: C503A140006 X-Stat-Signature: dsai1q6gyh36c7kfomh9k1gkhxp7myqf X-Rspam-User: X-HE-Tag: 1728569531-415642 X-HE-Meta: U2FsdGVkX1+rAGhTsP4Kr5Fas7gvMXo7xQgK9pgrwBdehgHGrpUm2OZ4pVJaRpJ5ADphz/Sf85QmSR216qHPhuSsKi2rhnLddWgki8s02eY/pP6daY1vPzpewA5rSIxIdNwcfMGqjHV8ojapyZtUobqTja7EwJKcc0s/S3LO169g7BFmUD8LtVRIORNt2aj3REZyAt5OwobR3MUdKbZ3dK2kJSwWV1DcOFc2Oc5hTfNIP0AZucOzaT/yiEesmmDQmmYo+UM9iG73PFUrJw/8DMusygu3wO/0LFpjaKH/cIimyR5Q6WgC6IgriONaqTYjzSbe2UnrMbs/VM0mejbhWzZ8CmLimv24MCLAmjgLh3V4yk0qqzPTcW+CAq8Wzr4pdBGzjUSL2wYpAeF19Ui1DgHoAzg2FQINDk55d7nEy0seEhLBmhDa1UpfgDPNT+csqvgICo/+1/k7AcLKlCfjzTAl9FxTyK1EhH/0kDey8YEUUBsk9yxikFyZq+ciZPFWGWOv22EctVqb5a+f27zXwXwYP7FTm7TapxSAGWB7iZBf2gRrAF9y41EUpjSV+bL0kesaoTgWlWe3mfJqqmJGbCXeQEfXLfc0AuezPzFTJvtsVrR+LZS3nzsIVjoiVATwRTMR2s4bNMbdLpMoiUNTrRik88Y4QjbOBYaZu69BrsamlOOxxJsnK56GvEHFDPYiOYOIi0c21s4nqCwtbp4uvco2SmIkdyez+ZHPSz7s6XKubNrMrp6KCL2n9EiiNjb6q/6WWdRB+jE1vT2FdEF4J2vOR2nEqYX6Ta9/v49PS2njvZuqbvLjTw3VT93ikN4eDaZluMp+jgsLgXr0nzbLPMtHrEaTi8K4CQfm7TQ/c3oiKDqjhiQKieOqJinjzEwae6hWssP+9JmyLfKBiSdIrwhKnrY7TRidNx3Qh5B3GK7loo0m/XMI3ZwodiPHKC2cSoyFtkRJVF0UtwFWRnx RTvWJ1YE SXUy34ruHbGys1U6tVtQuNss8A/jTM9t+qwuNMOq/DjnkuxBHt1DyzAK5sFpxmpWiJ6h5ahxxETWSRDltVgFD+xfGpjyW9L5DXdz4uFcMN7Rh4xNX3vnYgQsoYI/bf2XLy0TCbcDkIk/Ieci1UFQvL/TNlnWS+7NWx/BgNZFzIg0WubOCYRFSd4m78+KM4KawsBNdfK2RFqunexI= 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_vfs_cache_pressure belongs to fs/dcache.c, move it to fs/dcache.c from kernel/sysctl.c. As a part of fs/dcache.c cleaning, sysctl_vfs_cache_pressure is changed to a static variable, and change the inline-type function vfs_pressure_ratio() to out-of-inline type, export vfs_pressure_ratio() with EXPORT_SYMBOL_GPL to be used by other files. Move the unneeded include(linux/dcache.h). Signed-off-by: Kaixiong Yu Reviewed-by: Kees Cook Reviewed-by: Jan Kara Reviewed-by: Christian Brauner --- v3; - change the title v2: - update the changelog to call out changing the inline-type function vfs_pressure_ratio() to out-of-inline type --- fs/dcache.c | 21 +++++++++++++++++++-- include/linux/dcache.h | 7 +------ kernel/sysctl.c | 9 --------- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/fs/dcache.c b/fs/dcache.c index b4d5e9e1e43d..de240b7f6c47 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -73,8 +73,13 @@ * If no ancestor relationship: * arbitrary, since it's serialized on rename_lock */ -int sysctl_vfs_cache_pressure __read_mostly = 100; -EXPORT_SYMBOL_GPL(sysctl_vfs_cache_pressure); +static int sysctl_vfs_cache_pressure __read_mostly = 100; + +unsigned long vfs_pressure_ratio(unsigned long val) +{ + return mult_frac(val, sysctl_vfs_cache_pressure, 100); +} +EXPORT_SYMBOL_GPL(vfs_pressure_ratio); __cacheline_aligned_in_smp DEFINE_SEQLOCK(rename_lock); @@ -211,8 +216,20 @@ static struct ctl_table fs_dcache_sysctls[] = { }, }; +static struct ctl_table vm_dcache_sysctls[] = { + { + .procname = "vfs_cache_pressure", + .data = &sysctl_vfs_cache_pressure, + .maxlen = sizeof(sysctl_vfs_cache_pressure), + .mode = 0644, + .proc_handler = proc_dointvec_minmax, + .extra1 = SYSCTL_ZERO, + }, +}; + static int __init init_fs_dcache_sysctls(void) { + register_sysctl_init("vm", vm_dcache_sysctls); register_sysctl_init("fs", fs_dcache_sysctls); return 0; } diff --git a/include/linux/dcache.h b/include/linux/dcache.h index bff956f7b2b9..c81c2e9e13df 100644 --- a/include/linux/dcache.h +++ b/include/linux/dcache.h @@ -508,12 +508,7 @@ static inline int simple_positive(const struct dentry *dentry) return d_really_is_positive(dentry) && !d_unhashed(dentry); } -extern int sysctl_vfs_cache_pressure; - -static inline unsigned long vfs_pressure_ratio(unsigned long val) -{ - return mult_frac(val, sysctl_vfs_cache_pressure, 100); -} +unsigned long vfs_pressure_ratio(unsigned long val); /** * d_inode - Get the actual inode of this dentry diff --git a/kernel/sysctl.c b/kernel/sysctl.c index d638a1bac9af..6f03fc749794 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -46,7 +46,6 @@ #include #include #include -#include #include #include #include @@ -2024,14 +2023,6 @@ static struct ctl_table kern_table[] = { }; static struct ctl_table vm_table[] = { - { - .procname = "vfs_cache_pressure", - .data = &sysctl_vfs_cache_pressure, - .maxlen = sizeof(sysctl_vfs_cache_pressure), - .mode = 0644, - .proc_handler = proc_dointvec_minmax, - .extra1 = SYSCTL_ZERO, - }, #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \ (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL)) { From patchwork Thu Oct 10 15:22:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yukaixiong X-Patchwork-Id: 13830204 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 14AD0CF11F5 for ; Thu, 10 Oct 2024 14:12:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6F1546B00A7; Thu, 10 Oct 2024 10:12:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 69FCF6B00A8; Thu, 10 Oct 2024 10:12:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 51A566B00A9; Thu, 10 Oct 2024 10:12:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 32FE96B00A7 for ; Thu, 10 Oct 2024 10:12:18 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 784B440446 for ; Thu, 10 Oct 2024 14:12:15 +0000 (UTC) X-FDA: 82657882314.20.C166A19 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf18.hostedemail.com (Postfix) with ESMTP id 267CB1C0023 for ; Thu, 10 Oct 2024 14:12:14 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf18.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728569492; a=rsa-sha256; cv=none; b=e8+myxhcF25RLOHnKwHSnSNMWsMyB3a8UYt2pX3utA1uds/RjPnyo83491qiZVAA+4+xPM YEbPx45/KbT0NYUmGZGLGrMAQZyGMX8O++XO7VKozA+FCwiNeHdpNERBEsVwzW5fAPdRmC LxMNaUdfKz0MDoZ4FAXeiZpHPDojh58= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf18.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.191 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=1728569492; 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=u8JaX8yZxafhl1NuaoUCGwH4mMy31GRUFlzJBy/6WaI=; b=6GexzKydfgxPDnmfbpp+OM5atFu43Ll2B/entuUg18Zr8XvgRpl7aHSEDNmUIVQolpMZFA nzgsx+8ANvRKlDoPjifJExLvkqp6x4KOjbq342IqMSc6g9ZtI4HED0BveoZvn9aiazP3lJ 0rDlipuQjPhKQWXnTdi1JJc8XGBSLsQ= Received: from mail.maildlp.com (unknown [172.19.88.163]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4XPWn13NLdz1HKky; Thu, 10 Oct 2024 22:08:05 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id 688EA18001B; Thu, 10 Oct 2024 22:12:12 +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; Thu, 10 Oct 2024 22:12:09 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v3 -next 13/15] x86: vdso: move the sysctl to arch/x86/entry/vdso/vdso32-setup.c Date: Thu, 10 Oct 2024 23:22:13 +0800 Message-ID: <20241010152215.3025842-14-yukaixiong@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241010152215.3025842-1-yukaixiong@huawei.com> References: <20241010152215.3025842-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-Rspam-User: X-Rspamd-Queue-Id: 267CB1C0023 X-Rspamd-Server: rspam01 X-Stat-Signature: sr1pucfx5ze8k5j8b1xapdu4knhso3au X-HE-Tag: 1728569534-61823 X-HE-Meta: U2FsdGVkX1/Ecx1OAeGtdOvPBl2nagzBiDFqR7I8zUwb1UQCDBDS8pGqkQsGeGSp0q0Jt7iO5q7cp4nXesC7OTtss4KLK+YfAtEGMf5M+XTCbKs01VgPfuTclUYkZmnR9PBnmbgkVDYFb2wr7q62LAOuwjHCX5Mi4LWsoppsi9ybdfs2u9TWCaivk1axrsGa9xpS+UygX+VLAr/t/Spb7JEkaqeE7tlHLMpe/gkYi9CR/qoNt7IfVQIljRikaFI+/E/rqEbZ/wHrhjTRW6GPJsxhWLZWsraw98Nb9tHVlaBsdpqCNGRSjTADqxCMtxVO95NxSMxBVv5cEI7PpJdkX6WAxXmxUgN6tCYOqAWKX4jmOkQWCqLCBQ0r7p7xs2V16CmitvAzzULHUBy/+xEvpwuVpmQ+yq7g0DbQYm+ockN+dh7w07xvPU2t9aJ0O1mQJKMrWySv6IHAj+Cz4TuaRfWjGz1I8AGl5cBYvWP2chuPRcko/Q90sWcMWDCRGWRKAAqSePWoYJYfnw4DJIn2Qy3Rv4VOVfbbEGNgiCOQMiT0J8DZHCQ58gQt78JPCNh+MIMkTgrRYOm9URtmHsOaIlb/UYGNLwCV5kmzJZILescG8zGAYyRcbwOAHey50F5bZo6oFHnTzkpN7i3GKNAeRcybdOBFGDEKHle3WkZSYBto6weyyfp1+rCTaiHWZPLoWRmsU5dmF3AsXEvsPsrfYigqMKguLd0cQ0H7H/oX6cSKxkO4pE2WOY7R2QaeKRIfmTYbV+cOnNuRSn4U+Fgl4nH3LML/fh07dVRCtnOYJErBJALQ/N2bzDIPfYMgOyxnfKgDUyF2VvI5+ku3LGog4a1nBo3gk9xTlc7t7tSlo0P2w7qQTa6OrVveIWJAI4TEcB50bvSLHQ2DPDTAHGm3zx3hGzn5R3i0ZfAT3WrsrPXOmTkv0DO+Fn58jTgteppQBKDq7vMpTB8/FQQiVFc k8yKIinD I68Pn4zZ4y/i0tCEvdJ2HTmAVEslWrpUczz/3ePg32YtkWyVtNt+7GX7Z62Wd1IBg8+9mOXhE/U+UTGdcJl0GfkwohxowAq6rvbV4UFiAxhHddTn8pR3Fl2JESthFOvHBwxhaHfcR8aRgN/RN2w5fdtaohJRbHIRkitqi 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: When CONFIG_X86_32 is defined and CONFIG_UML is not defined, vdso_enabled belongs to arch/x86/entry/vdso/vdso32-setup.c. So, move it into its own file. Before this patch, vdso_enabled was allowed to be set to a value exceeding 1 on x86_32 architecture. After this patch is applied, vdso_enabled is not permitted to set the value more than 1. It does not matter, because according to the function load_vdso32(), only vdso_enabled is set to 1, VDSO would be enabled. Other values all mean "disabled". The same limitation could be seen in the function vdso32_setup(). Signed-off-by: Kaixiong Yu Reviewed-by: Kees Cook --- arch/x86/entry/vdso/vdso32-setup.c | 16 +++++++++++----- kernel/sysctl.c | 8 +------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/arch/x86/entry/vdso/vdso32-setup.c b/arch/x86/entry/vdso/vdso32-setup.c index 76e4e74f35b5..5a6886a006ab 100644 --- a/arch/x86/entry/vdso/vdso32-setup.c +++ b/arch/x86/entry/vdso/vdso32-setup.c @@ -51,15 +51,17 @@ __setup("vdso32=", vdso32_setup); __setup_param("vdso=", vdso_setup, vdso32_setup, 0); #endif -#ifdef CONFIG_X86_64 #ifdef CONFIG_SYSCTL -/* Register vsyscall32 into the ABI table */ #include -static struct ctl_table abi_table2[] = { +static struct ctl_table vdso_table[] = { { +#ifdef CONFIG_X86_64 .procname = "vsyscall32", +#elif (defined(CONFIG_X86_32) && !defined(CONFIG_UML)) + .procname = "vdso_enabled", +#endif .data = &vdso32_enabled, .maxlen = sizeof(int), .mode = 0644, @@ -71,10 +73,14 @@ static struct ctl_table abi_table2[] = { static __init int ia32_binfmt_init(void) { - register_sysctl("abi", abi_table2); +#ifdef CONFIG_X86_64 + /* Register vsyscall32 into the ABI table */ + register_sysctl("abi", vdso_table); +#elif (defined(CONFIG_X86_32) && !defined(CONFIG_UML)) + register_sysctl_init("vm", vdso_table); +#endif return 0; } __initcall(ia32_binfmt_init); #endif /* CONFIG_SYSCTL */ -#endif /* CONFIG_X86_64 */ diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 6f03fc749794..24617be93119 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2023,17 +2023,11 @@ static struct ctl_table kern_table[] = { }; static struct ctl_table vm_table[] = { -#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \ - (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL)) +#if defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL) { .procname = "vdso_enabled", -#ifdef CONFIG_X86_32 - .data = &vdso32_enabled, - .maxlen = sizeof(vdso32_enabled), -#else .data = &vdso_enabled, .maxlen = sizeof(vdso_enabled), -#endif .mode = 0644, .proc_handler = proc_dointvec, .extra1 = SYSCTL_ZERO, From patchwork Thu Oct 10 15:22:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yukaixiong X-Patchwork-Id: 13830205 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 92C75CF11F8 for ; Thu, 10 Oct 2024 14:12:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2367E6B00A8; Thu, 10 Oct 2024 10:12:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1BFFF6B00A9; Thu, 10 Oct 2024 10:12:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 03A356B00AA; Thu, 10 Oct 2024 10:12:21 -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 D9C1F6B00A8 for ; Thu, 10 Oct 2024 10:12:21 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 262381602F2 for ; Thu, 10 Oct 2024 14:12:18 +0000 (UTC) X-FDA: 82657882482.06.ED88FEC Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf17.hostedemail.com (Postfix) with ESMTP id ED22D40005 for ; Thu, 10 Oct 2024 14:12:17 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=none; spf=pass (imf17.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.255 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=1728569402; 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=Tc5FnBsSafy4CY1NgyRn7ck2eWhFzRsh6zdvbwaDRUk=; b=JvK4AOcqE7ZLzwlICFK40qysQe09Aoax/ARklxtLv2XLjGQVFFxfyucoluBYfgK1X/HgSj XKYuDIZcm6dW+x1xM7ljH5LZac2OVhrw6aKN+xDooMTe6KLNT8ThsjXw7JPWdM7VPnIVja r4JhHphpew7cYbxmEtmIZoRmXnpdEFU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728569402; a=rsa-sha256; cv=none; b=q3Kj26OnxAGv1u7KJnyJp7Or/hGsemp52d2PAngWIdLeIlKYom9xjwGwlmceTTN7VgNIOK QRMeX36hzE6ieLazNyojUVpU5dKhSoIhMpEoU4iL9CxTAq6pe7P2snF/gLXsPPydUKZ8UN GuKrCQ0jS1jSU/wjPnXigUZPCFewS8Q= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=none; spf=pass (imf17.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.194]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4XPWqp5qzmz1T8PS; Thu, 10 Oct 2024 22:10:30 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id 95E1A1401E9; Thu, 10 Oct 2024 22:12:15 +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; Thu, 10 Oct 2024 22:12:12 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v3 -next 14/15] sh: vdso: move the sysctl to arch/sh/kernel/vsyscall/vsyscall.c Date: Thu, 10 Oct 2024 23:22:14 +0800 Message-ID: <20241010152215.3025842-15-yukaixiong@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241010152215.3025842-1-yukaixiong@huawei.com> References: <20241010152215.3025842-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: 3bjxnbxkuciaof4iey35axndms8qkogf X-Rspamd-Queue-Id: ED22D40005 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1728569537-483374 X-HE-Meta: U2FsdGVkX19Vhn7EewABA5Sd1ay0JaY33EVkdlb2yAcsXz3p/JED0Bf679f4rFL1o55BIB53s2PDRSWLVqS40nZ2iIzeGeI63owLppjKzhgM/j21TsmWSz/pGaXYS1ERbKTNgYM1VlTllBNjwEykVASuFpOUQXa+IRnGNPsP4gPANxZFQxnj0ubvKEUiL8BKEng+BDY+3gW0DvY/gTYxf/vkPMdNYaVHH2aDSZWRpswryAV9ye4z6iPb24++t3A6a71d64NYpyfMGW/L/B5jFOUdk8etfaHvUP1kYYwRIfg6sm1/TaJzHJlRyTJ1gRPHhItOJoEzWylZs1d7cnpiiVsJcFMbOOkY2cHYy/zlGzKtYRpz5mmD6akX/FankcoeK4QNuHrm/UMfiz8kmEUG3QEJBkplHjfx4Z/Qtid58BtzItNt2p4eczHXQL/QVo3TcyoXgMFZW4VoUpVxKyjX08TsgOUPq19MEcMJJGmb9d9eDV11w0vQrdlHvQnXp5idpF1MKmbJ28ACgYW5zEM0mB6f+VpqjBcLmJjKyeVJnfZdMe6szv93bnab6pEdjVkwPITdABSLgwpe6jzsMYykUlzhkij+K4/LnFjPSYR+UETptQ/jEu21SHH9Ipwg2yVFvYLe+v/lvXNz4Hi3AieRmJZsjyDNLcBcIWbLVjcyDfy1JfgfIPYYRbTs+Bil+CleIVnA5sNHyoV60FhEN92/gsdFjiHCL7ICAxPFNGZEdmhD08gkXkkhGklGwy6pvLz9KUUDwKk6t3mnK+O3yMsVdUNgwc8QCZ/6VoHfo/zN1JloPFyDLJJ6RKiWgFx9i8yIeFkS2mAKyuAM9fNTn5d5jv/8+CS395GDG7fSc6OEz6c2Fe1Olw0w6EHOZXN4bnJvhpIUZS/FogdMobvLPtD3FGEjMaF+2Gf82/ANSlPPqiOp/5CBqjD5BFUhd2CoKv3hPsZSivtYHU6PGfCYbot nHo9vNe5 KtkdEFzez+Irq9wYc0Ak+tYep9toT80hXoMsM72P6otuq3m6Dfdx8U9eINoIYfMbnejICyaZoHUJvm0GI72/E/abY7BKRJUPq38Fmxj3hQE/NsWZ3uLLNVhQtchXrfs2YKvueY8gazCeR3vvHjk13xzXL7Q9p162a0ThX 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: When CONFIG_SUPERH and CONFIG_VSYSCALL are defined, vdso_enabled belongs to arch/sh/kernel/vsyscall/vsyscall.c. So, move it into its own file. After this patch is applied, all sysctls of vm_table would be moved. So, delete vm_table. Signed-off-by: Kaixiong Yu Reviewed-by: Kees Cook --- v3: - change the title --- arch/sh/kernel/vsyscall/vsyscall.c | 14 ++++++++++++++ kernel/sysctl.c | 14 -------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/arch/sh/kernel/vsyscall/vsyscall.c b/arch/sh/kernel/vsyscall/vsyscall.c index add35c51e017..43bc3715e38c 100644 --- a/arch/sh/kernel/vsyscall/vsyscall.c +++ b/arch/sh/kernel/vsyscall/vsyscall.c @@ -14,6 +14,7 @@ #include #include #include +#include #include /* @@ -30,6 +31,17 @@ static int __init vdso_setup(char *s) } __setup("vdso=", vdso_setup); +static struct ctl_table vdso_table[] = { + { + .procname = "vdso_enabled", + .data = &vdso_enabled, + .maxlen = sizeof(vdso_enabled), + .mode = 0644, + .proc_handler = proc_dointvec, + .extra1 = SYSCTL_ZERO, + }, +}; + /* * These symbols are defined by vsyscall.o to mark the bounds * of the ELF DSO images included therein. @@ -55,6 +67,8 @@ int __init vsyscall_init(void) &vsyscall_trapa_start, &vsyscall_trapa_end - &vsyscall_trapa_start); + register_sysctl_init("vm", vdso_table); + return 0; } diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 24617be93119..f04da9f3abc6 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2022,23 +2022,9 @@ static struct ctl_table kern_table[] = { #endif }; -static struct ctl_table vm_table[] = { -#if defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL) - { - .procname = "vdso_enabled", - .data = &vdso_enabled, - .maxlen = sizeof(vdso_enabled), - .mode = 0644, - .proc_handler = proc_dointvec, - .extra1 = SYSCTL_ZERO, - }, -#endif -}; - int __init sysctl_init_bases(void) { register_sysctl_init("kernel", kern_table); - register_sysctl_init("vm", vm_table); return 0; } From patchwork Thu Oct 10 15:22:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yukaixiong X-Patchwork-Id: 13830206 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 E6F88CF11F8 for ; Thu, 10 Oct 2024 14:12:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 19BB88D0002; Thu, 10 Oct 2024 10:12:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1244F8D0001; Thu, 10 Oct 2024 10:12:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EDF6F8D0002; Thu, 10 Oct 2024 10:12:24 -0400 (EDT) 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 CB95E8D0001 for ; Thu, 10 Oct 2024 10:12:24 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id F0208406D7 for ; Thu, 10 Oct 2024 14:12:21 +0000 (UTC) X-FDA: 82657882608.08.B4CFFF3 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf15.hostedemail.com (Postfix) with ESMTP id 050CEA0022 for ; Thu, 10 Oct 2024 14:12:20 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=none; spf=pass (imf15.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.188 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=1728569360; 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=Gc1RbTE3+aKHDGGTQUC0qobGrXdk6WSS5uJGgexqL2Q=; b=MJRucp3VgOIH15nSVBSKsEpof+TZ7drpTU8zRNFIDU+dtIr0zZUJ8D+4aP5SCNmVZd9rfU ILWX+CVAqjmJPft1aEBJw5Fdi8iFAHtSTZ6bFefUu8NQ5K5rKjpMPLIFTcOC/tX/BdF2W4 /p3Wqb5xdJdAuXFh0Usq9i99J0Ok5Sg= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=none; spf=pass (imf15.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.188 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=1728569360; a=rsa-sha256; cv=none; b=Si0GXKSVcyXU+OJTzQCGJAXvUVxyleUXTSnXWe4OffO7Tp1IriTJCOUjf0R5udaNj8xJpA KfFQMZtpQS9/OlGVLnMSA2uyACWGHZ6LzYzDYfooxX4P3rQBTNvIgB/eG7jIEAVtuT6pDS +9iT/5hi27QwJ9Q5IcBnG+4BAhanZKE= Received: from mail.maildlp.com (unknown [172.19.163.48]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4XPWq6495SzfdDh; Thu, 10 Oct 2024 22:09:54 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id CE3A218007C; Thu, 10 Oct 2024 22:12:18 +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; Thu, 10 Oct 2024 22:12:15 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v3 -next 15/15] sysctl: remove unneeded include Date: Thu, 10 Oct 2024 23:22:15 +0800 Message-ID: <20241010152215.3025842-16-yukaixiong@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241010152215.3025842-1-yukaixiong@huawei.com> References: <20241010152215.3025842-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-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 050CEA0022 X-Stat-Signature: 5p4wero11qz5imb8n8juratmfn9xtkbt X-Rspam-User: X-HE-Tag: 1728569540-622082 X-HE-Meta: U2FsdGVkX1/5o5dz3cmFziG9dg85tQt1zYMRlh2GmGrja2djjyba/dLf+8ciSFSK6zhod/K2Qd8qGyNpBmBaaxdDbplHwhUCsZnWsH+cBVsNR61PXbEH9AfZGf/xWr03awGPOw2h4KI6LVfd3Y+E2MBv9oKPXVABUtF7GQomz6euPuTxRuSrH7Nd1GaBs5AmBFDEIngR+hdPbLdg9N5iy2KGpS2n6pTnVBy9MgiULERLdBoRR3U018PAZffxJW/ezxMpfNyVI2RHNIHci89OA8zGN+kfc9qiaZGIbuIBEOeWdgbZFvj2GeDpIYERaz8LbefZYCdqMm4dxGo+fYG7PZwbRzNcrlE4ERgz5hannNQv/SZ1FCtuhRt3b706hQkob0rCurXrwI6ZTYk2Mc3aB/6Kut1lXcokiOSKL5weH/9EBsiO+KppWW6ikyctKxDQgwUgbLQ0ypK9bXl54Vbn1kNstqhjLxEnHfetct9spcF/b1qdCaDvuEtkN/aSntOfoV803EQcEFPrR4GzNrHSAbt8+c1KoRJ4CBDeWvDhTk6Cup90RQIg5XLwfTbXlzYs/0aDDmU6l7jmeHTyNPmsvmt5R5kSphY6n8muIjXpEoWYo54vVCNuD8NCo5NgkI6b6Bruq0ykr3TrqNY/+IBA/SaheE0U8Wsd7ZuY2yKCIqTXRv+BGLM4cekB83c4/VtquYLjaOGQJlJ5lho6AW3RCNyA/YDbftTIljRZbsIk2cpq+Qc2srliZzt4Ql3CW8zgQpqDDmentHZigb0laBlNFayAXzoUUGdSDc0DH5EPezHOS/kFd+AE+Egd8ScKFiuDu40RXCwA8pslHQtJn0rfPBv5BvVB45fKx71FxE3h8xr95E4sjr8hxKUEHbOHnhlg8GjZsP3Deo9tW5g8okj1XJnXUqoNMMIQdvJHbYaNYZYwJLQR2t4qMRyKF3ZlbVoYGa7ezvkKfu3yI57oXgm 0zaSFTzF 8K2rz7B3nqseSMsiL6rFvz9etvNs8WNqtDLpgc7nvzISY/HP+OZ6ITUPZ05Ou69Kfc/zDZkGK3hcl/BcLh9garZluz8u+mmwgPkg7Frdi4OGgBDrgidimhjv4Rh584X7jo+mH+giIgThUp71nsd3fokv3WvrLd1PVisxOTkk86QihbQk= 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: Removing unneeded mm includes in kernel/sysctl.c. Signed-off-by: Kaixiong Yu Reviewed-by: Kees Cook --- kernel/sysctl.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/kernel/sysctl.c b/kernel/sysctl.c index f04da9f3abc6..6e3e0ce4da79 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -20,8 +20,6 @@ */ #include -#include -#include #include #include #include @@ -30,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -41,7 +38,6 @@ #include #include #include -#include #include #include #include @@ -52,13 +48,11 @@ #include #include #include -#include #include #include #include #include #include -#include #include #include "../lib/kstrtox.h"