Received: by 10.223.176.5 with SMTP id f5csp180917wra; Tue, 30 Jan 2018 09:50:09 -0800 (PST) X-Google-Smtp-Source: AH8x225oJ9WNomSyTYeY8JgRedxrr8DdHpVvVjB6pZtBPglz87LToOclSkFUiD3vUoIR5aIZ8OHh X-Received: by 10.98.79.12 with SMTP id d12mr31404619pfb.186.1517334609401; Tue, 30 Jan 2018 09:50:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517334609; cv=none; d=google.com; s=arc-20160816; b=Ag2CEfNv9Fz3VFkeBEFGnRdYU7oeBp9LE2oF4uc+i7iYIl7mVpvaSGeDAFvyS45G9N FGHMutxp9xNmsLlqBEMQueciJu8kHR6rGAVzb4+pZFUKloDn8uZ8S3pEpt4graVVI0+N Ov6N8m+TJkznUZt7Vh/AEco1Y2zZ4Jw+fdyo04+5dVDV8sb1Gv2SzOOvYuP3fBIBXLYb 5DJR2o4fle+mWcjtJOnCtNI8CalyTjETwPAL3Lbd2BjtnfvrCTI6gpVwXRRjnv24hwvn 2uRbc3HCnpe8c1bTV4UmG5E6MYKMJziJmJYUe475mWah1eC/R09arbA+7RDeuIBNmbY7 Njjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=7/XrsFjLbzZnGlzIz0cfIufucy8Gd2eYlQlSi3doFFM=; b=xstz4omSEL3ivQKymsTxoNN4RGxHkWjOTbbUmJZRfZ7H8h20EiQ2HYDsBLHKT2TvOB 7p9piqCHcs2kysR6n2LX8rwBOZuM5bS116petxBynbynBw9a/xm/Aiummko5m1zcx3vV bdRzxTZBzg+jVIBqg8Ob2NlugGPBr5Y546Cl67v2TXg2cc90axB6uHfJ+yih2yauBUlx jatD677JTqsb1S2L/BQUmQQyXOQVtXy7wTk1eKqgaQs7X1MBfMPKb8DLSDvnvtOtNb5Y TAwpWwW2r3xycOgLxUkReSwUygrUP8fqFpXRroaQT/kZvpQqGBhWc11er4pq5P6b0gTS ituw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v22si2932382pfd.22.2018.01.30.09.49.54; Tue, 30 Jan 2018 09:50:09 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753327AbeA3QKa (ORCPT + 99 others); Tue, 30 Jan 2018 11:10:30 -0500 Received: from mx2.suse.de ([195.135.220.15]:56448 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752147AbeA3QK3 (ORCPT ); Tue, 30 Jan 2018 11:10:29 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 8935BAE83; Tue, 30 Jan 2018 16:10:27 +0000 (UTC) Date: Tue, 30 Jan 2018 17:10:25 +0100 From: Michal Hocko To: Zi Yan Cc: Zi Yan , Andrew Morton , "Kirill A . Shutemov" , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH] Lock mmap_sem when calling migrate_pages() in do_move_pages_to_node() Message-ID: <20180130161025.GH21609@dhcp22.suse.cz> References: <20180130030011.4310-1-zi.yan@sent.com> <20180130081415.GO21609@dhcp22.suse.cz> <5A7094DA.4000804@cs.rutgers.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5A7094DA.4000804@cs.rutgers.edu> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue 30-01-18 10:52:58, Zi Yan wrote: > > > Michal Hocko wrote: > > On Mon 29-01-18 22:00:11, Zi Yan wrote: > >> From: Zi Yan > >> > >> migrate_pages() requires at least down_read(mmap_sem) to protect > >> related page tables and VMAs from changing. Let's do it in > >> 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(). > > > > This doesn't make much sense to me, to be honest. We are holding > > mmap_sem for _read_ so we allow parallel updates like page faults > > or unmaps. Therefore we are isolating pages prior to the migration. > > > > The sole purpose of the mmap_sem in add_page_for_migration is to protect > > from vma going away _while_ need it to get the proper page. > > Then, I am wondering why we are holding mmap_sem when calling > migrate_pages() in existing code. > http://elixir.free-electrons.com/linux/latest/source/mm/migrate.c#L1576 You mean in the original code? I strongly suspect this was to not take it for each page. -- Michal Hocko SUSE Labs