From patchwork Tue Sep 3 03:29:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yukaixiong X-Patchwork-Id: 13787950 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 3F93BCD3427 for ; Tue, 3 Sep 2024 03:31:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5A6268D0127; Mon, 2 Sep 2024 23:31:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5565E8D0119; Mon, 2 Sep 2024 23:31:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 41E2D8D0127; Mon, 2 Sep 2024 23:31:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 2680E8D0119 for ; Mon, 2 Sep 2024 23:31:10 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 9759716010C for ; Tue, 3 Sep 2024 03:31:09 +0000 (UTC) X-FDA: 82522001058.19.DB94CF4 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf07.hostedemail.com (Postfix) with ESMTP id 1A82A40014 for ; Tue, 3 Sep 2024 03:31:06 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=none; spf=pass (imf07.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=1725334220; 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=1+uGiXQyelMEBDm1UN2avaaiQu1zwQexosIDFQPm00A=; b=32qHCruRbF+SgmZg9hLaGo0Bt10gV7EeEpAJqJE75YwXm6P96u0HqPgZjSrmdAXTPgfxh/ ifpk4VarPcd50MDOKBbrdu9AxQ+3APRDjFTyJSWpv3oa/TAf+2ukQJnnRiEZjiVEJzjBre BfwP6KzZ1rmBhHS8AGPI/DTo6OZ64rs= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=none; spf=pass (imf07.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=1725334220; a=rsa-sha256; cv=none; b=kkqDuukDaMEwOpwsPP5Dpo2RiAiCGrijCqLkkgrUP2Kdp7qUXbf1qOGSiQ+ybYQKmBI9Ce 2k7syTYF1DPL8FS3djKIDtSldlK/anSZAnneeDN7r3xla3cFvz8YwoiXmFL1qolMdLsf+Z cAhSpT4E369GR86Vf/IAUk1HdnrLaeA= Received: from mail.maildlp.com (unknown [172.19.162.112]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4WyWNh4sHnz2Dbj8; Tue, 3 Sep 2024 11:30:44 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id 505771402CF; Tue, 3 Sep 2024 11:31: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; Tue, 3 Sep 2024 11:31:00 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v2 -next 01/15] mm: vmstat: move sysctls to its own files Date: Tue, 3 Sep 2024 11:29:57 +0800 Message-ID: <20240903033011.2870608-2-yukaixiong@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240903033011.2870608-1-yukaixiong@huawei.com> References: <20240903033011.2870608-1-yukaixiong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemh100016.china.huawei.com (7.202.181.102) X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 1A82A40014 X-Stat-Signature: 6k97zbmbjud3gum9tm45k88zgqcuafrb X-HE-Tag: 1725334266-42096 X-HE-Meta: U2FsdGVkX1+bCw1CdCNr1rlFg45STO1BgRypocRlEUZ0tXJf+0hSWNWs1bxh1z29MFeEbQ39uAXhYR/+imHJAYI2mM6xzo3r04irWf0x4pAakUjpecnf9AZ1D9j0QhCojccsHhwYtgH1E1K+SFb4u5fx0ipH7k22ZCEsvRt7qouIdpl1NyTtAKOm7d6QB6T+669Hb+45aquwkDQtchRFvm0Ogw3X8GRiS+/J733D8OhgwM6xGwjO14/07ViYSUZ0poh6jLqH8k6UrpiMYivG5yJRuUR54j2SsAv+7WGgIXFNVHA0H1kMlNixrryj0fz5IeNRRO47rmIgFhsoCkyjETRvwME6gOcvQ9P37mJ6iJ4o2aNst7xYDUylLS0nG//Vmxlo4uHMvhzQmhk9oTgEGZXJRFqwLjXK3d+/nbGDJaTvgy9vTI35hbbUB5TwAOw3mTr3RTWfI39FBpcAqeiQ7P4yjAOMuqp+/jigWOdWc0ww5b4Cs4wjNj/t7iIlmYkkWYKiZ9Udz3eE1rdZtUY6UAyOkdIw6SRcNI6EBHmG3NFdb7gY1eDCt+MSASAhrU58hTf9ya4J3/7OOOoPaal6mhHhGo2huwKhOPVbFSyDXFME81a0cbloitw6tDA/jVXbkL+BvysKGe8Lf/9iWDdnkdOqlPJC8MaWGixiIGXvyxkUXfiMudzpk4kqLVm3CdJ+ctJfjI69/S2WkCc43FwWCgJZ4COOH/Kbmj2nGsyQXjcKnW2HW1sV//HHFHh4oY8U+DUNf/kwDKi83Aknq3cNIYVKRT5Ggx9cil+9iEdS6AiJkRmgpRofJRbw0ZypzerxOkHxDCiVVMWZotPqWbUNRxAowi6B1a6QGr7djijyIjRnYpSnTBa2AeJhESQ4Y9vgxg7e2jdLmBy1C+ced55kr5kIFwY/eLw6uQlmsMxG1CxKPDSvoye4heE5hi9QpALqcesk34izPzg1r143OCD tIVxaNFC attR4I4NVCjYCwo6TzcB89MUhd1TqNkhnS4lRrM7HBvan7pVRy7tarP/qx7FiTYhsxZ61dckT4xtG35EAjQdc/Ql6CHyaGfsSD1DuGiy2n4Otwc0nUPbRdPaHZF6JuIh7ocZqtFl4Jv0gNQu6wGvNhq7rae+mL8F5MuF7YKL9iTPO9fcMY6h0ALNSpluo+fRqH+clgT6iEmvujsM= 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 --- include/linux/vmstat.h | 11 ----------- kernel/sysctl.c | 28 ---------------------------- mm/vmstat.c | 42 +++++++++++++++++++++++++++++++++++++++--- 3 files changed, 39 insertions(+), 42 deletions(-) diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h index d2761bf8ff32..b2ccb6845595 100644 --- a/include/linux/vmstat.h +++ b/include/linux/vmstat.h @@ -10,15 +10,8 @@ #include #include -extern int sysctl_stat_interval; - #ifdef CONFIG_NUMA -#define ENABLE_NUMA_STAT 1 -#define DISABLE_NUMA_STAT 0 -extern int sysctl_vm_numa_stat; DECLARE_STATIC_KEY_TRUE(vm_numa_stat_key); -int sysctl_vm_numa_stat_handler(const struct ctl_table *table, int write, - void *buffer, size_t *length, loff_t *ppos); #endif struct reclaim_stat { @@ -304,10 +297,6 @@ void quiet_vmstat(void); void cpu_vm_stats_fold(int cpu); void refresh_zone_stat_thresholds(void); -struct ctl_table; -int vmstat_refresh(const struct ctl_table *, int write, void *buffer, size_t *lenp, - loff_t *ppos); - void drain_zonestat(struct zone *zone, struct per_cpu_zonestat *); int calculate_pressure_threshold(struct zone *zone); diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 79e6cb1d5c48..726b866af57b 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -49,7 +49,6 @@ #include #include #include -#include #include #include #include @@ -2081,17 +2080,6 @@ static struct ctl_table vm_table[] = { .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_TWO_HUNDRED, }, -#ifdef CONFIG_NUMA - { - .procname = "numa_stat", - .data = &sysctl_vm_numa_stat, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = sysctl_vm_numa_stat_handler, - .extra1 = SYSCTL_ZERO, - .extra2 = SYSCTL_ONE, - }, -#endif { .procname = "drop_caches", .data = &sysctl_drop_caches, @@ -2157,22 +2145,6 @@ static struct ctl_table vm_table[] = { .extra1 = SYSCTL_ZERO, }, #endif -#ifdef CONFIG_SMP - { - .procname = "stat_interval", - .data = &sysctl_stat_interval, - .maxlen = sizeof(sysctl_stat_interval), - .mode = 0644, - .proc_handler = proc_dointvec_jiffies, - }, - { - .procname = "stat_refresh", - .data = NULL, - .maxlen = 0, - .mode = 0600, - .proc_handler = vmstat_refresh, - }, -#endif #ifdef CONFIG_MMU { .procname = "mmap_min_addr", diff --git a/mm/vmstat.c b/mm/vmstat.c index bb081ae4d0ae..343735ab669d 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}}; @@ -1937,7 +1940,7 @@ static void refresh_vm_stats(struct work_struct *work) refresh_cpu_vm_stats(true); } -int vmstat_refresh(const struct ctl_table *table, int write, +static int vmstat_refresh(const struct ctl_table *table, int write, void *buffer, size_t *lenp, loff_t *ppos) { long val; @@ -2175,6 +2178,38 @@ static int __init vmstat_late_init(void) late_initcall(vmstat_late_init); #endif +#ifdef CONFIG_PROC_FS +static struct ctl_table vmstat_table[] = { +#ifdef CONFIG_SMP + { + .procname = "stat_interval", + .data = &sysctl_stat_interval, + .maxlen = sizeof(sysctl_stat_interval), + .mode = 0644, + .proc_handler = proc_dointvec_jiffies, + }, + { + .procname = "stat_refresh", + .data = NULL, + .maxlen = 0, + .mode = 0600, + .proc_handler = vmstat_refresh, + }, +#endif +#ifdef CONFIG_NUMA + { + .procname = "numa_stat", + .data = &sysctl_vm_numa_stat, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = sysctl_vm_numa_stat_handler, + .extra1 = SYSCTL_ZERO, + .extra2 = SYSCTL_ONE, + }, +#endif +}; +#endif + struct workqueue_struct *mm_percpu_wq; void __init init_mm_internals(void) @@ -2206,6 +2241,7 @@ void __init init_mm_internals(void) proc_create_seq("pagetypeinfo", 0400, NULL, &pagetypeinfo_op); proc_create_seq("vmstat", 0444, NULL, &vmstat_op); proc_create_seq("zoneinfo", 0444, NULL, &zoneinfo_op); + register_sysctl_init("vm", vmstat_table); #endif } From patchwork Tue Sep 3 03:29:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yukaixiong X-Patchwork-Id: 13787951 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 B7380CD3429 for ; Tue, 3 Sep 2024 03:31:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 225B58D0128; Mon, 2 Sep 2024 23:31:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1D5358D0119; Mon, 2 Sep 2024 23:31:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ECCAB8D0128; Mon, 2 Sep 2024 23:31:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id CC7968D0119 for ; Mon, 2 Sep 2024 23:31:11 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 841E4AAB6A for ; Tue, 3 Sep 2024 03:31:11 +0000 (UTC) X-FDA: 82522001142.06.76ACE33 Received: from szxga06-in.huawei.com (szxga06-in.huawei.com [45.249.212.32]) by imf24.hostedemail.com (Postfix) with ESMTP id EA0EE180003 for ; Tue, 3 Sep 2024 03:31:08 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=none; spf=pass (imf24.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=1725334174; 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=k643HuXqRo/qlFx0br9juOBCyLvqt/UZbp11IW/33Zs=; b=bHeYEsQ1an41ny4SR8E4EFiQOVStbwGMr1tDrrAAyHfdRJSORmS5lI/AbpEU1auuy1yMyE 1835QhtPqaMz/fH6JixAPvpQJkfCQo/5eW4GgN/QuxW7D+7iK68g02l8lvrhEApXB3rgMy O8LzqBuyyM8YldukcnbGG3poR8e+uj8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725334174; a=rsa-sha256; cv=none; b=ewFZAopcKFGYScf5tR98+28WrjHzpkwSY5Q0JGIytS3R6yCN2Pgu3l7gpWrVvrWGtyv1Q8 mBBKlXqUvZa8Ia8hx63CQNoxJebJYZII/vt/eUMzwTRops+E+gqZcOCigRt4wgS0cgeWSa 9eAdgT7Hf+ZpojDX71g454VjyWI1mSI= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=none; spf=pass (imf24.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.88.163]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4WyWLn4hysz1xwsQ; Tue, 3 Sep 2024 11:29:05 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id C9B1F18002B; Tue, 3 Sep 2024 11:31:05 +0800 (CST) Received: from huawei.com (10.175.113.32) by kwepemh100016.china.huawei.com (7.202.181.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Tue, 3 Sep 2024 11:31:03 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v2 -next 02/15] mm: filemap: move sysctl to its own file Date: Tue, 3 Sep 2024 11:29:58 +0800 Message-ID: <20240903033011.2870608-3-yukaixiong@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240903033011.2870608-1-yukaixiong@huawei.com> References: <20240903033011.2870608-1-yukaixiong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemh100016.china.huawei.com (7.202.181.102) X-Stat-Signature: k4ks4naeo7c59pbn6sg4n9cxnnm9k4cz X-Rspamd-Queue-Id: EA0EE180003 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1725334268-225218 X-HE-Meta: U2FsdGVkX18u+XOF0gaNfhORFS19e8a56WK+7CaHjon39lCZD4oiUQnvCYGWEhoy4sasZWk/c+csPvWDPknd32AJf6FEhksusB1o6rhj3uqwu6XKXIG1hFo/3RCb6TUivavCLzOP3qCysXtpUgmQ5T3AaZlRx2IqUfQdtJG8XPZrUfgqv50gZ13ikzCbqPlHUdTNn+e5UNqX+nY07+K65jdYv7ZmvJW6bo5yImCaWvmWmjGY3QvEX9XIks0LaznWlgc+S6o0pQPLYg+R3H3AomLqbVr0vnvwKigFHy5jp//GlC2CtEyRha8XKzp04cm5HKPJHOpAZToeix+QqCmqenmCZmeyPqwNVS9h8fyaOIS5arxHeQcyFLvTVTOd3YjvVWyObr/rM5d47e7dhqkWqUmy8gI8+sxm/Ivc2UDisC++CR3Qrmg2nbRsTlcqaaIYcL1TccKEnpbUDP0QhPUZ9sqE6/njkEIAYJ0zo5mLpYo6kZ3+tl5BSo7QXiTVC229kH5GNZZyK8j+AtxvTbBg78Dl4ht8FslyKR/fAqB4b+N/UMYSqxb7yXNRvr7DtfB0GIAEZbltEiJSqlXlXR0e3dlmJYpohYDPMdy7zfF3Pzit7cRVjstkUv6puGN6v8neIL7h4GpTnp3G4syCTjy9fJ4MM+wNAuGSJDLKMwphoGXCb0K7h1NSIEHFEg94NGqhFB0fcNXPaeMKuG06omxU2/4meYHKhrTjD3vDG59eWBf31B4WtfLM2tcKocz3MJERGHMCbqtkjLJ/+CqzBJaojbb6g8SdtGWVkAEphNb9g6E3DYTYsP4O1wXl8RAqBhU1jMyDYJn8qZinHPauNlMZQq0y7JtPxHaooTi4df4ub88AQ30ooFg7swVxqGgJeg/wfSK+VQJduSXVVl8Q9CAVFBLucRJFBFvBYJTgf7Gtjrv6naE92fyapZqI8YueaALSWur3zef9FijDqEXHEmE 5wFuaEFi +23gSiUIrR8NGVLtilaACrnf+puJ6eiHlwoisuAm77LUIxCnRJMJ4Q3tG5UfAl3t+W9/HcvfAKCisaaj+8a0DS8mVn6qK/3rK7/qOo/lqdjHLTwH0Ia/XE4rXpPS6mz7e+qlPNn17qd95X9nPNDGtVEqOlrdTPw+0JKqR 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 its own file, and removes the redundant external variable declaration. Signed-off-by: Kaixiong Yu Reviewed-by: Kees Cook --- 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 a7c74a840249..ca196ba1e2d8 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -39,8 +39,6 @@ struct user_struct; struct pt_regs; struct folio_batch; -extern int sysctl_page_lock_unfairness; - void mm_core_init(void); void init_mm_internals(void); diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 726b866af57b..2a875b739054 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2089,14 +2089,6 @@ static struct ctl_table vm_table[] = { .extra1 = SYSCTL_ONE, .extra2 = SYSCTL_FOUR, }, - { - .procname = "page_lock_unfairness", - .data = &sysctl_page_lock_unfairness, - .maxlen = sizeof(sysctl_page_lock_unfairness), - .mode = 0644, - .proc_handler = proc_dointvec_minmax, - .extra1 = SYSCTL_ZERO, - }, #ifdef CONFIG_MMU { .procname = "max_map_count", diff --git a/mm/filemap.c b/mm/filemap.c index 065d130c1c07..98e36e2b7290 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include "internal.h" @@ -1069,6 +1070,19 @@ static wait_queue_head_t *folio_waitqueue(struct folio *folio) return &folio_wait_table[hash_ptr(folio, PAGE_WAIT_TABLE_BITS)]; } +/* How many times do we accept lock stealing from under a waiter? */ +static int sysctl_page_lock_unfairness = 5; +static struct ctl_table filemap_sysctl_table[] = { + { + .procname = "page_lock_unfairness", + .data = &sysctl_page_lock_unfairness, + .maxlen = sizeof(sysctl_page_lock_unfairness), + .mode = 0644, + .proc_handler = proc_dointvec_minmax, + .extra1 = SYSCTL_ZERO, + } +}; + void __init pagecache_init(void) { int i; @@ -1077,6 +1091,7 @@ void __init pagecache_init(void) init_waitqueue_head(&folio_wait_table[i]); page_writeback_init(); + register_sysctl_init("vm", filemap_sysctl_table); } /* @@ -1224,9 +1239,6 @@ static inline bool folio_trylock_flag(struct folio *folio, int bit_nr, return true; } -/* How many times do we accept lock stealing from under a waiter? */ -int sysctl_page_lock_unfairness = 5; - static inline int folio_wait_bit_common(struct folio *folio, int bit_nr, int state, enum behavior behavior) { From patchwork Tue Sep 3 03:29:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yukaixiong X-Patchwork-Id: 13787952 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 60603CA101E for ; Tue, 3 Sep 2024 03:31:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A8ABA8D0129; Mon, 2 Sep 2024 23:31:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A37F68D0119; Mon, 2 Sep 2024 23:31:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 902688D0129; Mon, 2 Sep 2024 23:31:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 5D7B98D0119 for ; Mon, 2 Sep 2024 23:31:14 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id E92B9C022B for ; Tue, 3 Sep 2024 03:31:13 +0000 (UTC) X-FDA: 82522001226.29.E4B89D6 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf03.hostedemail.com (Postfix) with ESMTP id 8487420006 for ; Tue, 3 Sep 2024 03:31:11 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=none; spf=pass (imf03.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=1725334248; 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=QuLI0KDHhsT4Cqz+63KC1p0e4yof9oOpzKduwhM9ndg=; b=MlKL/NdGTTBwgX73GZcS02TiRkVG+20adkWHtCrnkOTxe9ikeyTERJd7EjUnUd6iodqB6E sXTCwBZs8KmB9axH1FxUVLShs6TdbHKulGLoMEonxvyQY/VeSM5gUCZrjalKOKsdf/7gZW kEmEgIqnylRVmxMG1QyWTVT4wcm9krY= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=none; spf=pass (imf03.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=1725334248; a=rsa-sha256; cv=none; b=F6K98YR86DocQgfuV6UOpqsa7tDcwIdsiJyUH18gLAPJSONWY5LJEHMSXjXpMvAf2ACHpi cUm6GLHMnzmMsUfAjkMKSf4csnGMQAaEVDjY9vJ52JW+1kVm9pAhNaHzm6+g0/rytEelv3 udNBUnWtCDHxq//eXaLSHXZuWC7uXsY= Received: from mail.maildlp.com (unknown [172.19.88.234]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4WyWHS4qH9z20mjM; Tue, 3 Sep 2024 11:26:12 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id 4B0F51402C6; Tue, 3 Sep 2024 11:31:08 +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; Tue, 3 Sep 2024 11:31:05 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v2 -next 03/15] mm: swap: move sysctl to its own file Date: Tue, 3 Sep 2024 11:29:59 +0800 Message-ID: <20240903033011.2870608-4-yukaixiong@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240903033011.2870608-1-yukaixiong@huawei.com> References: <20240903033011.2870608-1-yukaixiong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemh100016.china.huawei.com (7.202.181.102) X-Rspam-User: X-Stat-Signature: cye1dpxbyrpsopety4kfn197afnt3r4s X-Rspamd-Queue-Id: 8487420006 X-Rspamd-Server: rspam11 X-HE-Tag: 1725334271-793341 X-HE-Meta: U2FsdGVkX18PQR+YKznN1Jxute8cfASaQrfo2KyCuF6FjHxosSRkkiaJGPLmN2Q3AMblLhTcaldOWWmixWxDr141G3UCo8nJZJpdpbo6Pm2sAIdbWPlbvF/cYYMq0oWdTZ5vOrxwUSkZT7dgStMnQcOFrsmhYSdVrKLmegLXZn4RPGJ7zZzwRdEKt3sBm3hy1YKv3jirGn1+SiLxCdAZSqn9WyZGGH9slmWLojakgOAEaHl7M9j3sYOo9LQ+SZntSL1oAW7grsltD3yNOBkYLYLoflgr2dRXz0IuD5/pCxvzHytdnsWX/X462tx5/4VelgPbj7JyeasV061dpFeFa2BDgLT8SBX/EEMZYAIClNTfW4hnKXVsc+OutcP/mJhkXoIvwZC/5N1zmS79bbV05uh9ZotjL4DvV1Q2J1ThQDctSy8RkLDr2sOOp8g9T8a2yF6YG4CZJdsdeKllvHJI7LWQeSra0mDrBHWhksciNEOPzl84sW2ZB68o96m1vZzUWYMNeXXSlC5LrbSHus0wzaA7aIondCR6XhPJMcCwAK+0KQV3H4Z4SggCThGPPKGSFoAmx+I0q6tokafh1gTcW5QQWy/rrzhMTDZJq1iBn7CYCCDwX3kVNPGuAbQeO/bTUTgXH0gbOogF9sbjbc6hFi8DULfE3ShSCH251D7Ql1qp7QrqiANEtBvWbXe8eZLPdoKA623JWeuOaME2KKpddTGTdYcXARGJVGhQvb2ar0AGWSFBtH9KtSs4sK+HtbdfKjdVaXpTyKuDmuPZyRMhUYthRQRgn1tubB/jpUjyWS5hcWwSdhTS6FY1L+acl8X9i6Ccx4S3sfAwSqKKKaWHAG5Bi4hURtKSB3GCbW9WRHmhNf6syPcAidQNEU2TLtk7UF98llzxaExTgRbqGflkmeF7usBvuksNmlr8dy1BsCDh6nwJTYablr/FdiWP13Y3dNj8Iyx+pCLFHgU3nLs 4/wldpBd YSWcf0iDB/WkRmI3KdjsZKzL9/OQyXSwTFT6WD6kHXh4x2Atu4Gt3cLp8KNsY1SLivT+bufqdcfu7nYWYJ2E7tBGGiiCHyTyrUZ6A2UqhfqUduxpRoD+E8T61L4Z1MAklJ65HgwKhz0kjlCOIwAZOPwsdCwTVLgUpF6Z1vsFpvJBg41c= 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 into its own file. Removes the redundant external variable declaration and unneeded include(linux/swap.h). Signed-off-by: Kaixiong Yu Reviewed-by: Kees Cook --- 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 ca196ba1e2d8..99f3c84652d8 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -75,8 +75,6 @@ static inline void totalram_pages_add(long count) } extern void * high_memory; -extern int page_cluster; -extern const int page_cluster_max; #ifdef CONFIG_SYSCTL extern int sysctl_legacy_va_layout; diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 2a875b739054..9fad501311a1 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -21,7 +21,6 @@ #include #include -#include #include #include #include @@ -2054,15 +2053,6 @@ static struct ctl_table vm_table[] = { .mode = 0644, .proc_handler = overcommit_kbytes_handler, }, - { - .procname = "page-cluster", - .data = &page_cluster, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = proc_dointvec_minmax, - .extra1 = SYSCTL_ZERO, - .extra2 = (void *)&page_cluster_max, - }, { .procname = "dirtytime_expire_seconds", .data = &dirtytime_expire_interval, diff --git a/mm/swap.c b/mm/swap.c index 510573d7e82e..07cbd55938e8 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -45,7 +45,7 @@ /* How many pages do we try to swap or page in/out together? As a power of 2 */ int page_cluster; -const int page_cluster_max = 31; +static const int page_cluster_max = 31; struct cpu_fbatches { /* @@ -1089,6 +1089,18 @@ void folio_batch_remove_exceptionals(struct folio_batch *fbatch) fbatch->nr = j; } +static struct ctl_table swap_sysctl_table[] = { + { + .procname = "page-cluster", + .data = &page_cluster, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = proc_dointvec_minmax, + .extra1 = SYSCTL_ZERO, + .extra2 = (void *)&page_cluster_max, + } +}; + /* * Perform any setup for the swap system */ @@ -1105,4 +1117,6 @@ void __init swap_setup(void) * Right now other parts of the system means that we * _really_ don't want to cluster much more */ + + register_sysctl_init("vm", swap_sysctl_table); } diff --git a/mm/swap.h b/mm/swap.h index f8711ff82f84..7283593a0d4a 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 Tue Sep 3 03:30:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yukaixiong X-Patchwork-Id: 13787953 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 0BC1FCD3427 for ; Tue, 3 Sep 2024 03:31:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D25C28D012A; Mon, 2 Sep 2024 23:31:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B726A8D0119; Mon, 2 Sep 2024 23:31:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A131D8D012A; Mon, 2 Sep 2024 23:31:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 873598D0119 for ; Mon, 2 Sep 2024 23:31:16 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 46917120379 for ; Tue, 3 Sep 2024 03:31:16 +0000 (UTC) X-FDA: 82522001352.28.529DBDB Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf16.hostedemail.com (Postfix) with ESMTP id C7697180009 for ; Tue, 3 Sep 2024 03:31:13 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=none; spf=pass (imf16.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=1725334226; a=rsa-sha256; cv=none; b=0IW3KjdsSRKtrjVhJsHC1RHKr39w7tf6EV6FbQOQLP0pAhTli2cxGg3HC3d4xTGl14b89t 3cn4P7UpR3aPWKELiK/r8byRY30j0TiHYb+D7Xqq3hzRxvR65wph3cPJhIHSsOHk6/wYks ToXEyppUPBDtA4GWnQuwd8yqoYtxe1M= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=none; spf=pass (imf16.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=1725334226; 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=dPZ4B66OrpxX1lXvlzW3vSo48wGUSKYJIM1Kmd147qI=; b=cyN+Yd85ddgYVkUujdPGhutftwTj+HuceOcOYXjWXVlRkjNt/AsOkGUUX/jY7QtgiMr436 L8CcpAaAjNNIqF8YgB8wQNtvkFDLKe7e8bSXXFBbWCArRQ1pcp9jufDmt6fZ32UJdLx5pY q2TPtUv3L49wrTo9pOg/K7GeXz4b+r4= Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4WyWNr1FM9z2DbjD; Tue, 3 Sep 2024 11:30:52 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id CAF761400D7; Tue, 3 Sep 2024 11:31:10 +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; Tue, 3 Sep 2024 11:31:08 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v2 -next 04/15] mm: vmscan: move vmscan sysctls to its own file Date: Tue, 3 Sep 2024 11:30:00 +0800 Message-ID: <20240903033011.2870608-5-yukaixiong@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240903033011.2870608-1-yukaixiong@huawei.com> References: <20240903033011.2870608-1-yukaixiong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemh100016.china.huawei.com (7.202.181.102) X-Stat-Signature: ocgz5w9548gdggf6kktuez3nw75h3hqr X-Rspamd-Queue-Id: C7697180009 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1725334273-156854 X-HE-Meta: U2FsdGVkX18FFR9WiUyrT/tRpnGZIdCBPH7YcsnX8rqEaf6UI3IjsWr6i5LA7i+ldMwGBTVdNayde84f/hHP8TZFYES20qa0l7lLu1sQ9O6C/AA/VfN4fnvG+NsoHBDafdYz724cg/fhtcLeE5bj1zdr1ZIeHw2k2Gx8/NU/4fv2BP8iRMo7hZ9Khrgb5jZTwcOETCiFct0nFQaobF5Kx0bBgUDgDp0Q15iBcUImhXKpZGwY40XhGHbOKw9nzxygvPIZ+C2qKSf+U0ic+pJd2FcL/pu9KU+cuL429D80SC/Lq8i69AEHIrjHW+0i4Q1So3pkxXTOFclg88RgVu2uVB3VTIuxRkNwxeNGFrW9TaDZlXfHMHYR9zX5a8pG+tDlG5XxgI2lMmxCWQhFcP95EuRMZvLHsk6K8gYgP5nYA6LLSKkzkceHl981ZxgvHpea4sMw5+W87iw50KBWS2oPDQ//T6nsMItU4azP3wPoFGgeLYETVjmbLRxespCf72FUupCgmN4pIOrY4WRMSbWZ/0UzSSXrBzWu7w22RSsg+sKXllforOPWKP7Ed7f1BSGGEDHQca5SBe1ZR0GJxxHGHxI6Ju/tjC4zWnJIAQllGGuvLGqrZhLRqbgJXa3h/eTHAxyVG/fDL/FgJEd0sbSRUPN89wmBqjRau6qz59iA10rEhs7AR/cs2bgxcRICzo/+upi2SLcM1sCiKFu49ZMggpm+9q+lI0bN36KhdqMZfvkvbRnQM0aRjoy532J0Wi0g/LjNa4IvJLw1cQ2hTzd5juyje2tdmMjfq8fEfFhDUsiW9+YixDr06ctycnavkkFd2OI7jzuyGj7huVQKym4TWkr84girQzHuHt8vzcWG2dYJVBv8x94Wkr0aGi45y9pZK49gjHj8nTRx0rE0mfrOeR5r/JSDRWmiv9Jetzq++HuIqe04ATyDer3Asb78YY60IwwNmHJluEVlwSBUVVR rVFmMzAv nOoZbbM58qQkORIT1K0zPQUQvTekPktok18EtPhUP71kdiF9uxmVTUx33kEpHj3RCZIMPt6QiwitTx97m1eA9yjSi53mKo/sPAb0x2DNOTZK/s4g9qISHYtUDNIqwMeY0PA+TvXbOub4GoS6v+liP/tRQMU9hXF66sezJVPx7mVq4JQA= 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 its own file, 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 --- include/linux/swap.h | 9 --------- kernel/sysctl.c | 19 ------------------- mm/internal.h | 10 ++++++++++ mm/vmscan.c | 23 +++++++++++++++++++++++ 4 files changed, 33 insertions(+), 28 deletions(-) diff --git a/include/linux/swap.h b/include/linux/swap.h index ca533b478c21..c95fb8d87b05 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h @@ -425,19 +425,10 @@ extern int vm_swappiness; long remove_mapping(struct address_space *mapping, struct folio *folio); #ifdef CONFIG_NUMA -extern int node_reclaim_mode; extern int sysctl_min_unmapped_ratio; extern int sysctl_min_slab_ratio; -#else -#define node_reclaim_mode 0 #endif -static inline bool node_reclaim_enabled(void) -{ - /* Is any node_reclaim_mode bit set? */ - return node_reclaim_mode & (RECLAIM_ZONE|RECLAIM_WRITE|RECLAIM_UNMAP); -} - void check_move_unevictable_folios(struct folio_batch *fbatch); extern void __meminit kswapd_run(int nid); diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 9fad501311a1..184d39944e16 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2061,15 +2061,6 @@ static struct ctl_table vm_table[] = { .proc_handler = dirtytime_interval_handler, .extra1 = SYSCTL_ZERO, }, - { - .procname = "swappiness", - .data = &vm_swappiness, - .maxlen = sizeof(vm_swappiness), - .mode = 0644, - .proc_handler = proc_dointvec_minmax, - .extra1 = SYSCTL_ZERO, - .extra2 = SYSCTL_TWO_HUNDRED, - }, { .procname = "drop_caches", .data = &sysctl_drop_caches, @@ -2117,16 +2108,6 @@ static struct ctl_table vm_table[] = { .extra1 = SYSCTL_ZERO, }, #endif -#ifdef CONFIG_NUMA - { - .procname = "zone_reclaim_mode", - .data = &node_reclaim_mode, - .maxlen = sizeof(node_reclaim_mode), - .mode = 0644, - .proc_handler = proc_dointvec_minmax, - .extra1 = SYSCTL_ZERO, - }, -#endif #ifdef CONFIG_MMU { .procname = "mmap_min_addr", diff --git a/mm/internal.h b/mm/internal.h index 44c8dec1f0d7..482e63d70d96 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -1029,9 +1029,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) { @@ -1043,6 +1047,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 a9b6a8196f95..b736fa322935 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -7373,6 +7373,28 @@ void __meminit kswapd_stop(int nid) pgdat_kswapd_unlock(pgdat); } +static struct ctl_table vmscan_sysctl_table[] = { + { + .procname = "swappiness", + .data = &vm_swappiness, + .maxlen = sizeof(vm_swappiness), + .mode = 0644, + .proc_handler = proc_dointvec_minmax, + .extra1 = SYSCTL_ZERO, + .extra2 = SYSCTL_TWO_HUNDRED, + }, +#ifdef CONFIG_NUMA + { + .procname = "zone_reclaim_mode", + .data = &node_reclaim_mode, + .maxlen = sizeof(node_reclaim_mode), + .mode = 0644, + .proc_handler = proc_dointvec_minmax, + .extra1 = SYSCTL_ZERO, + } +#endif +}; + static int __init kswapd_init(void) { int nid; @@ -7380,6 +7402,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 Tue Sep 3 03:30:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yukaixiong X-Patchwork-Id: 13787954 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 8A04CCD3427 for ; Tue, 3 Sep 2024 03:31:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 312D08D012B; Mon, 2 Sep 2024 23:31:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 299338D0119; Mon, 2 Sep 2024 23:31:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 13EB08D012B; Mon, 2 Sep 2024 23:31:19 -0400 (EDT) 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 E80258D0119 for ; Mon, 2 Sep 2024 23:31:18 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id A80FE401CD for ; Tue, 3 Sep 2024 03:31:18 +0000 (UTC) X-FDA: 82522001436.12.D03F096 Received: from szxga06-in.huawei.com (szxga06-in.huawei.com [45.249.212.32]) by imf17.hostedemail.com (Postfix) with ESMTP id 51F8540008 for ; Tue, 3 Sep 2024 03:31:15 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf17.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.32 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725334183; 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=SwRNGbfpwMbdyyvPRdQcI5dR+jj2JDC8mynWoyw5ybI=; b=Xk1FIVJG41zCJEKw5rXcyxueh6Y3ewBLE3kipw1bnNHc3lsDJDkj03/H3pnWRWZZFCE+bX cbU8jlz3KKzejC19uJgiPr37jSB4QYyPJfZx4tA5IjWPoNCU/6oEeaRI+Jl4QkVVb5taLe JZ1AAfF+cHrraTqCVMzw/YoAXG1Y1ss= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725334183; a=rsa-sha256; cv=none; b=HZ5N9lowDczU/m/TYJ2aVMj6KcFfRi6hrdvPcwB+lMN/ViCl+FAoGUuf/W1HfwzHHMrkeu pFn5oPEfcQ+0CgmolrF0+vnddbr5q2uYIxI6I6Jyq1E6UXSgQ1bioWimcmy9LC3auQ7WDG yMp6NKIIO6oCt+mz/+iimbfMTszIL4s= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf17.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.32 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com Received: from mail.maildlp.com (unknown [172.19.88.234]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4WyWLx1BsCz1xwrl; Tue, 3 Sep 2024 11:29:13 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id 55E8A1402C6; Tue, 3 Sep 2024 11:31: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; Tue, 3 Sep 2024 11:31:10 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v2 -next 05/15] mm: util: move sysctls into it own files Date: Tue, 3 Sep 2024 11:30:01 +0800 Message-ID: <20240903033011.2870608-6-yukaixiong@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240903033011.2870608-1-yukaixiong@huawei.com> References: <20240903033011.2870608-1-yukaixiong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemh100016.china.huawei.com (7.202.181.102) X-Rspamd-Queue-Id: 51F8540008 X-Stat-Signature: afy3twy3twqxr55cnerixy168ympeedq X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1725334275-215260 X-HE-Meta: U2FsdGVkX18Po70sBwkSrSIWA4083dw3aAbzLm2tLRGzQw3TQorfiXapgKtY5+SC5du31h6GMoLrFURXNno1JCwtEiOGv4Lt3j/U5lPCWWuBI8mOSHY7Q19cdKslljVemRUaXghOlUeYzq2ah01Z4cVBSMxFuO6O7ul3YhAj6TbjLeBbvxtou9FkBkQWN5yEcCITUHeBpn+9XV39DH7LZlUZ2bGZUHNzxYHJ8cyZsBd7rOhJRDVKFClSPIHOGG9ajGkq4JxK1co8b4m9Oamooji9M0oGK8LQLzrNMmkQ1R4/ALFKChr74aMWS5pbT0aGfHNc+jDq31hSWJa06f4HG4IwCsTfaDPBGwo0Ust0aSrteT8Mt9MyMnLkDN9iliNru/tlQXIWkFWimQ2CPVuDP+P8CjY2TcHt1BeyQB1fXLHYNoHZVuAvjh1ViTUEtItyp7ZyoTuUQI4xm5TWdPH5mtLAbZo1c2gLUl2hhJ6SY6MO3Ne95qKI5WrZOr/V7q7ph3PpOUjvG1GZs34afuEVn4XMyJzWllWlnfKVGkBFTHU5dEsqm1razIjVw0Y/KDxuQ0S62EyuwBUS4gU0tZ8FL20pFJXYUrTIoGyM/So7c2TpwUkH1/vyRn7Lowo1oYtbcl3Q8WcVaAfLHUjnsSVNwi2nm5zfyScJrWrCf4zCC+hBv9VKYTth9uq0z5XYpXI+PXdzWMqmjsN7a0kKZvw1mM08twvRvm45/aeWIjGmydDEZFwbr/ntAgjYK3zUn3cRoiiNOlHW162fRr9K/7QUanLAQGFu4Gbgt3oE5892iVtz4z2z20l7r/hi3bmPVMZS5jVXXJRCIRNTSZnjx9LaLfiY4DFICQo/FndwUeC67gyBEf7gDeKw9ZKyaZ4Ak+nidsLhAp/z+vwNOXwNZnmkQ5Bx+A/E7cd3zKDBXnnrOL4lpsnx3XlUOr/adCcfYeWIQ1TZ6x2kp61hyX4MRtZ younDl2C ge/PQY9DhoXRO2ULqO2iPJagRQZyXuDz/ZxmTKBWE6TQWyl4I00e7NRklGqUrrc3MXt+6qa+Fvft3W5hd1bfnnwAFqjnGzbo0CTM04SbJ59va3YDG3BmKAjnX0xIAIJgZkGhO0XE7vrM6Ws0jXYwwuEXNVwJD+g+24wPbssK9E2cNRNg= 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 its own file, 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 --- 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 99f3c84652d8..93ae80146ee2 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -200,17 +200,6 @@ extern int sysctl_max_map_count; extern unsigned long sysctl_user_reserve_kbytes; extern unsigned long sysctl_admin_reserve_kbytes; -extern int sysctl_overcommit_memory; -extern int sysctl_overcommit_ratio; -extern unsigned long sysctl_overcommit_kbytes; - -int overcommit_ratio_handler(const struct ctl_table *, int, void *, size_t *, - loff_t *); -int overcommit_kbytes_handler(const struct ctl_table *, int, void *, size_t *, - loff_t *); -int overcommit_policy_handler(const struct ctl_table *, int, void *, size_t *, - loff_t *); - #if defined(CONFIG_SPARSEMEM) && !defined(CONFIG_SPARSEMEM_VMEMMAP) #define nth_page(page,n) pfn_to_page(page_to_pfn((page)) + (n)) #define folio_page_idx(folio, p) (page_to_pfn(p) - folio_pfn(folio)) diff --git a/include/linux/mman.h b/include/linux/mman.h index bcb201ab7a41..e62ef272d140 100644 --- a/include/linux/mman.h +++ b/include/linux/mman.h @@ -58,8 +58,6 @@ | MAP_HUGE_1GB) extern int sysctl_overcommit_memory; -extern int sysctl_overcommit_ratio; -extern unsigned long sysctl_overcommit_kbytes; extern struct percpu_counter vm_committed_as; #ifdef CONFIG_SMP diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 184d39944e16..ad3ac6f6c808 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2030,29 +2030,6 @@ static struct ctl_table kern_table[] = { }; static struct ctl_table vm_table[] = { - { - .procname = "overcommit_memory", - .data = &sysctl_overcommit_memory, - .maxlen = sizeof(sysctl_overcommit_memory), - .mode = 0644, - .proc_handler = overcommit_policy_handler, - .extra1 = SYSCTL_ZERO, - .extra2 = SYSCTL_TWO, - }, - { - .procname = "overcommit_ratio", - .data = &sysctl_overcommit_ratio, - .maxlen = sizeof(sysctl_overcommit_ratio), - .mode = 0644, - .proc_handler = overcommit_ratio_handler, - }, - { - .procname = "overcommit_kbytes", - .data = &sysctl_overcommit_kbytes, - .maxlen = sizeof(sysctl_overcommit_kbytes), - .mode = 0644, - .proc_handler = overcommit_kbytes_handler, - }, { .procname = "dirtytime_expire_seconds", .data = &dirtytime_expire_interval, @@ -2133,20 +2110,6 @@ static struct ctl_table vm_table[] = { .extra1 = SYSCTL_ZERO, }, #endif - { - .procname = "user_reserve_kbytes", - .data = &sysctl_user_reserve_kbytes, - .maxlen = sizeof(sysctl_user_reserve_kbytes), - .mode = 0644, - .proc_handler = proc_doulongvec_minmax, - }, - { - .procname = "admin_reserve_kbytes", - .data = &sysctl_admin_reserve_kbytes, - .maxlen = sizeof(sysctl_admin_reserve_kbytes), - .mode = 0644, - .proc_handler = proc_doulongvec_minmax, - }, #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS { .procname = "mmap_rnd_bits", diff --git a/mm/util.c b/mm/util.c index 4f1275023eb7..27ae0365f5f7 100644 --- a/mm/util.c +++ b/mm/util.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -902,14 +903,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; @@ -924,8 +927,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; @@ -960,8 +963,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; @@ -971,6 +974,54 @@ int overcommit_kbytes_handler(const struct ctl_table *table, int write, void *bu return ret; } +static struct ctl_table util_sysctl_table[] = { + { + .procname = "overcommit_memory", + .data = &sysctl_overcommit_memory, + .maxlen = sizeof(sysctl_overcommit_memory), + .mode = 0644, + .proc_handler = overcommit_policy_handler, + .extra1 = SYSCTL_ZERO, + .extra2 = SYSCTL_TWO, + }, + { + .procname = "overcommit_ratio", + .data = &sysctl_overcommit_ratio, + .maxlen = sizeof(sysctl_overcommit_ratio), + .mode = 0644, + .proc_handler = overcommit_ratio_handler, + }, + { + .procname = "overcommit_kbytes", + .data = &sysctl_overcommit_kbytes, + .maxlen = sizeof(sysctl_overcommit_kbytes), + .mode = 0644, + .proc_handler = overcommit_kbytes_handler, + }, + { + .procname = "user_reserve_kbytes", + .data = &sysctl_user_reserve_kbytes, + .maxlen = sizeof(sysctl_user_reserve_kbytes), + .mode = 0644, + .proc_handler = proc_doulongvec_minmax, + }, + { + .procname = "admin_reserve_kbytes", + .data = &sysctl_admin_reserve_kbytes, + .maxlen = sizeof(sysctl_admin_reserve_kbytes), + .mode = 0644, + .proc_handler = proc_doulongvec_minmax, + }, +}; + +static int __init init_vm_util_sysctls(void) +{ + register_sysctl_init("vm", util_sysctl_table); + return 0; +} +subsys_initcall(init_vm_util_sysctls); +#endif /* CONFIG_SYSCTL */ + /* * Committed memory limit enforced when OVERCOMMIT_NEVER policy is used */ From patchwork Tue Sep 3 03:30:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yukaixiong X-Patchwork-Id: 13787955 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 79CB0CD3427 for ; Tue, 3 Sep 2024 03:31:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B01A68D012C; Mon, 2 Sep 2024 23:31:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A3E3F8D0119; Mon, 2 Sep 2024 23:31:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8B30E8D012C; Mon, 2 Sep 2024 23:31:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 688BD8D0119 for ; Mon, 2 Sep 2024 23:31:21 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 2ABEF1A0185 for ; Tue, 3 Sep 2024 03:31:21 +0000 (UTC) X-FDA: 82522001562.18.B5AC1CB Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf04.hostedemail.com (Postfix) with ESMTP id BDF8440005 for ; Tue, 3 Sep 2024 03:31:18 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf04.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=1725334186; 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=iPwFQaf7WCoscfpZNLzYQ6t8U+8MAHfLgeNyODJjFyg=; b=RP/FLCMvegul/ufQpartCNc9nXZe8S/az9zfbEmaerrqBg2MVwf7NBqUNNEhlUaja76ZQG Xj9v2i2bmjNVcDB8u0J0k7KL5Az+s/uDPTk/7CmYfBh391DC2BStmRz2JQKJ/dUNXra55n 1MhET+4NvQg99r2/b6E0T5yUV/lDAC8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725334186; a=rsa-sha256; cv=none; b=gnZxXvH2uW9/nAL7sDx6xhs3P7S2TmtSbcXvXekdc6VfBCOPt8OH9Ftr/LJhnKihHPI4y7 7ossEkyPhulfLRIu7sANhDysNtbc5q6tPSmyQUl73ju3jgO97XhBWmlgoR6iC4zDqo7GHi Is2eUdPzUu/KdbTjxlfDI9lFLxOb4nE= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf04.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.190 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com Received: from mail.maildlp.com (unknown [172.19.88.163]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4WyWHc1xTJz20mjS; Tue, 3 Sep 2024 11:26:20 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id DA1AD180019; Tue, 3 Sep 2024 11:31:15 +0800 (CST) Received: from huawei.com (10.175.113.32) by kwepemh100016.china.huawei.com (7.202.181.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Tue, 3 Sep 2024 11:31:13 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v2 -next 06/15] mm: mmap: move sysctl into its own file Date: Tue, 3 Sep 2024 11:30:02 +0800 Message-ID: <20240903033011.2870608-7-yukaixiong@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240903033011.2870608-1-yukaixiong@huawei.com> References: <20240903033011.2870608-1-yukaixiong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemh100016.china.huawei.com (7.202.181.102) X-Rspamd-Queue-Id: BDF8440005 X-Stat-Signature: phrnsyedz1owpbm94hwa4d7ja9zkec7x X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1725334278-627421 X-HE-Meta: U2FsdGVkX1+DQMqVXKS1i3s7o3WWimy2ojyLgw4cYBw747c1H0iRVu71+FdjT4OsgXkrNA3BzsAR+YPbQpxzvauEPrWI1BH6njKbjF27s67hK/60CFj3svAjsDYNb1yT04Q8T32Cedt+pUQiIE3kbAG/VBI/aIJ7Uz2zwTaZSQWKjCK//5T2jmOFHgfKZ8uxOrFRKmytK8ZlGQqGC2PnF4Geq8XQd/ZknybVPYJOJKwfvbtjwxltp/0rdInogNLhkG9k0UqEobVWuT2viVaF5qoAYQdR4Am+6cYMvRaElb5cvdazEaH/+MDFn9mRi7T4/LxYt3zrMvqM4pzSC2mdfWGj0ItxGELL18MPSFugWyMF/XjoUGBwKd61gMTF1SCXX2p+nrVM657fA8DOgX/RQ0L2rDtETKuKBgCskK5XD7v8Aa2F6Vd3VG/YvgEJZFEsYxnZvu9ke1PRyumTrXf7dLNIFWWcA16QqDlmKn4FCDstOpf3zjaRsucSiqeiGNtJLDxhPIH6+F/wnfKE6RfJCQaHTVvZFcwunq/16zSXo+BFWBZxdIL6CurvOxeU0NI3Zbop5Mw6JV4qp3jJekW7ZBovcpIZ5ecS68kZxa77AH4ZImvVkvtDMWW0l2c0enZnWikNL+TE91snyN9h4jJ55d72oEw/Z4SSVyUYTlwBMPwH7wW7pjBEg6TZJ8vb5eoC1XAlpLhjz97b4mSnmKnu2oXLntB8uEagdadm8P2/IhU/CBUEaXfCI7Nn1kWArBLmCvMhzZBO6/yKp4tsCShVq5gVSgFlRiDGxWLyZ+jfXXVCuXgOiUi5i6fhUgkpzkEA4fbqRMXVf8QrhPgUR6Xy+Sej2ef2j7pi+snRKfmozy4KYLBmesbqEjQuYdGQRJYAwguESZgdn5m1aMnRX+fbv0Tfm7Kw4egvb+fCYz71HIs7CDHCgqj/CqEKRnBSFsnWnZoGmz3TQlTqfIlFIK1 vmdwGxhM h4TeKZZ6hGkSWMKtqjTE2DiB5ve6AE6nbIAyX2Choh65HdgjjJyS4rYuD7V9MkRM69Y+w4NZWvPzwi993p67UOXFrZ0loYznZ/jQkJ+uNkeBe/dOXtF3x3jt3M2VaYXfY3g8mRfrcXBjuj+a4CSbdZc4ONH8vqsVAaGQQbBZrih2r3Jc= 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 its own file, 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 --- v2: - fix sysctl_max_map_count undeclared issue in mm/nommu.c --- kernel/sysctl.c | 50 +-------------------------------------------- mm/mmap.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 49 deletions(-) diff --git a/kernel/sysctl.c b/kernel/sysctl.c index ad3ac6f6c808..41d4afc978e6 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -127,12 +127,6 @@ enum sysctl_writes_mode { static enum sysctl_writes_mode sysctl_writes_strict = SYSCTL_WRITES_STRICT; #endif /* CONFIG_PROC_SYSCTL */ - -#if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \ - defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT) -int sysctl_legacy_va_layout; -#endif - #endif /* CONFIG_SYSCTL */ /* @@ -2047,16 +2041,7 @@ static struct ctl_table vm_table[] = { .extra1 = SYSCTL_ONE, .extra2 = SYSCTL_FOUR, }, -#ifdef CONFIG_MMU - { - .procname = "max_map_count", - .data = &sysctl_max_map_count, - .maxlen = sizeof(sysctl_max_map_count), - .mode = 0644, - .proc_handler = proc_dointvec_minmax, - .extra1 = SYSCTL_ZERO, - }, -#else +#ifndef CONFIG_MMU { .procname = "nr_trim_pages", .data = &sysctl_nr_trim_pages, @@ -2074,17 +2059,6 @@ static struct ctl_table vm_table[] = { .proc_handler = proc_dointvec_minmax, .extra1 = SYSCTL_ZERO, }, -#if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \ - defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT) - { - .procname = "legacy_va_layout", - .data = &sysctl_legacy_va_layout, - .maxlen = sizeof(sysctl_legacy_va_layout), - .mode = 0644, - .proc_handler = proc_dointvec_minmax, - .extra1 = SYSCTL_ZERO, - }, -#endif #ifdef CONFIG_MMU { .procname = "mmap_min_addr", @@ -2110,28 +2084,6 @@ static struct ctl_table vm_table[] = { .extra1 = SYSCTL_ZERO, }, #endif -#ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS - { - .procname = "mmap_rnd_bits", - .data = &mmap_rnd_bits, - .maxlen = sizeof(mmap_rnd_bits), - .mode = 0600, - .proc_handler = proc_dointvec_minmax, - .extra1 = (void *)&mmap_rnd_bits_min, - .extra2 = (void *)&mmap_rnd_bits_max, - }, -#endif -#ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS - { - .procname = "mmap_rnd_compat_bits", - .data = &mmap_rnd_compat_bits, - .maxlen = sizeof(mmap_rnd_compat_bits), - .mode = 0600, - .proc_handler = proc_dointvec_minmax, - .extra1 = (void *)&mmap_rnd_compat_bits_min, - .extra2 = (void *)&mmap_rnd_compat_bits_max, - }, -#endif }; int __init sysctl_init_bases(void) diff --git a/mm/mmap.c b/mm/mmap.c index c018f5a5bffd..e3d888aa1e25 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2120,6 +2120,57 @@ struct vm_area_struct *_install_special_mapping( &special_mapping_vmops); } +#ifdef CONFIG_SYSCTL +#if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \ + defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT) +int sysctl_legacy_va_layout; +#endif + +static struct ctl_table mmap_table[] = { + { + .procname = "max_map_count", + .data = &sysctl_max_map_count, + .maxlen = sizeof(sysctl_max_map_count), + .mode = 0644, + .proc_handler = proc_dointvec_minmax, + .extra1 = SYSCTL_ZERO, + }, +#if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \ + defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT) + { + .procname = "legacy_va_layout", + .data = &sysctl_legacy_va_layout, + .maxlen = sizeof(sysctl_legacy_va_layout), + .mode = 0644, + .proc_handler = proc_dointvec_minmax, + .extra1 = SYSCTL_ZERO, + }, +#endif +#ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS + { + .procname = "mmap_rnd_bits", + .data = &mmap_rnd_bits, + .maxlen = sizeof(mmap_rnd_bits), + .mode = 0600, + .proc_handler = proc_dointvec_minmax, + .extra1 = (void *)&mmap_rnd_bits_min, + .extra2 = (void *)&mmap_rnd_bits_max, + }, +#endif +#ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS + { + .procname = "mmap_rnd_compat_bits", + .data = &mmap_rnd_compat_bits, + .maxlen = sizeof(mmap_rnd_compat_bits), + .mode = 0600, + .proc_handler = proc_dointvec_minmax, + .extra1 = (void *)&mmap_rnd_compat_bits_min, + .extra2 = (void *)&mmap_rnd_compat_bits_max, + }, +#endif +}; +#endif /* CONFIG_SYSCTL */ + /* * initialise the percpu counter for VM */ @@ -2129,6 +2180,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 Tue Sep 3 03:30:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yukaixiong X-Patchwork-Id: 13787956 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 33941CD3427 for ; Tue, 3 Sep 2024 03:31:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 902238D012D; Mon, 2 Sep 2024 23:31:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 88C088D0119; Mon, 2 Sep 2024 23:31:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 77AB28D012D; Mon, 2 Sep 2024 23:31:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 549CD8D0119 for ; Mon, 2 Sep 2024 23:31:24 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 111F21C4E32 for ; Tue, 3 Sep 2024 03:31:24 +0000 (UTC) X-FDA: 82522001688.08.1EC9F64 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf03.hostedemail.com (Postfix) with ESMTP id 87B1D20007 for ; Tue, 3 Sep 2024 03:31:21 +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.255 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=1725334189; 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=9rk57q7UG5urcM2ZAYiXpyp7swA7U//KWTASEp+Wahs=; b=EZelARm73qjs9TJc7qFCobSqtwP4o4IVQcvlofqUgytjuYJJ+KA+IUh5xUuZKQrkqZ8RtX UsKdpx6iBAeTSYSy7srLmK4xpbuN9RrPodLIlEWpBKCo7zJNq5MhiG5krWqt+ufHL+qUlb UK+LsX6aFgdLaa7uDieINeGkrKIOt94= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725334189; a=rsa-sha256; cv=none; b=29Gk5XAJRg2A+yjGz+TMKIRksXw/wriYXMT+bdk4rdaNzsP/bxjx56WiDksyQ+kBV/buMi d28YQZw68ris9YXzNQfYqjoM+snpB9YjX4Sgi+tVf3V89cJf7R4ABj3WD801W3jhbe4HRj 4ya9AUW8p2ifbXjKJmtxCLua/1uJglE= 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.255 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com Received: from mail.maildlp.com (unknown [172.19.88.194]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4WyWNG5PdYz14GB1; Tue, 3 Sep 2024 11:30:22 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id 6917F1402D0; Tue, 3 Sep 2024 11:31:18 +0800 (CST) Received: from huawei.com (10.175.113.32) by kwepemh100016.china.huawei.com (7.202.181.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Tue, 3 Sep 2024 11:31:15 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v2 -next 07/15] security: min_addr: move sysctl into its own file Date: Tue, 3 Sep 2024 11:30:03 +0800 Message-ID: <20240903033011.2870608-8-yukaixiong@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240903033011.2870608-1-yukaixiong@huawei.com> References: <20240903033011.2870608-1-yukaixiong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemh100016.china.huawei.com (7.202.181.102) X-Rspamd-Queue-Id: 87B1D20007 X-Stat-Signature: r31n66nsnc4hiwhzujj7b6f857zrwehz X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1725334281-256374 X-HE-Meta: U2FsdGVkX1/+2L6uAOajtlJq7A/ntzuqZZ3tde4YzHlCtfJZvL0++S3gTEwIc5DAl/ot4YIuDXG2YSkHUDmCrOYSZyenznq6Pvxgm8pE6Bqvo6j7fyHru0RFJZM1cVC9Lvx3kEnuWYEmVgXoh3y6xoRwAxsa9oRMtKZU8D8fSB3Qj7YOaZxJsHmsAj9XISZZsxA2Hc1YygSBGBZsgUdZxqGQK6+OuTx7lRbac4tNJ0ItlfprfeMOT8Wtfjs0iXZsxFMd5eGSi0aO2bGCbLEULt/pA13o00ApkgwAiXJgLKQNKzHAw5dyPGu04x12dAbxT0R5+LQZKGpeoWNQyS4ZVpvTB2tuEDHzORr1e4+eIcMuh5GD2DZFbNy0CZfPogXqLa6QkH3oCyXJC7QfETEk1FB5Yt1r/7/s6C8gbA04hxR3sOPq0lGhOCBOU4DLdla8fQHMHFHuxYcZZICXP7lJ9CawpvkI6VBsxvIHM0d0JD1UrWVyQbAId3n+ocyxAZ3jMuNwoSXnGWMGBEzn69YHak1HYOCpxx6FK3OFoQP+kExvKyiW0xSyJmk9Tg4ee/4PmRfCJzCXjQDQxp8sj1kIpk2Swsvi772GgRLYrjStHQhl56z9YqdgfEG4WwBgGdbI+wk0OKgxPAzXu08BAnv7Jw6gRPTtyP3vhcES4FnViIs8caxH2GRQMe/kFVfvpOgMjY8fI3fswwMCworazC6L9hqL/wmHf6ARBlQyuCo5EpuIEiaV7D9qM8RE47ShzSQIS8YFjtv9/Bn53fK0X4Oe84qg8j3bt9eftRIIsXZ4ZjrV1qWa+fz7/6VvfXkgQcJOP4hIdXJ9+0LlnBo9Ajh4J/Xn0I31YRjUXTF0FrGxCh0GDZGLFbaVWNDlomKrDOBCi42CAIhMoEnoQnkZzMY4lxTjvhtrLQkHtYfVFdS2cGV3sjOlr41CJYcaVr39kPd4VN5dxa4Ta8u/wV8tQtV NAksTUEs Jb+rCetFWGu5qvnWgtNMhIEWBQ5t+l5LLVUsUviEuleIS9pK5u1DNcMUevX3myfy2Kb3PaTBJohPr2DcfTj6XZwgGtVlASAdKA/8MawTHq8/VjyF27ufWdWnuShNSj7iMfu5gxW7bgPMJUfpu9XTwIB05+TvWKguXXY8PKbERHDNv9qNRe0sK9Ao4LwHAbxkfxtSuoiDfHoG+5UIjVSN0uKvbXg== 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 into its own file 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 --- v2: - update the changelog to explain why drop CONFIG_MMU check. --- kernel/sysctl.c | 9 --------- security/min_addr.c | 11 +++++++++++ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 41d4afc978e6..0c0bab3dad7d 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2059,15 +2059,6 @@ static struct ctl_table vm_table[] = { .proc_handler = proc_dointvec_minmax, .extra1 = SYSCTL_ZERO, }, -#ifdef CONFIG_MMU - { - .procname = "mmap_min_addr", - .data = &dac_mmap_min_addr, - .maxlen = sizeof(unsigned long), - .mode = 0644, - .proc_handler = mmap_min_addr_handler, - }, -#endif #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \ (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL)) { diff --git a/security/min_addr.c b/security/min_addr.c index 0ce267c041ab..b2f61649e110 100644 --- a/security/min_addr.c +++ b/security/min_addr.c @@ -44,8 +44,19 @@ int mmap_min_addr_handler(const struct ctl_table *table, int write, return ret; } +static struct ctl_table min_addr_sysctl_table[] = { + { + .procname = "mmap_min_addr", + .data = &dac_mmap_min_addr, + .maxlen = sizeof(unsigned long), + .mode = 0644, + .proc_handler = mmap_min_addr_handler, + }, +}; + static int __init init_mmap_min_addr(void) { + register_sysctl_init("vm", min_addr_sysctl_table); update_mmap_min_addr(); return 0; From patchwork Tue Sep 3 03:30:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yukaixiong X-Patchwork-Id: 13787957 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 6D3E2CA101E for ; Tue, 3 Sep 2024 03:31:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AD7D98D012E; Mon, 2 Sep 2024 23:31:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A88FB8D0119; Mon, 2 Sep 2024 23:31:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8B3978D012E; Mon, 2 Sep 2024 23:31:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 69A1B8D0119 for ; Mon, 2 Sep 2024 23:31:27 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id EA181140110 for ; Tue, 3 Sep 2024 03:31:26 +0000 (UTC) X-FDA: 82522001772.09.9F6EB2E Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf22.hostedemail.com (Postfix) with ESMTP id 68017C000F for ; Tue, 3 Sep 2024 03:31:23 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=none; spf=pass (imf22.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725334238; 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=2gJg9h+VjfAAtBgHCJbDMkNW8UhmZE/p1J3FKhMixXM=; b=PRoNMboCWhwnKYX/pNpXeJ7MfNZFus9vE937vgrV629qmlUsr9cC9Gjp+Jc9NsTucSRJWK E9Qr82QFnOfYxNrHL+/L4fKCOPeXJD/6kSJ4BLnf3DS+Fst8Np3bXC5o7z2oAOYKqbjVWf 9RWXYxBXczIiJnoYEJ9pljpgpzgPECY= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=none; spf=pass (imf22.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725334238; a=rsa-sha256; cv=none; b=3T6SDiBJ+I0iWF+gdVp2ZGvfHabzHHq4NT1AwPvY2Gn6fiuJlhtGcK1DZ1sJ5ws2GSN3vy YU3MenG4i7lTNfCuzDn1pUYKP+Fvh9kIMT6ZASSzWuxeKm9DvtOcvC1dZh/P6iXFzkLw1q 8dn1breoKbZI7BU4JDvFkflUOSLieUc= Received: from mail.maildlp.com (unknown [172.19.163.48]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4WyWLy2TBxzgYTY; Tue, 3 Sep 2024 11:29:14 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id E61DD180087; Tue, 3 Sep 2024 11:31:20 +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; Tue, 3 Sep 2024 11:31:18 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v2 -next 08/15] mm: nommu: move sysctl to its own file Date: Tue, 3 Sep 2024 11:30:04 +0800 Message-ID: <20240903033011.2870608-9-yukaixiong@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240903033011.2870608-1-yukaixiong@huawei.com> References: <20240903033011.2870608-1-yukaixiong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemh100016.china.huawei.com (7.202.181.102) X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 68017C000F X-Stat-Signature: kuws73uinqcqss47qxennns7w9fhmwra X-HE-Tag: 1725334283-369961 X-HE-Meta: U2FsdGVkX1+XT+mzHcCjuBxif3A4HFdellFHM/2WSkuaT91l0va/fV0d9+SRFm+OkoX+amdZ0pegR+H29HoVDC6M4xglE6CMEiwSbIZP+Sa5HECOhTfKlSbCpK1rT1uLYd43JzxM5zqQL8VqSvsLVmshj/yxrKrOfFBZzm+sxOyLQBpqs8ZYkW7x20+CTauFJBF0VM1Sjb7/vyLhIPeHrGNIwW4kN65G9ybHxOdCPBPdHglOnIHXfIcd9h7krutIsWAwShGTg03aRYLc5is8Khc/8UgrHLAHxmca7ss1YDS9uJP2+ohIAFV0vpTqe62d+pF5wMPUtzt0Aa4P08QGGzCYFybDMJ2cK0uwxkcmrcEnpI7uA+zdqPg/09F9l/iWyZvgZHbVwyyV96CLGTg7UTRLuhB8FJJu3hh/ssehnMG+/3FQI7RtXiAjmUDKFnKwI5LYOALoM7D61WR5s9JmPEgU3P8Qf8GZfyjdHm6sJluIbsoAoK9k0NKD2GczEj+IqadPEOERTZTUMp35aVvcvTApUlTbYhGPkoYBPnrSnUq8mpdJrRYGYoLqpERDG4CCrlSOm5aovE/A+kSYLFwKVoYTSql0kZT1X/ooVe/twe99fAw0rLrao2SHFN66q51l3aVEf4v/ySRZ7y+VstMf5VCeeRGihpngFBgQEZeyHsCndmgqGmixSTwjup1mHWnmQkis9ApjRLxGn6J6ij3Y7119o0ylZTGZWgWDBZsWCH//ttPBUiNcJjq7Gm94VIyRxgcQCSJlx9q1F2bUF+2hCOBalNDbOOWC4F7u5jlKRHm9UYLyz0/0Z3Z+HFfkHrrooAPJEEI7PftsaAVED9g0M/+KN6drSi6/twVuHWo+vKSEX6l+WNbk+IOousLqVKZpwoKHkrbCz4eVcUPTrzlNXhdoMDxKJgh2i52iJ38jRqVHBrmDGkXD0siMM80cPiFIuVn6o0uBA/VIrvA0Glo I03+0twl S65dr2WtKRQImgNHniZLQcccj5H7xwdFZzV1Jwh18kGnMqeHr26HXDtNy5I1ONjhJRrfuBv9bzuiQb8+Y10JcfG1j75/cE25t1TaXTh+nN/VjGgG8f+7JncV04PdkXlSgNVS7iLGAcfHJ44L//uq21Tgp7A== 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 into its own file from /kernel/sysctl.c. And remove the useless extern variable declaration from include/linux/mm.h Signed-off-by: Kaixiong Yu --- 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 93ae80146ee2..b7f12988237a 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -4044,8 +4044,6 @@ unsigned long wp_shared_mapping_range(struct address_space *mapping, pgoff_t first_index, pgoff_t nr); #endif -extern int sysctl_nr_trim_pages; - #ifdef CONFIG_PRINTK void mem_dump_obj(void *object); #else diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 0c0bab3dad7d..d3de31ec74bf 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2041,16 +2041,6 @@ static struct ctl_table vm_table[] = { .extra1 = SYSCTL_ONE, .extra2 = SYSCTL_FOUR, }, -#ifndef CONFIG_MMU - { - .procname = "nr_trim_pages", - .data = &sysctl_nr_trim_pages, - .maxlen = sizeof(sysctl_nr_trim_pages), - .mode = 0644, - .proc_handler = proc_dointvec_minmax, - .extra1 = SYSCTL_ZERO, - }, -#endif { .procname = "vfs_cache_pressure", .data = &sysctl_vfs_cache_pressure, diff --git a/mm/nommu.c b/mm/nommu.c index 385b0c15add8..48b2812f492a 100644 --- a/mm/nommu.c +++ b/mm/nommu.c @@ -48,7 +48,6 @@ struct page *mem_map; unsigned long max_mapnr; EXPORT_SYMBOL(max_mapnr); unsigned long highest_memmap_pfn; -int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS; int heap_stack_gap = 0; atomic_long_t mmap_pages_allocated; @@ -392,6 +391,19 @@ SYSCALL_DEFINE1(brk, unsigned long, brk) return mm->brk = brk; } +static int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS; + +static struct ctl_table nommu_table[] = { + { + .procname = "nr_trim_pages", + .data = &sysctl_nr_trim_pages, + .maxlen = sizeof(sysctl_nr_trim_pages), + .mode = 0644, + .proc_handler = proc_dointvec_minmax, + .extra1 = SYSCTL_ZERO, + }, +}; + /* * initialise the percpu counter for VM and region record slabs */ @@ -402,6 +414,7 @@ void __init mmap_init(void) ret = percpu_counter_init(&vm_committed_as, 0, GFP_KERNEL); VM_BUG_ON(ret); vm_region_jar = KMEM_CACHE(vm_region, SLAB_PANIC|SLAB_ACCOUNT); + register_sysctl_init("vm", nommu_table); } /* From patchwork Tue Sep 3 03:30:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yukaixiong X-Patchwork-Id: 13787958 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 2201DCD3427 for ; Tue, 3 Sep 2024 03:31:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EA7098D012F; Mon, 2 Sep 2024 23:31:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E80278D0119; Mon, 2 Sep 2024 23:31:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D6D208D012F; Mon, 2 Sep 2024 23:31:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id B68528D0119 for ; Mon, 2 Sep 2024 23:31:29 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 6A27F1C13A2 for ; Tue, 3 Sep 2024 03:31:29 +0000 (UTC) X-FDA: 82522001898.10.F8E7C31 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf19.hostedemail.com (Postfix) with ESMTP id 169F71A0005 for ; Tue, 3 Sep 2024 03:31:26 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=none; spf=pass (imf19.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=1725334193; 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=GsszZcU5MEX5KSbdKVfP/hsrZJbmsi1mtRWwn7a0E1w=; b=S/TWNVKIKhrbcL9DoAplLrOx2D6GOOwirGHDjHwF7yukWeDjQNIzIg0vhnoEKp7uk1f4se wUC7lfx545GEJkzQX5iuF5SC4mM362GnHc+oQ357i/CCu778Pyc4TIhHAfc4OOWOUHf5FI j6dDbPvkluuBx2Be7Yk6qGMZKgcEjys= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725334193; a=rsa-sha256; cv=none; b=wHiVOlQDQ4orb6qWUe1l5e7/iBWh4K61Z4tu3MJwQPogX7MpGjEQWIeXORGTmZOGx8pNFo jZBDnACFzP1pgSxT4gjxsT3bb1H8WmwzZmTJ6ydaTwd8Vs5hAOK1dBAkwtyrypN7sONqW9 rBa9ATbECGNPfINlc8idy8Y1Un2SK4s= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=none; spf=pass (imf19.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.48]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4WyWNM5w5pz18Mv5; Tue, 3 Sep 2024 11:30:27 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id 77D0C180087; Tue, 3 Sep 2024 11:31:23 +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; Tue, 3 Sep 2024 11:31:20 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v2 -next 09/15] fs: fs-writeback: move sysctl to its own file Date: Tue, 3 Sep 2024 11:30:05 +0800 Message-ID: <20240903033011.2870608-10-yukaixiong@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240903033011.2870608-1-yukaixiong@huawei.com> References: <20240903033011.2870608-1-yukaixiong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemh100016.china.huawei.com (7.202.181.102) X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 169F71A0005 X-Stat-Signature: n6ctgmk9wez4j7cnuhxdzoz6mdqfkjiw X-HE-Tag: 1725334286-558105 X-HE-Meta: U2FsdGVkX18128/1LtF7HihE7KKAfVjgG8RTl3yeouPiPMiwxQqYuDiMVTZKlgaLLbUXkSr/OtBSyA9Tv69B5nOCpex6P/maeZb9gYMN5vzr+HdeKHMPgzRMaWrFCc/KtbXYR/IoE8oHi5hoomDFDIW6I1InZlnDyYizdVMBFOFm68Ltt0XOSim5oP/FRhIMhnmUKNadbmCPPxVXLndBSVcpQWlhSuZuYTN8amDvSFhfhASXDE5FdrDbKFBdau9NRMA1RXcgtoeyrVRr6JP4K2AEuon5isGv7dfdVWH60/VhEh5oSOaAqx2PDsIh6Q/34Xf5tlImNoHxga+25TBLqxXcYevhW0S1VFo9fuSGriL1C3BYzXQGuX0LrXFBezKDePW7AnVEAZsm1dwibJeVUdoRHKJ0dUOI3+WDBPL8Ig/+Am+j/H2OR9o1NAhX7zMVW/B0DpEpLL6f358QCSEpeW6aiPlsL65LDEP3q7v35gZ1IEWkJmf92MIo0vtc6Tcb39SnnfXb44RpWWyVyuGb0oj3X2A9WrPhFGO/aei/11t64ZJm63EtERllQNdLrFATISrKg8V0goipMO0gY7sACv4fSP1G/2bMPhmunPdCC17XC2ud6dXcFVoBNel7MI9iFFuOCciD+Kp8/8MVxy8btO94qME0i/mZDT6MEZAH6/nzVlPnNuCzPD5o7/wpPWJmVa0g24rSYq33ux5Sa3CC57Bqu1b43JLv665Six/HSoAl2ufl3SIo7qzFmttk4cMfm/WQu8t2WG1K59xLq8HJAwBEmhdpstxpYriMQWoZr3upNgLdPJ+DAN/uhDV0NqAgeUwlZMQkx2eqob/GBLN5wTv7gBm7BcBajtHLZMwTx69tsgLG4wDhysE+9FzQ7+7dG/zzAuCk8+fklqN4iwioZEhnHaIikA8atw4Y75uTyN/H0QPgyhTwO6ITZAY55Ykrg8IauvF6ezdt+JybpSE S8HD60Pg /Pa+Ijdm7nyQUfCmiKaqT9QIkdFomhETxkxL4MAVivNEIcmffHhqAmwnVG/4OAe6NTKrDe2a4bgX7AlqgWC+De43gBpw6nxtyiE8KryNrOZbwXP1y+xGNRK+EXcpYH7LtBJ/r2De39OlVccdilawdYDAyEc6Y7E1aTSarcysVTicnxF0= 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 into its own file 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 --- fs/fs-writeback.c | 28 ++++++++++++++++++++-------- include/linux/writeback.h | 4 ---- kernel/sysctl.c | 8 -------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index d8bec3c1bb1f..9217afaa31d3 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c @@ -2413,14 +2413,7 @@ static void wakeup_dirtytime_writeback(struct work_struct *w) schedule_delayed_work(&dirtytime_work, dirtytime_expire_interval * HZ); } -static int __init start_dirtytime_writeback(void) -{ - schedule_delayed_work(&dirtytime_work, dirtytime_expire_interval * HZ); - return 0; -} -__initcall(start_dirtytime_writeback); - -int dirtytime_interval_handler(const struct ctl_table *table, int write, +static int dirtytime_interval_handler(const struct ctl_table *table, int write, void *buffer, size_t *lenp, loff_t *ppos) { int ret; @@ -2431,6 +2424,25 @@ int dirtytime_interval_handler(const struct ctl_table *table, int write, return ret; } +static struct ctl_table vm_fs_writeback_table[] = { + { + .procname = "dirtytime_expire_seconds", + .data = &dirtytime_expire_interval, + .maxlen = sizeof(dirtytime_expire_interval), + .mode = 0644, + .proc_handler = dirtytime_interval_handler, + .extra1 = SYSCTL_ZERO, + }, +}; + +static int __init start_dirtytime_writeback(void) +{ + schedule_delayed_work(&dirtytime_work, dirtytime_expire_interval * HZ); + register_sysctl_init("vm", vm_fs_writeback_table); + return 0; +} +__initcall(start_dirtytime_writeback); + /** * __mark_inode_dirty - internal function to mark an inode dirty * diff --git a/include/linux/writeback.h b/include/linux/writeback.h index d6db822e4bb3..5f35b24aff7b 100644 --- a/include/linux/writeback.h +++ b/include/linux/writeback.h @@ -351,12 +351,8 @@ extern struct wb_domain global_wb_domain; /* These are exported to sysctl. */ extern unsigned int dirty_writeback_interval; extern unsigned int dirty_expire_interval; -extern unsigned int dirtytime_expire_interval; extern int laptop_mode; -int dirtytime_interval_handler(const struct ctl_table *table, int write, - void *buffer, size_t *lenp, loff_t *ppos); - void global_dirty_limits(unsigned long *pbackground, unsigned long *pdirty); unsigned long wb_calc_thresh(struct bdi_writeback *wb, unsigned long thresh); unsigned long cgwb_calc_thresh(struct bdi_writeback *wb); diff --git a/kernel/sysctl.c b/kernel/sysctl.c index d3de31ec74bf..373e018b950c 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2024,14 +2024,6 @@ static struct ctl_table kern_table[] = { }; static struct ctl_table vm_table[] = { - { - .procname = "dirtytime_expire_seconds", - .data = &dirtytime_expire_interval, - .maxlen = sizeof(dirtytime_expire_interval), - .mode = 0644, - .proc_handler = dirtytime_interval_handler, - .extra1 = SYSCTL_ZERO, - }, { .procname = "drop_caches", .data = &sysctl_drop_caches, From patchwork Tue Sep 3 03:30:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yukaixiong X-Patchwork-Id: 13787959 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 EF358CD3429 for ; Tue, 3 Sep 2024 03:31:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 499DF8D0130; Mon, 2 Sep 2024 23:31:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 335658D0119; Mon, 2 Sep 2024 23:31:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 160F38D0130; Mon, 2 Sep 2024 23:31:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id E28B38D0119 for ; Mon, 2 Sep 2024 23:31:31 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id AD9311C4E32 for ; Tue, 3 Sep 2024 03:31:31 +0000 (UTC) X-FDA: 82522001982.03.5CF1C07 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf16.hostedemail.com (Postfix) with ESMTP id 3C1C318000B for ; Tue, 3 Sep 2024 03:31:28 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf16.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725334266; a=rsa-sha256; cv=none; b=W0gI8qzTA1/3STAWQcVpZNgO5vQDffpkcll4pngxT1Q9KMuT7u3NBkiumqnlZWRRDad0s4 N+GHENcBbmuc5fgYXsuCAxvAVK7VK4WUGcJiCQ8OEm/wNyxdzrFMGdjaVtzW/rtJsyXd0K antgqdiSF8gN5JGhjEFQJyGvni4pfFM= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf16.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.189 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=1725334266; 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=7iGQDt0hhjblbE/jy5UXK9JJi1RMkoXsxikX3jxX3us=; b=BLDqLt+vWA1EJq6DpfKydJ+UvMFdlvq8cVLbZo8Y6MSYE5JgFrijSqJbGUtkcxYR5lsNN9 +ojhHkIWYr8INmrW0pBJPb0EWUfui7Btq3fnC8BzNtFhSaVURsK9Fl4UfOymiblpi4GBOI a2ML/+/3oeo1h6Q8D3DakzdiijJaUo0= Received: from mail.maildlp.com (unknown [172.19.163.48]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4WyWHn6dS2z69V1; Tue, 3 Sep 2024 11:26:29 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id F2EBE180087; Tue, 3 Sep 2024 11:31:25 +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; Tue, 3 Sep 2024 11:31:23 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v2 -next 10/15] fs: drop_caches: move sysctl to its own file Date: Tue, 3 Sep 2024 11:30:06 +0800 Message-ID: <20240903033011.2870608-11-yukaixiong@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240903033011.2870608-1-yukaixiong@huawei.com> References: <20240903033011.2870608-1-yukaixiong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemh100016.china.huawei.com (7.202.181.102) X-Rspam-User: X-Rspamd-Queue-Id: 3C1C318000B X-Rspamd-Server: rspam01 X-Stat-Signature: z71hk6n6ee81ijr91ngpza8y8nc1ke4s X-HE-Tag: 1725334288-223541 X-HE-Meta: U2FsdGVkX1/ADZoEsijDdGvQGPupwUciTiVAxzha039lyS1Ed8Vbi+Y2RYOiEAkaP/xAiNaw53PMgf1n1AW0P3dRWEkrzdett4Ich0NNDyUPJ8io0QAWDikdsqLZWneFAFYz+YLdRSAi5C/SzTB9KBlD9aUK/MwOUULo6M1D4qAG3BFzCfUl6Ne4235JQtah1t+Rs9Eh2rQ04rjPkJiOVC5zwSaqvJGdt2rbwo92+vIJxJXX3HWMM3SzdhytyBIL23lS/d7kIAB3hCXq7l8ZnRXDPEFc6vgXeYIuDXQL6G0tuC61xjLiYevsxCT78d5vNUx2zlSiyYI3eIc8fwF/HM8KeepwoWjozKMvSfCDNSdv3ceYDoKT6d2W/JjZErrbnHDrqBUMS3REgHOTzn+C6SJG5kQcSYkmdG5ne50dxUc2yI11nFmjKe63II6AhCQYGh2a1s1tqBWf/kI6PhD7WRPnVQDaNfd2lbCoNPQDnDHJ54JI9Sur46E/jnlP1Y7YfZ5gQCayaPt5iPoGrpd4iRY7H07pGrcXyx0e3wtlHXhnXFYMk0rzfGjiY9DeUyH0gpsKm8fjRiPJrQhc/TnpJ9JjswXmh4uzIxQnskhwBEyO1CJsRqdxQ+WoJWSBzw/nJoK3MA1+2ABlZpBGMnJ4S/NK/suLLVP6xEeFKO5yAIjDxK3IvHR5LKH5LlsSc90n5rlgRPUibj0tONgeeK1Rzdu6ewDFj2ARviZEQKI5jaR+BL1VvcJiRLGp+qJEYWgE6+d9M1n4Y277QqDOwlGUB+ObrHSAsIj0enLRtqNzmVOm3LKuRi3ZCml/HarQBdvSpkaQyi718gaGRB0vo8wW/J+WMjE7K3MvDYUgaxPsmLCIZKTUVbZ54Piho/YMgAr7apYwedsQC8bPLmmgLMvlwOIkdRS5YI1TSuImdyDbAJNpabRv/pE2kK02W66/04jhyX26PlEzPj8Mjcjj8wt iM5E/tzf nRC+Csyzsb3keFlQKLdehbzSl/QTCSEeOgop8SZni6OpB7QippwMFMw3rZ5HGBmsdOUmduBGAjoaRP/hvwBZvg/vUEq0lmHYtMrluxqc0l8ma2ojNxAbyhtTkGGvmbEbL3hBEUvQeQGHmQKj7ezMy+dK7+nHgRtnCMMZV0KSZw6HEvtQzZkSi+ssD0nWBTrz3PwbqrwBNnPx+pSFtaTgiPOMU0A== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: The sysctl_drop_caches to fs/drop_caches.c, move it into its own file from /kernel/sysctl.c. And remove the useless extern variable declaration from include/linux/mm.h Signed-off-by: Kaixiong Yu Reviewed-by: Kees Cook --- fs/drop_caches.c | 23 +++++++++++++++++++++-- include/linux/mm.h | 6 ------ kernel/sysctl.c | 9 --------- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/fs/drop_caches.c b/fs/drop_caches.c index d45ef541d848..f2551ace800f 100644 --- a/fs/drop_caches.c +++ b/fs/drop_caches.c @@ -14,7 +14,7 @@ #include "internal.h" /* A global variable is a bit ugly, but it keeps the code simple */ -int sysctl_drop_caches; +static int sysctl_drop_caches; static void drop_pagecache_sb(struct super_block *sb, void *unused) { @@ -48,7 +48,7 @@ static void drop_pagecache_sb(struct super_block *sb, void *unused) iput(toput_inode); } -int drop_caches_sysctl_handler(const struct ctl_table *table, int write, +static int drop_caches_sysctl_handler(const struct ctl_table *table, int write, void *buffer, size_t *length, loff_t *ppos) { int ret; @@ -77,3 +77,22 @@ int drop_caches_sysctl_handler(const struct ctl_table *table, int write, } return 0; } + +static struct ctl_table drop_caches_table[] = { + { + .procname = "drop_caches", + .data = &sysctl_drop_caches, + .maxlen = sizeof(int), + .mode = 0200, + .proc_handler = drop_caches_sysctl_handler, + .extra1 = SYSCTL_ONE, + .extra2 = SYSCTL_FOUR, + }, +}; + +static int __init init_vm_drop_caches_sysctls(void) +{ + register_sysctl_init("vm", drop_caches_table); + return 0; +} +fs_initcall(init_vm_drop_caches_sysctls); diff --git a/include/linux/mm.h b/include/linux/mm.h index b7f12988237a..d48933b47076 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3765,12 +3765,6 @@ static inline int in_gate_area(struct mm_struct *mm, unsigned long addr) extern bool process_shares_mm(struct task_struct *p, struct mm_struct *mm); -#ifdef CONFIG_SYSCTL -extern int sysctl_drop_caches; -int drop_caches_sysctl_handler(const struct ctl_table *, int, void *, size_t *, - loff_t *); -#endif - void drop_slab(void); #ifndef CONFIG_MMU diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 373e018b950c..d638a1bac9af 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2024,15 +2024,6 @@ static struct ctl_table kern_table[] = { }; static struct ctl_table vm_table[] = { - { - .procname = "drop_caches", - .data = &sysctl_drop_caches, - .maxlen = sizeof(int), - .mode = 0200, - .proc_handler = drop_caches_sysctl_handler, - .extra1 = SYSCTL_ONE, - .extra2 = SYSCTL_FOUR, - }, { .procname = "vfs_cache_pressure", .data = &sysctl_vfs_cache_pressure, From patchwork Tue Sep 3 03:30:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yukaixiong X-Patchwork-Id: 13787960 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 E377DCA101E for ; Tue, 3 Sep 2024 03:31:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 13C8B8D0131; Mon, 2 Sep 2024 23:31:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0C4CE8D0119; Mon, 2 Sep 2024 23:31:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E7FCD8D0131; Mon, 2 Sep 2024 23:31:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id CC0E68D0119 for ; Mon, 2 Sep 2024 23:31:35 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 85AC6AAB04 for ; Tue, 3 Sep 2024 03:31:35 +0000 (UTC) X-FDA: 82522002150.19.F6B394E Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf02.hostedemail.com (Postfix) with ESMTP id 60D2A80005 for ; Tue, 3 Sep 2024 03:31:32 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=none; spf=pass (imf02.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=1725334198; 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=N3NvLzAWMi5td0cMRJ65bdLAyhA5wt/Ciq2d5iq/wFM=; b=v1Ugu5fiyHNCwuOGExM5He7OXoDFIGD9VZhuTxem+bxltZZrEaPwpfg4nSP6GI9fAX3QIc mDgWps2Kd9gq03P2mprS8bvH2TwkR7m0pLDrwm3Ib80s4Q12rbAfGRsj43Pa09LWNnFGqI TuRhGjBKO9004c9wBMwiTMPObhxqScI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725334198; a=rsa-sha256; cv=none; b=5gyGJYeb3YBCeLXGCNgfQ/v6N8Ameue2S2iy7f3wxRxm/2dfrN1iSKnBqvzzi0G3PpKrdD OKWB4XK25DdS3KhF+f5LqQItTJW3KsWAMH0RLZvEvtN0PBkzbMCdwF99C356VnXEPC69OC KhaPlGJNE2HTVwN7T2VgUC/JuRY9mqg= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=none; spf=pass (imf02.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4WyWPB00lCz1j82f; Tue, 3 Sep 2024 11:31:09 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id 72CE51400D7; Tue, 3 Sep 2024 11:31:28 +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; Tue, 3 Sep 2024 11:31:25 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v2 -next 11/15] sunrpc: use vfs_pressure_ratio() helper Date: Tue, 3 Sep 2024 11:30:07 +0800 Message-ID: <20240903033011.2870608-12-yukaixiong@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240903033011.2870608-1-yukaixiong@huawei.com> References: <20240903033011.2870608-1-yukaixiong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemh100016.china.huawei.com (7.202.181.102) X-Stat-Signature: rp313mkwm98zoeba144nd7rza5z77phx X-Rspamd-Queue-Id: 60D2A80005 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1725334292-535712 X-HE-Meta: U2FsdGVkX19IcVDYyZa/QP/K9NfYxZ2nIKbqljucBZ2BC1GFdzak5Hd4vgp42/SV93XQaphKikw5CyYZ4dqj0MFxaHDfPcYRBVqZCqgmlThtcDQr6fx+WQ04slQsnmGVx+sPxYU2Mf3jTtPUalUqDkSYNV3p890lIR8xRjskeHpbeeyx0VL/Ft9BrfqmLsDiqxYod8o/wTdgKwwk4z+B9GrBEjSTGV98nF+hDN4L0/89QRYEMm6oMW0PxswVyLtY3Ui9dbnLmiHZXTuZoCDmsjDTWQlRgZN/ijovSqrjwxSxoyx1Cy38snOwOHKHpMp+QB0aOqRd20VwftomUs0kOQx0EE986N7sci3+6qADrPy0IJXfqBhG7F8Ox5m0Tps1HjAgknVLXT6HdHTfBb87kUc73a2cEQsAI+FRZsoBbIjCHP6MgTOKYuY0QlQH+1KgVB8YzRvk/gfYDiqAfBrIXaJ/XTicLenofD2X1cqSOgUWMlZNTpvWPSGW/QJHtnNRWU8M1VGnlXVKh0/AvYjCzdVTmGBlDK0DKnryNVF8h4c6cKwRyyu8+ndUWgrr5PgDqx3wNgZv+hgzw49d1w9bvS4s9t+EWrydSO/5tnvIPE0J6yOvvXv7evF9Nj/+9zhNumrRIPaVifVRoyobsu2tWalpzI6vGvPNqjtCtcpNdrs3jBHyMGnBT/CMqKgBiFyj5AuTK1FQ9pESZg6o0lFM4LQTQYK6/zxW7oCXRFhe2YdekluevB9wXG7t8PJOwTXJnY/HcgzF/8PuDddqKKSgyrZCWDi84K5nhLfsMhzbsrEipEw9Ib1+AwoaW7Ip8W7AW5i7Tm/SQSex3nvHwxXcQLAtxRAwemYoIXkKC7EZ2QXApZ2FmaNSclF+7CK6iavwy84XOpuw0FoET3hGQsDRSBDQYoyhpCxQNBohyWr4rNEk5051Iag5YNcYGXDmKpi0WWy7e7d2b8ms1xyWCPI idYlqS21 GhhQBdFWamv1i70u44GZ6nJerafV3hL6jZ8g8DOgqrqf2+qqP4Y2VPiaVjcdo2+RoFlRJ8OfZ5h6s0wUk5wKOmH2N7jrbiUhMUmUlkK96bG6OTDW7KYYBYkPuLQzGktiNz7kreUjO2AhCvgismvqnDtOjtLl1nrEMfCvob/lhvaH/rTY7VJqX3yrhDpl0N+2Bu08uqSuZkg6bBh+izeJAUGNi5P5LebopvxUZXQ86Y6lK7bPykvO9hFvHGw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Use vfs_pressure_ratio() to simplify code. Signed-off-by: Kaixiong Yu Reviewed-by: Kees Cook Acked-by: Anna Schumaker --- net/sunrpc/auth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/sunrpc/auth.c b/net/sunrpc/auth.c index 04534ea537c8..3d2b51d7e934 100644 --- a/net/sunrpc/auth.c +++ b/net/sunrpc/auth.c @@ -489,7 +489,7 @@ static unsigned long rpcauth_cache_shrink_count(struct shrinker *shrink, struct shrink_control *sc) { - return number_cred_unused * sysctl_vfs_cache_pressure / 100; + return vfs_pressure_ratio(number_cred_unused); } static void From patchwork Tue Sep 3 03:30:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yukaixiong X-Patchwork-Id: 13787961 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 7CF51CA101E for ; Tue, 3 Sep 2024 03:31:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7555C8D0132; Mon, 2 Sep 2024 23:31:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6B7C68D0119; Mon, 2 Sep 2024 23:31:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 57F408D0132; Mon, 2 Sep 2024 23:31:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 36BD78D0119 for ; Mon, 2 Sep 2024 23:31:37 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id B1AA1401CD for ; Tue, 3 Sep 2024 03:31:36 +0000 (UTC) X-FDA: 82522002192.14.9183819 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf29.hostedemail.com (Postfix) with ESMTP id 61ACC120004 for ; Tue, 3 Sep 2024 03:31:33 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=none; spf=pass (imf29.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725334200; 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=JXWgL2fIsADO6hlayuZM6T9P5NxRk5ZKD6PY3Fe0TkQ=; b=t2KsYEjWLmIfBguOvV9ax7aesZ4i6K++vPJx+C4tpvIwAib9yXHByu28dwnxnpb74ltIKw uDLIBj5AQoFkBo0JTrUt6Ph85bu5hvzlELcS6aP70RhOzSBN0/T1xGuAGcgZeb+ZyAjS9a 0Af9/j3l2o5znKlnlRFH2Y4KeYZDP+w= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725334200; a=rsa-sha256; cv=none; b=18LSdg/zZILrkqqPKiwKQ3PJQ/fZbSWzB6kR7kaJQs4R7sAh7e9DRRnxbThDLinXDQmB7B BreJ+b5UY5ReiqPBnd8uk4JqBxjtJUJznGgw8t9eGiCCQa1ayZW5znz06H5LMhqE3Cii0B +B/QdlZzarZhlyQWH91DMilpiLfEGx0= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=none; spf=pass (imf29.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.194]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4WyWM82cThzgYvk; Tue, 3 Sep 2024 11:29:24 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id EC29C1402D0; Tue, 3 Sep 2024 11:31:30 +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; Tue, 3 Sep 2024 11:31:28 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v2 -next 12/15] fs: dcache: move the sysctl into its own file Date: Tue, 3 Sep 2024 11:30:08 +0800 Message-ID: <20240903033011.2870608-13-yukaixiong@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240903033011.2870608-1-yukaixiong@huawei.com> References: <20240903033011.2870608-1-yukaixiong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemh100016.china.huawei.com (7.202.181.102) X-Stat-Signature: 87ubfmnhpdjcek93j8jo46djhzd119i7 X-Rspamd-Queue-Id: 61ACC120004 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1725334293-985253 X-HE-Meta: U2FsdGVkX18eSumkHKffar4jMpV4MB/gVWaFlB+egqBHK5D1++WFzUsxo3PAjBU3kWsvB2iY34RAepZcjduzPIdMmPoaSKputMxMatkh4ztuOwO7TrFf0EttkTvf8wAhg8YDIvaq6h3uy9+73dkbK3a5lgkRcpcy31b9BT5Tir7RfK6douINpQmQAREJn12bon4S0fH+cHKDmS/Px4er6lh0px8dhsDcNd0AfhuFjA3BanbQQTEJo4aKqun+rrOAOR4/5hW60udqfWnlx+CkzlWaOHCCRH+RqnJP8a4Xt+/BJoYG+3UwFzEsK7RIP2Fc8Enpbi9CF6WKcW70xfRYkhAsRyefe/fwN83+7wQnnnGGo1BiKsMgywRaQghsNGRgfmNahoiMimt0S+1op4rKWVcfUn6/yTTYnsSsWR7wFP6xU8xYMDTuY9UVxE8x+mYVDCicIK2lQjEGFDGokGs+MXCwXoJ2HZaYW5vE01vNYeDTuRyLnXsTKacYrMGZPcdwdVBiiPbpGoXLf0WclQPpswrisc+/b3+yQTanvsUnZo+ibfsSrrYSZGJIPMnjBNc6mqhahzS5WDM8VDhDHvqifFxnJJizCMEdKs4Z3HH5i7pwBQbEJSiuPz+voOPxbdVwu/pi/+zv6FR8YBeoY7vqrI0gK7EWmIcpTVQTyqG/cbfDZpqKkL0m5fkHNN35j9PQ906iUUsgu//2FbmzIe32isLOUgw0SgGm0DCCHXZjN/6fB1jIY+E296/2fMqiGoqpw4E2PW5kSDXe3MiyhpT1KgKgJ0Qr4yhUhECoJku/j8KFjD0exjBYFkv4qRsueuxz+t6YI6og1x4RiDDijPjxOarqOGdqw6eks48wDu20v8mlQqG6sYV7YVYDSqSgbXxq6IiUdmr5cg91t4SOzE79iXBAicogAkQbg9fS0Y2OPNCRfp8jNdMB4PFuBsM11jOilnRZLfozE4p0cPlObvJ aivul+Qq MJQhBuh2q6o455sVyLdZH/mg6TX3StQNoQ/yb/CheznaIf7vj8vLs1VFaIwGR1097vOcgwpw2AQCaqe3iBziomfkMWvQZzENtTgIspJDYzXHk5BC3LP4bklfwGv5Gvi4EkjGBg+qIPpD/f+ERpyrduqO6H7vNSNQkfvUc93EbAOYmVDw= 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 its own file 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 --- 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 0f6b16ba30d0..17ea029fa9c9 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); @@ -201,8 +206,20 @@ static struct ctl_table fs_dcache_sysctls[] = { }, }; +static struct ctl_table vm_dcache_sysctls[] = { + { + .procname = "vfs_cache_pressure", + .data = &sysctl_vfs_cache_pressure, + .maxlen = sizeof(sysctl_vfs_cache_pressure), + .mode = 0644, + .proc_handler = proc_dointvec_minmax, + .extra1 = SYSCTL_ZERO, + }, +}; + static int __init init_fs_dcache_sysctls(void) { + register_sysctl_init("vm", vm_dcache_sysctls); register_sysctl_init("fs", fs_dcache_sysctls); return 0; } diff --git a/include/linux/dcache.h b/include/linux/dcache.h index bff956f7b2b9..c81c2e9e13df 100644 --- a/include/linux/dcache.h +++ b/include/linux/dcache.h @@ -508,12 +508,7 @@ static inline int simple_positive(const struct dentry *dentry) return d_really_is_positive(dentry) && !d_unhashed(dentry); } -extern int sysctl_vfs_cache_pressure; - -static inline unsigned long vfs_pressure_ratio(unsigned long val) -{ - return mult_frac(val, sysctl_vfs_cache_pressure, 100); -} +unsigned long vfs_pressure_ratio(unsigned long val); /** * d_inode - Get the actual inode of this dentry diff --git a/kernel/sysctl.c b/kernel/sysctl.c index d638a1bac9af..6f03fc749794 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -46,7 +46,6 @@ #include #include #include -#include #include #include #include @@ -2024,14 +2023,6 @@ static struct ctl_table kern_table[] = { }; static struct ctl_table vm_table[] = { - { - .procname = "vfs_cache_pressure", - .data = &sysctl_vfs_cache_pressure, - .maxlen = sizeof(sysctl_vfs_cache_pressure), - .mode = 0644, - .proc_handler = proc_dointvec_minmax, - .extra1 = SYSCTL_ZERO, - }, #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \ (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL)) { From patchwork Tue Sep 3 03:30:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yukaixiong X-Patchwork-Id: 13787962 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 9B110CA101E for ; Tue, 3 Sep 2024 03:31:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C36BB8D0133; Mon, 2 Sep 2024 23:31:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BE7488D0119; Mon, 2 Sep 2024 23:31:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A395F8D0133; Mon, 2 Sep 2024 23:31:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 86F688D0119 for ; Mon, 2 Sep 2024 23:31:39 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 4FD531A0218 for ; Tue, 3 Sep 2024 03:31:39 +0000 (UTC) X-FDA: 82522002318.24.4EA9DEB Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) by imf22.hostedemail.com (Postfix) with ESMTP id C823DC0007 for ; Tue, 3 Sep 2024 03:31:36 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf22.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.35 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725334227; a=rsa-sha256; cv=none; b=uT90mBYB0fwLDBRbDoRPLiskKsEj/91rdSzmGW7Vb1unraDBASNZBgsCQVUPzac22Jo7Ol +xz2zyuyEO+ApjngblZ57LH+DGZIzMbi7qN7y8LCWrBISDVpggZuzvCuorY20ZJtIJA2hm +as/mrD5vpt1GWluZhY9niWSEqZ4ENY= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf22.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.35 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725334227; 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=xvzVUeKHkl6lHJ3cZnWK9VGhkhxSWFwxKFEsY+AhXmA=; b=WskjsEFwZokiln4etj6NN1TBUwJMnLz7b2ndhhqMoBwb5AEY9ph0d2NgkcOVbAj3+B2Xjf HjfSXxtjj70t8y2tZeqmhhEcJMm1o0cIFDq9oYMf8iJ+MJdBwPasuGXTFnpuF4JU/0jMFo I3fd1CzHJbEzxODMUaA4OnpOUqpHKso= Received: from mail.maildlp.com (unknown [172.19.88.163]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4WyWPG2FBqz1S9bC; Tue, 3 Sep 2024 11:31:14 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id 861B9180019; Tue, 3 Sep 2024 11:31:33 +0800 (CST) Received: from huawei.com (10.175.113.32) by kwepemh100016.china.huawei.com (7.202.181.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Tue, 3 Sep 2024 11:31:30 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v2 -next 13/15] x86: vdso: move the sysctl into its own file Date: Tue, 3 Sep 2024 11:30:09 +0800 Message-ID: <20240903033011.2870608-14-yukaixiong@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240903033011.2870608-1-yukaixiong@huawei.com> References: <20240903033011.2870608-1-yukaixiong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemh100016.china.huawei.com (7.202.181.102) X-Rspamd-Queue-Id: C823DC0007 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 5ko6tmctz8qnspjx76qcefib673ym7kn X-HE-Tag: 1725334296-53124 X-HE-Meta: U2FsdGVkX19ZU6MLd6N7xC3Ulw8DSdQdWNNvuN6Yl1ogWYacJ6NUL5ISc9JQqlXEe/9nwDd9doYrrbFrDMoUIyl/IUYJ7bWnn1lXK8X+MixmlO3Elw9QV6w+hIofyhmQnfrpDM+z5r4ULWMiJnrcxfSSAjqSFoY6/JA43YWEnLvLIqC8Z2D0ck1Y+iLZ5oGISLVosLVOK1819AiCTGawo/cTlffNq9wZ2bpFz+4s5h1KM6mznZEjy6KrL4857hQa4R/hc/JGc4FT0JJhcvwC65zEeF2FRO+J1eP3tpiPRW2U62TnH8ErEPifRtCxbWr2A64u9nyPTkJx8ZiF5MOU7m4l8ZQlnv/weGnRB0Ga3+O50zQKa3hZZcD7ONI9kcnE5LKai8KR+oQdh5EwVR8U+S0LII9lUHCTxXTeUYv8LSSCvQVzTFtVeTyxljMH7mWOmbMjBGE/GVQQM9zWlGTKo02T6YPiMExMHYPBlGxDfJ99g0v+1FdToYzRx+hRVm9xrMBFz9g5I4glnDLDZ/bmJZ+52ITScwZgfwp+HABs85qkmL2NATY04cha4uAwdIh9z8D0OATZM57BbjEDfOQ7lguOOBg3xTdiOJjiOdPEbguYJKyQbExXkfd99uLCj+8MmQqLGbmxWpIrzS90l9XzhYNHPDINoZAQPOvOqQdtBn/8U74AY0VKeVZfTcnqSY8JUEnFYbE6WNzNDDsmqB1RXXeorA9yU7vWtSKAPZFNe8miww39kgKrt6jEwmvVclYu2omT3qhGFWi7HdnxL5dqrWjgxbJ/tsCsx9bJGG1tZG/l8ChU8AZghtq0/tI8ESyg6szegiAbTrRxdIeuDpGp71nRoXDAX4OyIGq9njCOr5buSgOumOQKRZnkH32xF4UTprDXx5a3vPKHini6YbPMPaBoQ2RYrVcRhJIWWJZuhYZkFOTOegDZz+4Jt7pV3nvwZKU6F/K3dejxvDqGOWc PfPDqncE 2r+IZP5DAsaxHbTvR/bZWWZ0HQeE8BeUT/BlqrzpKBR1oRv445Gm478FO4LrLjCOiD4EBcvCAiRKoP5U8OGxT9fQBE4yp7G1HDBJ063lsTemPrFPaTAjYaZkf2MT+r4jIBcbSE2rSS2wcEHDnOXS8wP/1SethQclt9DKo X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: When CONFIG_X86_32 is defined and CONFIG_UML is not defined, vdso_enabled belongs to arch/x86/entry/vdso/vdso32-setup.c. So, move it into its own file. Before this patch, vdso_enabled was allowed to be set to a value exceeding 1 on x86_32 architecture. After this patch is applied, vdso_enabled is not permitted to set the value more than 1. It does not matter, because according to the function load_vdso32(), only vdso_enabled is set to 1, VDSO would be enabled. Other values all mean "disabled". The same limitation could be seen in the function vdso32_setup(). Signed-off-by: Kaixiong Yu Reviewed-by: Kees Cook --- arch/x86/entry/vdso/vdso32-setup.c | 16 +++++++++++----- kernel/sysctl.c | 8 +------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/arch/x86/entry/vdso/vdso32-setup.c b/arch/x86/entry/vdso/vdso32-setup.c index 76e4e74f35b5..5a6886a006ab 100644 --- a/arch/x86/entry/vdso/vdso32-setup.c +++ b/arch/x86/entry/vdso/vdso32-setup.c @@ -51,15 +51,17 @@ __setup("vdso32=", vdso32_setup); __setup_param("vdso=", vdso_setup, vdso32_setup, 0); #endif -#ifdef CONFIG_X86_64 #ifdef CONFIG_SYSCTL -/* Register vsyscall32 into the ABI table */ #include -static struct ctl_table abi_table2[] = { +static struct ctl_table vdso_table[] = { { +#ifdef CONFIG_X86_64 .procname = "vsyscall32", +#elif (defined(CONFIG_X86_32) && !defined(CONFIG_UML)) + .procname = "vdso_enabled", +#endif .data = &vdso32_enabled, .maxlen = sizeof(int), .mode = 0644, @@ -71,10 +73,14 @@ static struct ctl_table abi_table2[] = { static __init int ia32_binfmt_init(void) { - register_sysctl("abi", abi_table2); +#ifdef CONFIG_X86_64 + /* Register vsyscall32 into the ABI table */ + register_sysctl("abi", vdso_table); +#elif (defined(CONFIG_X86_32) && !defined(CONFIG_UML)) + register_sysctl_init("vm", vdso_table); +#endif return 0; } __initcall(ia32_binfmt_init); #endif /* CONFIG_SYSCTL */ -#endif /* CONFIG_X86_64 */ diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 6f03fc749794..24617be93119 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2023,17 +2023,11 @@ static struct ctl_table kern_table[] = { }; static struct ctl_table vm_table[] = { -#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \ - (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL)) +#if defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL) { .procname = "vdso_enabled", -#ifdef CONFIG_X86_32 - .data = &vdso32_enabled, - .maxlen = sizeof(vdso32_enabled), -#else .data = &vdso_enabled, .maxlen = sizeof(vdso_enabled), -#endif .mode = 0644, .proc_handler = proc_dointvec, .extra1 = SYSCTL_ZERO, From patchwork Tue Sep 3 03:30:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yukaixiong X-Patchwork-Id: 13787963 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 6F25ACD3427 for ; Tue, 3 Sep 2024 03:31:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CFA358D0134; Mon, 2 Sep 2024 23:31:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C85798D0119; Mon, 2 Sep 2024 23:31:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AD5098D0134; Mon, 2 Sep 2024 23:31:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 9077B8D0119 for ; Mon, 2 Sep 2024 23:31:41 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 4F98AC0307 for ; Tue, 3 Sep 2024 03:31:41 +0000 (UTC) X-FDA: 82522002402.25.5F1F6B6 Received: from szxga06-in.huawei.com (szxga06-in.huawei.com [45.249.212.32]) by imf24.hostedemail.com (Postfix) with ESMTP id E341D180004 for ; Tue, 3 Sep 2024 03:31:38 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf24.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.32 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725334223; a=rsa-sha256; cv=none; b=Y1cCgAZMrScF65gj4pCmB3jzwa7pdEcElU70KAEgIrCCOnSi4b22fKrup7AHYzD4un7Wmk 03zAktB4jaLhIfl+XuFX8IzQhflF5InQtg+NTmvt5HemMThMBryPhOYtvlNW+jS/6xtFz8 qotaHJXe0WrlOv4QMUbYwgb5HCNJZcQ= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf24.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.32 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725334223; 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=VfYEzkPFsF9AkAknCzuaF9x0tumE2fk5uby1PFfWFEY=; b=DYbP2k45hW+KWLLl1CZhRcWpG5Fzj7MYKFrJY+f9DvqOR/HZRCHU/FRXBLt/sNW8JXv0na KLD58vv1+aQsBYNMLPdE+mN4SWTdfM1XqPYLqP3q0Oitc0/TZgRjrwCRnzA9tB7U+MhF50 6w20Rva9ZxFfXd34hBoOau0ndz+zViI= Received: from mail.maildlp.com (unknown [172.19.88.214]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4WyWMM6C3nz1xwsb; Tue, 3 Sep 2024 11:29:35 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id 0D2CE1A016C; Tue, 3 Sep 2024 11:31:36 +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; Tue, 3 Sep 2024 11:31:33 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v2 -next 14/15] sh: vdso: move the sysctl into its own file Date: Tue, 3 Sep 2024 11:30:10 +0800 Message-ID: <20240903033011.2870608-15-yukaixiong@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240903033011.2870608-1-yukaixiong@huawei.com> References: <20240903033011.2870608-1-yukaixiong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemh100016.china.huawei.com (7.202.181.102) X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: E341D180004 X-Stat-Signature: xmdanyx5ehthcy68uqzypyps5s7cjbib X-Rspam-User: X-HE-Tag: 1725334298-911326 X-HE-Meta: U2FsdGVkX1+OBCXa1CkzNNKfLodSEI6iGaKq8MpNRJNea7TIQMA7DYgJnCto7t3EPI1UKaUlzyZcJljQkC+UMDlo0OM0+0JXdP6a8lVUBp6/XWZIpOQkhcMhoDeY15pCsRyut7o/Xz0DfRjjtWPCYaKnvbV18MVzRXYiBYxYt/BliayGypT4mc0DMssTpoC87SQ5ORU0ST4egIU162eWgbRvwbdCjVeyj0+dVfHER/UJ6piGKJw1Apo1ls35TNshlxTUpnfJUH7suXuzODzTTbVJsUXnjp0zvckfTyzrK/JbE7aHaK+kOEF1MipnvkV9X8zpzqgTTnwh9nPjdoIjVey2lwEhUHdSRk+BPcyZzXeNM9PKOfEa35oZmsGr25eq0LkRYeSuDYHqGgnoHCe/sm179kjiLIknkIkVpXoa5SrNRCv/78qvQNyTGdjwI2mDFuPIFteIlqGI6w5OoTFCSZyy5GVkS+Ay25/BrkXW3sBD/jR7ZHklczpMZJA19+91+qU2VAUMrmtx2qJgJjv4w0VchTRACFr/9dcWWyiLz3titMHjpz96JFxJXLoFD27YgFKJj2v0e7qH67qn+ytQTnhjNNuKrxiMSuTb5Q5Wva1Ibcg6jqurTxm2B9q2GtELLYvxzHFnF4naEK9AEuahwP9ZpuBtzjpQiouv9TtF1jBn0lY5chXkJEPQ3YqNiG+1ZjnUP4Ltle7HQzPNsVgASTdd15oSptNsiC5cUZMMWHOWyB4Z+iC7sJNVFKFzbrNggNZ5y0MVq895g0l0PGFBSqY8mi+tU9V1X5FAobbS6T75sdIhF7QwDWBjA6ecs4EnCGPKH55qTAAbTmMesvtJMk8Xmvv2Ydql3/rVCP2YXPjymZNciZ1tD8y7TPQdWMGozVTkJjeWW/z7l60x6g6WMYynaOqdmTKGCPwBOY0FoGgL8eFwmPLHpPZgrwg9Kuf5quObMzzI8PpGKRMw/N6 icfW220m CnYEJg9DZLx/MJ6bHSYihzht6wIx+94Ada4Vz6D9TGOZOEZQGIXHDhBs7CFTlaTeStOyPojkU4HRUNmHPzRz4v3bvq0sNkAht0zdr1DUvvdcdhWPZ27ga/tOVGPMFlHW2evRuph+Cu+lvqr3dQmYgprKG0izrhwdKz2U0 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 --- arch/sh/kernel/vsyscall/vsyscall.c | 14 ++++++++++++++ kernel/sysctl.c | 14 -------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/arch/sh/kernel/vsyscall/vsyscall.c b/arch/sh/kernel/vsyscall/vsyscall.c index add35c51e017..43bc3715e38c 100644 --- a/arch/sh/kernel/vsyscall/vsyscall.c +++ b/arch/sh/kernel/vsyscall/vsyscall.c @@ -14,6 +14,7 @@ #include #include #include +#include #include /* @@ -30,6 +31,17 @@ static int __init vdso_setup(char *s) } __setup("vdso=", vdso_setup); +static struct ctl_table vdso_table[] = { + { + .procname = "vdso_enabled", + .data = &vdso_enabled, + .maxlen = sizeof(vdso_enabled), + .mode = 0644, + .proc_handler = proc_dointvec, + .extra1 = SYSCTL_ZERO, + }, +}; + /* * These symbols are defined by vsyscall.o to mark the bounds * of the ELF DSO images included therein. @@ -55,6 +67,8 @@ int __init vsyscall_init(void) &vsyscall_trapa_start, &vsyscall_trapa_end - &vsyscall_trapa_start); + register_sysctl_init("vm", vdso_table); + return 0; } diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 24617be93119..f04da9f3abc6 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2022,23 +2022,9 @@ static struct ctl_table kern_table[] = { #endif }; -static struct ctl_table vm_table[] = { -#if defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL) - { - .procname = "vdso_enabled", - .data = &vdso_enabled, - .maxlen = sizeof(vdso_enabled), - .mode = 0644, - .proc_handler = proc_dointvec, - .extra1 = SYSCTL_ZERO, - }, -#endif -}; - int __init sysctl_init_bases(void) { register_sysctl_init("kernel", kern_table); - register_sysctl_init("vm", vm_table); return 0; } From patchwork Tue Sep 3 03:30:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yukaixiong X-Patchwork-Id: 13787964 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 7A351CA101E for ; Tue, 3 Sep 2024 03:31:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 18ABF8D0135; Mon, 2 Sep 2024 23:31:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 114228D0119; Mon, 2 Sep 2024 23:31:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E30DE8D0135; Mon, 2 Sep 2024 23:31:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id BE8338D0119 for ; Mon, 2 Sep 2024 23:31:43 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 7B8FA1601BA for ; Tue, 3 Sep 2024 03:31:43 +0000 (UTC) X-FDA: 82522002486.15.7C9CCE3 Received: from szxga06-in.huawei.com (szxga06-in.huawei.com [45.249.212.32]) by imf06.hostedemail.com (Postfix) with ESMTP id 62AF6180004 for ; Tue, 3 Sep 2024 03:31:41 +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.32 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725334278; a=rsa-sha256; cv=none; b=MSl4ctKYYXDxcZ5RT8sRivsW34a27LrGoBZRXxHvMWoPtP58RpcKdCZ8OwL/YZsCHuTBHZ /44S6SMPFm/U8YuXaxkxnGVL1WRVWAVNjjMZ7MV2wTEwM8A11D6cGF9KZrJdhqExSFaV0a lln1OlYRRXEiQdW+Xuo3kKWL322cLpM= 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.32 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725334278; 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=mQWP82lHT4RCvMqxbzEIa7Lr5Fr/QNBHCGl6GsGhasQ=; b=DYue2RZ+gfj944WDsdBQWmKqQu46nq1GPUEEO4wr6aHmOT9a8Lp4pbhWktayO3PRpRHAgt bmwNos+cZhm1AQPLI+w6l1q82dnk2kMwWeH2QKnNFaqLXf4cjgZpVFn8O7tykt1phQ33RE EmrfadfPnbWq+bLK1Z5PnC36pCT9cMY= Received: from mail.maildlp.com (unknown [172.19.162.112]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4WyWMQ2c15z1xwrZ; Tue, 3 Sep 2024 11:29:38 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id 881BE140360; Tue, 3 Sep 2024 11:31:38 +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; Tue, 3 Sep 2024 11:31:35 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v2 -next 15/15] sysctl: remove unneeded include Date: Tue, 3 Sep 2024 11:30:11 +0800 Message-ID: <20240903033011.2870608-16-yukaixiong@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240903033011.2870608-1-yukaixiong@huawei.com> References: <20240903033011.2870608-1-yukaixiong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemh100016.china.huawei.com (7.202.181.102) X-Rspam-User: X-Rspamd-Queue-Id: 62AF6180004 X-Rspamd-Server: rspam01 X-Stat-Signature: 8a3sg8zhdmu5xruxpw1widsdz84x1ba5 X-HE-Tag: 1725334301-66536 X-HE-Meta: U2FsdGVkX1+8k4WPUi8iFjmc7x+X5uHGqkHZoj0/G4oAjWUntO+VdG6rB4PCTOysN8ZxbdFzUj4RujUZ6OlJSn21nfZaAAS7V+h4XqWQdXtWaCrp2a5bv1kumt+Mzbzy28Sn3ose54+m69otyu0wJFgeEwnyjmZxfmW1z5ND6XjbylKA24iDkjMqU5lfSpPyvcxtUJjKlzOOtdql0rajJejXeiTYUSBa6x0yxa1L85i/Evpllxn2GBJnjhUSp8lFzZRzrZCWV+7eVVRujR1F0VSj2hicY07FoqRrJDTTdgsSQU3NKW62BELkoe4OX3sxDEML5ZAtd0+ZALxt5SRApEEI8ZG2F4UiVBJkdoTqwsqF9WUmdYxRFoU4Dql12/+ZYGw1hYFwJpHby2Q68gP5EUGOsbTOsbXEv9Yv2VyopOVBd929Ti2C4s8pAZUTveTV1hGm+KAYuEYsf3TySLFhtf+JF9rnpt/J4UcGEBO3VULJPSDMA9jP4Q5KKEwagR5S/sKt4PHVd/9h2DntN9efG0fSOkGWwU/ZQMGQRlcIqdXiMSIEUHglWGTf/PwVKlRsEeRrVNias39TOup0L8a5MYLu+/GkJz2At1G6wm+oZl2GTbU6X3BDmNA/yzPyFL7NtxwOSfwe6mEvcTDae1PbJOYwMi5CZJysRK1JtBIpGEgpGCcYTtglbXUhTMQdPGDBiLkALSzxeeJ52I4fMPi8LoEiA47kqEmSPCQTr9LtAST3XhX+ZvBLgPXTtNsdOqEWy7V/gfoOP1JgCa2aOP7+fi+5mcgDxZy8WQ/9eEb5Jl3fMeQvhhtx1EMhwdybnhFqmUEce1Y5iwZCSk32qJ/x5PZzUA3L1jAtyLuQXVh4RtbNtu6m6cN+K5qwDzpjbUGrDGu/awA5o72kJwYOhci5I4fi6Uxma2JFLEsh/cYCKgE3e+3Uvbmwo55OSeHLVZ8IYBP+mIBmIdlZxYKvJee JgJIszfZ OzrxSip92gIxwDgav91ROiBayarChEU5woHPDABjG85BItfS28u/Cum+ZaL0DlzHYvbD2LXIHDMd1fu4vpiAEt0OvySAaaUClXFcTtsDxy6J+suQzVUOi0mcTFIxmTKmGV6H7koAiJiTwDDChcbGX5QzHJ7rrREBjXO9Q1XXTRUcrl2TJRhmGCJkZ+2dcqgpM/Kd2BeKDe5928gQ= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Removing unneeded mm includes in kernel/sysctl.c. Signed-off-by: Kaixiong Yu Reviewed-by: Kees Cook --- kernel/sysctl.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/kernel/sysctl.c b/kernel/sysctl.c index f04da9f3abc6..6e3e0ce4da79 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -20,8 +20,6 @@ */ #include -#include -#include #include #include #include @@ -30,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -41,7 +38,6 @@ #include #include #include -#include #include #include #include @@ -52,13 +48,11 @@ #include #include #include -#include #include #include #include #include #include -#include #include #include "../lib/kstrtox.h"