2021-05-29 10:47:59

by Kefeng Wang

[permalink] [raw]
Subject: [PATCH 00/15] init_mm: setup init_mm text/data/brk by new setup_initial_init_mm() helper

Add setup_initial_init_mm() helper and use it to cleanup the text,
data and brk setup code.

Kefeng Wang (15):
mm: add setup_initial_init_mm() helper
arc: convert to setup_initial_init_mm()
arm: convert to setup_initial_init_mm()
arm64: convert to setup_initial_init_mm()
csky: convert to setup_initial_init_mm()
h8300: convert to setup_initial_init_mm()
m68k: convert to setup_initial_init_mm()
nds32: convert to setup_initial_init_mm()
nios2: convert to setup_initial_init_mm()
openrisc: convert to setup_initial_init_mm()
powerpc: convert to setup_initial_init_mm()
riscv: convert to setup_initial_init_mm()
s390: convert to setup_initial_init_mm()
sh: convert to setup_initial_init_mm()
x86: convert to setup_initial_init_mm()

arch/arc/mm/init.c | 5 +----
arch/arm/kernel/setup.c | 5 +----
arch/arm64/kernel/setup.c | 5 +----
arch/csky/kernel/setup.c | 5 +----
arch/h8300/kernel/setup.c | 5 +----
arch/m68k/kernel/setup_mm.c | 5 +----
arch/m68k/kernel/setup_no.c | 5 +----
arch/nds32/kernel/setup.c | 5 +----
arch/nios2/kernel/setup.c | 5 +----
arch/openrisc/kernel/setup.c | 5 +----
arch/powerpc/kernel/setup-common.c | 5 +----
arch/riscv/kernel/setup.c | 5 +----
arch/s390/kernel/setup.c | 5 +----
arch/sh/kernel/setup.c | 5 +----
arch/x86/kernel/setup.c | 5 +----
include/linux/mm_types.h | 10 ++++++++++
16 files changed, 25 insertions(+), 60 deletions(-)

--
2.26.2


2021-05-29 10:48:00

by Kefeng Wang

[permalink] [raw]
Subject: [PATCH 11/15] powerpc: convert to setup_initial_init_mm()

Use setup_initial_init_mm() helper to simplify code.

Cc: Michael Ellerman <[email protected]>
Cc: Benjamin Herrenschmidt <[email protected]>
Cc: [email protected]
Signed-off-by: Kefeng Wang <[email protected]>
---
arch/powerpc/kernel/setup-common.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
index 046fe21b5c3b..c046d99efd18 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -928,10 +928,7 @@ void __init setup_arch(char **cmdline_p)

klp_init_thread_info(&init_task);

- init_mm.start_code = (unsigned long)_stext;
- init_mm.end_code = (unsigned long) _etext;
- init_mm.end_data = (unsigned long) _edata;
- init_mm.brk = klimit;
+ setup_initial_init_mm(_stext, _etext, _edata, _end);

mm_iommu_init(&init_mm);
irqstack_early_init();
--
2.26.2

2021-05-29 10:48:58

by Kefeng Wang

[permalink] [raw]
Subject: [PATCH 14/15] sh: convert to setup_initial_init_mm()

Use setup_initial_init_mm() helper to simplify code.

Cc: Yoshinori Sato <[email protected]>
Cc: Rich Felker <[email protected]>
Cc: [email protected]
Signed-off-by: Kefeng Wang <[email protected]>
---
arch/sh/kernel/setup.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c
index 4144be650d41..1fcb6659822a 100644
--- a/arch/sh/kernel/setup.c
+++ b/arch/sh/kernel/setup.c
@@ -294,10 +294,7 @@ void __init setup_arch(char **cmdline_p)

if (!MOUNT_ROOT_RDONLY)
root_mountflags &= ~MS_RDONLY;
- init_mm.start_code = (unsigned long) _text;
- init_mm.end_code = (unsigned long) _etext;
- init_mm.end_data = (unsigned long) _edata;
- init_mm.brk = (unsigned long) _end;
+ setup_initial_init_mm(_text, _etext, _edata, _end);

code_resource.start = virt_to_phys(_text);
code_resource.end = virt_to_phys(_etext)-1;
--
2.26.2

