From patchwork Mon Dec 23 14:15:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaixiong Yu X-Patchwork-Id: 13918954 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 00F2DE7718E for ; Mon, 23 Dec 2024 14:19:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 73F096B00AF; Mon, 23 Dec 2024 09:19:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6EC6E6B00B4; Mon, 23 Dec 2024 09:19:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 567136B00B5; Mon, 23 Dec 2024 09:19:44 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 331AA6B00AF for ; Mon, 23 Dec 2024 09:19:44 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id D7995A1806 for ; Mon, 23 Dec 2024 14:19:43 +0000 (UTC) X-FDA: 82926431532.11.6167873 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf18.hostedemail.com (Postfix) with ESMTP id E2C2F1C000C for ; Mon, 23 Dec 2024 14:19:23 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=none; spf=pass (imf18.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=1734963556; 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=kkeawcA2Ivr3oQxrii7ZBXnTeXsAU4dzmySeTIgTS7E=; b=yb7PpKQishKOOiU1/EvIQre2DIP/pFbbyWjMDUde7j6NbfAQz3jqR2vpDFCEzgBk/iUY63 ROwGSbTljNd28envmM1npsE/rWoSKojpuyyLp7VWzsEHHjCcG2GpdJc3063dcJDFMv5Ktd XMmDr6gXwREqME2wJNRtCkG9npb1KOU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734963556; a=rsa-sha256; cv=none; b=VIt3M9XYxtpGPJsjgreOIjM8/X89EwC5uwHYa8e1Hy8I/cST6M+QbKzCM78Rqgbhjf0v49 MJSeVhQD0Kx+eEihtQtSScxQT5WsD5JbQSon1yRrbQ4qYkYEZH1H3Cnw+gN3tvk/dDbLHX OJ5+7Hmdg7y17oojRax0JKuji+ismFQ= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=none; spf=pass (imf18.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.162.112]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4YH0T43gyMz1kwqV; Mon, 23 Dec 2024 22:16:56 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id 883851402E2; Mon, 23 Dec 2024 22:19: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; Mon, 23 Dec 2024 22:19:34 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v4 -next 01/15] mm: vmstat: move sysctls to mm/vmstat.c Date: Mon, 23 Dec 2024 22:15:20 +0800 Message-ID: <20241223141550.638616-2-yukaixiong@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241223141550.638616-1-yukaixiong@huawei.com> References: <20241223141550.638616-1-yukaixiong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemh100016.china.huawei.com (7.202.181.102) X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: E2C2F1C000C X-Stat-Signature: petm33m5z7hy13jnqpsmo4mpoji51b8e X-Rspam-User: X-HE-Tag: 1734963563-802916 X-HE-Meta: U2FsdGVkX1/w94xMhDGHgcovfxJzPaC3uEI3gn8wJUedpA7PE7CTRnl5CVXzgzFsp/YKWXOkovDTRYdOIcskzigav74cMl1evU0JTuc15v2qtBmK+1kgTdXAHIZmIbXu5SEHtssJMJ+GRO/FzfT1K0Voh3shHwOl8mXf374Llbnzk0c54zmq3g3G8VrQlSPvVmQm49sA1wc9E87qCJx4L6d3dskMlX1s6ic5Qv6ys0abelfCHlcpDjdQxfCWrkevb7qosPTWElfE6qLThS98QbZrs8sSaemvoxRnh7XiL/phffNN1dlvXG/uXqUXIHOAAyW/+c4Gg2zx+Bu0gzY4jPNTFCoykCawyc+2knetAaLvxHGkujgxWflbvTMmUSI498yjinusSGN6A3zydInt42tK7ULKKI0+Ozn8t7KieSeeJVFGwTEyQNiwX4dNt0c7ZaMRm0m9OM/7/ExZBpzIkc+Q4skJinExCFXYG3ZUh6Og1CnKiYUoHFBurUM7oHgRSzloIcvzDhJo7ktX9mY/TEwvL8X1MvQRSc2mQK1p8LPAktLg1rgRA5jcTULNCC/DwKIyWTq4FF/SPh7hoT1PboHH8ctrKYf3eL22jii+j/cBmemGZ/InZAwF68NPl4+XUvGy+AkvvYsDaRmAN7YwT4GkECCyETA0h8HuwgmS/9OD6yuJopq4SwZD2jTqd80XHl8t7+1mtsnrYKgzKIfCli2WpVChmAlhcrAWubTPX/hXZDjxW0kAYhTcskp0YTZZqDSga0d+BLSRl+hMVb5sCXdEAQ0sRnTNslWo+syvuznQabZNhqYHtmSgwPqZ9+MpfGXoxLA4tDGAfvCulcJod/xaEbXA+9C2c9nE8kamPF6zKhEpznYgbcfumyGLVz+YpXSze0OOflaemSIzhMec2OnqywqZLQ89EWhC6quxkhrcgWAnNfYIYAmaAk9f8QrHRQzElt+C6tb1E/UhfpQ HZ7AHkAm oHrMvAxmSmph6QYbiHWABU0GPSwn3UipBR+ARh90eWwhALPckx7wb1L8Of/WmXA+cp09qZMlVPxScIxpKgnq4gFB7aHrHJFAMgjgeWz1LjIxTZBL38XvKoCbaS7/oZ+A+m5A97pgzIhpILkUkX/TA6qIVewaRhOZcOvJg7MGg98zLp9A= 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 --- v4: - const qualify struct ctl_table vmstat_table 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 9f3a04345b86..4751e3ecc467 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 7ae7a4136855..f1ab251fc2d0 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -49,7 +49,6 @@ #include #include #include -#include #include #include #include @@ -2071,17 +2070,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, @@ -2147,22 +2135,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 4d016314a56c..cb4dcd4c6715 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}}; @@ -1938,7 +1941,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 @@ -1947,7 +1950,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; @@ -2185,6 +2188,38 @@ static int __init vmstat_late_init(void) late_initcall(vmstat_late_init); #endif +#ifdef CONFIG_PROC_FS +static const 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) @@ -2216,6 +2251,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 Mon Dec 23 14:15:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaixiong Yu X-Patchwork-Id: 13918955 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 0CD1DE7718D for ; Mon, 23 Dec 2024 14:19:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 93B4B6B00B2; Mon, 23 Dec 2024 09:19:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8EA0B6B00B4; Mon, 23 Dec 2024 09:19:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7628F6B00B5; Mon, 23 Dec 2024 09:19:47 -0500 (EST) 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 5A84B6B00B2 for ; Mon, 23 Dec 2024 09:19:47 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 0FC05AF4AC for ; Mon, 23 Dec 2024 14:19:47 +0000 (UTC) X-FDA: 82926431658.11.4470B7E Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf03.hostedemail.com (Postfix) with ESMTP id 1A8312000F for ; Mon, 23 Dec 2024 14:19:26 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf03.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734963567; 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=DrWd0FeM2jrAHnTiWf5Y6nez0/qEj0jb/w/pvhZDC5Y=; b=bf9u1lWKy8QVAi3GyAE4/peNb2NJv11hlJexfSazbRejLqLPkYevltKcyqI2XNoyaK1XdY 4UA6Xpd111uafsHU3lun++jDjNa4Pq07IlGjinHVV7zqIXXEdrVZr+Sb5T22GeLLvE5GiL qIoTFOjeYbjzWGFxvO70F9zRs9ED/2o= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf03.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734963567; a=rsa-sha256; cv=none; b=2ljzZgjr2EZjXrXGxba4wwW6AT2LBL7iQQJ/sRA2Q/feDHLSREFVQmjJUA7hy2jdHcsPWz 8oCb5+jqbpIxoHnLgMiWPDbJkmQQohoLMsvGYjZlGWcABit3WLpnoeCDvgQltl0LPIspZe JRHoU8TuAmD8NiUFFV6LR3sb1Pd8rxk= Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4YH0SM1Wztz11NKN; Mon, 23 Dec 2024 22:16:19 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id C2CF31800D1; Mon, 23 Dec 2024 22:19: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; Mon, 23 Dec 2024 22:19:37 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v4 -next 02/15] mm: filemap: move sysctl to mm/filemap.c Date: Mon, 23 Dec 2024 22:15:21 +0800 Message-ID: <20241223141550.638616-3-yukaixiong@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241223141550.638616-1-yukaixiong@huawei.com> References: <20241223141550.638616-1-yukaixiong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemh100016.china.huawei.com (7.202.181.102) X-Rspamd-Queue-Id: 1A8312000F X-Stat-Signature: u5agkwe5xc6tep7yhnbriqp36gow414z X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1734963566-37230 X-HE-Meta: U2FsdGVkX19nYaXtyD/iOjn6GEZa0m+fIADn9O3VQZj9f1KRpWgqkk4/nn+J6R7rFNunRdD6R9qxR04ZZTDwOVQQvwYH1hZfEMCdffln7YUkvOMY44ulZcgB3D6oW6x1ewrPR1zYo8HEHy3DbS51g2AgxpMkHqyLdQ04psPAz0P3CKIM4VWbB1ZX37uEZyfdXGNf2cespjJEzMDVuj5T4QDfnrrcvmFAJqtxdOUiu8H4ZyoaSRjP1QyxPdTdD9bKDU8alN5qM5Hz9Utpih19R2wWn7kFCqUhXtGjfmWGRu90rYncjWMU6hWyqviFF/itcl9FVoLZXzrGGL8tCfzbBaKdmVlNkaNHgppnbrUftsLy12u1/PCjJggW4bDqcgsfxMmkPB1JR2Q5ZNODEY9J5YtINSQ0QUhBSDyrVxQgCVRRKKJQgn3XUG/sO/uef93SRLGnh+wXEKKVRgmi2R+awxROXtGbviDSTPbzgKXLqX6IVXM89vfgHUaD9NWHqV5ctnbUFo2Hb4AcVuMchAJhkIm2IID7Li18+P1rM01ETq2fHJPyFbay6OMwcAvwEVVaE7FE3JH+d+bQQ2F+ugwIryy9SOm4gI9VgXphALOYp9hZjDScPVUeZqOmfB1YOXKGwvS4XVuUhnj+pOFMmH+6w37XxCmpXZmA/00ssgQHNYp7YJNHfo+xdGbNnK2nqgFKzNUyqcdadMq2Vkp7zVNq5xA947jrr9XepsylT8UlGCey6MS2WsOQgGd+kZODBJOLzds/0EzZ8Ey2bXcC5TitPZf/z3x47wMcIk+2LXmOWuNkG9Ek0IKakHGJZlwo8fheobR9BZkaDJ68rChzx0Bh49XiBJ7pWMPp8dV/HMZ1EdOGcFk4WRYFjWErS7BrEl7lm3hliutBwjUKmZ9HH2UX3x8eexUkpE83+ulvDetQVH4mWl7JlsZns1yQ6I+8vaRV02t4hmkFLRN6JsPoK1T rbHBz/D8 JOdgYyh3pyDHVbCa6yqJP4/5bvmazcArBDwGEjNOwPvUd1512RaAkFKlfagVirGQ3SG7eDbRiTc7lLny/S5ZTkOrlpCq1Cqj2BhNBU6q2y1/hr/e/Xx19pp5IrWAuOAloVhovb0ATmrR/mQK11s0daqeHAlu4dwt5K3RbuppDlNvHCJo= 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 --- v4: - const qualify struct ctl_table filemap_sysctl_table 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 d61b9c7a3a7b..dbdf8950d681 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -40,8 +40,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 f1ab251fc2d0..23c8db80da5d 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2079,14 +2079,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 899dab55d235..bb7aff8960a4 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -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 const 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 Mon Dec 23 14:15:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaixiong Yu X-Patchwork-Id: 13918956 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 AF103E7718B for ; Mon, 23 Dec 2024 14:19:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 455FB6B00B5; Mon, 23 Dec 2024 09:19:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 405CB6B00B6; Mon, 23 Dec 2024 09:19:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2CDCD6B00B7; Mon, 23 Dec 2024 09:19:51 -0500 (EST) 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 0D2D66B00B5 for ; Mon, 23 Dec 2024 09:19:51 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id AA9311C6A1F for ; Mon, 23 Dec 2024 14:19:50 +0000 (UTC) X-FDA: 82926431280.21.FC514D7 Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) by imf13.hostedemail.com (Postfix) with ESMTP id 51FC620003 for ; Mon, 23 Dec 2024 14:19:10 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf13.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=1734963553; a=rsa-sha256; cv=none; b=A0S7TiNExhn0gonp+/BYI2hCUy7ibgA2sW5SukVF2vJtBN+PUHKL45N/kGSBtbUzHaKL6r 5JbuQifWaer0ylYSS9jqnbC6YvgCRp7gOc8+uEVO+h5gG+mS8lyjXUr9Bd79Uz69tpvIwX 6GDXDWZWR5uoV1hyaS1ChvmU7KeOLoY= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf13.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=1734963553; 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=4RL/9lE7KC55TAt+DcK4y1ybUzXuOOxoqDbBIyF0dTA=; b=H1MASwi5BahZPwRd4clCSqoijGaDr7E4/WRs7jrZbMlvnQu/YffxGGbaqZ/T3jBtGKf3Gk c/uDcfIu0IJsOkEzC1JoWBv6mRY/No3d3RmpKchBBh9WTOeNukgeqrvGxHdmFXZSGqOEH5 vYgKUmwGaYukpb6IaWSPrP1gHUjlABg= Received: from mail.maildlp.com (unknown [172.19.88.163]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4YH0TB1fQ0z1T711; Mon, 23 Dec 2024 22:17:02 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id 087BF180043; Mon, 23 Dec 2024 22:19:44 +0800 (CST) Received: from huawei.com (10.175.113.32) by kwepemh100016.china.huawei.com (7.202.181.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Mon, 23 Dec 2024 22:19:40 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v4 -next 03/15] mm: swap: move sysctl to mm/swap.c Date: Mon, 23 Dec 2024 22:15:22 +0800 Message-ID: <20241223141550.638616-4-yukaixiong@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241223141550.638616-1-yukaixiong@huawei.com> References: <20241223141550.638616-1-yukaixiong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemh100016.china.huawei.com (7.202.181.102) X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 51FC620003 X-Stat-Signature: td5cdm6amgjq6e55gpe57hkhhkmkfgub X-Rspam-User: X-HE-Tag: 1734963550-874470 X-HE-Meta: U2FsdGVkX1/aa/9nUE8HBGpdnljyWMMIR9TMs24T2zGMEE6f5KRuWwfTGk2KXFZaVmCqRweTPGn9oM8jfMeQacDnz51g6gZIfD+hdUzQPPAUqPgFcp2IJl3JBuuHt4cKkB3+36ld1TTqxU4BUVb4Ek3PHrXICpg1HrnRJ7FmEaHF1AZ7U0me2p5jW++B8CwZ1f4APA0fWAHJJjsYItccooAMNG1InDg+C6Ee6MQ2Om8VldoHz9eW6Mp4z5yEJl9kQ2XpEhxCAb+bdMK0LVuiBh5IFKYxNyOcRiVmLMxjDsIujyA9hPkcEI0Yx0lXJyPQgso+JeQUsXhShWWrEjcjnpHPMc4fHUIa7cQWAGC+NQyzERv0YWr/NAt+tCc9+PMLh7of3eGoWf5goW+x6DYMZhCMs+ETUTtG/LgIM/jcWI3AOB3iQWPxMw1YsJ7Y++Zgeqen/c5iz/n2HkE4CzdphMKrjGi8sekV061zKEiirOdqfEEut2+g0ojhRiVh9MKC4/2eNwgYHFB73inTc42EV2VnCEIJEN5eSfGn6LdHMKd8zaB8yla9aEfvYzItUB5svKE49aN9IPT00HYXupUDFC9RZ6HWYrSRb3BZW1zBxynQKntTo2nul71DDJnI4/zYCA6xs8HbakZfpPipzIVSrER+yJ1E3kGpknHqYAcJ9EQ0Qp1FFuZ/FTXirw7XU5h3DStqCuq8a5hrsB5UAyJkB7m6gym8Sg9IHeClYOQTZdyZoCxlfcX823StEDuPdh8kNkiTsCwi6WtPsAKSRz4p5uiq7XRCt+AVY0etGLJP9+sCSqhjJ9kUzKHMKyHGBZf/pDkmt1wXdnJaNy8Mk9gHHLzi5NvPggv629lTcBHsRoIJ18jo+hASh9/pt0bsf+gz518Ysr3CSoPKdg7gJFK1De6y/+6I1pgAyJV1zyVx1cVxTjkxQhIAMI60cv4/GFI8l5dNZVgTt4NhM4N0Ch5 0jwhkLl3 LqIDQ2QOcsKzE5lJ3yx3nwsbRVdsiPmPwF0XmuhwqWQ26cc6Na41LNB4MOUtb4RKl20A5h6D9xf1HrnTBtNQAnb3lh0Cd6jkJofC9kpmB7DRLyviE6PFFyQRwRjdSZ2jJDB360BuE2N4oxUcwbk0+sKZFKfD66DJuqQxB 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 --- v4: - const qualify struct ctl_table swap_sysctl_table 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 dbdf8950d681..8941ba3d9a77 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -76,8 +76,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 23c8db80da5d..ab5d94f07e53 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -21,7 +21,6 @@ #include #include -#include #include #include #include @@ -2044,15 +2043,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 062c8565b899..d3344123381c 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 { /* @@ -1072,6 +1072,18 @@ void folio_batch_remove_exceptionals(struct folio_batch *fbatch) fbatch->nr = j; } +static const 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 */ @@ -1088,4 +1100,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 Mon Dec 23 14:15:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaixiong Yu X-Patchwork-Id: 13918957 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 57EEFE7718E for ; Mon, 23 Dec 2024 14:19:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D57DA6B00B7; Mon, 23 Dec 2024 09:19:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D075D6B00B9; Mon, 23 Dec 2024 09:19:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BCF2D6B00B8; Mon, 23 Dec 2024 09:19:53 -0500 (EST) 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 9F6FC6B00AC for ; Mon, 23 Dec 2024 09:19:53 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 569B3160DD8 for ; Mon, 23 Dec 2024 14:19:53 +0000 (UTC) X-FDA: 82926431154.25.2551515 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf04.hostedemail.com (Postfix) with ESMTP id 471FA40018 for ; Mon, 23 Dec 2024 14:19:10 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=none; spf=pass (imf04.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.187 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=1734963556; a=rsa-sha256; cv=none; b=vyqykacPwvi+gg9ptHm5jsI3Pw97PPHwfHtf+te+RcSTvbbl4g3karNmxZDXNaDYcN+pQo XlrmYj6tQH9TkxW6wkFWVzvRp2dtnwV7ALK77pyKYCiJuvYZUHzXBPsJYrU6Sb/rVsAa6N MFXVIjsI9KzvxubVgUbohNIIHyhnAxY= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=none; spf=pass (imf04.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.187 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=1734963556; 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=rjfvDvGC+RNbFh+4I8dtAyivcxgIKW/Ns7KG+z0vGWo=; b=WKEVQHK7MVDBjANLmmaSRBhSq/etnnBN41/pFyN8PW3CbFFOc6Sp+HTxyWFfef89dcVZ8V trePeES3vsr6a1zMqqCcTfBvQ31GPGskUeQYJYq1vkDMKMOPrvtVMfG84zLxL9A7Ki5jqd F4uWztIgKQum//AFHOUe0YGoVgZsdzE= Received: from mail.maildlp.com (unknown [172.19.163.174]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4YH0ST4tLgz11NKd; Mon, 23 Dec 2024 22:16:25 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id 44843140391; Mon, 23 Dec 2024 22:19:47 +0800 (CST) Received: from huawei.com (10.175.113.32) by kwepemh100016.china.huawei.com (7.202.181.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Mon, 23 Dec 2024 22:19:43 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v4 -next 04/15] mm: vmscan: move vmscan sysctls to mm/vmscan.c Date: Mon, 23 Dec 2024 22:15:23 +0800 Message-ID: <20241223141550.638616-5-yukaixiong@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241223141550.638616-1-yukaixiong@huawei.com> References: <20241223141550.638616-1-yukaixiong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemh100016.china.huawei.com (7.202.181.102) X-Rspamd-Queue-Id: 471FA40018 X-Stat-Signature: hs9d7z5th5n7hc76hrtqet99xspgu4e7 X-Rspam-User: X-Rspamd-Server: rspam09 X-HE-Tag: 1734963550-189964 X-HE-Meta: U2FsdGVkX1+pW1a5ZnsHNmn/zOLbF9kR31pvWlt7H6fV5OE8SCGDc38BK9G0OF/0S0WNWY0mmlaRO7munVcWV2UPirCsSxqsnzaQC1NdLG+ZhE3sPx8EdLEDPdlcfqeBik/Z8lAiZ69r0rqFPD+6k/OAtskp++Z7dDKrOxp35YFhb27CpyrMCfET098XbHEGWRlVZ5XzEBeYPPeZ7j4Noratii7IdolurepAnbTs1FOa02ockNNGhhQr5jwjr29X17Dw1OrMdSsxZKaF6XP7oMpmlsV4yod2pKkQ3tV/z00Aj54ZQRSUBP3r61drdeN1YBO35geei8iiTVY36zLUT39ZZr2NhJ2fQrUWQGHrAtgTjYEP2DEF3i6phzOdUoPaHGq54Vbsq/dMM4cLFNbiBa7TC6Ks3W9y4dVsl6Pj/yoH/KomCvOp5LVq1qJhyzmcK/1Yj+xP7EmLxzwmo3uQaWcSZhwPYzaY0MhhkbMitAPVMct2gAS5AUSR+yUKP4I7aPX4cTIcZdB7qzEUUFWQWOcgPTAr8ylFPoCAkLjPsRXXxYtKC694eqOc/qM/OMhJjwEGsVDLlgv3ffuQM2BZrNXf1bBalRmK3KZBtdaImm/4dK/Aj+F0vwFQwG5qoeb5/GQlXF72KOCtx3MEGOWwvJ8MWIEtpkO2/JrM7LPbYI4L4UZF9/N75EUEqW4zs0VtXIR1Uef6nfF9F8Lzz1H3fXCWFD9MeHy/U5tANyzRdy5rKp39eQaWxTyOSSpOdnM9RpQzBR3hDEXySLK7cEVOFmA4q8fW2SeKXv3LOKT3IqjmCSUNk339XRo2Pm2RoZ6mvgJK8PAilcYxXLHQIuuPv5S8qTjgVlWR7g5HDUy6dirgjBgsI1TaTYCaYa38Y/2fYpFnu0x3kxjSy+y/1KutAlrRyBsaQiEDsBNq1wxbl47uU8GZd4K9cf+mLSJ/m7/cDlFI9BEYaV0segw+jOL gUdG+pvo Qu+pr306hR1zotrOOisCgtaHbAfCMGYS4H5E0ZEJfunHwHXrEvUXJH17DTbMuhxMdgvlS5Mi7wgA98q/3e39cI5AuDX4h7/RkeXigq/6TPpgwDS6yBCVUGA4gobX16tEhK/YCsYWH6jdqhUSvVzQ+f9aWkXjN2MyBGYjjN+ZTp8c0gv4= 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 --- v4: - const qualify struct ctl_table vmscan_sysctl_table 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 187715eec3cb..db1a28683e10 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h @@ -427,19 +427,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 ab5d94f07e53..cb6ca272fe9f 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2051,15 +2051,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, @@ -2107,16 +2098,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 39227887e47b..ea2623dc414a 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -1095,9 +1095,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) { @@ -1109,6 +1113,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 39886f435ec5..10cc05b5952d 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -7351,6 +7351,28 @@ void __meminit kswapd_stop(int nid) pgdat_kswapd_unlock(pgdat); } +static const 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; @@ -7358,6 +7380,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 Mon Dec 23 14:15:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaixiong Yu X-Patchwork-Id: 13918958 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 80F95E7718D for ; Mon, 23 Dec 2024 14:19:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0FAD66B00B9; Mon, 23 Dec 2024 09:19:57 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0AD4A6B00BA; Mon, 23 Dec 2024 09:19:57 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E8FF26B00BB; Mon, 23 Dec 2024 09:19:56 -0500 (EST) 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 C60AE6B00B9 for ; Mon, 23 Dec 2024 09:19:56 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 8DBE0B0112 for ; Mon, 23 Dec 2024 14:19:56 +0000 (UTC) X-FDA: 82926431658.22.1E8A321 Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) by imf26.hostedemail.com (Postfix) with ESMTP id 26A8C140002 for ; Mon, 23 Dec 2024 14:19:24 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf26.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=1734963551; 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=taIXuv5KVzGPe7WXZE30ImYwJcKhcAjffBsGPsVIWcY=; b=DbIh39fSfaOhTiO2L+fqf0KComhfdZUeHmDamO7u3iaBf1Ttm8JgvTawtUPKRXGF6aZSbv RsXmPfD83osdiH+pEwADIzQVWj9nJODRifPM0omvtjm2DkSjbZ/YGpGESJOYFtpB2BMFXr EF/Bq6d9zAL9033yBZlURHlU5r+uGdE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734963551; a=rsa-sha256; cv=none; b=k7OhTeGL4f2dVPeY5E/XirC3zH3XFxpDraLUgxxdS4Wnk363ny+FZ1pPDoZvB53tJVCd8+ A81CVRgQdAVbRJ+0++slWJyHDkThRTW1uNbR2IZSYUSxAaJicDJ/m2LnU5A17/MLhO2pGt 1n+58Wm7BMgFGd0sCwdCMmRGTTH8tug= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf26.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.35 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4YH0TJ599gz1T7HM; Mon, 23 Dec 2024 22:17:08 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id 81DB01402DE; Mon, 23 Dec 2024 22:19: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; Mon, 23 Dec 2024 22:19:47 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v4 -next 05/15] mm: util: move sysctls to mm/util.c Date: Mon, 23 Dec 2024 22:15:24 +0800 Message-ID: <20241223141550.638616-6-yukaixiong@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241223141550.638616-1-yukaixiong@huawei.com> References: <20241223141550.638616-1-yukaixiong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemh100016.china.huawei.com (7.202.181.102) X-Rspamd-Queue-Id: 26A8C140002 X-Rspam-User: X-Rspamd-Server: rspam07 X-Stat-Signature: wxdg6i4kr1poktbqwjs54knfki13outm X-HE-Tag: 1734963564-500422 X-HE-Meta: U2FsdGVkX1+R7cvUb9r7dEgPS2wO91TE1tqD34fD+OKYOwbrQIRp+cjEHpGxGQK3FUkFdK3zdjdmrHuDf4d1jS62n4f4ll/llHj8SzmuNKgqc+nb68ETpyzZb9wfCebQNkWo6i4Sf2Xiezdwj9bvwNOeRCuSkVC8+bUlbbrlBQ3V9SLLLZzmbqvog0JqROsBCqsAs6pKpC8j83R8zHqgmxLN74TDqaYJxUXcpvWMeNkicZjuXwe70B5pfh/L2TySIEXpgRnZcpmBMyOwgfnSSXddnfN2r6q5e47ObSRhOGpKUdHeno/p05jfFTrzQVN5ac1JRVBFdo6Jv2tgM3EnteFNDUpuMWf5Pip06olSsDtGGbuXEWHTuscmFPEt+MEmsTjyrLuR0lZdfxafTp/t749BBN1UIzDpxvNW8FenfU5XDA/kvuMMvjLNleFQlchve6TLzrsKCjhUe+sRMFnHSSHPeBgvnH77yZ/Fx2X0wbjpMd3pqB1RX2N43eQMa3lsQQMhBbXMVD4MClHuuQwAlUEWyT2GGlYZWQRVRQPi5dZdNBe8ujk7mEgyxX+xbtn7Fb0scmb9T3bKPIn6y/u11KxMsrqIA9r1/I2Tka28KGV396bBmV+Usrb0ZXpJxZuYMA80R1KI+ahvf7cJziwEN4uiNrBtyUz1RcUX1PjZYWJihLSMlowouAH9y/z/aRA0gEyNGnbe8ZpychgeLiwMI4ClwRJuliWm+VL9e0dhcGOaotxgQPYMreOITjepqXJwq+dZJ3fX9rcp8QrTyndJL2h/0vOkTSQdZJh05sNz9fHYnYUwq3rfwBAotvGuMFGNfV3WpYKfhTURw428+APt+NoYkARBXX+gAuUV2L1Nq9m5I855AMBmt0oL3S6164e9MOe4WjoKw7/6rs4DNjhYSA4P6/ev3Ye5cPSQFnooaADrna30NnlSgLyDxr76HpM23mT33FGnX4UA4umZXgq EqL3VpVs V5DSGH1sicmltFtuwHnadlRqycyItFB70gFHJzVnc1qSERlu4K8qgbVgkc3s2M/FWa3/hLZTmpG2iNIOYeD5dv2QrHchprCr+hygyGLuZ0cCtI4sBwn/NZ8Iruzu/PG8aDZMl2r1MU+Afs3SFiaYugdbVHTyvu+xHItybOOSndBMDJhU= 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 --- v4: - const qualify struct ctl_table util_sysctl_table 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 8941ba3d9a77..b3b87c1dc1e4 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -205,17 +205,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 a842783ffa62..bce214fece16 100644 --- a/include/linux/mman.h +++ b/include/linux/mman.h @@ -59,8 +59,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 cb6ca272fe9f..aea3482106e0 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2020,29 +2020,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, @@ -2123,20 +2100,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 b7dc6fabaae5..6c64664937b3 100644 --- a/mm/util.c +++ b/mm/util.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -911,14 +912,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; @@ -933,8 +936,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; @@ -969,8 +972,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; @@ -980,6 +983,54 @@ int overcommit_kbytes_handler(const struct ctl_table *table, int write, void *bu return ret; } +static const 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 Mon Dec 23 14:15:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaixiong Yu X-Patchwork-Id: 13918959 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 CC62CE7718D for ; Mon, 23 Dec 2024 14:20:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 604926B00BD; Mon, 23 Dec 2024 09:20:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5B55A6B00BE; Mon, 23 Dec 2024 09:20:00 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3B8936B00BF; Mon, 23 Dec 2024 09:20:00 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 186F36B00BD for ; Mon, 23 Dec 2024 09:20:00 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id D00161C6B1C for ; Mon, 23 Dec 2024 14:19:59 +0000 (UTC) X-FDA: 82926431784.26.D84AD8F Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf20.hostedemail.com (Postfix) with ESMTP id B07661C0019 for ; Mon, 23 Dec 2024 14:19:17 +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.187 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734963554; 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=KRRQWJMozcVAKYVMUwFg78+lDlVV7L8SHkPde0RbLo4=; b=uw6S3lEVjcOPbG89C8WDncq/a0FHYY7De2OqCDAR37c3/n4TX/z2fGMCot8etyoAZUva1U 3AogIenMYcAeuKtyxiIRk56EWlJqM4uDE4pBfOJObAz9CrMBF3moCq0KTD2lQEN96BSc5s wktEtRq1gPtv8vGVGHaKvC1CtxRecEo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734963554; a=rsa-sha256; cv=none; b=p5+uT8C6R947V+hdzhksGtCqVjupjaAXYboD/LdqfxnW8LT0y9ziinzqYGm3C8ALvHiakk phEHiBIZPTx5V6dz2Sm0sVxDZKspJR6+BZQq722pDJRSIMy/z1ZTyWF8LpIouMTwr/mSPh Vl8aZi6DwYNqAvaRPPvAU74SWSlkKzw= 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.187 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com Received: from mail.maildlp.com (unknown [172.19.163.48]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4YH0TS0T9czhZZ4; Mon, 23 Dec 2024 22:17:16 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id BD245180087; Mon, 23 Dec 2024 22:19: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; Mon, 23 Dec 2024 22:19:50 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v4 -next 06/15] mm: mmap: move sysctl to mm/mmap.c Date: Mon, 23 Dec 2024 22:15:25 +0800 Message-ID: <20241223141550.638616-7-yukaixiong@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241223141550.638616-1-yukaixiong@huawei.com> References: <20241223141550.638616-1-yukaixiong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemh100016.china.huawei.com (7.202.181.102) X-Rspamd-Queue-Id: B07661C0019 X-Rspam-User: X-Rspamd-Server: rspam07 X-Stat-Signature: kutyij4b6usuhg68dcyusa4t1j8u3au5 X-HE-Tag: 1734963557-841496 X-HE-Meta: U2FsdGVkX1+UNzWXhi5jJmmYcehe5QTxVtmuqAwmNvIfT+kNfLvdLzo02F6IDJPssJgoaEKBHkAd9W0E3CJUu8fbN7OmddCbLp0LPGTWNQAlvGtYcLyXmA6G3oQyVmxRO6Rlp7BAZYmaDx0jadL7PQZK+HYf3PsHt4bJ0fXZRc+y089rT667GIwnLVqzyOFVHZJGsT9gMbfDxMHP+D/lqABAZwGwoBF6A0NkSIMn5SLJv1czXT89T93Vgpgt7HQOE2qEOHJpbbwo6fDFHhtFdfsyvnmlbyf05XGwSMbb5Q1JS8XtmoAlGnYpQ04BAdLbT+1QGDheUrAgroNDckcxnTe92T5eFD2OjFey/JHO8yTnOUbw0wOSWVh65DyTHG1o5pdaKYaq06MEal2FNqi8RNod+8cVRhfz/WwA6GbyRpaaoThZby/A/rjrXQUMUmDRQgN4PT9bvH3lU77ShxVlwv4ibnzq9g4Q9UlZMpLBDcbcEVZ8XWpblkfgz3jlIm7w0sYtbQSrhwWA9RWC9QRej33tJEqHi4RFgOGnGXNQlPDVkRMAXUL8YBNJiBW8V6Q9Ya8+q0QrquRAA8G6/8iKTrhTQG8TftIU3EbdS3O1pa4iqHYGTB67fKOm8EHCB8mLpWA/UwMpyzggOtU4fxvTj4XPnE8JxFWhfcZY/KxLKLQe+kR2veiAK01AzyS0yFGeHZtA5teymSgAFYr6YLQkDKYt/a9N+ElEofI56h04bMpwYw7zc0WLfL93zaI6EZDv0/cmUNyWTjnS0VPraCchQNLSY7p1x3FEx2WwCzFEblYbk3xuGZZp/s9s9Gz9fwQ9savOrE2Ew8FEuOk/0dMAn7qSN1svBwmjmgEpDOiMZ50YY/2p3SeffsLKNtDX7Myu4Qj0x8qt5SIgnxDVBgXF5Y+nY56Q0jLFTSDBpxg0Nf2C7P9pSttjm+OYra4lqKoyYCg9nitf4PGKEO9PKh7 b0K6Thxc vqxRKJEqNKOO7JgInvuJ3vGde5BEZSt2gdPLoLTD1AHezRw/lYhE+hjCSyLUVrgAjvgCmvG0B+mPHtcXepzGu8kX9a2HE34L9ZS149WBZOO5Ll5ydEYa/24EznpXElmRYek4eh0OtOb5M2TmfGHydZFRG9TVmEQ4DrXGvLcJJOOpLIPk= 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 --- v4: - const qualify struct ctl_table mmap_table 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 aea3482106e0..9c245898f535 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 */ /* @@ -2037,16 +2031,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, @@ -2064,17 +2049,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", @@ -2100,28 +2074,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 aef835984b1c..cc579aafd7ba 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1603,6 +1603,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 const 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 */ @@ -1612,6 +1663,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 Mon Dec 23 14:15:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaixiong Yu X-Patchwork-Id: 13918960 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 CF7DBE7718B for ; Mon, 23 Dec 2024 14:20:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 62F596B00BE; Mon, 23 Dec 2024 09:20:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 602776B00BF; Mon, 23 Dec 2024 09:20:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4C9DE6B00C0; Mon, 23 Dec 2024 09:20:03 -0500 (EST) 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 30C506B00BE for ; Mon, 23 Dec 2024 09:20:03 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id AA29B14161B for ; Mon, 23 Dec 2024 14:20:02 +0000 (UTC) X-FDA: 82926431574.06.C9A2EE8 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf19.hostedemail.com (Postfix) with ESMTP id 6CBF01A0019 for ; Mon, 23 Dec 2024 14:19:19 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf19.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734963583; 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=JmVbJ1u7I/fiM/mZTKbXVhm296hUyc9nVwr6w+TBxSU=; b=RSn4+mh+ppy/QEUOfzKwD5/IH7T1Mj0uVrWpluzsWIcVmtjhfDjVu6YRCUWPhTdx/zYYId g9HS/Z1wGgomt2CMIhaF68LeNfauIXIFpHKNqEqR3yPGtEHeEIGQwtfNCPHWAACvFQdp0W wW7l31nuGaqyCMBGqos4kR+FYI0dJE0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734963583; a=rsa-sha256; cv=none; b=cK/PR77e+uPyi2QGpyBc/fdA1xCOTMxycuQ4LBtVtPD0UT9PZ0XZnT8KZ//QvyQ1ntyeWT d7pM5O9ApdjRQCMEMUxcCLlVXoFPo/LCNucN6OzTxecSG5O9n2WruYVppIPvzPlJAXos2y bAJjs8bufezgRSm+V7ANIL4I79a82aU= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf19.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4YH0TW251zzhZZ9; Mon, 23 Dec 2024 22:17:19 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id 01A5C1800D1; Mon, 23 Dec 2024 22:19:57 +0800 (CST) Received: from huawei.com (10.175.113.32) by kwepemh100016.china.huawei.com (7.202.181.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Mon, 23 Dec 2024 22:19:53 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v4 -next 07/15] security: min_addr: move sysctl to security/min_addr.c Date: Mon, 23 Dec 2024 22:15:26 +0800 Message-ID: <20241223141550.638616-8-yukaixiong@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241223141550.638616-1-yukaixiong@huawei.com> References: <20241223141550.638616-1-yukaixiong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemh100016.china.huawei.com (7.202.181.102) X-Stat-Signature: on8t1ozcu5suc9dakhyk6mi9zrbbx7c1 X-Rspamd-Queue-Id: 6CBF01A0019 X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1734963559-509745 X-HE-Meta: U2FsdGVkX18XIihjUCht/8Ny8N60E63y50a/3oxe384GxzzauaupynklWr2t+mo9MPIDcS8LZ9hQZIo/abFtNz4yEi20Rb/ezU33By/zIQnGXR+bCghgJ14zk2CUEOH9Zd8GVOSfFWs/6GwW3Br/JwzrB0Vk0Aww+h2P+s7ekO6bA3gYgHXxmOXY7QgDo0VCFiVXSH9G2UoR0+SqFW5UVRaPhxw/s7z+qjmSDkVCXYnMJXFEjXrjwv3clAvHrAecaIcYCxVdPnoe4VcWIss0E4+dX33GVohLGXVToK99D/fg6qc5Ru6EFZ81croIy+Xrtqks04IMXAmedQXEBG9U2NlG41ngczvgYjJNbpgMBemuvaec2ApkpFYa0VMAmQka2uJXNJd7d+a0/F4QZwKlUBUITILu504AW/QH+RoCQOPenSQU5+S562xVpTcPLRU5tHf5r/+VR7LdUar/yNSbmk6NivuenSB8fFIStR5uhmGGMpA/hV/CYl3xeRUCn21WPo8QkTiqogq2Ind13wdjFf2PwQW8psDNZuLrTxe4vUHtFAYwB6LPzkQz2+PsrFSEdBnNe/j4j5vEUA0pvccEEaY4dlK3a7AcRZq+5hMUIlWBopIvySHKvLDHzMaoaFC2hEm1tKQ9UXg02OBL6VYMQ1xm1iscy4ZMA9mrCc1fKSlCDp5CmFnjiIYJRUcPE5+bmilo8vG+QhyDAhFKqCsC7It5k/9bdRhSHDdm4/8/Yb3fyTX2wcXTejxSm25GPjwIMXsUBsLr6yarlgpi/waX/IvlLpY4KfspZWf6DXT5widiR2LJGtxOTfrY+70QELgn6CuIDgSLGQPkQiJW8EH52uCNyetXJ56um215VgNzpUbfX5mQCkk+noCFgfgnl3nPyOVD3YdQQphzHy59Cg4ZN7H2Fy8H11DZnIfKVx5NG+1O6TKIFysl1G7mQCyIm1iXvBz7Ajf7nS1NMp/pk6L n3a7iUQQ DxfyolNvxc25mK0IzPZ+TnKm8C8K7OeknCUwfl08+YAjs3+RRROcymfwR3B0beVzXjO5qGECI0ZqsxifcdvRf3vFOKB17oE1plPz473S22EmtOpPE3uJC7oTyyHdV4AHdi2m7/KQZVdELSmyMOf/5B/Bub6pNyXfNPZ2IIoDgwkJdhhivK/JwGLT0Hhf6swvp8oLaOEkPB3hGVGLqOhfPgv0ruYOmjatMsgef+siUD1xErDK92mdfAq/VFRN8roUNsEvF3hZWllgHiDWNMc3xrH2jcA== 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 --- v4: - const qualify struct ctl_table min_addr_sysctl_table 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 9c245898f535..62a58e417c40 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2049,15 +2049,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..df1bc643d886 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 const 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 Mon Dec 23 14:15:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaixiong Yu X-Patchwork-Id: 13918961 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 16B20E7718B for ; Mon, 23 Dec 2024 14:20:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9FCF36B00C0; Mon, 23 Dec 2024 09:20:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9ABA86B00C1; Mon, 23 Dec 2024 09:20:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 84E4B6B00C2; Mon, 23 Dec 2024 09:20:08 -0500 (EST) 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 62EB26B00C0 for ; Mon, 23 Dec 2024 09:20:08 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 298BF1C7AF4 for ; Mon, 23 Dec 2024 14:20:08 +0000 (UTC) X-FDA: 82926432540.11.C7DCC64 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf06.hostedemail.com (Postfix) with ESMTP id BE03B180011 for ; Mon, 23 Dec 2024 14:19:38 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf06.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.190 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=1734963577; 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=KSwhYT2WK8fapxw3LL6iWwicHeC3MEU+LN4cXu8E0hM=; b=GqYQu5wQWbkOOc13EQaq0CCUFAltULqQXlw7FUeDwt+Twar29aia1DgzHdxO5vxGKyy6XR Lagx2ibNcMcgERoCHL0RerBI8sE1HfOc2Rxx6S/paezmLh9S8gO1VH2iE456xnzimaq5h6 V4yoINNuoDvfi76m+7FRMH3xHXZAD4A= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf06.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.190 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734963577; a=rsa-sha256; cv=none; b=7J52+pCeYwQJQU+37vbj79hnZInNC+0Zy2E880Wz7Lw20YZWL0meNJSbtAzCFB4whRXvno ef6DdmrRZbvRyLk+nhD37lczWWncJunJ5e2r/T+tPmm6Uf+1w46gWPm8ZuyD9wbI9h3L0n 0dnnr0uDyT0mrZ3DU6oW1k/49zYmjEw= Received: from mail.maildlp.com (unknown [172.19.88.214]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4YH0VL21prz21npX; Mon, 23 Dec 2024 22:18:02 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id 39B151A016C; Mon, 23 Dec 2024 22:20:00 +0800 (CST) Received: from huawei.com (10.175.113.32) by kwepemh100016.china.huawei.com (7.202.181.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Mon, 23 Dec 2024 22:19:56 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v4 -next 08/15] mm: nommu: move sysctl to mm/nommu.c Date: Mon, 23 Dec 2024 22:15:27 +0800 Message-ID: <20241223141550.638616-9-yukaixiong@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241223141550.638616-1-yukaixiong@huawei.com> References: <20241223141550.638616-1-yukaixiong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemh100016.china.huawei.com (7.202.181.102) X-Rspamd-Queue-Id: BE03B180011 X-Rspamd-Server: rspam12 X-Stat-Signature: zipdbb7rh8ppptd1957cfw3ihuoi933d X-Rspam-User: X-HE-Tag: 1734963578-477045 X-HE-Meta: U2FsdGVkX1+xY3ZT+bpieTEF8yLcheb6H6HzNo3Cao8EpEs+Z2zuC8Y0dgB0lj8JW562kXcUO5OCUd0NKPOQ8PeyimQXpn1iJh2LG8VGA/ZZonOt6rABD8brNpWRMEwVbSSpWv2PUzfh/XVuS5dzNDncPU72scmoHUXfekO/zzUFeRL3JFCx8kN+R11nKmdlItl91erI6bg2a7GlDIFwCBOxcSFBq6yakV57f3yeyqJIUGakUKLCTR/VAwrnbpi9REc9Qmmr313+0gBuH/A+RxVMUB0K19Q4OS+r6w5TFBhbDODEu+RHiMdVxum8hrsEu5HL1x9giXlbww3B6adtEXiEmhV7iyoWKtG2qXp4PGYswk6lNZIul3cmoBpNlj7qXM68D8FdhzmpwZb/z4AqQNB93Pjf7lLN/X2fFrCL90e4/BDRvTGsuN+m0YIH513JUpaX+5EUeEC3Ju48oyNX+rzL2isybSEDk41KGn2nTdSh9aP5BmqvTj67PiMQ5Zq7ursdrqK2hYVj8IVOmsscDYZy84lm2ANzOoNkWCxl6csWauwZxEc92bIoFxdrE8lzgzInIrij1dLYajtT+MRuijvlwgfUCh+9iTmTK0p3t0JPXeR4KNtZcNYgjfzWOXeQfAU/AkJ6Rpvwx4eBSbKBVg3fzCmzy34XlILTg0tpCVQjP/CgbvmF6usuKjfkLnbYDIyMpx4QFpNiQXaX6S0X8Pqr0LmhTUhSAmPQmWsQtLGMkO4z7R4ispXBnkAupZFmezcDxZXgH/YYTt5TowK38IMNh+IB8a/+jpwdWQVvpXoOPPF2x13fLeLDfvHOOEUo69/qseNXgS1xAJwn/r/vcaqGqfeYxGEuD+K+rIIFPr0CltsLQc8/tqysjfIgkbOAcJIi5LiK44Ylf6K6MuzyoH7puN/dqfui3DQpZmo0Er5CJM/d5I/IF8sHVMAsqhn6FchJ7WIVcxHyEm9//5r xMAKVW9N Zc4tSujEaBnh8e9hnfKcOLbr2+N+Q56ZPuuyCP3Y43L/mb0j8BOUILl0sRolM3sRIJ5Xtzj6hkxjgsFlEzwSQMAyQB78WipDyZnY7beWbFpbgGr5H/hdJSXb/fU4RaeDepX+69EzH+zZf43wO6F0p1gT2SA== 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 --- v4: - const qualify struct ctl_table nommu_table 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 b3b87c1dc1e4..9813b5b9c093 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -4080,8 +4080,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 62a58e417c40..97f9abffff0f 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2031,16 +2031,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 baa79abdaf03..3c32f8b1eb54 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 const 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 Mon Dec 23 14:15:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaixiong Yu X-Patchwork-Id: 13918962 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 7DD6CE7718E for ; Mon, 23 Dec 2024 14:20:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8CA426B00C1; Mon, 23 Dec 2024 09:20:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 830316B00C2; Mon, 23 Dec 2024 09:20:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6C72F6B00C3; Mon, 23 Dec 2024 09:20:10 -0500 (EST) 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 4ACCE6B00C1 for ; Mon, 23 Dec 2024 09:20:10 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 01B46160E09 for ; Mon, 23 Dec 2024 14:20:09 +0000 (UTC) X-FDA: 82926432624.04.9AD4176 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf13.hostedemail.com (Postfix) with ESMTP id AFD922000B for ; Mon, 23 Dec 2024 14:19:30 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf13.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734963572; a=rsa-sha256; cv=none; b=oYcmlg+Ep44o58N2++159Zzez96AEyRa1pHwOqYMmag6oPrY2T3Ct3ol+YvXSWoNj8sxRu McYB5y2N1sOM8u03u0ADARxbHgPZftYYPDSLhZBo7rcFtQzw2APLAr3b0cw/UvPRn1lsGt S97B+gR4Zd2k6rRnhNWQa8jKc5Vdx0Y= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf13.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=1734963572; 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=Giw4aSA7nLP9q76arckZL69EH5cSA1K/X7FELVtRGE8=; b=2pgn9lU7fhnrm1VRi1/tPVdiKQlL0nOYBizdWQ5m9/+fBx4nsi8ncGGRK5m/ZET+Y19k0a y/0c8u/N4FsjorO39lGKFHRqBKAQUK43X8B6bhhh4IybMX+FZjfFxZWGwzuqMHz9R1ycwG bJNufgj9LRjK9Jbk1GTcsZn5BPKc2ls= Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4YH0Vf5Nw9zrRn0; Mon, 23 Dec 2024 22:18:18 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id 7E6C31800D1; Mon, 23 Dec 2024 22:20:03 +0800 (CST) Received: from huawei.com (10.175.113.32) by kwepemh100016.china.huawei.com (7.202.181.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Mon, 23 Dec 2024 22:20:00 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v4 -next 09/15] fs: fs-writeback: move sysctl to fs/fs-writeback.c Date: Mon, 23 Dec 2024 22:15:28 +0800 Message-ID: <20241223141550.638616-10-yukaixiong@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241223141550.638616-1-yukaixiong@huawei.com> References: <20241223141550.638616-1-yukaixiong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemh100016.china.huawei.com (7.202.181.102) X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: AFD922000B X-Stat-Signature: ejo7oaiantm3h854ym1g7caq9tay3j89 X-Rspam-User: X-HE-Tag: 1734963570-875082 X-HE-Meta: U2FsdGVkX19gzbKA/ggJthuJiD0XCPBOrXMtSmFgy+bYD+uiJEm5aWofrfyDJ1VQmFWK9xO5FTAuUJWXaUaB7khrGr59ObLbpmglbNF0/UVvXslDhwlzizfRvRDnofuvvsr/fo9GMgKbfOPuKs7W80kZI1r/VyVQKTkLuKtCtMgjC4meZAY3aXr4tcGLR5RYH0GhHMVKMxkThV0LrPhe2516oPUA/nDzSc1TJufNNdyIJ2z+QFkhP288Cq38UBmenVJxH8DDvqFfU7PVGA35lkQpu/9HXuLpukDkxCMUcrmJf7D/cYMIJNCfcHD1yL/gywlrZ1QFEKIXLn32TmYwteAHktxkocALAqq/CbAoTHbC1KGmvoAz/y4yEFyVGvyXaDX3qF45E6Ea41c0fCc8t3Vsm68yG+iIpGVBLAXeWiyRrJyxCcqKU39Fy0U+QqNgVvOm2dQaGvDaTQ4ZqQa59mifxFfq19ON607g/LPhmvtxMdUypw9UoeV7xX5petVSktm5exB39xmaPgAejw2uKEdgOXVsOBCJsGX7kcdxHD35MMb6CGoCwSbM63L0ez4v7cb9D93A48QmN3OumChNJR/CpbLop0TFa7Vo/+5ibumD5LIlgUGxmq26LLvkuBJ1sPlM76VlwCjhv5BsXJor7u57HVs5wflbVusQRovHP8C3/W9GV9i4r5ZVTrt4z0L9iWGIBztgAuZ7mVc2yXeCfmx9iENj+biGuJq6H6Lr4AP9qhsO/vh0TVCEoXTqzrBPWjXmwqE7JTVo9MZGZ61QX5rGdAt3lc3Bgc3/w4QztmoSeG3wJ3wAqDFnF/4am9bNj9yl/WleQb5cTK7CUnf+G+DrEQrXCpzv0pVw4y2E/UnDV8QYRZ4Qdr7voSWL7z63p8TcaDzq9ZsVAjRBGTsmaN9JpcJLgqPO+Gn+ejFRXU+uD/8bsmyYEKwiI+EK7/q858dU9iKMcm2Oo5Bsdo2 qTZw6fvw rGHHoxrXNE1bkH6R/98IdESOPyd18Ov/F1U6BwEpgrHSe/dvRL0EoC/hx9MqU+3dFzlCeUMXRtaRIoEYaOGGOsvJZYKadciZEEm0oDe4/shGZimTZMHPffNyR8gXcGyEZFB4sCOvZtemzZX3WYOBsnwkOf7jdrbJnPTdwg9xVjwZ61Bs= 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 --- v4: - const qualify struct ctl_table vm_fs_writeback_table 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 5980ac24c7a4..4f907e8dbfff 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) { @@ -2435,14 +2435,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; @@ -2453,6 +2446,25 @@ int dirtytime_interval_handler(const struct ctl_table *table, int write, return ret; } +static const 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 d11b903c2edb..caf4f0b12235 100644 --- a/include/linux/writeback.h +++ b/include/linux/writeback.h @@ -327,12 +327,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 97f9abffff0f..c5527f59e3f2 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2014,14 +2014,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 Mon Dec 23 14:15:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaixiong Yu X-Patchwork-Id: 13918963 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 429B7E7718D for ; Mon, 23 Dec 2024 14:20:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DF4C66B00C4; Mon, 23 Dec 2024 09:20:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DCA876B00C5; Mon, 23 Dec 2024 09:20:12 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C45096B00C6; Mon, 23 Dec 2024 09:20:12 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id A35A36B00C4 for ; Mon, 23 Dec 2024 09:20:12 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 63732120DE0 for ; Mon, 23 Dec 2024 14:20:12 +0000 (UTC) X-FDA: 82926432708.04.FEF9DB4 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf21.hostedemail.com (Postfix) with ESMTP id D30C01C001F for ; Mon, 23 Dec 2024 14:18:56 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf21.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734963574; a=rsa-sha256; cv=none; b=ZziOkADeDm6lqlGf2/XBfIY/A76zpkUVy8rNymhMvOUKasrCSRBj5e5YBPvFvm/Z4kByNm c7Nu6hHMd3gWplUPxdf526mROs6rYMTtT0wh8ZyEH32kZuiKGqD1A6zI0V85/WVjTKMwic j/WM4rduFpQSQRn0rld1Dn51M6LrMMM= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf21.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734963574; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=t1Coy0cpaf42368gn+/HEcB4evuE9OzA1O1eQ3WKeRA=; b=OC0pkVuTdJHHRptJtelft/rmUsy+30g5GtnTLWjTEN7v87vw7dzJbvpIdOxbQbXeWNBsVh PMiAaCRiIAKv+JVESez0oY1gjzXL/wKOXZ50fkZ2XThnAve9o3AxB7ghOtsO+FnZOaKGlu 19PR6+mZ/zNvBmIIOF9UKqQfgWVVghQ= Received: from mail.maildlp.com (unknown [172.19.163.174]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4YH0Ss0jx3z11NJh; Mon, 23 Dec 2024 22:16:45 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id A9EB8140391; Mon, 23 Dec 2024 22:20:06 +0800 (CST) Received: from huawei.com (10.175.113.32) by kwepemh100016.china.huawei.com (7.202.181.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Mon, 23 Dec 2024 22:20:03 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v4 -next 10/15] fs: drop_caches: move sysctl to fs/drop_caches.c Date: Mon, 23 Dec 2024 22:15:29 +0800 Message-ID: <20241223141550.638616-11-yukaixiong@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241223141550.638616-1-yukaixiong@huawei.com> References: <20241223141550.638616-1-yukaixiong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemh100016.china.huawei.com (7.202.181.102) X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: D30C01C001F X-Stat-Signature: pg5of7yj5ws3op7pnz7m9w35kcbtbd5i X-Rspam-User: X-HE-Tag: 1734963536-435621 X-HE-Meta: U2FsdGVkX18xe00wZ/MNR5QK8kds/nD5jRrJKick4A/nrRjsqczLcE5erdKZJGfEzuN0ivUiV71UqV7pqMmBNi154kN12VRoIBMzXyoyaHLEbU658/ZDZErI4i8Ae1/+AKx11nBcfTXixWh8X/bN0ny7KZMRO7A9dd8vH8tHCYMG6BNOYWUDXKtxJqk7xARe0aZIqz1/IqJilGZHmd9dchOfPty9q4unm8HNIPW0avaak5MSVGG2TCK+monkOvhQMHzdEIOLLbUqkgi1FIBGBeCgxjR3X9lF8tBI8wnjOWti0B/1KoTmDLaO6fnloMUG6Ur11PcUSKn2khTWuuW9hN4DRSkW39Ce2OUZbedz1c5m/NrTYmLeV9I5G7jVkyf9+WXxRg1JofCkjEsT3WkdDt4TZksvwqGViaYxa0kDlBJ8Im+OS7ypx/FqSOlCwjguPHb02cSQhZG0yJwCNzVbo10lPknS05z+amUFEBnKAUT+RvyTlKnpMUULKNVu0+1EkOVPSwupxlvU27vHrs20bLsWDPDfFS1q38h/R0th/Jr+lFlt+y6hwmYVeIDgEeGCOZgYKdH0KhSJbrvTfxckmL1Lqm0smS6AJZYl3FKJE1IYK/lJr2f2sM17FIqR9OYIz79pH1pbPyve9ljYrP3hCHVplwMjwgCYliYu882H99RdnaxZm5LC+SDZDgmhwFJhaP4ynE7VOKAzzJvWAHUlCfsT1n+T2j8HONuf9nNKaDobbEVLuPL25aN4E1EkxUgVBcUiFIYVuSMFf0vj9FHFNRKVlR2XqvfNnF+jCRcV+zHpAiAGZFdSqCXv0yZY9x7QmCBgUaTjL+yytwPj0Cf1M+D29DdOxlqqoH1/CmmnbKe4BeQXglXHGONe88VSpH94DsUeXjZiUsK2SOMpvNeyCMzAzZcjGbndui1b/1cyB72u5/zi7bjVO9TeOMOL5AjMG4CfE8b17B5tnm5LWR2 q+ivN5+K 4eDDVSrqeYV3aupN7G14JhNldhaqV8d1pbc0H+A4QSL1HC7cNzq7mHUVUwFQoMZ+lGc9Eo3DcNWyxcelCsBvGmMDbMYh8Wqx72xeHaF2zT62D2Qnwcb6CeXp567dlCud13b/fg9yD466Fvs6xkFfG51+Ib+qS0dioiaLB+by0s7M2xZ3ZhUZPZQVG3B/2w7iXziw/A0CrmQ0WvRKG43q3AEvC+Q== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: The sysctl_drop_caches to fs/drop_caches.c, move it to fs/drop_caches.c from /kernel/sysctl.c. And remove the useless extern variable declaration from include/linux/mm.h Signed-off-by: Kaixiong Yu Reviewed-by: Kees Cook Reviewed-by: Jan Kara Reviewed-by: Christian Brauner --- v4: - const qualify struct ctl_table drop_caches_table v3: - change the title --- --- fs/drop_caches.c | 23 +++++++++++++++++++++-- include/linux/mm.h | 6 ------ kernel/sysctl.c | 9 --------- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/fs/drop_caches.c b/fs/drop_caches.c index d45ef541d848..019a8b4eaaf9 100644 --- a/fs/drop_caches.c +++ b/fs/drop_caches.c @@ -14,7 +14,7 @@ #include "internal.h" /* A global variable is a bit ugly, but it keeps the code simple */ -int sysctl_drop_caches; +static int sysctl_drop_caches; static void drop_pagecache_sb(struct super_block *sb, void *unused) { @@ -48,7 +48,7 @@ static void drop_pagecache_sb(struct super_block *sb, void *unused) iput(toput_inode); } -int drop_caches_sysctl_handler(const struct ctl_table *table, int write, +static int drop_caches_sysctl_handler(const struct ctl_table *table, int write, void *buffer, size_t *length, loff_t *ppos) { int ret; @@ -77,3 +77,22 @@ int drop_caches_sysctl_handler(const struct ctl_table *table, int write, } return 0; } + +static const struct ctl_table drop_caches_table[] = { + { + .procname = "drop_caches", + .data = &sysctl_drop_caches, + .maxlen = sizeof(int), + .mode = 0200, + .proc_handler = drop_caches_sysctl_handler, + .extra1 = SYSCTL_ONE, + .extra2 = SYSCTL_FOUR, + }, +}; + +static int __init init_vm_drop_caches_sysctls(void) +{ + register_sysctl_init("vm", drop_caches_table); + return 0; +} +fs_initcall(init_vm_drop_caches_sysctls); diff --git a/include/linux/mm.h b/include/linux/mm.h index 9813b5b9c093..387f579a6c18 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3803,12 +3803,6 @@ static inline int in_gate_area(struct mm_struct *mm, unsigned long addr) extern bool process_shares_mm(struct task_struct *p, struct mm_struct *mm); -#ifdef CONFIG_SYSCTL -extern int sysctl_drop_caches; -int drop_caches_sysctl_handler(const struct ctl_table *, int, void *, size_t *, - loff_t *); -#endif - void drop_slab(void); #ifndef CONFIG_MMU diff --git a/kernel/sysctl.c b/kernel/sysctl.c index c5527f59e3f2..7fb77cbcc24d 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2014,15 +2014,6 @@ static struct ctl_table kern_table[] = { }; static struct ctl_table vm_table[] = { - { - .procname = "drop_caches", - .data = &sysctl_drop_caches, - .maxlen = sizeof(int), - .mode = 0200, - .proc_handler = drop_caches_sysctl_handler, - .extra1 = SYSCTL_ONE, - .extra2 = SYSCTL_FOUR, - }, { .procname = "vfs_cache_pressure", .data = &sysctl_vfs_cache_pressure, From patchwork Mon Dec 23 14:15:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaixiong Yu X-Patchwork-Id: 13918964 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 8726CE7718E for ; Mon, 23 Dec 2024 14:20:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B35606B00C5; Mon, 23 Dec 2024 09:20:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AE5CF6B00C6; Mon, 23 Dec 2024 09:20:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 95EEF6B00C7; Mon, 23 Dec 2024 09:20:16 -0500 (EST) 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 7522A6B00C5 for ; Mon, 23 Dec 2024 09:20:16 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 2B6BCC1815 for ; Mon, 23 Dec 2024 14:20:16 +0000 (UTC) X-FDA: 82926432414.30.9420A9D Received: from szxga06-in.huawei.com (szxga06-in.huawei.com [45.249.212.32]) by imf02.hostedemail.com (Postfix) with ESMTP id 249D780011 for ; Mon, 23 Dec 2024 14:19:00 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=none; spf=pass (imf02.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.32 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=1734963596; 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=nqyhYC9VHRbpINjzAU6rWoUpGKxiH+bHUC0qsLRtufg=; b=6eaSSAZWOzrSRVXg3yftXifi/Sn1qqodqqwVIznKMTbJaBxse1C+XEkhkpqs/aKP3mqref ot/KesjxRWJdvcGZvp7kyhQ/kpGhYFyk/B0DPSvFwSwC9WQOZpasPBcztdCA++mzT5W1M7 r0deEoGMHE2JDs0hhMEYL1Bu1KGmOAw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734963596; a=rsa-sha256; cv=none; b=Yy0I/9aZAPY4UMLL1QgjaacF4pvutz6+AIBLWIOqSp7ZpdX3NIlPKy1ALE0SdYKuAFugmz CuJp9F+QJgbD7xr8DdFube6FCsJlVFfEAyRqAg4328Xbp6xK88ILlI87TDRcmm3/3IjL8r OqOKLwkqtPWfMb4UQ/H866dxaJzrBtI= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=none; spf=pass (imf02.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.32 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 szxga06-in.huawei.com (SkyGuard) with ESMTP id 4YH0Y932FCz20mdY; Mon, 23 Dec 2024 22:20:29 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id E624E1402DE; Mon, 23 Dec 2024 22:20: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; Mon, 23 Dec 2024 22:20:06 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v4 -next 11/15] sunrpc: simplify rpcauth_cache_shrink_count() Date: Mon, 23 Dec 2024 22:15:30 +0800 Message-ID: <20241223141550.638616-12-yukaixiong@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241223141550.638616-1-yukaixiong@huawei.com> References: <20241223141550.638616-1-yukaixiong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemh100016.china.huawei.com (7.202.181.102) X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 249D780011 X-Stat-Signature: zwos7gm8493tqj8h4xdxx6a7broijdo3 X-Rspam-User: X-HE-Tag: 1734963540-792716 X-HE-Meta: U2FsdGVkX1/kkGEaHDRWV8e9mjkPcUSg4UB3r3iqgs7Cm/69C5c4thHFnGRgF7OUHJ1Er+fpj5TAP+PyAJ7ZJTITh+gyLF/h7Cg7XtgCBt5abwQGn34u6Bxbo4q+XUUYLDWQXzWYrPpQvhSKf5jYhVTkc6wycJCyBDy2FWLyPP3EZLyBAnPlixSe2q92n3c88zgyAoi9LS4jBxetRmjC2+2K4jwvT8h3YLNBDxMvqIQjuHEbxT1Uovx4YWAW2L7lqRFMi9s4+onw4ub76LApiLLUbNCnTbdGnvJ6t/5alGZEwfGxrs35ZoUwnvq2D5nw7J7MUtuwf+MusHhMKA3ITiNiTWV0D8YCqGxxIGDq/RIkx3Li7i1gg7Lh2ooDJKgGIRn3pPXS9auGkIN0QRyWt352cn0UfojqK3Xrx/LurS+bHuRhoMVC6gRo9P6P/D6uDJYhJqYsHpMWOV9NXmUqiIZmqe5ppRZQSPq6efM+SeuXH2HBeK0wdSHqc9eKinkbJqHjtRkRcMTv+m53Jhpd8O/yHwcoCqAP5EY8G7QTjigGAAYVq/5fC2b8DqX3cz65zVYfg/ZIQxDTjpvPy9Y0hoDUhVWFs9js+cPyg4WDjBhPlJiIzfXIOZg7amWY6b876u4xpFpc8wxnry8ZLauYk/ZgpJP9yG8kjwLC6FpFADyknBRXqlaeYTNOiUlwdYbRE6GHWWZ0AKVfeg4Je1wNw9kZ9PZtO/v2t8kkabezpuKitkmhpKzUpYPWLXwx69Mitp4BdZ0hwLpYx8SpaYvVGFeuN5vr7YhkESI3O0avSarB52mxVT/otKdoyo91M7U3f0QvSB/rYN/PRm8nJFcjoQf4D19ixUy7qdlY9CV6Chhtews6ptzoQvndDTUAPO0MXGMWkQZaaM1s2cuWav8QMGj+tXOUtXuZXXQhrdc9uMxmbWute1Z3oLFSHGyDottaaG9c/Det+aSGxssY1uu t3KC/5zE dkBPTtza2vW63BXJBdBtOZU3CT2CPb7vF1b5QeNYfczJUVoDqs4lv2IAJ136uziwT1KcD3eA8JAaNoXCrN6aNS2tj9CO0eKdRmYo0J5+SmpAJCHhpYGDqSM9itk4bfkBSbZpTyOGP1vWfRp/Kd2VjRkRhSVEvC/QSGAdmJU2HH7rg7OHCs3mmmcmdOpSDVSHaxvVurNbTZzr/AJlsnaNvo7GGve4n6/VuDRjdo5wYEWB58NE= 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: It is inappropriate to use sysctl_vfs_cache_pressure here. The sysctl is documented as: This percentage value controls the tendency of the kernel to reclaim the memory which is used for caching of directory and inode objects. So, simplify result of rpcauth_cache_shrink_count() to "return number_cred_unused;". Signed-off-by: Kaixiong Yu Reviewed-by: Kees Cook Acked-by: Anna Schumaker Acked-by: Jeff Layton --- v4: - Simplify result of rpcauth_cache_shrink_count(). --- --- 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..5a827afd8e3b 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 number_cred_unused; } static void From patchwork Mon Dec 23 14:15:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaixiong Yu X-Patchwork-Id: 13918965 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 B7A4FE7718D for ; Mon, 23 Dec 2024 14:20:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EBB6C6B00C8; Mon, 23 Dec 2024 09:20:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E68036B00C9; Mon, 23 Dec 2024 09:20:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CB9EA6B00CA; Mon, 23 Dec 2024 09:20:19 -0500 (EST) 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 A2EA06B00C8 for ; Mon, 23 Dec 2024 09:20:19 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 45E5A44589 for ; Mon, 23 Dec 2024 14:20:19 +0000 (UTC) X-FDA: 82926432624.24.3934508 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf12.hostedemail.com (Postfix) with ESMTP id 2663B4000F for ; Mon, 23 Dec 2024 14:19:59 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=none; spf=pass (imf12.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=1734963577; 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=iG1btJ1mUTZm1Q/QXF8tiuwQRU5p8WJAy3Rzeg9lzIU=; b=ElCpcOtOF8C5tffGRRfsF8TFf4sMlWwEWJmYF79t/o1579pGHPvZzop2fzjyi8U/Fzim+e 83KlfQUDP9dn0Z1qcCGsoUQp9MEfTEX1SfVi0lhkZPwpPz3m/onU022cKK3jvB092w+NzW NeSVjLdRUi/bFt5A9HcBkrj+yDIwLDk= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=none; spf=pass (imf12.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=1734963577; a=rsa-sha256; cv=none; b=4VPGUf7+cnGYJsgJD3h+N/BGshi7ty6MlIE1NZZPMVLVVt1nLKCffxL0iF0r0DLsG3/7M5 d0SgS6NIAldyvyXRh1uf5KVlwrvX5D+xQ/ZaIpAjRQj9hfxlYlu2zxhkf9fBkPNJD/ARZ5 ZjGzGBERGeJhJ9drZ/BNxRk5gtWIB0U= Received: from mail.maildlp.com (unknown [172.19.162.112]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4YH0Tl6qjgz2DjPQ; Mon, 23 Dec 2024 22:17:31 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id 2DAFF1402E0; Mon, 23 Dec 2024 22:20:13 +0800 (CST) Received: from huawei.com (10.175.113.32) by kwepemh100016.china.huawei.com (7.202.181.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Mon, 23 Dec 2024 22:20:09 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v4 -next 12/15] fs: dcache: move the sysctl to fs/dcache.c Date: Mon, 23 Dec 2024 22:15:31 +0800 Message-ID: <20241223141550.638616-13-yukaixiong@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241223141550.638616-1-yukaixiong@huawei.com> References: <20241223141550.638616-1-yukaixiong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemh100016.china.huawei.com (7.202.181.102) X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 2663B4000F X-Rspam-User: X-Stat-Signature: spqppbgrp6fwgwrxmsofc6939zcnwobc X-HE-Tag: 1734963599-253223 X-HE-Meta: U2FsdGVkX1+fj6jr/K+645Rz5KIsgXpMKuIeIrKfUUnMTsWckbrmUrVKaX3Z+QCT4liBktok+E+rvfIyBkIMDHUg+mN19RKI1A3YvmAHyN34KhQTMuxwYBHtPNQj0/bK4AJFNXE2AQSo5mFObVCJFdmZCvqlzY8IhVIR04d+MKwJ0UhZfFzL8c4jo4vLEO6BLEtIDUf3x4QSdR71e1Dou9O2sgZA13g3O8Tor+LyN4b+SF42XdHS1jmFEIlUReWDhk3oNH5Hw0FfVxcdmT8H9kk5uHCsVXA/6mH6/Nzg9btRa2n4V44l5w0aaV1YZYg3KalE3tfUwzhnMuMIScTRX2dCaX5ohXd2MuWqP72oFyg7cyL++p1WHSWu83gfmoJQXDpoh2VLk5xBTdpoz2HxiJQaLszFayvxPFzzPqnlIyn6sTm5TQSP1Pg2PBzMmgrjvdKtZmhoN5NWVIJG8JveGH0xHCoa9cqp7I1Nda0//L4whLtYl5/ewoldY0Y39nqT7eJoXBJoYvqQ3A90gmMWxbSED4tBAT80ZevOMZb8DHf/KyFzrL+Y7Kr7ndLPaElvDB8G9UxHS0vh3F38sp7tbOxCg+TN8glhDlYm1QhS+glPovIi5bo4zWWJbug2afUbjfQMGhFf9uN1cXxZN6nYbJEniqydBrCKXeXr4R67IBkDEGOv8Z8BIwJAlrreKGm+QDaP2sbw+B56Deybf6adkWS0VSEppTMPHOZIUUCl511dOthKdGwLfyTykEJ7qZlIHJIiTxA84NdQ7G7zbq6IH2LL3hglTzPoEdjhiOCi+rEFaQ4MlTT2jrIeyAXTP/59rEnPETMOiLA+rCbOKpL9svbhV0vJGUtHkoXrSn22eq1KnJukGkrdht0H7cOHqyA7GJ4A7T/n4twdfRvh/IApcOF9gB2/DrwFNUII8GOuQmVu0EccGn3GBckX+yCz0JCucJ/Jkf88Q9pFXJmYQ5d lrFIpSJJ WCnA06aZpqcuTcirlXjxn4g85v5ST9GvF/nShs1M0mimQxxLsOUpL6wV9PgM/itRUHBpsLwc9bYO78Kj/8wsR5oD4UYpGGmm5NOgeXSpCi+SxhX9CHQeGXXNNtQDaCoBavcMT6Cp0Xn8s7ZasB3JSa6EC7+0/3rLgVitp0w5B6f6Gz5Y= 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 --- v4: - const qualify struct ctl_table vm_dcache_sysctls 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..77ca6e9bb71e 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 const 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 7fb77cbcc24d..860dea8f1587 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -46,7 +46,6 @@ #include #include #include -#include #include #include #include @@ -2014,14 +2013,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 Mon Dec 23 14:15:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaixiong Yu X-Patchwork-Id: 13918966 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 B9FBDE7718D for ; Mon, 23 Dec 2024 14:20:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AC4676B00CA; Mon, 23 Dec 2024 09:20:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A72596B00CB; Mon, 23 Dec 2024 09:20:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 913DA6B00CC; Mon, 23 Dec 2024 09:20:22 -0500 (EST) 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 677106B00CA for ; Mon, 23 Dec 2024 09:20:22 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 154BF80EC3 for ; Mon, 23 Dec 2024 14:20:22 +0000 (UTC) X-FDA: 82926433128.04.FB2EB0F Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf11.hostedemail.com (Postfix) with ESMTP id AB1EC40008 for ; Mon, 23 Dec 2024 14:19:44 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf11.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=1734963591; 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=XVAP2YL/LcT7j+M6fgTBY91P4QxjGaa6nQWMftrtHB8=; b=vtUe5KA/U6IHy7euIfBwZsj4iA+Wv18B5W9JRsTRBLQYlZhhbtVVFEprDXHZB0fUAkxC8q I3EA40UdeGUkBr1Go4pxuc9oWPJ5WHmtXtQwtAG388r0TT74s2YD97UIqOYitipoVHmjZU R1PjZEAtwRH4ERbci27QrN4etI4z0U0= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf11.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=1734963591; a=rsa-sha256; cv=none; b=KXggV5Gq0e7v5JChB5G25k6988x3Ni3FZbCwoCfe6OyEgILzAvdSa492JA70/M3mCFQMOM 5Izcu/uhMk3rs5TtxK6WFHVwJfQOYVKgC7HlilC76wNWIe2Gp0C7LX9shixTRbFh/GtkTw kQkhIuG8FOmFDa+knp5NkxQ9l1WVvAc= Received: from mail.maildlp.com (unknown [172.19.88.163]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4YH0Tq2xVNz1kwqP; Mon, 23 Dec 2024 22:17:35 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id 6ED25180043; Mon, 23 Dec 2024 22:20:16 +0800 (CST) Received: from huawei.com (10.175.113.32) by kwepemh100016.china.huawei.com (7.202.181.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Mon, 23 Dec 2024 22:20:13 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v4 -next 13/15] x86: vdso: move the sysctl to arch/x86/entry/vdso/vdso32-setup.c Date: Mon, 23 Dec 2024 22:15:32 +0800 Message-ID: <20241223141550.638616-14-yukaixiong@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241223141550.638616-1-yukaixiong@huawei.com> References: <20241223141550.638616-1-yukaixiong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemh100016.china.huawei.com (7.202.181.102) X-Rspamd-Queue-Id: AB1EC40008 X-Rspamd-Server: rspam12 X-Stat-Signature: dsb6uzoaomndgk8mqsgw9ri7gaf3z9wt X-Rspam-User: X-HE-Tag: 1734963584-872440 X-HE-Meta: U2FsdGVkX1+Ixmg/GAByhEOWz+cSx8aCJFe6vzLGx5aHZYforeb5gfiEe8/t4vVehLpxqZfX08W0rKiLZehufG0JCEUWP1P1LmQvf0sPpbqUU53N553gwq8GRtnDX162WbLt23TWN/jg5BaVa2Dgd1PAD/9RwQxKfnh9QfaYZkASaRLWfuLkKcD0YUo6S/dt7MhCAgmuNppAxiy9zgs6bIcaRqGz6a/xJIvyivmc17WAu3U2sfVOle1gsB1W6HGbkemHuh5FGlCAA+FBYxuYikDdtVi+nxYCWTIsXU0OHnHqK1oTHDMYLqw3Xqk37FujJBhWrtHNOASjowzrXL2KpG4wdckR5p15OtbmCydtegJ+dP0Lgxdi9qalo8nUBlFWAI3+5CanLGD/PIDpnvBcplsY8XUQD1V+1y7mof+WSwjH1s2njF2gFReMG8NUA7KCdJLYpPPYUe+xpZ/MyVTvqsVwWl7mZUwB/IMnGGdBwMHlO+aRmo8vY5RiX5Hfb6HUhE3ayQ9X0sTL5roonB7Xt1o2G7m+2L4oi7zs+QqSrDgCyM2YenJu5nLjZP3Y3epHuNRXtM7XfJstfRZHHWvgvuEm5hXa3ppmnlGGvqkXEjfeAL/8cktZeCCUbDXVksiRLFRFqLj40QDxITekR6ISBaxqpi66UVt55KKNKLvfNBBlvAJlCudM1CG8ra1MzBSEGiO6XgBaY2V3224DZtPfgNjV0ArXO5tYa+jBDcLxH4/LK0YBZbsImyuuzWOcpZQQ4t7Y8IyD8tqe4BDRXXh/AqDfqs8BhzJRpgZ2htaYaDGw6BoHiQ/VV3kExXiPAe8tC1MLIuZxZ3VjbP0Pv//MRJgCpgV8kvXP6moWODNyaEOr6nm6Z94JLMtK7gOsh5RusLFJV5ikDe8bd/vzNWjldLVEf7jEQP9taCUPVVPKkRL0IIhtsZHT3b6F7zigtwGbE++fC2UW25UvDDs90S4 Plb1otmY aGGE+1h3YAHatog+d38vLlRxfgERCIUvnNw479qXcrUXUXPOQAUxqNI07DgKWV6zJKwQ96xCOrvDeIxUR+9OLomiXJm4Z30cT+ocpwFG+t1iy4iJObb9k/RyjbHwe7pq1nfjwTQ+wOPqmvs6ZOglQgqVPFi+w4X0kOdgSIfKl10rRApk= 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 --- v4: - const qualify struct ctl_table vdso_table --- --- 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..f71625f99bf9 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 const 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 860dea8f1587..7ff07b7560b4 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2013,17 +2013,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 Mon Dec 23 14:15:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaixiong Yu X-Patchwork-Id: 13918967 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 87589E7718D for ; Mon, 23 Dec 2024 14:20:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AC4A06B00CC; Mon, 23 Dec 2024 09:20:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A70DE6B00CD; Mon, 23 Dec 2024 09:20:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 873776B00CE; Mon, 23 Dec 2024 09:20:26 -0500 (EST) 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 649156B00CC for ; Mon, 23 Dec 2024 09:20:26 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 2C7E6A1790 for ; Mon, 23 Dec 2024 14:20:26 +0000 (UTC) X-FDA: 82926432582.07.CBCF92D Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf27.hostedemail.com (Postfix) with ESMTP id 13C6E40010 for ; Mon, 23 Dec 2024 14:19:41 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=none; spf=pass (imf27.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=1734963588; a=rsa-sha256; cv=none; b=wAdGwyhcP0fo0m6cjag4rzLG8EW/BRRBhLOBByiqxNqg/NPPR8TKGWVDgNAnL3sACSCZ3d x8wk5bQhlK11ui/llTDYTd0GGCgPRduJJoN/Td0F26pmr+5Ur0OPJFKZUfj+hbmN6J4uuf sbkTwpCcRi7h95QfcCOFiKq0jLfuPo8= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=none; spf=pass (imf27.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=1734963588; 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=gIV2P9qgOzeX6vIBEmCKcWS42kXvq88UpPmzYlQq5r0=; b=BDGSuCEeP+1xcn6TmNp1sYMBrny+h6jvDln7iBLnjZMM5Tv9O/j6nJQZd3FfvZRaVPAe3p hsohorjpIAEPbttdVt33zPU263zKV3IX+Ho9/nP21bsK6N56uOXBNdBBnmMJwAXW9orITR XaxZM+zN6GvkMeRa2orabkoNaxMRCWY= Received: from mail.maildlp.com (unknown [172.19.163.174]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4YH0T62Ssrz1V74N; Mon, 23 Dec 2024 22:16:58 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id A0242140391; Mon, 23 Dec 2024 22:20:19 +0800 (CST) Received: from huawei.com (10.175.113.32) by kwepemh100016.china.huawei.com (7.202.181.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Mon, 23 Dec 2024 22:20:16 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v4 -next 14/15] sh: vdso: move the sysctl to arch/sh/kernel/vsyscall/vsyscall.c Date: Mon, 23 Dec 2024 22:15:33 +0800 Message-ID: <20241223141550.638616-15-yukaixiong@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241223141550.638616-1-yukaixiong@huawei.com> References: <20241223141550.638616-1-yukaixiong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemh100016.china.huawei.com (7.202.181.102) X-Rspamd-Queue-Id: 13C6E40010 X-Stat-Signature: 7wofiwhf3atmcyhxe7xbrq5hgpp6q81g X-Rspam-User: X-Rspamd-Server: rspam09 X-HE-Tag: 1734963581-638076 X-HE-Meta: U2FsdGVkX1+l4PaGbxG5dsIzln7ggpJLaQ0evtyLCeXI0M/zC2w0wrVc/fqa2jZpzSDYE+xcGoK1f3YA0GgYOX7ZBD4G8Hi2893Lr/EBcDHUucKY5YcZ1SP9LWuenpVVZTwbhjXCnQejwSywswdWn6H9UzTUVmP//WUFzt9NH1cSYJY2O/5QF0pxtg4TBqq1mFxhSFs7YkgN/UOjqsAcijP5r3eFmO0YTVxkmJ+RbhNSCG71A4m1wH6Qn8ej4xFMKUYgJ6CVPcMEbGPvv8rVaojh6p08jU9pLcukSA0OgUsUb797Lp4FEv6livAFKec/CEDg1kCsFcPxibyPVeq+XGfh2ts5dNSy4kUt493Y3yO/BAPzXIijHISwpUSdgQUrpoxhlbppzMrsoyspTBnxkFnkdY99Ez9GMZ/gosvvmuc5CdawsDQa/EsyrOngIw7WlbNcED3QR1yh3juFSDMIA6LhvvYX50CtaGqnE5lgibYyALjABPpbuJN0ZJrJ2uQ1DmOtF1nsT8OWXuGwBPgi5WDuopY8ipylvV8be64/OpOEaTwGIgYwXCtEfHVPqEhNW4oYL07yhfhN5XDdczH5vE1C4av+HWnQQsZ7ShXN22RNKHvfEx6pufyxqzQclLG5qNH+P8mXmiPyp6DfnSz34iCzgxEaq1uL7SUgCwQ7A0j0cL/WndeF0peoQyYT7nlfs7W+6ND+JdqDjEkAbLGO7Cvu9qN/xyKJYKLoQ5iH9ZS3Qeq9F4bvNoEgdqdT6ZlsYyy72XtIxfyC6aQdTbfC2ZsReGQVzo18sNBazucTo5SLcaQHWlr/gukNUT6FUXviGnxwgO0dYE1WaB1Xo4ZzHMqmgMXlc61/Ck5yOMGrwadWX8H4Qfmm595OwIS1JvnSi8fFANUech4xcnV6LTlT/is5AodWsewW58ujRNW3a6aWt+dUklgFjvDAaoRT+Kw62yq6PoT7rMtohZZStqn 1Ud5WPqM HSUDPxhEiP6rAWuHgcIR5NUmpd1Fknfevad9z90o4V/ppvqe1jvGX2bXVRDo7JvSPEzvEC1Gr6ENDWkMrbWAQHyyhuRuFeciIYNjHDaWuaW/cLbwFdVKj1oZMGe07tGao++JGl02iYoWcQvBh0sOoTakp0jpXIV0//hdL 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 --- v4: - const qualify struct ctl_table vdso_table 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..898132f34e6a 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 const 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 7ff07b7560b4..cebd0ef5d19d 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2012,23 +2012,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 Mon Dec 23 14:15:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaixiong Yu X-Patchwork-Id: 13918968 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 5ED4EE7718B for ; Mon, 23 Dec 2024 14:20:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 124D36B00CD; Mon, 23 Dec 2024 09:20:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0D5226B00CE; Mon, 23 Dec 2024 09:20:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EB6006B00CF; Mon, 23 Dec 2024 09:20:28 -0500 (EST) 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 CA80F6B00CD for ; Mon, 23 Dec 2024 09:20:28 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 8B668AF3AE for ; Mon, 23 Dec 2024 14:20:28 +0000 (UTC) X-FDA: 82926432624.06.FB2D202 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf07.hostedemail.com (Postfix) with ESMTP id 5D6A940014 for ; Mon, 23 Dec 2024 14:19:23 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf07.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=1734963591; a=rsa-sha256; cv=none; b=E58cza23ID/IxOoEojXJUpCX/TxvoW16Nf6/P0o6XPXAZtH8Yegz5O5wdJepSa1zoAbFsH QhTwZNNNeIQhtMwFSDMMuMeqiQU9byutGEn3+us6ce7lfXYFq+KNDMhURd8WlTmSQy6BNC R71/WLicOfYRxbOX+riX7klGQDj271Y= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf07.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=1734963591; 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=q5iUf9alx8fXV8NL64WVHdOdYqCO9Dar/iei9FgYKlU=; b=2h6yWwgnmy/kyek8+sxRlcteNClzwARsrvTTC/cH7lInwxeDo9XHWRUMQmFTrMNkabT07m c6KnjoowE7HKblIsbs3ZBTIFlO3TJWQJSupuRj/atC8HTMJ9dYucHL6x7ICpr3+1MKYGSZ uCN1z739yrzLrBjbRbs8zOvbmX+RNcI= Received: from mail.maildlp.com (unknown [172.19.163.17]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4YH0Tx66Xlz1kwqQ; Mon, 23 Dec 2024 22:17:41 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id DB2F81A0188; Mon, 23 Dec 2024 22:20:22 +0800 (CST) Received: from huawei.com (10.175.113.32) by kwepemh100016.china.huawei.com (7.202.181.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Mon, 23 Dec 2024 22:20:19 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v4 -next 15/15] sysctl: remove unneeded include Date: Mon, 23 Dec 2024 22:15:34 +0800 Message-ID: <20241223141550.638616-16-yukaixiong@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241223141550.638616-1-yukaixiong@huawei.com> References: <20241223141550.638616-1-yukaixiong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemh100016.china.huawei.com (7.202.181.102) X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 5D6A940014 X-Stat-Signature: 4uppbq6hx8f5t71giffi76s63hpe7iu6 X-Rspam-User: X-HE-Tag: 1734963563-820700 X-HE-Meta: U2FsdGVkX19QxTKoQ0zZgfcLp8JnirfPhoajKHMvrohQhE9znI46nN/IxcNiQWSZBvULA1n6AzSg+KVi/vyTX56Xy99FJ7RMuHiiHKMQ1EJMcN45jHLGKr9lKr+eJ1UemRUTrMtCjICYWjEDA4b3O0yrNv+iXhAAVEn+p6a/PyF4m+D++6tMaDqxjWxuyD2tzTwIew7EE8Y80WEX0wgDqYaT/xaK5II5f4VLXNn7ZOJD20OKg8bxoy2hFjngfniwl7QHiUvEVSZrvuMPlMdIYrVdafp8fmrjp9moR2BMhiQgLzuV1vKq8FZ+iWHW3+0Ic1B92g+hNtl62PpJTX3p0w7kwPbP4+aynhYvla6kkevDLYZ69vD5fCAQWwGtBZN4gdZz+lf/t/bAIK2lJyaB36I5ecyv9JZHGdtb2RmDpzHKaF3hwyaau3au7l2PY1fYQ0kak8g3oSMeya5WETrhUZlG09pqIX5iahugffUUaV9/Oz9BxsGZjIatqUgk2IpHjR4TOk5YGSkM+VrRm5Ac5DGxKOedk64OaVOJmicuGClpcy7uZMwQ1cmUxjgWeuSN0tptRcmsMBwxrlheL6LIwcG+DKNcwHZtalasTfo83oxYcgLBVNE7RwSP3W5cTsI7BiYgvn1b35tBlBdPD9902x87TIMDJXke1nezPAeIOZfjT6RgIDlloNpCpf6Y1FEYGM/FswCZuwN5CBWETst7tGDnKZ6Zh4WUurQ8dPB+FKkKo2NOGQMV5/7VQUVD7pmxZOC+xpJci0cHRMTeSspr9N9iOTctkFbiUocya4PdqUM2aW2UM3kJe287iKFcOKBoldhYEbx2mq28Y347embGJKvA4LtZMWdX7ff5GaBHkSMLL9gyHmjZJz6WY3ZhwgO4XEjEn3raL8/DlWRxWGWNdOyb+vU0ljAYjw7kmKSVUdbJapnhFZsJSKnQM6I+tLyqUgR0s0WcaOcy633WVeR 6CJgVsCA LQuVFkSonVo/QKisu9WlpECrhmhT9H6RwYJbofZNxnF5rKZk6JGgWRbLRRRKK01YpOvYOgARAAo5iyoyIyMTXwYun2ank5HiB+m7X3OZaBosxgpMXArfLfYRCmWJ51L8G5Dbyo9+Qg4gyJq1cEEU5Dj0lYjQLgE61j5rrZDb8h6gNRbk= 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 cebd0ef5d19d..aece984bee19 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"