lkml.org 
[lkml]   [2018]   [Jan]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] Lock mmap_sem when calling migrate_pages() in do_move_pages_to_node()


Hugh Dickins wrote:
> On Mon, 29 Jan 2018, Zi Yan wrote:
>> From: Zi Yan <zi.yan@cs.rutgers.edu>
>>
>> migrate_pages() requires at least down_read(mmap_sem) to protect
>> related page tables and VMAs from changing. Let's do it in
>
> Page tables are protected by their locks. VMAs may change while
> migration is active on them, but does that need locking against?
>
>> do_page_moves() for both do_move_pages_to_node() and
>> add_page_for_migration().
>>
>> Also add this lock requirement in the comment of migrate_pages().
>>
>> Signed-off-by: Zi Yan <zi.yan@cs.rutgers.edu>
>> ---
>> mm/migrate.c | 13 +++++++++++--
>> 1 file changed, 11 insertions(+), 2 deletions(-)
>>
>> diff --git a/mm/migrate.c b/mm/migrate.c
>> index 5d0dc7b85f90..52d029953c32 100644
>> --- a/mm/migrate.c
>> +++ b/mm/migrate.c
>> @@ -1354,6 +1354,9 @@ static int unmap_and_move_huge_page(new_page_t get_new_page,
>> * or free list only if ret != 0.
>> *
>> * Returns the number of pages that were not migrated, or an error code.
>> + *
>> + * The caller must hold at least down_read(mmap_sem) for to-be-migrated pages
>> + * to protect related page tables and VMAs from changing.
>
> I have not been keeping up with Michal's recent migration changes,
> but migrate_pages() never used to need mmap_sem held (despite being
> called with an mmap_sem held from some of its callsites), and it
> would be a backward step to require that now.
>
> There is not even an mm argument to migrate_pages(), so which
> mm->mmap_sem do you think would be required for it? There may be
> particular cases in which it is required (when the new_page function
> involves the old_page's vma - is that so below?), but in general not.

mmap_sem is held during migrate_pages() in current implementation.
http://elixir.free-electrons.com/linux/latest/source/mm/migrate.c#L1576


--
Best Regards,
Yan Zi

[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2018-01-30 16:57    [W:0.065 / U:0.856 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site