Message ID | 20190620050328.8942-7-alex@ghiti.fr (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Fix mmap base in bottom-up mmap | expand |
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; > } > } >
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; >> } >> } >>
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; } }
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(-)