* [PATCH RESEND 1/8] s390: Start fallback of top-down mmap at mm->mmap_base
2019-06-20 5:03 [PATCH RESEND 0/8] Fix mmap base in bottom-up mmap Alexandre Ghiti
@ 2019-06-20 5:03 ` Alexandre Ghiti
2019-06-20 5:03 ` [PATCH RESEND 2/8] sh: " Alexandre Ghiti
` (8 subsequent siblings)
9 siblings, 0 replies; 17+ messages in thread
From: Alexandre Ghiti @ 2019-06-20 5:03 UTC (permalink / raw)
To: Andrew Morton
Cc: James E . J . Bottomley, Helge Deller, Heiko Carstens,
Vasily Gorbik, Christian Borntraeger, Yoshinori Sato,
Rich Felker, David S . Miller, Thomas Gleixner, Ingo Molnar,
Borislav Petkov, H . Peter Anvin, x86, Dave Hansen,
Andy Lutomirski, Peter Zijlstra, linux-parisc, linux-kernel,
linux-s390, linux-sh, sparclinux, linux-mm, Alexandre Ghiti
In case of mmap failure in top-down mode, there is no need to go through
the whole address space again for the bottom-up fallback: the goal of this
fallback is to find, as a last resort, space between the top-down mmap base
and the stack, which is the only place not covered by the top-down mmap.
Signed-off-by: Alexandre Ghiti <alex@ghiti.fr>
---
arch/s390/mm/mmap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
index cbc718ba6d78..4a222969843b 100644
--- a/arch/s390/mm/mmap.c
+++ b/arch/s390/mm/mmap.c
@@ -166,7 +166,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
if (addr & ~PAGE_MASK) {
VM_BUG_ON(addr != -ENOMEM);
info.flags = 0;
- info.low_limit = TASK_UNMAPPED_BASE;
+ info.low_limit = mm->mmap_base;
info.high_limit = TASK_SIZE;
addr = vm_unmapped_area(&info);
if (addr & ~PAGE_MASK)
--
2.20.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH RESEND 2/8] sh: Start fallback of top-down mmap at mm->mmap_base
2019-06-20 5:03 [PATCH RESEND 0/8] Fix mmap base in bottom-up mmap Alexandre Ghiti
2019-06-20 5:03 ` [PATCH RESEND 1/8] s390: Start fallback of top-down mmap at mm->mmap_base Alexandre Ghiti
@ 2019-06-20 5:03 ` Alexandre Ghiti
2019-06-20 5:03 ` [PATCH RESEND 3/8] sparc: " Alexandre Ghiti
` (7 subsequent siblings)
9 siblings, 0 replies; 17+ messages in thread
From: Alexandre Ghiti @ 2019-06-20 5:03 UTC (permalink / raw)
To: Andrew Morton
Cc: James E . J . Bottomley, Helge Deller, Heiko Carstens,
Vasily Gorbik, Christian Borntraeger, Yoshinori Sato,
Rich Felker, David S . Miller, Thomas Gleixner, Ingo Molnar,
Borislav Petkov, H . Peter Anvin, x86, Dave Hansen,
Andy Lutomirski, Peter Zijlstra, linux-parisc, linux-kernel,
linux-s390, linux-sh, sparclinux, linux-mm, Alexandre Ghiti
In case of mmap failure in top-down mode, there is no need to go through
the whole address space again for the bottom-up fallback: the goal of this
fallback is to find, as a last resort, space between the top-down mmap base
and the stack, which is the only place not covered by the top-down mmap.
Signed-off-by: Alexandre Ghiti <alex@ghiti.fr>
---
arch/sh/mm/mmap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/sh/mm/mmap.c b/arch/sh/mm/mmap.c
index 6a1a1297baae..4c7da92473dd 100644
--- a/arch/sh/mm/mmap.c
+++ b/arch/sh/mm/mmap.c
@@ -135,7 +135,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
if (addr & ~PAGE_MASK) {
VM_BUG_ON(addr != -ENOMEM);
info.flags = 0;
- info.low_limit = TASK_UNMAPPED_BASE;
+ info.low_limit = mm->mmap_base;
info.high_limit = TASK_SIZE;
addr = vm_unmapped_area(&info);
}
--
2.20.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH RESEND 3/8] sparc: Start fallback of top-down mmap at mm->mmap_base
2019-06-20 5:03 [PATCH RESEND 0/8] Fix mmap base in bottom-up mmap Alexandre Ghiti
2019-06-20 5:03 ` [PATCH RESEND 1/8] s390: Start fallback of top-down mmap at mm->mmap_base Alexandre Ghiti
2019-06-20 5:03 ` [PATCH RESEND 2/8] sh: " Alexandre Ghiti
@ 2019-06-20 5:03 ` Alexandre Ghiti
2019-06-20 5:03 ` [PATCH RESEND 4/8] x86, hugetlbpage: " Alexandre Ghiti
` (6 subsequent siblings)
9 siblings, 0 replies; 17+ messages in thread
From: Alexandre Ghiti @ 2019-06-20 5:03 UTC (permalink / raw)
To: Andrew Morton
Cc: James E . J . Bottomley, Helge Deller, Heiko Carstens,
Vasily Gorbik, Christian Borntraeger, Yoshinori Sato,
Rich Felker, David S . Miller, Thomas Gleixner, Ingo Molnar,
Borislav Petkov, H . Peter Anvin, x86, Dave Hansen,
Andy Lutomirski, Peter Zijlstra, linux-parisc, linux-kernel,
linux-s390, linux-sh, sparclinux, linux-mm, Alexandre Ghiti
In case of mmap failure in top-down mode, there is no need to go through
the whole address space again for the bottom-up fallback: the goal of this
fallback is to find, as a last resort, space between the top-down mmap base
and the stack, which is the only place not covered by the top-down mmap.
Signed-off-by: Alexandre Ghiti <alex@ghiti.fr>
---
arch/sparc/kernel/sys_sparc_64.c | 2 +-
arch/sparc/mm/hugetlbpage.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
index ccc88926bc00..ea1de1e5fa8d 100644
--- a/arch/sparc/kernel/sys_sparc_64.c
+++ b/arch/sparc/kernel/sys_sparc_64.c
@@ -206,7 +206,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
if (addr & ~PAGE_MASK) {
VM_BUG_ON(addr != -ENOMEM);
info.flags = 0;
- info.low_limit = TASK_UNMAPPED_BASE;
+ info.low_limit = mm->mmap_base;
info.high_limit = STACK_TOP32;
addr = vm_unmapped_area(&info);
}
diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
index f78793a06bbd..9c67f805abc8 100644
--- a/arch/sparc/mm/hugetlbpage.c
+++ b/arch/sparc/mm/hugetlbpage.c
@@ -86,7 +86,7 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
if (addr & ~PAGE_MASK) {
VM_BUG_ON(addr != -ENOMEM);
info.flags = 0;
- info.low_limit = TASK_UNMAPPED_BASE;
+ info.low_limit = mm->mmap_base;
info.high_limit = STACK_TOP32;
addr = vm_unmapped_area(&info);
}
--
2.20.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH RESEND 4/8] x86, hugetlbpage: Start fallback of top-down mmap at mm->mmap_base
2019-06-20 5:03 [PATCH RESEND 0/8] Fix mmap base in bottom-up mmap Alexandre Ghiti
` (2 preceding siblings ...)
2019-06-20 5:03 ` [PATCH RESEND 3/8] sparc: " Alexandre Ghiti
@ 2019-06-20 5:03 ` Alexandre Ghiti
2019-06-20 5:03 ` [PATCH RESEND 5/8] mm: Start fallback " Alexandre Ghiti
` (5 subsequent siblings)
9 siblings, 0 replies; 17+ messages in thread
From: Alexandre Ghiti @ 2019-06-20 5:03 UTC (permalink / raw)
To: Andrew Morton
Cc: James E . J . Bottomley, Helge Deller, Heiko Carstens,
Vasily Gorbik, Christian Borntraeger, Yoshinori Sato,
Rich Felker, David S . Miller, Thomas Gleixner, Ingo Molnar,
Borislav Petkov, H . Peter Anvin, x86, Dave Hansen,
Andy Lutomirski, Peter Zijlstra, linux-parisc, linux-kernel,
linux-s390, linux-sh, sparclinux, linux-mm, Alexandre Ghiti
In case of mmap failure in top-down mode, there is no need to go through
the whole address space again for the bottom-up fallback: the goal of this
fallback is to find, as a last resort, space between the top-down mmap base
and the stack, which is the only place not covered by the top-down mmap.
Signed-off-by: Alexandre Ghiti <alex@ghiti.fr>
---
arch/x86/mm/hugetlbpage.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
index fab095362c50..4b90339aef50 100644
--- a/arch/x86/mm/hugetlbpage.c
+++ b/arch/x86/mm/hugetlbpage.c
@@ -106,11 +106,12 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
{
struct hstate *h = hstate_file(file);
struct vm_unmapped_area_info info;
+ unsigned long mmap_base = get_mmap_base(0);
info.flags = VM_UNMAPPED_AREA_TOPDOWN;
info.length = len;
info.low_limit = PAGE_SIZE;
- info.high_limit = get_mmap_base(0);
+ info.high_limit = mmap_base;
/*
* If hint address is above DEFAULT_MAP_WINDOW, look for unmapped area
@@ -132,7 +133,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
if (addr & ~PAGE_MASK) {
VM_BUG_ON(addr != -ENOMEM);
info.flags = 0;
- info.low_limit = TASK_UNMAPPED_BASE;
+ info.low_limit = mmap_base;
info.high_limit = TASK_SIZE_LOW;
addr = vm_unmapped_area(&info);
}
--
2.20.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH RESEND 5/8] mm: Start fallback top-down mmap at mm->mmap_base
2019-06-20 5:03 [PATCH RESEND 0/8] Fix mmap base in bottom-up mmap Alexandre Ghiti
` (3 preceding siblings ...)
2019-06-20 5:03 ` [PATCH RESEND 4/8] x86, hugetlbpage: " Alexandre Ghiti
@ 2019-06-20 5:03 ` Alexandre Ghiti
2019-06-20 5:03 ` [PATCH RESEND 6/8] parisc: Use mmap_base, not mmap_legacy_base, as low_limit for bottom-up mmap Alexandre Ghiti
` (4 subsequent siblings)
9 siblings, 0 replies; 17+ messages in thread
From: Alexandre Ghiti @ 2019-06-20 5:03 UTC (permalink / raw)
To: Andrew Morton
Cc: James E . J . Bottomley, Helge Deller, Heiko Carstens,
Vasily Gorbik, Christian Borntraeger, Yoshinori Sato,
Rich Felker, David S . Miller, Thomas Gleixner, Ingo Molnar,
Borislav Petkov, H . Peter Anvin, x86, Dave Hansen,
Andy Lutomirski, Peter Zijlstra, linux-parisc, linux-kernel,
linux-s390, linux-sh, sparclinux, linux-mm, Alexandre Ghiti
In case of mmap failure in top-down mode, there is no need to go through
the whole address space again for the bottom-up fallback: the goal of this
fallback is to find, as a last resort, space between the top-down mmap base
and the stack, which is the only place not covered by the top-down mmap.
Signed-off-by: Alexandre Ghiti <alex@ghiti.fr>
---
mm/mmap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/mmap.c b/mm/mmap.c
index dedae10cb6e2..e563145c1ff4 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -2185,7 +2185,7 @@ arch_get_unmapped_area_topdown(struct file *filp, unsigned long addr,
if (offset_in_page(addr)) {
VM_BUG_ON(addr != -ENOMEM);
info.flags = 0;
- info.low_limit = TASK_UNMAPPED_BASE;
+ info.low_limit = arch_get_mmap_base(addr, mm->mmap_base);
info.high_limit = mmap_end;
addr = vm_unmapped_area(&info);
}
--
2.20.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH RESEND 6/8] parisc: Use mmap_base, not mmap_legacy_base, as low_limit for bottom-up mmap
2019-06-20 5:03 [PATCH RESEND 0/8] Fix mmap base in bottom-up mmap Alexandre Ghiti
` (4 preceding siblings ...)
2019-06-20 5:03 ` [PATCH RESEND 5/8] mm: Start fallback " Alexandre Ghiti
@ 2019-06-20 5:03 ` Alexandre Ghiti
2019-06-25 14:09 ` Helge Deller
2019-06-20 5:03 ` [PATCH RESEND 7/8] x86: Use mmap_*base, not mmap_*legacy_base, " Alexandre Ghiti
` (3 subsequent siblings)
9 siblings, 1 reply; 17+ messages in thread
From: Alexandre Ghiti @ 2019-06-20 5:03 UTC (permalink / raw)
To: Andrew Morton
Cc: James E . J . Bottomley, Helge Deller, Heiko Carstens,
Vasily Gorbik, Christian Borntraeger, Yoshinori Sato,
Rich Felker, David S . Miller, Thomas Gleixner, Ingo Molnar,
Borislav Petkov, H . Peter Anvin, x86, Dave Hansen,
Andy Lutomirski, Peter Zijlstra, linux-parisc, linux-kernel,
linux-s390, linux-sh, sparclinux, linux-mm, Alexandre Ghiti
Bottom-up mmap scheme is used twice:
- for legacy mode, in which mmap_legacy_base and mmap_base are equal.
- in case of mmap failure in top-down mode, where there is no need to go
through the whole address space again for the bottom-up fallback: the goal
of this fallback is to find, as a last resort, space between the top-down
mmap base and the stack, which is the only place not covered by the
top-down mmap.
Then this commit removes the usage of mmap_legacy_base field from parisc
code.
Signed-off-by: Alexandre Ghiti <alex@ghiti.fr>
---
arch/parisc/kernel/sys_parisc.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
index 5d458a44b09c..e987f3a8eb0b 100644
--- a/arch/parisc/kernel/sys_parisc.c
+++ b/arch/parisc/kernel/sys_parisc.c
@@ -119,7 +119,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
info.flags = 0;
info.length = len;
- info.low_limit = mm->mmap_legacy_base;
+ info.low_limit = mm->mmap_base;
info.high_limit = mmap_upper_limit(NULL);
info.align_mask = last_mmap ? (PAGE_MASK & (SHM_COLOUR - 1)) : 0;
info.align_offset = shared_align_offset(last_mmap, pgoff);
@@ -240,13 +240,11 @@ static unsigned long mmap_legacy_base(void)
*/
void arch_pick_mmap_layout(struct mm_struct *mm, struct rlimit *rlim_stack)
{
- mm->mmap_legacy_base = mmap_legacy_base();
- mm->mmap_base = mmap_upper_limit(rlim_stack);
-
if (mmap_is_legacy()) {
- mm->mmap_base = mm->mmap_legacy_base;
+ mm->mmap_base = mmap_legacy_base();
mm->get_unmapped_area = arch_get_unmapped_area;
} else {
+ mm->mmap_base = mmap_upper_limit(rlim_stack);
mm->get_unmapped_area = arch_get_unmapped_area_topdown;
}
}
--
2.20.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH RESEND 6/8] parisc: Use mmap_base, not mmap_legacy_base, as low_limit for bottom-up mmap
2019-06-20 5:03 ` [PATCH RESEND 6/8] parisc: Use mmap_base, not mmap_legacy_base, as low_limit for bottom-up mmap Alexandre Ghiti
@ 2019-06-25 14:09 ` Helge Deller
2019-06-26 5:20 ` Alex Ghiti
0 siblings, 1 reply; 17+ messages in thread
From: Helge Deller @ 2019-06-25 14:09 UTC (permalink / raw)
To: Alexandre Ghiti, Andrew Morton
Cc: James E . J . Bottomley, Heiko Carstens, Vasily Gorbik,
Christian Borntraeger, Yoshinori Sato, Rich Felker,
David S . Miller, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
H . Peter Anvin, x86, Dave Hansen, Andy Lutomirski,
Peter Zijlstra, linux-parisc, linux-kernel, linux-s390, linux-sh,
sparclinux, linux-mm
On 20.06.19 07:03, Alexandre Ghiti wrote:
> Bottom-up mmap scheme is used twice:
>
> - for legacy mode, in which mmap_legacy_base and mmap_base are equal.
>
> - in case of mmap failure in top-down mode, where there is no need to go
> through the whole address space again for the bottom-up fallback: the goal
> of this fallback is to find, as a last resort, space between the top-down
> mmap base and the stack, which is the only place not covered by the
> top-down mmap.
>
> Then this commit removes the usage of mmap_legacy_base field from parisc
> code.
>
> Signed-off-by: Alexandre Ghiti <alex@ghiti.fr>
Boot-tested on parisc and seems to work nicely, thus:
Acked-by: Helge Deller <deller@gmx.de>
Helge
> ---
> arch/parisc/kernel/sys_parisc.c | 8 +++-----
> 1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
> index 5d458a44b09c..e987f3a8eb0b 100644
> --- a/arch/parisc/kernel/sys_parisc.c
> +++ b/arch/parisc/kernel/sys_parisc.c
> @@ -119,7 +119,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
>
> info.flags = 0;
> info.length = len;
> - info.low_limit = mm->mmap_legacy_base;
> + info.low_limit = mm->mmap_base;
> info.high_limit = mmap_upper_limit(NULL);
> info.align_mask = last_mmap ? (PAGE_MASK & (SHM_COLOUR - 1)) : 0;
> info.align_offset = shared_align_offset(last_mmap, pgoff);
> @@ -240,13 +240,11 @@ static unsigned long mmap_legacy_base(void)
> */
> void arch_pick_mmap_layout(struct mm_struct *mm, struct rlimit *rlim_stack)
> {
> - mm->mmap_legacy_base = mmap_legacy_base();
> - mm->mmap_base = mmap_upper_limit(rlim_stack);
> -
> if (mmap_is_legacy()) {
> - mm->mmap_base = mm->mmap_legacy_base;
> + mm->mmap_base = mmap_legacy_base();
> mm->get_unmapped_area = arch_get_unmapped_area;
> } else {
> + mm->mmap_base = mmap_upper_limit(rlim_stack);
> mm->get_unmapped_area = arch_get_unmapped_area_topdown;
> }
> }
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH RESEND 6/8] parisc: Use mmap_base, not mmap_legacy_base, as low_limit for bottom-up mmap
2019-06-25 14:09 ` Helge Deller
@ 2019-06-26 5:20 ` Alex Ghiti
0 siblings, 0 replies; 17+ messages in thread
From: Alex Ghiti @ 2019-06-26 5:20 UTC (permalink / raw)
To: Helge Deller
Cc: James E . J . Bottomley, Heiko Carstens, Vasily Gorbik,
Christian Borntraeger, Yoshinori Sato, Rich Felker,
David S . Miller, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
H . Peter Anvin, x86, Dave Hansen, Andy Lutomirski,
Peter Zijlstra, linux-parisc, linux-kernel, linux-s390, linux-sh,
sparclinux, linux-mm, Andrew Morton
On 6/25/19 10:09 AM, Helge Deller wrote:
> On 20.06.19 07:03, Alexandre Ghiti wrote:
>> Bottom-up mmap scheme is used twice:
>>
>> - for legacy mode, in which mmap_legacy_base and mmap_base are equal.
>>
>> - in case of mmap failure in top-down mode, where there is no need to go
>> through the whole address space again for the bottom-up fallback: the goal
>> of this fallback is to find, as a last resort, space between the top-down
>> mmap base and the stack, which is the only place not covered by the
>> top-down mmap.
>>
>> Then this commit removes the usage of mmap_legacy_base field from parisc
>> code.
>>
>> Signed-off-by: Alexandre Ghiti <alex@ghiti.fr>
> Boot-tested on parisc and seems to work nicely, thus:
>
> Acked-by: Helge Deller <deller@gmx.de>
Thanks Helge,
Alex
>
> Helge
>
>
>
>> ---
>> arch/parisc/kernel/sys_parisc.c | 8 +++-----
>> 1 file changed, 3 insertions(+), 5 deletions(-)
>>
>> diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
>> index 5d458a44b09c..e987f3a8eb0b 100644
>> --- a/arch/parisc/kernel/sys_parisc.c
>> +++ b/arch/parisc/kernel/sys_parisc.c
>> @@ -119,7 +119,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
>>
>> info.flags = 0;
>> info.length = len;
>> - info.low_limit = mm->mmap_legacy_base;
>> + info.low_limit = mm->mmap_base;
>> info.high_limit = mmap_upper_limit(NULL);
>> info.align_mask = last_mmap ? (PAGE_MASK & (SHM_COLOUR - 1)) : 0;
>> info.align_offset = shared_align_offset(last_mmap, pgoff);
>> @@ -240,13 +240,11 @@ static unsigned long mmap_legacy_base(void)
>> */
>> void arch_pick_mmap_layout(struct mm_struct *mm, struct rlimit *rlim_stack)
>> {
>> - mm->mmap_legacy_base = mmap_legacy_base();
>> - mm->mmap_base = mmap_upper_limit(rlim_stack);
>> -
>> if (mmap_is_legacy()) {
>> - mm->mmap_base = mm->mmap_legacy_base;
>> + mm->mmap_base = mmap_legacy_base();
>> mm->get_unmapped_area = arch_get_unmapped_area;
>> } else {
>> + mm->mmap_base = mmap_upper_limit(rlim_stack);
>> mm->get_unmapped_area = arch_get_unmapped_area_topdown;
>> }
>> }
>>
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH RESEND 7/8] x86: Use mmap_*base, not mmap_*legacy_base, as low_limit for bottom-up mmap
2019-06-20 5:03 [PATCH RESEND 0/8] Fix mmap base in bottom-up mmap Alexandre Ghiti
` (5 preceding siblings ...)
2019-06-20 5:03 ` [PATCH RESEND 6/8] parisc: Use mmap_base, not mmap_legacy_base, as low_limit for bottom-up mmap Alexandre Ghiti
@ 2019-06-20 5:03 ` Alexandre Ghiti
2019-06-20 5:03 ` [PATCH RESEND 8/8] mm: Remove mmap_legacy_base and mmap_compat_legacy_code fields from mm_struct Alexandre Ghiti
` (2 subsequent siblings)
9 siblings, 0 replies; 17+ messages in thread
From: Alexandre Ghiti @ 2019-06-20 5:03 UTC (permalink / raw)
To: Andrew Morton
Cc: James E . J . Bottomley, Helge Deller, Heiko Carstens,
Vasily Gorbik, Christian Borntraeger, Yoshinori Sato,
Rich Felker, David S . Miller, Thomas Gleixner, Ingo Molnar,
Borislav Petkov, H . Peter Anvin, x86, Dave Hansen,
Andy Lutomirski, Peter Zijlstra, linux-parisc, linux-kernel,
linux-s390, linux-sh, sparclinux, linux-mm, Alexandre Ghiti
Bottom-up mmap scheme is used twice:
- for legacy mode, in which mmap_legacy_base and mmap_compat_legacy_base
are respectively equal to mmap_base and mmap_compat_base.
- in case of mmap failure in top-down mode, where there is no need to go
through the whole address space again for the bottom-up fallback: the goal
of this fallback is to find, as a last resort, space between the top-down
mmap base and the stack, which is the only place not covered by the
top-down mmap.
Then this commit removes the usage of mmap_legacy_base and
mmap_compat_legacy_base fields from x86 code.
Signed-off-by: Alexandre Ghiti <alex@ghiti.fr>
---
arch/x86/include/asm/elf.h | 2 +-
arch/x86/kernel/sys_x86_64.c | 4 ++--
arch/x86/mm/hugetlbpage.c | 4 ++--
arch/x86/mm/mmap.c | 20 +++++++++-----------
4 files changed, 14 insertions(+), 16 deletions(-)
diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
index 69c0f892e310..bbfd81453250 100644
--- a/arch/x86/include/asm/elf.h
+++ b/arch/x86/include/asm/elf.h
@@ -307,7 +307,7 @@ static inline int mmap_is_ia32(void)
extern unsigned long task_size_32bit(void);
extern unsigned long task_size_64bit(int full_addr_space);
-extern unsigned long get_mmap_base(int is_legacy);
+extern unsigned long get_mmap_base(void);
extern bool mmap_address_hint_valid(unsigned long addr, unsigned long len);
#ifdef CONFIG_X86_32
diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
index f7476ce23b6e..0bf8604bea5e 100644
--- a/arch/x86/kernel/sys_x86_64.c
+++ b/arch/x86/kernel/sys_x86_64.c
@@ -121,7 +121,7 @@ static void find_start_end(unsigned long addr, unsigned long flags,
return;
}
- *begin = get_mmap_base(1);
+ *begin = get_mmap_base();
if (in_32bit_syscall())
*end = task_size_32bit();
else
@@ -211,7 +211,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
info.flags = VM_UNMAPPED_AREA_TOPDOWN;
info.length = len;
info.low_limit = PAGE_SIZE;
- info.high_limit = get_mmap_base(0);
+ info.high_limit = get_mmap_base();
/*
* If hint address is above DEFAULT_MAP_WINDOW, look for unmapped area
diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
index 4b90339aef50..3a7f11e66114 100644
--- a/arch/x86/mm/hugetlbpage.c
+++ b/arch/x86/mm/hugetlbpage.c
@@ -86,7 +86,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
info.flags = 0;
info.length = len;
- info.low_limit = get_mmap_base(1);
+ info.low_limit = get_mmap_base();
/*
* If hint address is above DEFAULT_MAP_WINDOW, look for unmapped area
@@ -106,7 +106,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
{
struct hstate *h = hstate_file(file);
struct vm_unmapped_area_info info;
- unsigned long mmap_base = get_mmap_base(0);
+ unsigned long mmap_base = get_mmap_base();
info.flags = VM_UNMAPPED_AREA_TOPDOWN;
info.length = len;
diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
index aae9a933dfd4..54c9ff301323 100644
--- a/arch/x86/mm/mmap.c
+++ b/arch/x86/mm/mmap.c
@@ -113,13 +113,12 @@ static unsigned long mmap_legacy_base(unsigned long rnd,
* This function, called very early during the creation of a new
* process VM image, sets up which VM layout function to use:
*/
-static void arch_pick_mmap_base(unsigned long *base, unsigned long *legacy_base,
+static void arch_pick_mmap_base(unsigned long *base,
unsigned long random_factor, unsigned long task_size,
struct rlimit *rlim_stack)
{
- *legacy_base = mmap_legacy_base(random_factor, task_size);
if (mmap_is_legacy())
- *base = *legacy_base;
+ *base = mmap_legacy_base(random_factor, task_size);
else
*base = mmap_base(random_factor, task_size, rlim_stack);
}
@@ -131,7 +130,7 @@ void arch_pick_mmap_layout(struct mm_struct *mm, struct rlimit *rlim_stack)
else
mm->get_unmapped_area = arch_get_unmapped_area_topdown;
- arch_pick_mmap_base(&mm->mmap_base, &mm->mmap_legacy_base,
+ arch_pick_mmap_base(&mm->mmap_base,
arch_rnd(mmap64_rnd_bits), task_size_64bit(0),
rlim_stack);
@@ -142,23 +141,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm, struct rlimit *rlim_stack)
* applications and 32bit applications. The 64bit syscall uses
* mmap_base, the compat syscall uses mmap_compat_base.
*/
- arch_pick_mmap_base(&mm->mmap_compat_base, &mm->mmap_compat_legacy_base,
+ arch_pick_mmap_base(&mm->mmap_compat_base,
arch_rnd(mmap32_rnd_bits), task_size_32bit(),
rlim_stack);
#endif
}
-unsigned long get_mmap_base(int is_legacy)
+unsigned long get_mmap_base(void)
{
struct mm_struct *mm = current->mm;
#ifdef CONFIG_HAVE_ARCH_COMPAT_MMAP_BASES
- if (in_32bit_syscall()) {
- return is_legacy ? mm->mmap_compat_legacy_base
- : mm->mmap_compat_base;
- }
+ if (in_32bit_syscall())
+ return mm->mmap_compat_base;
#endif
- return is_legacy ? mm->mmap_legacy_base : mm->mmap_base;
+
+ return mm->mmap_base;
}
const char *arch_vma_name(struct vm_area_struct *vma)
--
2.20.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH RESEND 8/8] mm: Remove mmap_legacy_base and mmap_compat_legacy_code fields from mm_struct
2019-06-20 5:03 [PATCH RESEND 0/8] Fix mmap base in bottom-up mmap Alexandre Ghiti
` (6 preceding siblings ...)
2019-06-20 5:03 ` [PATCH RESEND 7/8] x86: Use mmap_*base, not mmap_*legacy_base, " Alexandre Ghiti
@ 2019-06-20 5:03 ` Alexandre Ghiti
2019-07-30 6:12 ` [PATCH RESEND 0/8] Fix mmap base in bottom-up mmap Alexandre Ghiti
2019-08-26 7:34 ` Alexandre Ghiti
9 siblings, 0 replies; 17+ messages in thread
From: Alexandre Ghiti @ 2019-06-20 5:03 UTC (permalink / raw)
To: Andrew Morton
Cc: James E . J . Bottomley, Helge Deller, Heiko Carstens,
Vasily Gorbik, Christian Borntraeger, Yoshinori Sato,
Rich Felker, David S . Miller, Thomas Gleixner, Ingo Molnar,
Borislav Petkov, H . Peter Anvin, x86, Dave Hansen,
Andy Lutomirski, Peter Zijlstra, linux-parisc, linux-kernel,
linux-s390, linux-sh, sparclinux, linux-mm, Alexandre Ghiti
Now that x86 and parisc do not use those fields anymore, remove them from
mm code.
Signed-off-by: Alexandre Ghiti <alex@ghiti.fr>
---
include/linux/mm_types.h | 2 --
mm/debug.c | 4 ++--
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index 1d1093474c1a..9a5935f9cc7e 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -364,11 +364,9 @@ struct mm_struct {
unsigned long pgoff, unsigned long flags);
#endif
unsigned long mmap_base; /* base of mmap area */
- unsigned long mmap_legacy_base; /* base of mmap area in bottom-up allocations */
#ifdef CONFIG_HAVE_ARCH_COMPAT_MMAP_BASES
/* Base adresses for compatible mmap() */
unsigned long mmap_compat_base;
- unsigned long mmap_compat_legacy_base;
#endif
unsigned long task_size; /* size of task vm space */
unsigned long highest_vm_end; /* highest vma end address */
diff --git a/mm/debug.c b/mm/debug.c
index 8345bb6e4769..3ddffe1efcda 100644
--- a/mm/debug.c
+++ b/mm/debug.c
@@ -134,7 +134,7 @@ void dump_mm(const struct mm_struct *mm)
#ifdef CONFIG_MMU
"get_unmapped_area %px\n"
#endif
- "mmap_base %lu mmap_legacy_base %lu highest_vm_end %lu\n"
+ "mmap_base %lu highest_vm_end %lu\n"
"pgd %px mm_users %d mm_count %d pgtables_bytes %lu map_count %d\n"
"hiwater_rss %lx hiwater_vm %lx total_vm %lx locked_vm %lx\n"
"pinned_vm %llx data_vm %lx exec_vm %lx stack_vm %lx\n"
@@ -162,7 +162,7 @@ void dump_mm(const struct mm_struct *mm)
#ifdef CONFIG_MMU
mm->get_unmapped_area,
#endif
- mm->mmap_base, mm->mmap_legacy_base, mm->highest_vm_end,
+ mm->mmap_base, mm->highest_vm_end,
mm->pgd, atomic_read(&mm->mm_users),
atomic_read(&mm->mm_count),
mm_pgtables_bytes(mm),
--
2.20.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH RESEND 0/8] Fix mmap base in bottom-up mmap
2019-06-20 5:03 [PATCH RESEND 0/8] Fix mmap base in bottom-up mmap Alexandre Ghiti
` (7 preceding siblings ...)
2019-06-20 5:03 ` [PATCH RESEND 8/8] mm: Remove mmap_legacy_base and mmap_compat_legacy_code fields from mm_struct Alexandre Ghiti
@ 2019-07-30 6:12 ` Alexandre Ghiti
2019-08-26 7:34 ` Alexandre Ghiti
9 siblings, 0 replies; 17+ messages in thread
From: Alexandre Ghiti @ 2019-07-30 6:12 UTC (permalink / raw)
To: Andrew Morton
Cc: James E . J . Bottomley, Helge Deller, Heiko Carstens,
Vasily Gorbik, Christian Borntraeger, Yoshinori Sato,
Rich Felker, David S . Miller, Thomas Gleixner, Ingo Molnar,
Borislav Petkov, H . Peter Anvin, x86, Dave Hansen,
Andy Lutomirski, Peter Zijlstra, linux-parisc, linux-kernel,
linux-s390, linux-sh, sparclinux, linux-mm
On 6/20/19 7:03 AM, Alexandre Ghiti wrote:
> This series fixes the fallback of the top-down mmap: in case of
> failure, a bottom-up scheme can be tried as a last resort between
> the top-down mmap base and the stack, hoping for a large unused stack
> limit.
>
> Lots of architectures and even mm code start this fallback
> at TASK_UNMAPPED_BASE, which is useless since the top-down scheme
> already failed on the whole address space: instead, simply use
> mmap_base.
>
> Along the way, it allows to get rid of of mmap_legacy_base and
> mmap_compat_legacy_base from mm_struct.
>
> Note that arm and mips already implement this behaviour.
>
> Alexandre Ghiti (8):
> s390: Start fallback of top-down mmap at mm->mmap_base
> sh: Start fallback of top-down mmap at mm->mmap_base
> sparc: Start fallback of top-down mmap at mm->mmap_base
> x86, hugetlbpage: Start fallback of top-down mmap at mm->mmap_base
> mm: Start fallback top-down mmap at mm->mmap_base
> parisc: Use mmap_base, not mmap_legacy_base, as low_limit for
> bottom-up mmap
> x86: Use mmap_*base, not mmap_*legacy_base, as low_limit for bottom-up
> mmap
> mm: Remove mmap_legacy_base and mmap_compat_legacy_code fields from
> mm_struct
>
> arch/parisc/kernel/sys_parisc.c | 8 +++-----
> arch/s390/mm/mmap.c | 2 +-
> arch/sh/mm/mmap.c | 2 +-
> arch/sparc/kernel/sys_sparc_64.c | 2 +-
> arch/sparc/mm/hugetlbpage.c | 2 +-
> arch/x86/include/asm/elf.h | 2 +-
> arch/x86/kernel/sys_x86_64.c | 4 ++--
> arch/x86/mm/hugetlbpage.c | 7 ++++---
> arch/x86/mm/mmap.c | 20 +++++++++-----------
> include/linux/mm_types.h | 2 --
> mm/debug.c | 4 ++--
> mm/mmap.c | 2 +-
> 12 files changed, 26 insertions(+), 31 deletions(-)
>
Hi everyone,
This is just a preparatory series for the merging of x86 mmap top-down
functions with
the generic ones (those should get into v5.3), if you could take some
time to take a look,
that would be great :)
Thanks,
Alex
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH RESEND 0/8] Fix mmap base in bottom-up mmap
2019-06-20 5:03 [PATCH RESEND 0/8] Fix mmap base in bottom-up mmap Alexandre Ghiti
` (8 preceding siblings ...)
2019-07-30 6:12 ` [PATCH RESEND 0/8] Fix mmap base in bottom-up mmap Alexandre Ghiti
@ 2019-08-26 7:34 ` Alexandre Ghiti
2019-08-26 22:37 ` Helge Deller
9 siblings, 1 reply; 17+ messages in thread
From: Alexandre Ghiti @ 2019-08-26 7:34 UTC (permalink / raw)
To: Andrew Morton
Cc: James E . J . Bottomley, Helge Deller, Heiko Carstens,
Vasily Gorbik, Christian Borntraeger, Yoshinori Sato,
Rich Felker, David S . Miller, Thomas Gleixner, Ingo Molnar,
Borislav Petkov, H . Peter Anvin, x86, Dave Hansen,
Andy Lutomirski, Peter Zijlstra, linux-parisc, linux-kernel,
linux-s390, linux-sh, sparclinux, linux-mm
On 6/20/19 7:03 AM, Alexandre Ghiti wrote:
> This series fixes the fallback of the top-down mmap: in case of
> failure, a bottom-up scheme can be tried as a last resort between
> the top-down mmap base and the stack, hoping for a large unused stack
> limit.
>
> Lots of architectures and even mm code start this fallback
> at TASK_UNMAPPED_BASE, which is useless since the top-down scheme
> already failed on the whole address space: instead, simply use
> mmap_base.
>
> Along the way, it allows to get rid of of mmap_legacy_base and
> mmap_compat_legacy_base from mm_struct.
>
> Note that arm and mips already implement this behaviour.
>
> Alexandre Ghiti (8):
> s390: Start fallback of top-down mmap at mm->mmap_base
> sh: Start fallback of top-down mmap at mm->mmap_base
> sparc: Start fallback of top-down mmap at mm->mmap_base
> x86, hugetlbpage: Start fallback of top-down mmap at mm->mmap_base
> mm: Start fallback top-down mmap at mm->mmap_base
> parisc: Use mmap_base, not mmap_legacy_base, as low_limit for
> bottom-up mmap
> x86: Use mmap_*base, not mmap_*legacy_base, as low_limit for bottom-up
> mmap
> mm: Remove mmap_legacy_base and mmap_compat_legacy_code fields from
> mm_struct
>
> arch/parisc/kernel/sys_parisc.c | 8 +++-----
> arch/s390/mm/mmap.c | 2 +-
> arch/sh/mm/mmap.c | 2 +-
> arch/sparc/kernel/sys_sparc_64.c | 2 +-
> arch/sparc/mm/hugetlbpage.c | 2 +-
> arch/x86/include/asm/elf.h | 2 +-
> arch/x86/kernel/sys_x86_64.c | 4 ++--
> arch/x86/mm/hugetlbpage.c | 7 ++++---
> arch/x86/mm/mmap.c | 20 +++++++++-----------
> include/linux/mm_types.h | 2 --
> mm/debug.c | 4 ++--
> mm/mmap.c | 2 +-
> 12 files changed, 26 insertions(+), 31 deletions(-)
>
Hi everyone,
Any thoughts about that series ? As said before, this is just a
preparatory patchset in order to
merge x86 mmap top down code with the generic version.
Thanks for taking a look,
Alex
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH RESEND 0/8] Fix mmap base in bottom-up mmap
2019-08-26 7:34 ` Alexandre Ghiti
@ 2019-08-26 22:37 ` Helge Deller
2019-08-28 4:53 ` Alex Ghiti
0 siblings, 1 reply; 17+ messages in thread
From: Helge Deller @ 2019-08-26 22:37 UTC (permalink / raw)
To: Alexandre Ghiti, Andrew Morton
Cc: James E . J . Bottomley, Heiko Carstens, Vasily Gorbik,
Christian Borntraeger, Yoshinori Sato, Rich Felker,
David S . Miller, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
H . Peter Anvin, x86, Dave Hansen, Andy Lutomirski,
Peter Zijlstra, linux-parisc, linux-kernel, linux-s390, linux-sh,
sparclinux, linux-mm
On 26.08.19 09:34, Alexandre Ghiti wrote:
> On 6/20/19 7:03 AM, Alexandre Ghiti wrote:
>> This series fixes the fallback of the top-down mmap: in case of
>> failure, a bottom-up scheme can be tried as a last resort between
>> the top-down mmap base and the stack, hoping for a large unused stack
>> limit.
>>
>> Lots of architectures and even mm code start this fallback
>> at TASK_UNMAPPED_BASE, which is useless since the top-down scheme
>> already failed on the whole address space: instead, simply use
>> mmap_base.
>>
>> Along the way, it allows to get rid of of mmap_legacy_base and
>> mmap_compat_legacy_base from mm_struct.
>>
>> Note that arm and mips already implement this behaviour.
>>
>> Alexandre Ghiti (8):
>> s390: Start fallback of top-down mmap at mm->mmap_base
>> sh: Start fallback of top-down mmap at mm->mmap_base
>> sparc: Start fallback of top-down mmap at mm->mmap_base
>> x86, hugetlbpage: Start fallback of top-down mmap at mm->mmap_base
>> mm: Start fallback top-down mmap at mm->mmap_base
>> parisc: Use mmap_base, not mmap_legacy_base, as low_limit for
>> bottom-up mmap
>> x86: Use mmap_*base, not mmap_*legacy_base, as low_limit for bottom-up
>> mmap
>> mm: Remove mmap_legacy_base and mmap_compat_legacy_code fields from
>> mm_struct
>>
>> arch/parisc/kernel/sys_parisc.c | 8 +++-----
>> arch/s390/mm/mmap.c | 2 +-
>> arch/sh/mm/mmap.c | 2 +-
>> arch/sparc/kernel/sys_sparc_64.c | 2 +-
>> arch/sparc/mm/hugetlbpage.c | 2 +-
>> arch/x86/include/asm/elf.h | 2 +-
>> arch/x86/kernel/sys_x86_64.c | 4 ++--
>> arch/x86/mm/hugetlbpage.c | 7 ++++---
>> arch/x86/mm/mmap.c | 20 +++++++++-----------
>> include/linux/mm_types.h | 2 --
>> mm/debug.c | 4 ++--
>> mm/mmap.c | 2 +-
>> 12 files changed, 26 insertions(+), 31 deletions(-)
>>
>
> Any thoughts about that series ? As said before, this is just a preparatory patchset in order to
> merge x86 mmap top down code with the generic version.
I just tested your patch series successfully on the parisc
architeture. You may add:
Tested-by: Helge Deller <deller@gmx.de> # parisc
Thanks!
Helge
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH RESEND 0/8] Fix mmap base in bottom-up mmap
2019-08-26 22:37 ` Helge Deller
@ 2019-08-28 4:53 ` Alex Ghiti
0 siblings, 0 replies; 17+ messages in thread
From: Alex Ghiti @ 2019-08-28 4:53 UTC (permalink / raw)
To: Helge Deller, Andrew Morton
Cc: James E . J . Bottomley, Heiko Carstens, Vasily Gorbik,
Christian Borntraeger, Yoshinori Sato, Rich Felker,
David S . Miller, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
H . Peter Anvin, x86, Dave Hansen, Andy Lutomirski,
Peter Zijlstra, linux-parisc, linux-kernel, linux-s390, linux-sh,
sparclinux, linux-mm
On 8/26/19 6:37 PM, Helge Deller wrote:
> On 26.08.19 09:34, Alexandre Ghiti wrote:
>> On 6/20/19 7:03 AM, Alexandre Ghiti wrote:
>>> This series fixes the fallback of the top-down mmap: in case of
>>> failure, a bottom-up scheme can be tried as a last resort between
>>> the top-down mmap base and the stack, hoping for a large unused stack
>>> limit.
>>>
>>> Lots of architectures and even mm code start this fallback
>>> at TASK_UNMAPPED_BASE, which is useless since the top-down scheme
>>> already failed on the whole address space: instead, simply use
>>> mmap_base.
>>>
>>> Along the way, it allows to get rid of of mmap_legacy_base and
>>> mmap_compat_legacy_base from mm_struct.
>>>
>>> Note that arm and mips already implement this behaviour.
>>>
>>> Alexandre Ghiti (8):
>>> s390: Start fallback of top-down mmap at mm->mmap_base
>>> sh: Start fallback of top-down mmap at mm->mmap_base
>>> sparc: Start fallback of top-down mmap at mm->mmap_base
>>> x86, hugetlbpage: Start fallback of top-down mmap at mm->mmap_base
>>> mm: Start fallback top-down mmap at mm->mmap_base
>>> parisc: Use mmap_base, not mmap_legacy_base, as low_limit for
>>> bottom-up mmap
>>> x86: Use mmap_*base, not mmap_*legacy_base, as low_limit for
>>> bottom-up
>>> mmap
>>> mm: Remove mmap_legacy_base and mmap_compat_legacy_code fields from
>>> mm_struct
>>>
>>> arch/parisc/kernel/sys_parisc.c | 8 +++-----
>>> arch/s390/mm/mmap.c | 2 +-
>>> arch/sh/mm/mmap.c | 2 +-
>>> arch/sparc/kernel/sys_sparc_64.c | 2 +-
>>> arch/sparc/mm/hugetlbpage.c | 2 +-
>>> arch/x86/include/asm/elf.h | 2 +-
>>> arch/x86/kernel/sys_x86_64.c | 4 ++--
>>> arch/x86/mm/hugetlbpage.c | 7 ++++---
>>> arch/x86/mm/mmap.c | 20 +++++++++-----------
>>> include/linux/mm_types.h | 2 --
>>> mm/debug.c | 4 ++--
>>> mm/mmap.c | 2 +-
>>> 12 files changed, 26 insertions(+), 31 deletions(-)
>>>
>>
>> Any thoughts about that series ? As said before, this is just a
>> preparatory patchset in order to
>> merge x86 mmap top down code with the generic version.
>
> I just tested your patch series successfully on the parisc
> architeture. You may add:
>
> Tested-by: Helge Deller <deller@gmx.de> # parisc
Thanks again Helge !
Alex
>
> Thanks!
> Helge
^ permalink raw reply [flat|nested] 17+ messages in thread