Message ID | 503499aae380db1c4673f146bcba6ad095021257.1426866405.git.ldufour@linux.vnet.ibm.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Am 20.03.2015 um 16:53 schrieb Laurent Dufour: > Some architecture would like to be triggered when a memory area is moved > through the mremap system call. > > This patch is introducing a new arch_remap mm hook which is placed in the > path of mremap, and is called before the old area is unmapped (and the > arch_unmap hook is called). > > To no break the build, this patch adds the empty hook definition to the > architectures that were not using the generic hook's definition. Just wanted to point out that I like that new hook as UserModeLinux can benefit from it. UML has the concept of stub pages where the UML host process can inject commands to guest processes. Currently we play nasty games in the TLB code to make all this work. arch_unmap() could make this stuff more clear and less error prone. Thanks, //richard
* Laurent Dufour <ldufour@linux.vnet.ibm.com> wrote: > Some architecture would like to be triggered when a memory area is moved > through the mremap system call. > > This patch is introducing a new arch_remap mm hook which is placed in the > path of mremap, and is called before the old area is unmapped (and the > arch_unmap hook is called). > > To no break the build, this patch adds the empty hook definition to the > architectures that were not using the generic hook's definition. > > Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com> > --- > arch/s390/include/asm/mmu_context.h | 6 ++++++ > arch/um/include/asm/mmu_context.h | 5 +++++ > arch/unicore32/include/asm/mmu_context.h | 6 ++++++ > arch/x86/include/asm/mmu_context.h | 6 ++++++ > include/asm-generic/mm_hooks.h | 6 ++++++ > mm/mremap.c | 9 +++++++-- > 6 files changed, 36 insertions(+), 2 deletions(-) > > diff --git a/arch/s390/include/asm/mmu_context.h b/arch/s390/include/asm/mmu_context.h > index 8fb3802f8fad..ddd861a490ba 100644 > --- a/arch/s390/include/asm/mmu_context.h > +++ b/arch/s390/include/asm/mmu_context.h > @@ -131,4 +131,10 @@ static inline void arch_bprm_mm_init(struct mm_struct *mm, > { > } > > +static inline void arch_remap(struct mm_struct *mm, > + unsigned long old_start, unsigned long old_end, > + unsigned long new_start, unsigned long new_end) > +{ > +} > + > #endif /* __S390_MMU_CONTEXT_H */ > diff --git a/arch/um/include/asm/mmu_context.h b/arch/um/include/asm/mmu_context.h > index 941527e507f7..f499b017c1f9 100644 > --- a/arch/um/include/asm/mmu_context.h > +++ b/arch/um/include/asm/mmu_context.h > @@ -27,6 +27,11 @@ static inline void arch_bprm_mm_init(struct mm_struct *mm, > struct vm_area_struct *vma) > { > } > +static inline void arch_remap(struct mm_struct *mm, > + unsigned long old_start, unsigned long old_end, > + unsigned long new_start, unsigned long new_end) > +{ > +} > /* > * end asm-generic/mm_hooks.h functions > */ > diff --git a/arch/unicore32/include/asm/mmu_context.h b/arch/unicore32/include/asm/mmu_context.h > index 1cb5220afaf9..39a0a553172e 100644 > --- a/arch/unicore32/include/asm/mmu_context.h > +++ b/arch/unicore32/include/asm/mmu_context.h > @@ -97,4 +97,10 @@ static inline void arch_bprm_mm_init(struct mm_struct *mm, > { > } > > +static inline void arch_remap(struct mm_struct *mm, > + unsigned long old_start, unsigned long old_end, > + unsigned long new_start, unsigned long new_end) > +{ > +} > + > #endif > diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h > index 883f6b933fa4..75cb71f4be1e 100644 > --- a/arch/x86/include/asm/mmu_context.h > +++ b/arch/x86/include/asm/mmu_context.h > @@ -172,4 +172,10 @@ static inline void arch_unmap(struct mm_struct *mm, struct vm_area_struct *vma, > mpx_notify_unmap(mm, vma, start, end); > } > > +static inline void arch_remap(struct mm_struct *mm, > + unsigned long old_start, unsigned long old_end, > + unsigned long new_start, unsigned long new_end) > +{ > +} > + > #endif /* _ASM_X86_MMU_CONTEXT_H */ So instead of spreading these empty prototypes around mmu_context.h files, why not add something like this to the PPC definition: #define __HAVE_ARCH_REMAP and define the empty prototype for everyone else? It's a bit like how the __HAVE_ARCH_PTEP_* namespace works. That should shrink this patch considerably. Thanks, Ingo
On 23/03/2015 09:52, Ingo Molnar wrote: > > * Laurent Dufour <ldufour@linux.vnet.ibm.com> wrote: > >> Some architecture would like to be triggered when a memory area is moved >> through the mremap system call. >> >> This patch is introducing a new arch_remap mm hook which is placed in the >> path of mremap, and is called before the old area is unmapped (and the >> arch_unmap hook is called). >> >> To no break the build, this patch adds the empty hook definition to the >> architectures that were not using the generic hook's definition. >> >> Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com> >> --- >> arch/s390/include/asm/mmu_context.h | 6 ++++++ >> arch/um/include/asm/mmu_context.h | 5 +++++ >> arch/unicore32/include/asm/mmu_context.h | 6 ++++++ >> arch/x86/include/asm/mmu_context.h | 6 ++++++ >> include/asm-generic/mm_hooks.h | 6 ++++++ >> mm/mremap.c | 9 +++++++-- >> 6 files changed, 36 insertions(+), 2 deletions(-) >> >> diff --git a/arch/s390/include/asm/mmu_context.h b/arch/s390/include/asm/mmu_context.h >> index 8fb3802f8fad..ddd861a490ba 100644 >> --- a/arch/s390/include/asm/mmu_context.h >> +++ b/arch/s390/include/asm/mmu_context.h >> @@ -131,4 +131,10 @@ static inline void arch_bprm_mm_init(struct mm_struct *mm, >> { >> } >> >> +static inline void arch_remap(struct mm_struct *mm, >> + unsigned long old_start, unsigned long old_end, >> + unsigned long new_start, unsigned long new_end) >> +{ >> +} >> + >> #endif /* __S390_MMU_CONTEXT_H */ >> diff --git a/arch/um/include/asm/mmu_context.h b/arch/um/include/asm/mmu_context.h >> index 941527e507f7..f499b017c1f9 100644 >> --- a/arch/um/include/asm/mmu_context.h >> +++ b/arch/um/include/asm/mmu_context.h >> @@ -27,6 +27,11 @@ static inline void arch_bprm_mm_init(struct mm_struct *mm, >> struct vm_area_struct *vma) >> { >> } >> +static inline void arch_remap(struct mm_struct *mm, >> + unsigned long old_start, unsigned long old_end, >> + unsigned long new_start, unsigned long new_end) >> +{ >> +} >> /* >> * end asm-generic/mm_hooks.h functions >> */ >> diff --git a/arch/unicore32/include/asm/mmu_context.h b/arch/unicore32/include/asm/mmu_context.h >> index 1cb5220afaf9..39a0a553172e 100644 >> --- a/arch/unicore32/include/asm/mmu_context.h >> +++ b/arch/unicore32/include/asm/mmu_context.h >> @@ -97,4 +97,10 @@ static inline void arch_bprm_mm_init(struct mm_struct *mm, >> { >> } >> >> +static inline void arch_remap(struct mm_struct *mm, >> + unsigned long old_start, unsigned long old_end, >> + unsigned long new_start, unsigned long new_end) >> +{ >> +} >> + >> #endif >> diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h >> index 883f6b933fa4..75cb71f4be1e 100644 >> --- a/arch/x86/include/asm/mmu_context.h >> +++ b/arch/x86/include/asm/mmu_context.h >> @@ -172,4 +172,10 @@ static inline void arch_unmap(struct mm_struct *mm, struct vm_area_struct *vma, >> mpx_notify_unmap(mm, vma, start, end); >> } >> >> +static inline void arch_remap(struct mm_struct *mm, >> + unsigned long old_start, unsigned long old_end, >> + unsigned long new_start, unsigned long new_end) >> +{ >> +} >> + >> #endif /* _ASM_X86_MMU_CONTEXT_H */ > > So instead of spreading these empty prototypes around mmu_context.h > files, why not add something like this to the PPC definition: > > #define __HAVE_ARCH_REMAP > > and define the empty prototype for everyone else? It's a bit like how > the __HAVE_ARCH_PTEP_* namespace works. > > That should shrink this patch considerably. My idea was to mimic the MMU hook's definition. This new hook is in the continuity of what have been done for arch_dup_mmap, arch_exit_mmap, arch_unmap and arch_bprm_mm_init. Do you think that there is a need to make this one in another way ? Thanks, Laurent.
CRIU is recreating the process memory layout by remapping the checkpointee memory area on top of the current process (criu). This includes remapping the vDSO to the place it has at checkpoint time. However some architectures like powerpc are keeping a reference to the vDSO base address to build the signal return stack frame by calling the vDSO sigreturn service. So once the vDSO has been moved, this reference is no more valid and the signal frame built later are not usable. This patch serie is introducing a new mm hook 'arch_remap' which is called when mremap is done and the mm lock still hold. The next patch is adding the vDSO remap and unmap tracking to the powerpc architecture. Changes in v2: -------------- - Following the Ingo Molnar's advice, enabling the call to arch_remap through the __HAVE_ARCH_REMAP macro. This reduces considerably the first patch. Laurent Dufour (2): mm: Introducing arch_remap hook powerpc/mm: Tracking vDSO remap arch/powerpc/include/asm/mmu_context.h | 36 +++++++++++++++++++++++++++++++++- mm/mremap.c | 11 +++++++++-- 2 files changed, 44 insertions(+), 3 deletions(-)
diff --git a/arch/s390/include/asm/mmu_context.h b/arch/s390/include/asm/mmu_context.h index 8fb3802f8fad..ddd861a490ba 100644 --- a/arch/s390/include/asm/mmu_context.h +++ b/arch/s390/include/asm/mmu_context.h @@ -131,4 +131,10 @@ static inline void arch_bprm_mm_init(struct mm_struct *mm, { } +static inline void arch_remap(struct mm_struct *mm, + unsigned long old_start, unsigned long old_end, + unsigned long new_start, unsigned long new_end) +{ +} + #endif /* __S390_MMU_CONTEXT_H */ diff --git a/arch/um/include/asm/mmu_context.h b/arch/um/include/asm/mmu_context.h index 941527e507f7..f499b017c1f9 100644 --- a/arch/um/include/asm/mmu_context.h +++ b/arch/um/include/asm/mmu_context.h @@ -27,6 +27,11 @@ static inline void arch_bprm_mm_init(struct mm_struct *mm, struct vm_area_struct *vma) { } +static inline void arch_remap(struct mm_struct *mm, + unsigned long old_start, unsigned long old_end, + unsigned long new_start, unsigned long new_end) +{ +} /* * end asm-generic/mm_hooks.h functions */ diff --git a/arch/unicore32/include/asm/mmu_context.h b/arch/unicore32/include/asm/mmu_context.h index 1cb5220afaf9..39a0a553172e 100644 --- a/arch/unicore32/include/asm/mmu_context.h +++ b/arch/unicore32/include/asm/mmu_context.h @@ -97,4 +97,10 @@ static inline void arch_bprm_mm_init(struct mm_struct *mm, { } +static inline void arch_remap(struct mm_struct *mm, + unsigned long old_start, unsigned long old_end, + unsigned long new_start, unsigned long new_end) +{ +} + #endif diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h index 883f6b933fa4..75cb71f4be1e 100644 --- a/arch/x86/include/asm/mmu_context.h +++ b/arch/x86/include/asm/mmu_context.h @@ -172,4 +172,10 @@ static inline void arch_unmap(struct mm_struct *mm, struct vm_area_struct *vma, mpx_notify_unmap(mm, vma, start, end); } +static inline void arch_remap(struct mm_struct *mm, + unsigned long old_start, unsigned long old_end, + unsigned long new_start, unsigned long new_end) +{ +} + #endif /* _ASM_X86_MMU_CONTEXT_H */ diff --git a/include/asm-generic/mm_hooks.h b/include/asm-generic/mm_hooks.h index 866aa461efa5..e507f4783a5b 100644 --- a/include/asm-generic/mm_hooks.h +++ b/include/asm-generic/mm_hooks.h @@ -26,4 +26,10 @@ static inline void arch_bprm_mm_init(struct mm_struct *mm, { } +static inline void arch_remap(struct mm_struct *mm, + unsigned long old_start, unsigned long old_end, + unsigned long new_start, unsigned long new_end) +{ +} + #endif /* _ASM_GENERIC_MM_HOOKS_H */ diff --git a/mm/mremap.c b/mm/mremap.c index 57dadc025c64..6a409ca09425 100644 --- a/mm/mremap.c +++ b/mm/mremap.c @@ -25,6 +25,7 @@ #include <asm/cacheflush.h> #include <asm/tlbflush.h> +#include <asm/mmu_context.h> #include "internal.h" @@ -286,8 +287,12 @@ static unsigned long move_vma(struct vm_area_struct *vma, old_len = new_len; old_addr = new_addr; new_addr = -ENOMEM; - } else if (vma->vm_file && vma->vm_file->f_op->mremap) - vma->vm_file->f_op->mremap(vma->vm_file, new_vma); + } else { + if (vma->vm_file && vma->vm_file->f_op->mremap) + vma->vm_file->f_op->mremap(vma->vm_file, new_vma); + arch_remap(mm, old_addr, old_addr+old_len, + new_addr, new_addr+new_len); + } /* Conceal VM_ACCOUNT so old reservation is not undone */ if (vm_flags & VM_ACCOUNT) {
Some architecture would like to be triggered when a memory area is moved through the mremap system call. This patch is introducing a new arch_remap mm hook which is placed in the path of mremap, and is called before the old area is unmapped (and the arch_unmap hook is called). To no break the build, this patch adds the empty hook definition to the architectures that were not using the generic hook's definition. Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com> --- arch/s390/include/asm/mmu_context.h | 6 ++++++ arch/um/include/asm/mmu_context.h | 5 +++++ arch/unicore32/include/asm/mmu_context.h | 6 ++++++ arch/x86/include/asm/mmu_context.h | 6 ++++++ include/asm-generic/mm_hooks.h | 6 ++++++ mm/mremap.c | 9 +++++++-- 6 files changed, 36 insertions(+), 2 deletions(-)