2021-05-29 10:48:58

by Kefeng Wang

[permalink] [raw]
Subject: [PATCH 04/15] arm64: convert to setup_initial_init_mm()

Use setup_initial_init_mm() helper to simplify code.

Cc: Catalin Marinas <[email protected]>
Cc: Will Deacon <[email protected]>
Cc: [email protected]
Signed-off-by: Kefeng Wang <[email protected]>
---
arch/arm64/kernel/setup.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
index ac8222443ea8..08b0308b7f3b 100644
--- a/arch/arm64/kernel/setup.c
+++ b/arch/arm64/kernel/setup.c
@@ -293,10 +293,7 @@ u64 cpu_logical_map(unsigned int cpu)

void __init __no_sanitize_address setup_arch(char **cmdline_p)
{
- init_mm.start_code = (unsigned long) _stext;
- init_mm.end_code = (unsigned long) _etext;
- init_mm.end_data = (unsigned long) _edata;
- init_mm.brk = (unsigned long) _end;
+ setup_initial_init_mm(_stext, _etext, _edata, _end);

*cmdline_p = boot_command_line;

--
2.26.2

2021-05-29 10:48:58

by Kefeng Wang

[permalink] [raw]
Subject: [PATCH 12/15] riscv: convert to setup_initial_init_mm()

Use setup_initial_init_mm() helper to simplify code.

Cc: Paul Walmsley <[email protected]>
Cc: Palmer Dabbelt <[email protected]>
Cc: [email protected]
Signed-off-by: Kefeng Wang <[email protected]>
---
arch/riscv/kernel/setup.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c
index 4db4d0b5911f..c6623015f85f 100644
--- a/arch/riscv/kernel/setup.c
+++ b/arch/riscv/kernel/setup.c
@@ -264,10 +264,7 @@ static void __init parse_dtb(void)
void __init setup_arch(char **cmdline_p)
{
parse_dtb();
- init_mm.start_code = (unsigned long) _stext;
- init_mm.end_code = (unsigned long) _etext;
- init_mm.end_data = (unsigned long) _edata;
- init_mm.brk = (unsigned long) _end;
+ setup_initial_init_mm(_stext, _etext, _edata, _end);

*cmdline_p = boot_command_line;

--
2.26.2

2021-05-29 10:48:58

by Kefeng Wang

[permalink] [raw]
Subject: [PATCH 15/15] x86: convert to setup_initial_init_mm()

Use setup_initial_init_mm() helper to simplify code.

Cc: Thomas Gleixner <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: [email protected]
Signed-off-by: Kefeng Wang <[email protected]>
---
arch/x86/kernel/setup.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index bdcdd29efea6..9bc914c24778 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -869,10 +869,7 @@ void __init setup_arch(char **cmdline_p)

if (!boot_params.hdr.root_flags)
root_mountflags &= ~MS_RDONLY;
- init_mm.start_code = (unsigned long) _text;
- init_mm.end_code = (unsigned long) _etext;
- init_mm.end_data = (unsigned long) _edata;
- init_mm.brk = _brk_end;
+ setup_initial_init_mm(_text, _etext, _edata, _brk_end);

code_resource.start = __pa_symbol(_text);
code_resource.end = __pa_symbol(_etext)-1;
--
2.26.2

2021-05-29 10:49:04

by Kefeng Wang

[permalink] [raw]
Subject: [PATCH 05/15] csky: convert to setup_initial_init_mm()

Use setup_initial_init_mm() helper to simplify code.

Cc: Guo Ren <[email protected]>
Cc: [email protected]
Signed-off-by: Kefeng Wang <[email protected]>
---
arch/csky/kernel/setup.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/arch/csky/kernel/setup.c b/arch/csky/kernel/setup.c
index e93bc6f74432..c64e7be2045b 100644
--- a/arch/csky/kernel/setup.c
+++ b/arch/csky/kernel/setup.c
@@ -78,10 +78,7 @@ void __init setup_arch(char **cmdline_p)
pr_info("Phys. mem: %ldMB\n",
(unsigned long) memblock_phys_mem_size()/1024/1024);

- init_mm.start_code = (unsigned long) _stext;
- init_mm.end_code = (unsigned long) _etext;
- init_mm.end_data = (unsigned long) _edata;
- init_mm.brk = (unsigned long) _end;
+ setup_initial_init_mm(_stext, _etext, _edata, _end);

parse_early_param();

--
2.26.2

2021-05-29 10:49:39

by Kefeng Wang

[permalink] [raw]
Subject: [PATCH 13/15] s390: convert to setup_initial_init_mm()

Use setup_initial_init_mm() helper to simplify code.

Cc: Heiko Carstens <[email protected]>
Cc: Vasily Gorbik <[email protected]>
Cc: Christian Borntraeger <[email protected]>
Cc: [email protected]
Signed-off-by: Kefeng Wang <[email protected]>
---
arch/s390/kernel/setup.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c
index 146d01700a55..3feb9c5972eb 100644
--- a/arch/s390/kernel/setup.c
+++ b/arch/s390/kernel/setup.c
@@ -1096,10 +1096,7 @@ void __init setup_arch(char **cmdline_p)

ROOT_DEV = Root_RAM0;

- init_mm.start_code = (unsigned long) _text;
- init_mm.end_code = (unsigned long) _etext;
- init_mm.end_data = (unsigned long) _edata;
- init_mm.brk = (unsigned long) _end;
+ setup_initial_init_mm(_text, _etext, _edata, _end);

if (IS_ENABLED(CONFIG_EXPOLINE_AUTO))
nospec_auto_detect();
--
2.26.2

2021-05-29 12:53:20

by Santosh Sivaraj

[permalink] [raw]
Subject: Re: [PATCH 11/15] powerpc: convert to setup_initial_init_mm()

Kefeng Wang <[email protected]> writes:

> Use setup_initial_init_mm() helper to simplify code.
>
> Cc: Michael Ellerman <[email protected]>
> Cc: Benjamin Herrenschmidt <[email protected]>
> Cc: [email protected]
> Signed-off-by: Kefeng Wang <[email protected]>
> ---
> arch/powerpc/kernel/setup-common.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
> index 046fe21b5c3b..c046d99efd18 100644
> --- a/arch/powerpc/kernel/setup-common.c
> +++ b/arch/powerpc/kernel/setup-common.c
> @@ -928,10 +928,7 @@ void __init setup_arch(char **cmdline_p)
>
> klp_init_thread_info(&init_task);
>
> - init_mm.start_code = (unsigned long)_stext;
> - init_mm.end_code = (unsigned long) _etext;
> - init_mm.end_data = (unsigned long) _edata;
> - init_mm.brk = klimit;
> + setup_initial_init_mm(_stext, _etext, _edata, _end);

This function definition is not visible for those who have subscribed only to
linuxppc-dev mailing list. I had to do a web-search with the ID.

Thanks,
Santosh

>
> mm_iommu_init(&init_mm);
> irqstack_early_init();
> --
> 2.26.2

2021-05-29 15:19:21

by Christophe Leroy

[permalink] [raw]
Subject: Re: [PATCH 11/15] powerpc: convert to setup_initial_init_mm()

Santosh Sivaraj <[email protected]> a écrit :

> Kefeng Wang <[email protected]> writes:
>
>> Use setup_initial_init_mm() helper to simplify code.

I only got that patch, and patchwork as well
(https://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=246315)

Can you tell where I can see and get the full series ?

And next time can you copy all patches to linuxppc-dev

Thanks
Christophe

>>
>> Cc: Michael Ellerman <[email protected]>
>> Cc: Benjamin Herrenschmidt <[email protected]>
>> Cc: [email protected]
>> Signed-off-by: Kefeng Wang <[email protected]>
>> ---
>> arch/powerpc/kernel/setup-common.c | 5 +----
>> 1 file changed, 1 insertion(+), 4 deletions(-)
>>
>> diff --git a/arch/powerpc/kernel/setup-common.c
>> b/arch/powerpc/kernel/setup-common.c
>> index 046fe21b5c3b..c046d99efd18 100644
>> --- a/arch/powerpc/kernel/setup-common.c
>> +++ b/arch/powerpc/kernel/setup-common.c
>> @@ -928,10 +928,7 @@ void __init setup_arch(char **cmdline_p)
>>
>> klp_init_thread_info(&init_task);
>>
>> - init_mm.start_code = (unsigned long)_stext;
>> - init_mm.end_code = (unsigned long) _etext;
>> - init_mm.end_data = (unsigned long) _edata;
>> - init_mm.brk = klimit;
>> + setup_initial_init_mm(_stext, _etext, _edata, _end);
>
> This function definition is not visible for those who have subscribed only to
> linuxppc-dev mailing list. I had to do a web-search with the ID.
>
> Thanks,
> Santosh
>
>>
>> mm_iommu_init(&init_mm);
>> irqstack_early_init();
>> --
>> 2.26.2


2021-05-29 16:14:46

by Christophe Leroy

[permalink] [raw]
Subject: Re: [PATCH 11/15] powerpc: convert to setup_initial_init_mm()

Kefeng Wang <[email protected]> a écrit :

> Use setup_initial_init_mm() helper to simplify code.
>
> Cc: Michael Ellerman <[email protected]>
> Cc: Benjamin Herrenschmidt <[email protected]>
> Cc: [email protected]
> Signed-off-by: Kefeng Wang <[email protected]>
> ---
> arch/powerpc/kernel/setup-common.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/arch/powerpc/kernel/setup-common.c
> b/arch/powerpc/kernel/setup-common.c
> index 046fe21b5c3b..c046d99efd18 100644
> --- a/arch/powerpc/kernel/setup-common.c
> +++ b/arch/powerpc/kernel/setup-common.c
> @@ -928,10 +928,7 @@ void __init setup_arch(char **cmdline_p)
>
> klp_init_thread_info(&init_task);
>
> - init_mm.start_code = (unsigned long)_stext;
> - init_mm.end_code = (unsigned long) _etext;
> - init_mm.end_data = (unsigned long) _edata;
> - init_mm.brk = klimit;
> + setup_initial_init_mm(_stext, _etext, _edata, _end);

This looks wrong, should be klimit instead of _end IIUC

>
> mm_iommu_init(&init_mm);
> irqstack_early_init();
> --
> 2.26.2


2021-05-30 00:26:03

by Guo Ren

[permalink] [raw]
Subject: Re: [PATCH 05/15] csky: convert to setup_initial_init_mm()

Acked-by: Guo Ren <[email protected]>

Thx

On Sat, May 29, 2021 at 6:46 PM Kefeng Wang <[email protected]> wrote:
>
> Use setup_initial_init_mm() helper to simplify code.
>
> Cc: Guo Ren <[email protected]>
> Cc: [email protected]
> Signed-off-by: Kefeng Wang <[email protected]>
> ---
> arch/csky/kernel/setup.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/arch/csky/kernel/setup.c b/arch/csky/kernel/setup.c
> index e93bc6f74432..c64e7be2045b 100644
> --- a/arch/csky/kernel/setup.c
> +++ b/arch/csky/kernel/setup.c
> @@ -78,10 +78,7 @@ void __init setup_arch(char **cmdline_p)
> pr_info("Phys. mem: %ldMB\n",
> (unsigned long) memblock_phys_mem_size()/1024/1024);
>
> - init_mm.start_code = (unsigned long) _stext;
> - init_mm.end_code = (unsigned long) _etext;
> - init_mm.end_data = (unsigned long) _edata;
> - init_mm.brk = (unsigned long) _end;
> + setup_initial_init_mm(_stext, _etext, _edata, _end);
>
> parse_early_param();
>
> --
> 2.26.2
>


--
Best Regards
Guo Ren

ML: https://lore.kernel.org/linux-csky/

2021-05-31 01:10:25

by Kefeng Wang

[permalink] [raw]
Subject: Re: [PATCH 11/15] powerpc: convert to setup_initial_init_mm()


On 2021/5/29 23:22, Christophe Leroy wrote:
> Santosh Sivaraj <[email protected]> a écrit :
>
>> Kefeng Wang <[email protected]> writes:
>>
>>> Use setup_initial_init_mm() helper to simplify code.
>
> I only got that patch, and patchwork as well
> (https://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=246315)
>
> Can you tell where I can see and get the full series ?
>
> And next time can you copy all patches to linuxppc-dev

ok, will be careful next time, thank for your reminding.

>
> Thanks
> Christophe
>
>>>
>>> Cc: Michael Ellerman <[email protected]>
>>> Cc: Benjamin Herrenschmidt <[email protected]>
>>> Cc: [email protected]
>>> Signed-off-by: Kefeng Wang <[email protected]>
>>> ---
>>>  arch/powerpc/kernel/setup-common.c | 5 +----
>>>  1 file changed, 1 insertion(+), 4 deletions(-)
>>>
>>> diff --git a/arch/powerpc/kernel/setup-common.c
>>> b/arch/powerpc/kernel/setup-common.c
>>> index 046fe21b5c3b..c046d99efd18 100644
>>> --- a/arch/powerpc/kernel/setup-common.c
>>> +++ b/arch/powerpc/kernel/setup-common.c
>>> @@ -928,10 +928,7 @@ void __init setup_arch(char **cmdline_p)
>>>
>>>      klp_init_thread_info(&init_task);
>>>
>>> -    init_mm.start_code = (unsigned long)_stext;
>>> -    init_mm.end_code = (unsigned long) _etext;
>>> -    init_mm.end_data = (unsigned long) _edata;
>>> -    init_mm.brk = klimit;
>>> +    setup_initial_init_mm(_stext, _etext, _edata, _end);
>>
>> This function definition is not visible for those who have subscribed
>> only to
>> linuxppc-dev mailing list. I had to do a web-search with the ID.
>>
>> Thanks,
>> Santosh
>>
>>>
>>>      mm_iommu_init(&init_mm);
>>>      irqstack_early_init();
>>> --
>>> 2.26.2
>
>
> .
>

2021-05-31 01:10:35

by Kefeng Wang

[permalink] [raw]
Subject: Re: [PATCH 11/15] powerpc: convert to setup_initial_init_mm()


On 2021/5/30 0:16, Christophe Leroy wrote:
> Kefeng Wang <[email protected]> a écrit :
>
>> Use setup_initial_init_mm() helper to simplify code.
>>
>> Cc: Michael Ellerman <[email protected]>
>> Cc: Benjamin Herrenschmidt <[email protected]>
>> Cc: [email protected]
>> Signed-off-by: Kefeng Wang <[email protected]>
>> ---
>>  arch/powerpc/kernel/setup-common.c | 5 +----
>>  1 file changed, 1 insertion(+), 4 deletions(-)
>>
>> diff --git a/arch/powerpc/kernel/setup-common.c
>> b/arch/powerpc/kernel/setup-common.c
>> index 046fe21b5c3b..c046d99efd18 100644
>> --- a/arch/powerpc/kernel/setup-common.c
>> +++ b/arch/powerpc/kernel/setup-common.c
>> @@ -928,10 +928,7 @@ void __init setup_arch(char **cmdline_p)
>>
>>      klp_init_thread_info(&init_task);
>>
>> -    init_mm.start_code = (unsigned long)_stext;
>> -    init_mm.end_code = (unsigned long) _etext;
>> -    init_mm.end_data = (unsigned long) _edata;
>> -    init_mm.brk = klimit;
>> +    setup_initial_init_mm(_stext, _etext, _edata, _end);
>
> This looks wrong, should be klimit instead of _end IIUC

see  arch/powerpc/kernel/setup-common.c:

unsigned long klimit = (unsigned long) _end;

the setup_initial_init_mm helper [1] should use the original _end


+static inline void setup_initial_init_mm(char *start_code,
+ char *end_code,
+ char *end_data,
+ char *brk)
+{
+ init_mm.start_code = (unsigned long)start_code;
+ init_mm.end_code = (unsigned long)end_code;
+ init_mm.end_data = (unsigned long)end_data;
+ init_mm.brk = (unsigned long)brk;
+}

[1] https://lkml.org/lkml/2021/5/29/84

>
>>
>>      mm_iommu_init(&init_mm);
>>      irqstack_early_init();
>> --
>> 2.26.2
>
>
> .
>