* [PATCH] mm: hugetlb: move hugeltb sysctls to its own file
@ 2023-03-09 12:20 Kefeng Wang
2023-03-09 20:34 ` Luis Chamberlain
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: Kefeng Wang @ 2023-03-09 12:20 UTC (permalink / raw)
To: Luis Chamberlain, Mike Kravetz, Muchun Song
Cc: Andrew Morton, linux-mm, linux-kernel, linux-fsdevel, Kees Cook,
Iurii Zaikin, Kefeng Wang
This moves all hugetlb sysctls to its own file, also kill an
useless hugetlb_treat_movable_handler() defination.
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
include/linux/hugetlb.h | 8 -------
kernel/sysctl.c | 32 --------------------------
mm/hugetlb.c | 51 ++++++++++++++++++++++++++++++++++++++---
3 files changed, 48 insertions(+), 43 deletions(-)
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index 7c977d234aba..4056b05d81ed 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -124,14 +124,6 @@ void hugepage_put_subpool(struct hugepage_subpool *spool);
void hugetlb_dup_vma_private(struct vm_area_struct *vma);
void clear_vma_resv_huge_pages(struct vm_area_struct *vma);
-int hugetlb_sysctl_handler(struct ctl_table *, int, void *, size_t *, loff_t *);
-int hugetlb_overcommit_handler(struct ctl_table *, int, void *, size_t *,
- loff_t *);
-int hugetlb_treat_movable_handler(struct ctl_table *, int, void *, size_t *,
- loff_t *);
-int hugetlb_mempolicy_sysctl_handler(struct ctl_table *, int, void *, size_t *,
- loff_t *);
-
int move_hugetlb_page_tables(struct vm_area_struct *vma,
struct vm_area_struct *new_vma,
unsigned long old_addr, unsigned long new_addr,
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index c14552a662ae..ce0297acf97c 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -2140,38 +2140,6 @@ static struct ctl_table vm_table[] = {
.extra1 = SYSCTL_ZERO,
.extra2 = SYSCTL_ONE,
},
-#endif
-#ifdef CONFIG_HUGETLB_PAGE
- {
- .procname = "nr_hugepages",
- .data = NULL,
- .maxlen = sizeof(unsigned long),
- .mode = 0644,
- .proc_handler = hugetlb_sysctl_handler,
- },
-#ifdef CONFIG_NUMA
- {
- .procname = "nr_hugepages_mempolicy",
- .data = NULL,
- .maxlen = sizeof(unsigned long),
- .mode = 0644,
- .proc_handler = &hugetlb_mempolicy_sysctl_handler,
- },
-#endif
- {
- .procname = "hugetlb_shm_group",
- .data = &sysctl_hugetlb_shm_group,
- .maxlen = sizeof(gid_t),
- .mode = 0644,
- .proc_handler = proc_dointvec,
- },
- {
- .procname = "nr_overcommit_hugepages",
- .data = NULL,
- .maxlen = sizeof(unsigned long),
- .mode = 0644,
- .proc_handler = hugetlb_overcommit_handler,
- },
#endif
{
.procname = "lowmem_reserve_ratio",
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 712e32b38295..c44958a0f586 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -4202,6 +4202,12 @@ static void __init hugetlb_sysfs_init(void)
hugetlb_register_all_nodes();
}
+#ifdef CONFIG_SYSCTL
+static void hugetlb_sysctl_init(void);
+#else
+static inline void hugetlb_sysctl_init(void) { }
+#endif
+
static int __init hugetlb_init(void)
{
int i;
@@ -4257,6 +4263,7 @@ static int __init hugetlb_init(void)
hugetlb_sysfs_init();
hugetlb_cgroup_file_init();
+ hugetlb_sysctl_init();
#ifdef CONFIG_SMP
num_fault_mutexes = roundup_pow_of_two(8 * num_possible_cpus());
@@ -4588,7 +4595,7 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
return ret;
}
-int hugetlb_sysctl_handler(struct ctl_table *table, int write,
+static int hugetlb_sysctl_handler(struct ctl_table *table, int write,
void *buffer, size_t *length, loff_t *ppos)
{
@@ -4597,7 +4604,7 @@ int hugetlb_sysctl_handler(struct ctl_table *table, int write,
}
#ifdef CONFIG_NUMA
-int hugetlb_mempolicy_sysctl_handler(struct ctl_table *table, int write,
+static int hugetlb_mempolicy_sysctl_handler(struct ctl_table *table, int write,
void *buffer, size_t *length, loff_t *ppos)
{
return hugetlb_sysctl_handler_common(true, table, write,
@@ -4605,7 +4612,7 @@ int hugetlb_mempolicy_sysctl_handler(struct ctl_table *table, int write,
}
#endif /* CONFIG_NUMA */
-int hugetlb_overcommit_handler(struct ctl_table *table, int write,
+static int hugetlb_overcommit_handler(struct ctl_table *table, int write,
void *buffer, size_t *length, loff_t *ppos)
{
struct hstate *h = &default_hstate;
@@ -4634,6 +4641,44 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
return ret;
}
+static struct ctl_table hugetlb_table[] = {
+ {
+ .procname = "nr_hugepages",
+ .data = NULL,
+ .maxlen = sizeof(unsigned long),
+ .mode = 0644,
+ .proc_handler = hugetlb_sysctl_handler,
+ },
+#ifdef CONFIG_NUMA
+ {
+ .procname = "nr_hugepages_mempolicy",
+ .data = NULL,
+ .maxlen = sizeof(unsigned long),
+ .mode = 0644,
+ .proc_handler = &hugetlb_mempolicy_sysctl_handler,
+ },
+#endif
+ {
+ .procname = "hugetlb_shm_group",
+ .data = &sysctl_hugetlb_shm_group,
+ .maxlen = sizeof(gid_t),
+ .mode = 0644,
+ .proc_handler = proc_dointvec,
+ },
+ {
+ .procname = "nr_overcommit_hugepages",
+ .data = NULL,
+ .maxlen = sizeof(unsigned long),
+ .mode = 0644,
+ .proc_handler = hugetlb_overcommit_handler,
+ },
+ { }
+};
+
+static void hugetlb_sysctl_init(void)
+{
+ register_sysctl_init("vm", hugetlb_table);
+}
#endif /* CONFIG_SYSCTL */
void hugetlb_report_meminfo(struct seq_file *m)
--
2.35.3
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] mm: hugetlb: move hugeltb sysctls to its own file
2023-03-09 12:20 [PATCH] mm: hugetlb: move hugeltb sysctls to its own file Kefeng Wang
@ 2023-03-09 20:34 ` Luis Chamberlain
2023-03-09 21:08 ` Andrew Morton
2023-03-09 21:30 ` Mike Kravetz
` (2 subsequent siblings)
3 siblings, 1 reply; 8+ messages in thread
From: Luis Chamberlain @ 2023-03-09 20:34 UTC (permalink / raw)
To: Kefeng Wang
Cc: Mike Kravetz, Muchun Song, Andrew Morton, linux-mm, linux-kernel,
linux-fsdevel, Kees Cook, Iurii Zaikin
On Thu, Mar 09, 2023 at 08:20:11PM +0800, Kefeng Wang wrote:
> This moves all hugetlb sysctls to its own file, also kill an
> useless hugetlb_treat_movable_handler() defination.
>
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
LGTM
Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
Mike and hugetlb gang, are you OK with me taking this patch through
sysctl-next to avoid conflicts as we trim down kernel/sysctl.c ?
Luis
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] mm: hugetlb: move hugeltb sysctls to its own file
2023-03-09 20:34 ` Luis Chamberlain
@ 2023-03-09 21:08 ` Andrew Morton
2023-03-09 22:20 ` Luis Chamberlain
0 siblings, 1 reply; 8+ messages in thread
From: Andrew Morton @ 2023-03-09 21:08 UTC (permalink / raw)
To: Luis Chamberlain
Cc: Kefeng Wang, Mike Kravetz, Muchun Song, linux-mm, linux-kernel,
linux-fsdevel, Kees Cook, Iurii Zaikin
On Thu, 9 Mar 2023 12:34:56 -0800 Luis Chamberlain <mcgrof@kernel.org> wrote:
> Mike and hugetlb gang, are you OK with me taking this patch through
> sysctl-next to avoid conflicts as we trim down kernel/sysctl.c ?
Sure, go ahead. Stephen will tell us if there's a collision with mm-git material.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] mm: hugetlb: move hugeltb sysctls to its own file
2023-03-09 12:20 [PATCH] mm: hugetlb: move hugeltb sysctls to its own file Kefeng Wang
2023-03-09 20:34 ` Luis Chamberlain
@ 2023-03-09 21:30 ` Mike Kravetz
2023-03-10 2:36 ` Muchun Song
2023-03-10 14:23 ` Kefeng Wang
3 siblings, 0 replies; 8+ messages in thread
From: Mike Kravetz @ 2023-03-09 21:30 UTC (permalink / raw)
To: Kefeng Wang
Cc: Luis Chamberlain, Muchun Song, Andrew Morton, linux-mm,
linux-kernel, linux-fsdevel, Kees Cook, Iurii Zaikin
On 03/09/23 20:20, Kefeng Wang wrote:
> This moves all hugetlb sysctls to its own file, also kill an
> useless hugetlb_treat_movable_handler() defination.
I guess hugetlb_treat_movable_handler should have been removed as part
of commit d6cb41cc44c6 mm, hugetlb: remove hugepages_treat_as_movable sysctl.
>
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> ---
> include/linux/hugetlb.h | 8 -------
> kernel/sysctl.c | 32 --------------------------
> mm/hugetlb.c | 51 ++++++++++++++++++++++++++++++++++++++---
> 3 files changed, 48 insertions(+), 43 deletions(-)
Thanks! Changes look fine to me,
Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
--
Mike Kravetz
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] mm: hugetlb: move hugeltb sysctls to its own file
2023-03-09 21:08 ` Andrew Morton
@ 2023-03-09 22:20 ` Luis Chamberlain
0 siblings, 0 replies; 8+ messages in thread
From: Luis Chamberlain @ 2023-03-09 22:20 UTC (permalink / raw)
To: Andrew Morton
Cc: Kefeng Wang, Mike Kravetz, Muchun Song, linux-mm, linux-kernel,
linux-fsdevel, Kees Cook, Iurii Zaikin
On Thu, Mar 09, 2023 at 01:08:40PM -0800, Andrew Morton wrote:
> On Thu, 9 Mar 2023 12:34:56 -0800 Luis Chamberlain <mcgrof@kernel.org> wrote:
>
> > Mike and hugetlb gang, are you OK with me taking this patch through
> > sysctl-next to avoid conflicts as we trim down kernel/sysctl.c ?
>
> Sure, go ahead. Stephen will tell us if there's a collision with mm-git material.
OK thanks, merged onto sysct-next ! Who knows maybe this release we'll
trim down completely that large kernel/sysctl.c file finally.
Luis
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] mm: hugetlb: move hugeltb sysctls to its own file
2023-03-09 12:20 [PATCH] mm: hugetlb: move hugeltb sysctls to its own file Kefeng Wang
2023-03-09 20:34 ` Luis Chamberlain
2023-03-09 21:30 ` Mike Kravetz
@ 2023-03-10 2:36 ` Muchun Song
2023-03-10 14:23 ` Kefeng Wang
3 siblings, 0 replies; 8+ messages in thread
From: Muchun Song @ 2023-03-10 2:36 UTC (permalink / raw)
To: Kefeng Wang
Cc: Luis Chamberlain, Mike Kravetz, Andrew Morton, linux-mm,
linux-kernel, linux-fsdevel, Kees Cook, Iurii Zaikin
> On Mar 9, 2023, at 20:20, Kefeng Wang <wangkefeng.wang@huawei.com> wrote:
>
> This moves all hugetlb sysctls to its own file, also kill an
> useless hugetlb_treat_movable_handler() defination.
>
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Reviewed-by: Muchun Song <songmuchun@bytedance.com>
Thanks.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] mm: hugetlb: move hugeltb sysctls to its own file
2023-03-09 12:20 [PATCH] mm: hugetlb: move hugeltb sysctls to its own file Kefeng Wang
` (2 preceding siblings ...)
2023-03-10 2:36 ` Muchun Song
@ 2023-03-10 14:23 ` Kefeng Wang
2023-03-10 19:53 ` Luis Chamberlain
3 siblings, 1 reply; 8+ messages in thread
From: Kefeng Wang @ 2023-03-10 14:23 UTC (permalink / raw)
To: Luis Chamberlain, Mike Kravetz, Muchun Song
Cc: Andrew Morton, linux-mm, linux-kernel, linux-fsdevel, Kees Cook,
Iurii Zaikin
On 2023/3/9 20:20, Kefeng Wang wrote:
> This moves all hugetlb sysctls to its own file, also kill an
> useless hugetlb_treat_movable_handler() defination.
>
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> ---
> include/linux/hugetlb.h | 8 -------
> kernel/sysctl.c | 32 --------------------------
> mm/hugetlb.c | 51 ++++++++++++++++++++++++++++++++++++++---
> 3 files changed, 48 insertions(+), 43 deletions(-)
>
> +#ifdef CONFIG_SYSCTL
> +static void hugetlb_sysctl_init(void);
Hi Luis,this should add __init as it is called by hugetlb_init,
could you help to change it, or I could send a new patch.
> +#else
> +static inline void hugetlb_sysctl_init(void) { }
> +#endif
> +
> static int __init hugetlb_init(void)
> {
> int i;
> @@ -4257,6 +4263,7 @@ static int __init hugetlb_init(void)
>
> hugetlb_sysfs_init();
> hugetlb_cgroup_file_init();
> + hugetlb_sysctl_init();
>
...
> +
> +static void hugetlb_sysctl_init(void)
ditto, sorry for the mistake.
Thanks.
> +{
> + register_sysctl_init("vm", hugetlb_table);
> +}
> #endif /* CONFIG_SYSCTL */
>
> void hugetlb_report_meminfo(struct seq_file *m)
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] mm: hugetlb: move hugeltb sysctls to its own file
2023-03-10 14:23 ` Kefeng Wang
@ 2023-03-10 19:53 ` Luis Chamberlain
0 siblings, 0 replies; 8+ messages in thread
From: Luis Chamberlain @ 2023-03-10 19:53 UTC (permalink / raw)
To: Kefeng Wang
Cc: Mike Kravetz, Muchun Song, Andrew Morton, linux-mm, linux-kernel,
linux-fsdevel, Kees Cook, Iurii Zaikin
On Fri, Mar 10, 2023 at 10:23:34PM +0800, Kefeng Wang wrote:
>
>
> On 2023/3/9 20:20, Kefeng Wang wrote:
> > This moves all hugetlb sysctls to its own file, also kill an
> > useless hugetlb_treat_movable_handler() defination.
> >
> > Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> > ---
> > include/linux/hugetlb.h | 8 -------
> > kernel/sysctl.c | 32 --------------------------
> > mm/hugetlb.c | 51 ++++++++++++++++++++++++++++++++++++++---
> > 3 files changed, 48 insertions(+), 43 deletions(-)
> >
>
> > +#ifdef CONFIG_SYSCTL
> > +static void hugetlb_sysctl_init(void);
>
> Hi Luis,this should add __init as it is called by hugetlb_init,
> could you help to change it, or I could send a new patch.
>
>
> > +#else
> > +static inline void hugetlb_sysctl_init(void) { }
> > +#endif
> > +
> > static int __init hugetlb_init(void)
> > {
> > int i;
> > @@ -4257,6 +4263,7 @@ static int __init hugetlb_init(void)
> > hugetlb_sysfs_init();
> > hugetlb_cgroup_file_init();
> > + hugetlb_sysctl_init();
> ...
> > +
> > +static void hugetlb_sysctl_init(void)
>
> ditto, sorry for the mistake.
Just send a fix.
Luis
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2023-03-10 19:53 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-09 12:20 [PATCH] mm: hugetlb: move hugeltb sysctls to its own file Kefeng Wang
2023-03-09 20:34 ` Luis Chamberlain
2023-03-09 21:08 ` Andrew Morton
2023-03-09 22:20 ` Luis Chamberlain
2023-03-09 21:30 ` Mike Kravetz
2023-03-10 2:36 ` Muchun Song
2023-03-10 14:23 ` Kefeng Wang
2023-03-10 19:53 ` Luis Chamberlain
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox