diff mbox

[RESEND,v3,1/2] mm: Introducing arch_remap hook

Message ID 9d827fc618a718830b2c47aa87e8be546914c897.1428916945.git.ldufour@linux.vnet.ibm.com (mailing list archive)
State Superseded
Headers show

Commit Message

Laurent Dufour April 13, 2015, 9:56 a.m. UTC
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).

The architectures which need to call this hook should define
__HAVE_ARCH_REMAP in their asm/mmu_context.h and provide the arch_remap
service with the following prototype:
void arch_remap(struct mm_struct *mm,
                unsigned long old_start, unsigned long old_end,
                unsigned long new_start, unsigned long new_end);

Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
Reviewed-by: Ingo Molnar <mingo@kernel.org>
---
 mm/mremap.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

Comments

Kirill A. Shutemov April 13, 2015, 11:58 a.m. UTC | #1
On Mon, Apr 13, 2015 at 11:56:27AM +0200, Laurent Dufour 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).
> 
> The architectures which need to call this hook should define
> __HAVE_ARCH_REMAP in their asm/mmu_context.h and provide the arch_remap
> service with the following prototype:
> void arch_remap(struct mm_struct *mm,
>                 unsigned long old_start, unsigned long old_end,
>                 unsigned long new_start, unsigned long new_end);
> 
> Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
> Reviewed-by: Ingo Molnar <mingo@kernel.org>
> ---
>  mm/mremap.c | 19 +++++++++++++------
>  1 file changed, 13 insertions(+), 6 deletions(-)
> 
> diff --git a/mm/mremap.c b/mm/mremap.c
> index 2dc44b1cb1df..009db5565893 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,13 +287,19 @@ 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) {
> -		err = vma->vm_file->f_op->mremap(vma->vm_file, new_vma);
> -		if (err < 0) {
> -			move_page_tables(new_vma, new_addr, vma, old_addr,
> -					 moved_len, true);
> -			return err;
> +	} else {
> +		if (vma->vm_file && vma->vm_file->f_op->mremap) {
> +			err = vma->vm_file->f_op->mremap(vma->vm_file, new_vma);
> +			if (err < 0) {
> +				move_page_tables(new_vma, new_addr, vma,
> +						  old_addr, moved_len, true);
> +				return err;
> +			}
>  		}
> +#ifdef __HAVE_ARCH_REMAP

It would be cleaner to provide dummy arch_remap() for !__HAVE_ARCH_REMAP
in some generic header.


> +		arch_remap(mm, old_addr, old_addr+old_len,
> +			   new_addr, new_addr+new_len);

Spaces around '+'?

> +#endif
>  	}
>  
>  	/* Conceal VM_ACCOUNT so old reservation is not undone */
> -- 
> 1.9.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
Laurent Dufour April 13, 2015, 12:41 p.m. UTC | #2
On 13/04/2015 13:58, Kirill A. Shutemov wrote:
> On Mon, Apr 13, 2015 at 11:56:27AM +0200, Laurent Dufour 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).
>>
>> The architectures which need to call this hook should define
>> __HAVE_ARCH_REMAP in their asm/mmu_context.h and provide the arch_remap
>> service with the following prototype:
>> void arch_remap(struct mm_struct *mm,
>>                 unsigned long old_start, unsigned long old_end,
>>                 unsigned long new_start, unsigned long new_end);
>>
>> Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
>> Reviewed-by: Ingo Molnar <mingo@kernel.org>
>> ---
>>  mm/mremap.c | 19 +++++++++++++------
>>  1 file changed, 13 insertions(+), 6 deletions(-)
>>
>> diff --git a/mm/mremap.c b/mm/mremap.c
>> index 2dc44b1cb1df..009db5565893 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,13 +287,19 @@ 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) {
>> -		err = vma->vm_file->f_op->mremap(vma->vm_file, new_vma);
>> -		if (err < 0) {
>> -			move_page_tables(new_vma, new_addr, vma, old_addr,
>> -					 moved_len, true);
>> -			return err;
>> +	} else {
>> +		if (vma->vm_file && vma->vm_file->f_op->mremap) {
>> +			err = vma->vm_file->f_op->mremap(vma->vm_file, new_vma);
>> +			if (err < 0) {
>> +				move_page_tables(new_vma, new_addr, vma,
>> +						  old_addr, moved_len, true);
>> +				return err;
>> +			}
>>  		}
>> +#ifdef __HAVE_ARCH_REMAP
> 
> It would be cleaner to provide dummy arch_remap() for !__HAVE_ARCH_REMAP
> in some generic header.

The idea was to not impact all the architectures as arch_unmap(),
arch_dup_mmap() or arch_exit_mmap() implies.

I look at the headers where such a dummy arch_remap could be put but I
can't figure out one which will not impact all the architecture.
What about defining a dummy service earlier in mm/remap.c in the case
__HAVE_ARCH_REMAP is not defined ?
Something like :
#ifndef __HAVE_ARCH_REMAP
static inline void void arch_remap(struct mm_struct *mm,
                                   unsigned long old_start,
                                   unsigned long old_end,
                                   unsigned long new_start,
                                   unsigned long new_end)
{
}
#endif

> 
> 
>> +		arch_remap(mm, old_addr, old_addr+old_len,
>> +			   new_addr, new_addr+new_len);
> 
> Spaces around '+'?

Nice catch ;)

Thanks,
Laurent.

> 
>> +#endif
>>  	}
>>  
>>  	/* Conceal VM_ACCOUNT so old reservation is not undone */
>> -- 
>> 1.9.1
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>> Please read the FAQ at  http://www.tux.org/lkml/
>
Kirill A. Shutemov April 13, 2015, 1:13 p.m. UTC | #3
On Mon, Apr 13, 2015 at 02:41:22PM +0200, Laurent Dufour wrote:
> On 13/04/2015 13:58, Kirill A. Shutemov wrote:
> > On Mon, Apr 13, 2015 at 11:56:27AM +0200, Laurent Dufour 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).
> >>
> >> The architectures which need to call this hook should define
> >> __HAVE_ARCH_REMAP in their asm/mmu_context.h and provide the arch_remap
> >> service with the following prototype:
> >> void arch_remap(struct mm_struct *mm,
> >>                 unsigned long old_start, unsigned long old_end,
> >>                 unsigned long new_start, unsigned long new_end);
> >>
> >> Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
> >> Reviewed-by: Ingo Molnar <mingo@kernel.org>
> >> ---
> >>  mm/mremap.c | 19 +++++++++++++------
> >>  1 file changed, 13 insertions(+), 6 deletions(-)
> >>
> >> diff --git a/mm/mremap.c b/mm/mremap.c
> >> index 2dc44b1cb1df..009db5565893 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,13 +287,19 @@ 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) {
> >> -		err = vma->vm_file->f_op->mremap(vma->vm_file, new_vma);
> >> -		if (err < 0) {
> >> -			move_page_tables(new_vma, new_addr, vma, old_addr,
> >> -					 moved_len, true);
> >> -			return err;
> >> +	} else {
> >> +		if (vma->vm_file && vma->vm_file->f_op->mremap) {
> >> +			err = vma->vm_file->f_op->mremap(vma->vm_file, new_vma);
> >> +			if (err < 0) {
> >> +				move_page_tables(new_vma, new_addr, vma,
> >> +						  old_addr, moved_len, true);
> >> +				return err;
> >> +			}
> >>  		}
> >> +#ifdef __HAVE_ARCH_REMAP
> > 
> > It would be cleaner to provide dummy arch_remap() for !__HAVE_ARCH_REMAP
> > in some generic header.
> 
> The idea was to not impact all the architectures as arch_unmap(),
> arch_dup_mmap() or arch_exit_mmap() implies.
> 
> I look at the headers where such a dummy arch_remap could be put but I
> can't figure out one which will not impact all the architecture.
> What about defining a dummy service earlier in mm/remap.c in the case
> __HAVE_ARCH_REMAP is not defined ?
> Something like :
> #ifndef __HAVE_ARCH_REMAP
> static inline void void arch_remap(struct mm_struct *mm,
>                                    unsigned long old_start,
>                                    unsigned long old_end,
>                                    unsigned long new_start,
>                                    unsigned long new_end)
> {
> }
> #endif

Or just #define arch_remap(...) do { } while (0)
Laurent Dufour April 13, 2015, 1:21 p.m. UTC | #4
On 13/04/2015 15:13, Kirill A. Shutemov wrote:
> On Mon, Apr 13, 2015 at 02:41:22PM +0200, Laurent Dufour wrote:
>> On 13/04/2015 13:58, Kirill A. Shutemov wrote:
>>> On Mon, Apr 13, 2015 at 11:56:27AM +0200, Laurent Dufour 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).
>>>>
>>>> The architectures which need to call this hook should define
>>>> __HAVE_ARCH_REMAP in their asm/mmu_context.h and provide the arch_remap
>>>> service with the following prototype:
>>>> void arch_remap(struct mm_struct *mm,
>>>>                 unsigned long old_start, unsigned long old_end,
>>>>                 unsigned long new_start, unsigned long new_end);
>>>>
>>>> Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
>>>> Reviewed-by: Ingo Molnar <mingo@kernel.org>
>>>> ---
>>>>  mm/mremap.c | 19 +++++++++++++------
>>>>  1 file changed, 13 insertions(+), 6 deletions(-)
>>>>
>>>> diff --git a/mm/mremap.c b/mm/mremap.c
>>>> index 2dc44b1cb1df..009db5565893 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,13 +287,19 @@ 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) {
>>>> -		err = vma->vm_file->f_op->mremap(vma->vm_file, new_vma);
>>>> -		if (err < 0) {
>>>> -			move_page_tables(new_vma, new_addr, vma, old_addr,
>>>> -					 moved_len, true);
>>>> -			return err;
>>>> +	} else {
>>>> +		if (vma->vm_file && vma->vm_file->f_op->mremap) {
>>>> +			err = vma->vm_file->f_op->mremap(vma->vm_file, new_vma);
>>>> +			if (err < 0) {
>>>> +				move_page_tables(new_vma, new_addr, vma,
>>>> +						  old_addr, moved_len, true);
>>>> +				return err;
>>>> +			}
>>>>  		}
>>>> +#ifdef __HAVE_ARCH_REMAP
>>>
>>> It would be cleaner to provide dummy arch_remap() for !__HAVE_ARCH_REMAP
>>> in some generic header.
>>
>> The idea was to not impact all the architectures as arch_unmap(),
>> arch_dup_mmap() or arch_exit_mmap() implies.
>>
>> I look at the headers where such a dummy arch_remap could be put but I
>> can't figure out one which will not impact all the architecture.
>> What about defining a dummy service earlier in mm/remap.c in the case
>> __HAVE_ARCH_REMAP is not defined ?
>> Something like :
>> #ifndef __HAVE_ARCH_REMAP
>> static inline void void arch_remap(struct mm_struct *mm,
>>                                    unsigned long old_start,
>>                                    unsigned long old_end,
>>                                    unsigned long new_start,
>>                                    unsigned long new_end)
>> {
>> }
>> #endif
> 
> Or just #define arch_remap(...) do { } while (0)
> 

I guessed you wanted the arch_remap() prototype to be exposed somewhere
in the code.

To be honest, I can't find the benefit of defining a dummy arch_remap()
in mm/remap.c if __HAVE_ARCH_REMAP is not defined instead of calling it
in move_vma if __HAVE_ARCH_REMAP is defined.
Is it really what you want ?

Thanks,
Laurent.
Pavel Emelyanov April 13, 2015, 1:35 p.m. UTC | #5
On 04/13/2015 04:21 PM, Laurent Dufour wrote:
> On 13/04/2015 15:13, Kirill A. Shutemov wrote:
>> On Mon, Apr 13, 2015 at 02:41:22PM +0200, Laurent Dufour wrote:
>>> On 13/04/2015 13:58, Kirill A. Shutemov wrote:
>>>> On Mon, Apr 13, 2015 at 11:56:27AM +0200, Laurent Dufour 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).
>>>>>
>>>>> The architectures which need to call this hook should define
>>>>> __HAVE_ARCH_REMAP in their asm/mmu_context.h and provide the arch_remap
>>>>> service with the following prototype:
>>>>> void arch_remap(struct mm_struct *mm,
>>>>>                 unsigned long old_start, unsigned long old_end,
>>>>>                 unsigned long new_start, unsigned long new_end);
>>>>>
>>>>> Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
>>>>> Reviewed-by: Ingo Molnar <mingo@kernel.org>
>>>>> ---
>>>>>  mm/mremap.c | 19 +++++++++++++------
>>>>>  1 file changed, 13 insertions(+), 6 deletions(-)
>>>>>
>>>>> diff --git a/mm/mremap.c b/mm/mremap.c
>>>>> index 2dc44b1cb1df..009db5565893 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,13 +287,19 @@ 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) {
>>>>> -		err = vma->vm_file->f_op->mremap(vma->vm_file, new_vma);
>>>>> -		if (err < 0) {
>>>>> -			move_page_tables(new_vma, new_addr, vma, old_addr,
>>>>> -					 moved_len, true);
>>>>> -			return err;
>>>>> +	} else {
>>>>> +		if (vma->vm_file && vma->vm_file->f_op->mremap) {
>>>>> +			err = vma->vm_file->f_op->mremap(vma->vm_file, new_vma);
>>>>> +			if (err < 0) {
>>>>> +				move_page_tables(new_vma, new_addr, vma,
>>>>> +						  old_addr, moved_len, true);
>>>>> +				return err;
>>>>> +			}
>>>>>  		}
>>>>> +#ifdef __HAVE_ARCH_REMAP
>>>>
>>>> It would be cleaner to provide dummy arch_remap() for !__HAVE_ARCH_REMAP
>>>> in some generic header.
>>>
>>> The idea was to not impact all the architectures as arch_unmap(),
>>> arch_dup_mmap() or arch_exit_mmap() implies.
>>>
>>> I look at the headers where such a dummy arch_remap could be put but I
>>> can't figure out one which will not impact all the architecture.
>>> What about defining a dummy service earlier in mm/remap.c in the case
>>> __HAVE_ARCH_REMAP is not defined ?
>>> Something like :
>>> #ifndef __HAVE_ARCH_REMAP
>>> static inline void void arch_remap(struct mm_struct *mm,
>>>                                    unsigned long old_start,
>>>                                    unsigned long old_end,
>>>                                    unsigned long new_start,
>>>                                    unsigned long new_end)
>>> {
>>> }
>>> #endif
>>
>> Or just #define arch_remap(...) do { } while (0)
>>
> 
> I guessed you wanted the arch_remap() prototype to be exposed somewhere
> in the code.
> 
> To be honest, I can't find the benefit of defining a dummy arch_remap()
> in mm/remap.c if __HAVE_ARCH_REMAP is not defined instead of calling it
> in move_vma if __HAVE_ARCH_REMAP is defined.
> Is it really what you want ?

I think Kirill meant something like e.g. the arch_enter_lazy_mmu_mode()
is implemented and called in mm/mremap.c -- the "generic" part is in the
include/asm-generic/pgtable.h and those architectures willing to have
their own implementation are in arch/$arch/...

Kirill, if I'm right with it, can you suggest the header where to put
the "generic" mremap hook's (empty) body?

-- Pavel
Kirill A. Shutemov April 13, 2015, 2:02 p.m. UTC | #6
On Mon, Apr 13, 2015 at 04:35:21PM +0300, Pavel Emelyanov wrote:
> On 04/13/2015 04:21 PM, Laurent Dufour wrote:
> > On 13/04/2015 15:13, Kirill A. Shutemov wrote:
> >> On Mon, Apr 13, 2015 at 02:41:22PM +0200, Laurent Dufour wrote:
> >>> On 13/04/2015 13:58, Kirill A. Shutemov wrote:
> >>>> On Mon, Apr 13, 2015 at 11:56:27AM +0200, Laurent Dufour 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).
> >>>>>
> >>>>> The architectures which need to call this hook should define
> >>>>> __HAVE_ARCH_REMAP in their asm/mmu_context.h and provide the arch_remap
> >>>>> service with the following prototype:
> >>>>> void arch_remap(struct mm_struct *mm,
> >>>>>                 unsigned long old_start, unsigned long old_end,
> >>>>>                 unsigned long new_start, unsigned long new_end);
> >>>>>
> >>>>> Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
> >>>>> Reviewed-by: Ingo Molnar <mingo@kernel.org>
> >>>>> ---
> >>>>>  mm/mremap.c | 19 +++++++++++++------
> >>>>>  1 file changed, 13 insertions(+), 6 deletions(-)
> >>>>>
> >>>>> diff --git a/mm/mremap.c b/mm/mremap.c
> >>>>> index 2dc44b1cb1df..009db5565893 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,13 +287,19 @@ 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) {
> >>>>> -		err = vma->vm_file->f_op->mremap(vma->vm_file, new_vma);
> >>>>> -		if (err < 0) {
> >>>>> -			move_page_tables(new_vma, new_addr, vma, old_addr,
> >>>>> -					 moved_len, true);
> >>>>> -			return err;
> >>>>> +	} else {
> >>>>> +		if (vma->vm_file && vma->vm_file->f_op->mremap) {
> >>>>> +			err = vma->vm_file->f_op->mremap(vma->vm_file, new_vma);
> >>>>> +			if (err < 0) {
> >>>>> +				move_page_tables(new_vma, new_addr, vma,
> >>>>> +						  old_addr, moved_len, true);
> >>>>> +				return err;
> >>>>> +			}
> >>>>>  		}
> >>>>> +#ifdef __HAVE_ARCH_REMAP
> >>>>
> >>>> It would be cleaner to provide dummy arch_remap() for !__HAVE_ARCH_REMAP
> >>>> in some generic header.
> >>>
> >>> The idea was to not impact all the architectures as arch_unmap(),
> >>> arch_dup_mmap() or arch_exit_mmap() implies.
> >>>
> >>> I look at the headers where such a dummy arch_remap could be put but I
> >>> can't figure out one which will not impact all the architecture.
> >>> What about defining a dummy service earlier in mm/remap.c in the case
> >>> __HAVE_ARCH_REMAP is not defined ?
> >>> Something like :
> >>> #ifndef __HAVE_ARCH_REMAP
> >>> static inline void void arch_remap(struct mm_struct *mm,
> >>>                                    unsigned long old_start,
> >>>                                    unsigned long old_end,
> >>>                                    unsigned long new_start,
> >>>                                    unsigned long new_end)
> >>> {
> >>> }
> >>> #endif
> >>
> >> Or just #define arch_remap(...) do { } while (0)
> >>
> > 
> > I guessed you wanted the arch_remap() prototype to be exposed somewhere
> > in the code.
> > 
> > To be honest, I can't find the benefit of defining a dummy arch_remap()
> > in mm/remap.c if __HAVE_ARCH_REMAP is not defined instead of calling it
> > in move_vma if __HAVE_ARCH_REMAP is defined.
> > Is it really what you want ?
> 
> I think Kirill meant something like e.g. the arch_enter_lazy_mmu_mode()
> is implemented and called in mm/mremap.c -- the "generic" part is in the
> include/asm-generic/pgtable.h and those architectures willing to have
> their own implementation are in arch/$arch/...
> 
> Kirill, if I'm right with it, can you suggest the header where to put
> the "generic" mremap hook's (empty) body?

I initially thought it would be enough to put it into
<asm-generic/mmu_context.h>, expecting it works as
<asm-generic/pgtable.h>. But that's not the case.

It probably worth at some point rework all <asm/mmu_context.h> to include
<asm-generic/mmu_context.h> at the end as we do for <asm/pgtable.h>.
But that's outside the scope of the patchset, I guess.

I don't see any better candidate for such dummy header. :-/
Laurent Dufour April 13, 2015, 2:11 p.m. UTC | #7
On 13/04/2015 16:02, Kirill A. Shutemov wrote:
> On Mon, Apr 13, 2015 at 04:35:21PM +0300, Pavel Emelyanov wrote:
>> On 04/13/2015 04:21 PM, Laurent Dufour wrote:
>>> On 13/04/2015 15:13, Kirill A. Shutemov wrote:
>>>> On Mon, Apr 13, 2015 at 02:41:22PM +0200, Laurent Dufour wrote:
>>>>> On 13/04/2015 13:58, Kirill A. Shutemov wrote:
>>>>>> On Mon, Apr 13, 2015 at 11:56:27AM +0200, Laurent Dufour 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).
>>>>>>>
>>>>>>> The architectures which need to call this hook should define
>>>>>>> __HAVE_ARCH_REMAP in their asm/mmu_context.h and provide the arch_remap
>>>>>>> service with the following prototype:
>>>>>>> void arch_remap(struct mm_struct *mm,
>>>>>>>                 unsigned long old_start, unsigned long old_end,
>>>>>>>                 unsigned long new_start, unsigned long new_end);
>>>>>>>
>>>>>>> Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
>>>>>>> Reviewed-by: Ingo Molnar <mingo@kernel.org>
>>>>>>> ---
>>>>>>>  mm/mremap.c | 19 +++++++++++++------
>>>>>>>  1 file changed, 13 insertions(+), 6 deletions(-)
>>>>>>>
>>>>>>> diff --git a/mm/mremap.c b/mm/mremap.c
>>>>>>> index 2dc44b1cb1df..009db5565893 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,13 +287,19 @@ 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) {
>>>>>>> -		err = vma->vm_file->f_op->mremap(vma->vm_file, new_vma);
>>>>>>> -		if (err < 0) {
>>>>>>> -			move_page_tables(new_vma, new_addr, vma, old_addr,
>>>>>>> -					 moved_len, true);
>>>>>>> -			return err;
>>>>>>> +	} else {
>>>>>>> +		if (vma->vm_file && vma->vm_file->f_op->mremap) {
>>>>>>> +			err = vma->vm_file->f_op->mremap(vma->vm_file, new_vma);
>>>>>>> +			if (err < 0) {
>>>>>>> +				move_page_tables(new_vma, new_addr, vma,
>>>>>>> +						  old_addr, moved_len, true);
>>>>>>> +				return err;
>>>>>>> +			}
>>>>>>>  		}
>>>>>>> +#ifdef __HAVE_ARCH_REMAP
>>>>>>
>>>>>> It would be cleaner to provide dummy arch_remap() for !__HAVE_ARCH_REMAP
>>>>>> in some generic header.
>>>>>
>>>>> The idea was to not impact all the architectures as arch_unmap(),
>>>>> arch_dup_mmap() or arch_exit_mmap() implies.
>>>>>
>>>>> I look at the headers where such a dummy arch_remap could be put but I
>>>>> can't figure out one which will not impact all the architecture.
>>>>> What about defining a dummy service earlier in mm/remap.c in the case
>>>>> __HAVE_ARCH_REMAP is not defined ?
>>>>> Something like :
>>>>> #ifndef __HAVE_ARCH_REMAP
>>>>> static inline void void arch_remap(struct mm_struct *mm,
>>>>>                                    unsigned long old_start,
>>>>>                                    unsigned long old_end,
>>>>>                                    unsigned long new_start,
>>>>>                                    unsigned long new_end)
>>>>> {
>>>>> }
>>>>> #endif
>>>>
>>>> Or just #define arch_remap(...) do { } while (0)
>>>>
>>>
>>> I guessed you wanted the arch_remap() prototype to be exposed somewhere
>>> in the code.
>>>
>>> To be honest, I can't find the benefit of defining a dummy arch_remap()
>>> in mm/remap.c if __HAVE_ARCH_REMAP is not defined instead of calling it
>>> in move_vma if __HAVE_ARCH_REMAP is defined.
>>> Is it really what you want ?
>>
>> I think Kirill meant something like e.g. the arch_enter_lazy_mmu_mode()
>> is implemented and called in mm/mremap.c -- the "generic" part is in the
>> include/asm-generic/pgtable.h and those architectures willing to have
>> their own implementation are in arch/$arch/...
>>
>> Kirill, if I'm right with it, can you suggest the header where to put
>> the "generic" mremap hook's (empty) body?
> 
> I initially thought it would be enough to put it into
> <asm-generic/mmu_context.h>, expecting it works as
> <asm-generic/pgtable.h>. But that's not the case.
> 
> It probably worth at some point rework all <asm/mmu_context.h> to include
> <asm-generic/mmu_context.h> at the end as we do for <asm/pgtable.h>.
> But that's outside the scope of the patchset, I guess.
> 
> I don't see any better candidate for such dummy header. :-/

Clearly, I'm not confortable with a rewrite of <asm/mmu_context.h> :(

So what about this patch, is this v3 acceptable ?

Cheers,
Laurent.
Kirill A. Shutemov April 13, 2015, 2:26 p.m. UTC | #8
On Mon, Apr 13, 2015 at 04:11:19PM +0200, Laurent Dufour wrote:
> On 13/04/2015 16:02, Kirill A. Shutemov wrote:
> > On Mon, Apr 13, 2015 at 04:35:21PM +0300, Pavel Emelyanov wrote:
> >> On 04/13/2015 04:21 PM, Laurent Dufour wrote:
> >>> On 13/04/2015 15:13, Kirill A. Shutemov wrote:
> >>>> On Mon, Apr 13, 2015 at 02:41:22PM +0200, Laurent Dufour wrote:
> >>>>> On 13/04/2015 13:58, Kirill A. Shutemov wrote:
> >>>>>> On Mon, Apr 13, 2015 at 11:56:27AM +0200, Laurent Dufour 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).
> >>>>>>>
> >>>>>>> The architectures which need to call this hook should define
> >>>>>>> __HAVE_ARCH_REMAP in their asm/mmu_context.h and provide the arch_remap
> >>>>>>> service with the following prototype:
> >>>>>>> void arch_remap(struct mm_struct *mm,
> >>>>>>>                 unsigned long old_start, unsigned long old_end,
> >>>>>>>                 unsigned long new_start, unsigned long new_end);
> >>>>>>>
> >>>>>>> Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
> >>>>>>> Reviewed-by: Ingo Molnar <mingo@kernel.org>
> >>>>>>> ---
> >>>>>>>  mm/mremap.c | 19 +++++++++++++------
> >>>>>>>  1 file changed, 13 insertions(+), 6 deletions(-)
> >>>>>>>
> >>>>>>> diff --git a/mm/mremap.c b/mm/mremap.c
> >>>>>>> index 2dc44b1cb1df..009db5565893 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,13 +287,19 @@ 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) {
> >>>>>>> -		err = vma->vm_file->f_op->mremap(vma->vm_file, new_vma);
> >>>>>>> -		if (err < 0) {
> >>>>>>> -			move_page_tables(new_vma, new_addr, vma, old_addr,
> >>>>>>> -					 moved_len, true);
> >>>>>>> -			return err;
> >>>>>>> +	} else {
> >>>>>>> +		if (vma->vm_file && vma->vm_file->f_op->mremap) {
> >>>>>>> +			err = vma->vm_file->f_op->mremap(vma->vm_file, new_vma);
> >>>>>>> +			if (err < 0) {
> >>>>>>> +				move_page_tables(new_vma, new_addr, vma,
> >>>>>>> +						  old_addr, moved_len, true);
> >>>>>>> +				return err;
> >>>>>>> +			}
> >>>>>>>  		}
> >>>>>>> +#ifdef __HAVE_ARCH_REMAP
> >>>>>>
> >>>>>> It would be cleaner to provide dummy arch_remap() for !__HAVE_ARCH_REMAP
> >>>>>> in some generic header.
> >>>>>
> >>>>> The idea was to not impact all the architectures as arch_unmap(),
> >>>>> arch_dup_mmap() or arch_exit_mmap() implies.
> >>>>>
> >>>>> I look at the headers where such a dummy arch_remap could be put but I
> >>>>> can't figure out one which will not impact all the architecture.
> >>>>> What about defining a dummy service earlier in mm/remap.c in the case
> >>>>> __HAVE_ARCH_REMAP is not defined ?
> >>>>> Something like :
> >>>>> #ifndef __HAVE_ARCH_REMAP
> >>>>> static inline void void arch_remap(struct mm_struct *mm,
> >>>>>                                    unsigned long old_start,
> >>>>>                                    unsigned long old_end,
> >>>>>                                    unsigned long new_start,
> >>>>>                                    unsigned long new_end)
> >>>>> {
> >>>>> }
> >>>>> #endif
> >>>>
> >>>> Or just #define arch_remap(...) do { } while (0)
> >>>>
> >>>
> >>> I guessed you wanted the arch_remap() prototype to be exposed somewhere
> >>> in the code.
> >>>
> >>> To be honest, I can't find the benefit of defining a dummy arch_remap()
> >>> in mm/remap.c if __HAVE_ARCH_REMAP is not defined instead of calling it
> >>> in move_vma if __HAVE_ARCH_REMAP is defined.
> >>> Is it really what you want ?
> >>
> >> I think Kirill meant something like e.g. the arch_enter_lazy_mmu_mode()
> >> is implemented and called in mm/mremap.c -- the "generic" part is in the
> >> include/asm-generic/pgtable.h and those architectures willing to have
> >> their own implementation are in arch/$arch/...
> >>
> >> Kirill, if I'm right with it, can you suggest the header where to put
> >> the "generic" mremap hook's (empty) body?
> > 
> > I initially thought it would be enough to put it into
> > <asm-generic/mmu_context.h>, expecting it works as
> > <asm-generic/pgtable.h>. But that's not the case.
> > 
> > It probably worth at some point rework all <asm/mmu_context.h> to include
> > <asm-generic/mmu_context.h> at the end as we do for <asm/pgtable.h>.
> > But that's outside the scope of the patchset, I guess.
> > 
> > I don't see any better candidate for such dummy header. :-/
> 
> Clearly, I'm not confortable with a rewrite of <asm/mmu_context.h> :(
> 
> So what about this patch, is this v3 acceptable ?

Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Pavel Emelyanov April 13, 2015, 2:32 p.m. UTC | #9
>>> I initially thought it would be enough to put it into
>>> <asm-generic/mmu_context.h>, expecting it works as
>>> <asm-generic/pgtable.h>. But that's not the case.
>>>
>>> It probably worth at some point rework all <asm/mmu_context.h> to include
>>> <asm-generic/mmu_context.h> at the end as we do for <asm/pgtable.h>.
>>> But that's outside the scope of the patchset, I guess.
>>>
>>> I don't see any better candidate for such dummy header. :-/
>>
>> Clearly, I'm not confortable with a rewrite of <asm/mmu_context.h> :(
>>
>> So what about this patch, is this v3 acceptable ?
> 
> Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>

Other than the #ifdef thing, the same:

Acked-by: Pavel Emelyanov <xemul@parallels.com>
Laurent Dufour April 13, 2015, 3:27 p.m. UTC | #10
On 13/04/2015 16:32, Pavel Emelyanov wrote:
>>>> I initially thought it would be enough to put it into
>>>> <asm-generic/mmu_context.h>, expecting it works as
>>>> <asm-generic/pgtable.h>. But that's not the case.
>>>>
>>>> It probably worth at some point rework all <asm/mmu_context.h> to include
>>>> <asm-generic/mmu_context.h> at the end as we do for <asm/pgtable.h>.
>>>> But that's outside the scope of the patchset, I guess.
>>>>
>>>> I don't see any better candidate for such dummy header. :-/
>>>
>>> Clearly, I'm not confortable with a rewrite of <asm/mmu_context.h> :(
>>>
>>> So what about this patch, is this v3 acceptable ?
>>
>> Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> 
> Other than the #ifdef thing, the same:
> 
> Acked-by: Pavel Emelyanov <xemul@parallels.com>
> 

Thanks Kirill and Pavel.

Should I send a new version fixing the spaces around the plus sign ?

Cheers,
Laurent.
Andrew Morton April 13, 2015, 8:59 p.m. UTC | #11
On Mon, 13 Apr 2015 17:02:19 +0300 "Kirill A. Shutemov" <kirill@shutemov.name> wrote:

> > Kirill, if I'm right with it, can you suggest the header where to put
> > the "generic" mremap hook's (empty) body?
> 
> I initially thought it would be enough to put it into
> <asm-generic/mmu_context.h>, expecting it works as
> <asm-generic/pgtable.h>. But that's not the case.
> 
> It probably worth at some point rework all <asm/mmu_context.h> to include
> <asm-generic/mmu_context.h> at the end as we do for <asm/pgtable.h>.
> But that's outside the scope of the patchset, I guess.
> 
> I don't see any better candidate for such dummy header. :-/

Do away with __HAVE_ARCH_REMAP and do it like this:

arch/x/include/asm/y.h:

	extern void arch_remap(...);
	#define arch_remap arch_remap

include/linux/z.h:

	#include <asm/y.h>

	#ifndef arch_remap
	static inline void arch_remap(...) { }
	#define arch_remap arch_remap
	#endif
Laurent Dufour April 14, 2015, 9:26 a.m. UTC | #12
On 13/04/2015 22:59, Andrew Morton wrote:
> On Mon, 13 Apr 2015 17:02:19 +0300 "Kirill A. Shutemov" <kirill@shutemov.name> wrote:
> 
>>> Kirill, if I'm right with it, can you suggest the header where to put
>>> the "generic" mremap hook's (empty) body?
>>
>> I initially thought it would be enough to put it into
>> <asm-generic/mmu_context.h>, expecting it works as
>> <asm-generic/pgtable.h>. But that's not the case.
>>
>> It probably worth at some point rework all <asm/mmu_context.h> to include
>> <asm-generic/mmu_context.h> at the end as we do for <asm/pgtable.h>.
>> But that's outside the scope of the patchset, I guess.
>>
>> I don't see any better candidate for such dummy header. :-/
> 
> Do away with __HAVE_ARCH_REMAP and do it like this:
> 
> arch/x/include/asm/y.h:
> 
> 	extern void arch_remap(...);
> 	#define arch_remap arch_remap
> 
> include/linux/z.h:
> 
> 	#include <asm/y.h>
> 
> 	#ifndef arch_remap
> 	static inline void arch_remap(...) { }
> 	#define arch_remap arch_remap
> 	#endif

Hi Andrew,

I like your idea, but I can't find any good candidate for <asm/y.h> and
<linux/z.h>.

I tried with <linux/mm.h> and <asm/mmu_context.h> but
<asm/mmu_context.h> is already including <linux/mm.h>.

Do you have any suggestion ?

Another option could be to do it like the actual arch_unmap() in
<asm-generic/mm_hooks.h> but this is the opposite of your idea, and Ingo
was not comfortable with this idea due to the impact of the other
architectures.

Cheers,
Laurent.
Andrew Morton April 14, 2015, 7:38 p.m. UTC | #13
On Tue, 14 Apr 2015 11:26:13 +0200 Laurent Dufour <ldufour@linux.vnet.ibm.com> wrote:

> > Do away with __HAVE_ARCH_REMAP and do it like this:
> > 
> > arch/x/include/asm/y.h:
> > 
> > 	extern void arch_remap(...);
> > 	#define arch_remap arch_remap
> > 
> > include/linux/z.h:
> > 
> > 	#include <asm/y.h>
> > 
> > 	#ifndef arch_remap
> > 	static inline void arch_remap(...) { }
> > 	#define arch_remap arch_remap
> > 	#endif
> 
> Hi Andrew,
> 
> I like your idea, but I can't find any good candidate for <asm/y.h> and
> <linux/z.h>.
> 
> I tried with <linux/mm.h> and <asm/mmu_context.h> but
> <asm/mmu_context.h> is already including <linux/mm.h>.
> 
> Do you have any suggestion ?
> 
> Another option could be to do it like the actual arch_unmap() in
> <asm-generic/mm_hooks.h> but this is the opposite of your idea, and Ingo
> was not comfortable with this idea due to the impact of the other
> architectures.

I don't see any appropriate header files for this.  mman.h is kinda
close.

So we create new header files, that's not a problem.  I'm torn between

a) include/linux/mm-arch-hooks.h (and 31
   arch/X/include/asm/mm-arch-hooks.h).  Mandate: mm stuff which can be
   overridded by arch

versus

b) include/linux/mremap.h (+31), with a narrower mandate.


This comes up fairly regularly so I suspect a) is better.  We'll add
things to it over time, and various bits of existing ad-hackery can be
moved over as cleanups.
Laurent Dufour April 15, 2015, 11:57 a.m. UTC | #14
On 14/04/2015 21:38, Andrew Morton wrote:
> On Tue, 14 Apr 2015 11:26:13 +0200 Laurent Dufour <ldufour@linux.vnet.ibm.com> wrote:
> 
>>> Do away with __HAVE_ARCH_REMAP and do it like this:
>>>
>>> arch/x/include/asm/y.h:
>>>
>>> 	extern void arch_remap(...);
>>> 	#define arch_remap arch_remap
>>>
>>> include/linux/z.h:
>>>
>>> 	#include <asm/y.h>
>>>
>>> 	#ifndef arch_remap
>>> 	static inline void arch_remap(...) { }
>>> 	#define arch_remap arch_remap
>>> 	#endif
>>
>> Hi Andrew,
>>
>> I like your idea, but I can't find any good candidate for <asm/y.h> and
>> <linux/z.h>.
>>
>> I tried with <linux/mm.h> and <asm/mmu_context.h> but
>> <asm/mmu_context.h> is already including <linux/mm.h>.
>>
>> Do you have any suggestion ?
>>
>> Another option could be to do it like the actual arch_unmap() in
>> <asm-generic/mm_hooks.h> but this is the opposite of your idea, and Ingo
>> was not comfortable with this idea due to the impact of the other
>> architectures.
> 
> I don't see any appropriate header files for this.  mman.h is kinda
> close.
> 
> So we create new header files, that's not a problem.  I'm torn between
> 
> a) include/linux/mm-arch-hooks.h (and 31
>    arch/X/include/asm/mm-arch-hooks.h).  Mandate: mm stuff which can be
>    overridded by arch
> 
> versus
> 
> b) include/linux/mremap.h (+31), with a narrower mandate.
> 
> 
> This comes up fairly regularly so I suspect a) is better.  We'll add
> things to it over time, and various bits of existing ad-hackery can be
> moved over as cleanups.

Thanks for the advice,

I'll do a), starting with the arch_remap macro, adding the 30 "empty"
arch/x/include/asm/mm-arch-hooks.h files, and implementing arch_remap
for powerpc.

Then, if the first patch is accepted, I may move the arch_*() stuff
defined in include/asm-generic/mm_hooks.h into
include/linux/mm-arch-hooks.h and filled some
arch/X/include/asm/mm-arch-hooks.h. The file
include/asm-generic/mm_hooks.h will then become empty, and been removed.

Cheers,
Laurent.


  * Anglais - détecté
  * Français
  * Anglais

  * Français
  * Anglais

 <javascript:void(0);>
Laurent Dufour April 15, 2015, 2:16 p.m. UTC | #15
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 framework, and a new
arch_remap hook 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 v5:
- Jumping over v4 which was too complex (PowerPC part) for the need.
- Introducing new mm hook framework as suggested by Andrew Morton.

Changes in v4:
- Reviewing the PowerPC part of the patch to handle partial unmap and remap
  of the vDSO.

Changes in v3:
- Fixed grammatical error in a comment of the second patch. 
  Thanks again, Ingo.

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 (3):
  mm: New mm hook framework
  mm: New arch_remap hook
  powerpc/mm: Tracking vDSO remap

 arch/alpha/include/asm/mm-arch-hooks.h      | 15 +++++++++++++++
 arch/arc/include/asm/mm-arch-hooks.h        | 15 +++++++++++++++
 arch/arm/include/asm/mm-arch-hooks.h        | 15 +++++++++++++++
 arch/arm64/include/asm/mm-arch-hooks.h      | 15 +++++++++++++++
 arch/avr32/include/asm/mm-arch-hooks.h      | 15 +++++++++++++++
 arch/blackfin/include/asm/mm-arch-hooks.h   | 15 +++++++++++++++
 arch/c6x/include/asm/mm-arch-hooks.h        | 15 +++++++++++++++
 arch/cris/include/asm/mm-arch-hooks.h       | 15 +++++++++++++++
 arch/frv/include/asm/mm-arch-hooks.h        | 15 +++++++++++++++
 arch/hexagon/include/asm/mm-arch-hooks.h    | 15 +++++++++++++++
 arch/ia64/include/asm/mm-arch-hooks.h       | 15 +++++++++++++++
 arch/m32r/include/asm/mm-arch-hooks.h       | 15 +++++++++++++++
 arch/m68k/include/asm/mm-arch-hooks.h       | 15 +++++++++++++++
 arch/metag/include/asm/mm-arch-hooks.h      | 15 +++++++++++++++
 arch/microblaze/include/asm/mm-arch-hooks.h | 15 +++++++++++++++
 arch/mips/include/asm/mm-arch-hooks.h       | 15 +++++++++++++++
 arch/mn10300/include/asm/mm-arch-hooks.h    | 15 +++++++++++++++
 arch/nios2/include/asm/mm-arch-hooks.h      | 15 +++++++++++++++
 arch/openrisc/include/asm/mm-arch-hooks.h   | 15 +++++++++++++++
 arch/parisc/include/asm/mm-arch-hooks.h     | 15 +++++++++++++++
 arch/powerpc/include/asm/mm-arch-hooks.h    | 28 ++++++++++++++++++++++++++++
 arch/powerpc/include/asm/mmu_context.h      | 23 ++++++++++++++++++++++-
 arch/s390/include/asm/mm-arch-hooks.h       | 15 +++++++++++++++
 arch/score/include/asm/mm-arch-hooks.h      | 15 +++++++++++++++
 arch/sh/include/asm/mm-arch-hooks.h         | 15 +++++++++++++++
 arch/sparc/include/asm/mm-arch-hooks.h      | 15 +++++++++++++++
 arch/tile/include/asm/mm-arch-hooks.h       | 15 +++++++++++++++
 arch/um/include/asm/mm-arch-hooks.h         | 15 +++++++++++++++
 arch/unicore32/include/asm/mm-arch-hooks.h  | 15 +++++++++++++++
 arch/x86/include/asm/mm-arch-hooks.h        | 15 +++++++++++++++
 arch/xtensa/include/asm/mm-arch-hooks.h     | 15 +++++++++++++++
 include/linux/mm-arch-hooks.h               | 25 +++++++++++++++++++++++++
 mm/mremap.c                                 | 17 +++++++++++------
 33 files changed, 521 insertions(+), 7 deletions(-)
 create mode 100644 arch/alpha/include/asm/mm-arch-hooks.h
 create mode 100644 arch/arc/include/asm/mm-arch-hooks.h
 create mode 100644 arch/arm/include/asm/mm-arch-hooks.h
 create mode 100644 arch/arm64/include/asm/mm-arch-hooks.h
 create mode 100644 arch/avr32/include/asm/mm-arch-hooks.h
 create mode 100644 arch/blackfin/include/asm/mm-arch-hooks.h
 create mode 100644 arch/c6x/include/asm/mm-arch-hooks.h
 create mode 100644 arch/cris/include/asm/mm-arch-hooks.h
 create mode 100644 arch/frv/include/asm/mm-arch-hooks.h
 create mode 100644 arch/hexagon/include/asm/mm-arch-hooks.h
 create mode 100644 arch/ia64/include/asm/mm-arch-hooks.h
 create mode 100644 arch/m32r/include/asm/mm-arch-hooks.h
 create mode 100644 arch/m68k/include/asm/mm-arch-hooks.h
 create mode 100644 arch/metag/include/asm/mm-arch-hooks.h
 create mode 100644 arch/microblaze/include/asm/mm-arch-hooks.h
 create mode 100644 arch/mips/include/asm/mm-arch-hooks.h
 create mode 100644 arch/mn10300/include/asm/mm-arch-hooks.h
 create mode 100644 arch/nios2/include/asm/mm-arch-hooks.h
 create mode 100644 arch/openrisc/include/asm/mm-arch-hooks.h
 create mode 100644 arch/parisc/include/asm/mm-arch-hooks.h
 create mode 100644 arch/powerpc/include/asm/mm-arch-hooks.h
 create mode 100644 arch/s390/include/asm/mm-arch-hooks.h
 create mode 100644 arch/score/include/asm/mm-arch-hooks.h
 create mode 100644 arch/sh/include/asm/mm-arch-hooks.h
 create mode 100644 arch/sparc/include/asm/mm-arch-hooks.h
 create mode 100644 arch/tile/include/asm/mm-arch-hooks.h
 create mode 100644 arch/um/include/asm/mm-arch-hooks.h
 create mode 100644 arch/unicore32/include/asm/mm-arch-hooks.h
 create mode 100644 arch/x86/include/asm/mm-arch-hooks.h
 create mode 100644 arch/xtensa/include/asm/mm-arch-hooks.h
 create mode 100644 include/linux/mm-arch-hooks.h
diff mbox

Patch

diff --git a/mm/mremap.c b/mm/mremap.c
index 2dc44b1cb1df..009db5565893 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,13 +287,19 @@  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) {
-		err = vma->vm_file->f_op->mremap(vma->vm_file, new_vma);
-		if (err < 0) {
-			move_page_tables(new_vma, new_addr, vma, old_addr,
-					 moved_len, true);
-			return err;
+	} else {
+		if (vma->vm_file && vma->vm_file->f_op->mremap) {
+			err = vma->vm_file->f_op->mremap(vma->vm_file, new_vma);
+			if (err < 0) {
+				move_page_tables(new_vma, new_addr, vma,
+						  old_addr, moved_len, true);
+				return err;
+			}
 		}
+#ifdef __HAVE_ARCH_REMAP
+		arch_remap(mm, old_addr, old_addr+old_len,
+			   new_addr, new_addr+new_len);
+#endif
 	}
 
 	/* Conceal VM_ACCOUNT so old reservation is not undone */