Received: by 10.223.176.5 with SMTP id f5csp3589410wra; Mon, 29 Jan 2018 15:49:15 -0800 (PST) X-Google-Smtp-Source: AH8x227QVyycd1bwK3vxG4um9BUAjlF6HtSZ4AKvAd+UNA2eD0OLrZC3szll1YqUwlhypHVjJabM X-Received: by 2002:a17:902:b410:: with SMTP id x16-v6mr2808107plr.157.1517269755283; Mon, 29 Jan 2018 15:49:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517269755; cv=none; d=google.com; s=arc-20160816; b=hoV/pGXmJg/bWW/VkYyW2qFV/O37lhUBA89DLVqLKn7RYRjlnNUYYuFhNad8oqEkOV MT1KB4MrCCB574Lh1wfw0nIT8+mcs8H0+lWIkoNeFMIUtfO7QzBzh2W3VG6KBEN5fJwY Z9BLFYeUJ4td0eHsHNpTfoAkA7JhSiQliWRrugVZNCMBOFG7+2isqhgFrpvkGsEmBxhC 2Jy8uIWAIELZZTBVhJFGjG3PMhK1XiX9Vz/n+w+ZKZUcUTn9KZV6VDdrmiR5HFnUzasS zXg3ql2aR2nQxYs/8TBKuqQUA1TsSfqR5B0D6V3cBz3IZllXalszatoqvjTPFqiiodgn pSWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :arc-authentication-results; bh=+9tCiX44VylM90lwIIAy7W6M/dYrKFU0wb4gYs3/4KI=; b=bI3xmCG5pkssIViAi+dICu9wgHVeoKRmKDTtHS/nSNCPNC55/kYL81lX4LHj2R+Kf2 V0VKcEaaFdp3OXvDb8hDJalRv+Am1lxnxAIn9gIcNTJ7zw72o/m+20USUS58k9jFsLGt n7+j0ZfzAbUEWn1tEWmHu1D8HafdbtFpJ2fxtZ/X4M1D8VwhQV5SLtWkgfnUpem4CWI8 VaJ25TsuIkjlGavXM7RbDV5gh/SBvMhs1WLFFLCyCif+ZI/Xg+PTvxpoq3EBAfxkaQl6 tPwK5UourtAlFvEp5/cptXEJa/SPZdGH33qqWEyEvkf9W/MwyzQg1sONAPkV9v+2dm1w u6nA== 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 s82si12803604pfg.317.2018.01.29.15.49.00; Mon, 29 Jan 2018 15:49:15 -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 S1751749AbeA2XsF (ORCPT + 99 others); Mon, 29 Jan 2018 18:48:05 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:53156 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751273AbeA2XsE (ORCPT ); Mon, 29 Jan 2018 18:48:04 -0500 Received: from akpm3.svl.corp.google.com (unknown [104.133.9.92]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 642EBFB6; Mon, 29 Jan 2018 23:48:03 +0000 (UTC) Date: Mon, 29 Jan 2018 15:48:02 -0800 From: Andrew Morton To: "Zi Yan" Cc: "Michal Hocko" , "Naoya Horiguchi" , "Kirill A. Shutemov" , "Vlastimil Babka" , "Andrea Reale" , "Anshuman Khandual" , linux-mm@kvack.org, LKML , "Michal Hocko" Subject: Re: [PATCH 1/3] mm, numa: rework do_pages_move Message-Id: <20180129154802.594025d081789b6620f001bd@linux-foundation.org> In-Reply-To: <07425013-A7A9-4BB8-8FAA-9581D966A29B@cs.rutgers.edu> References: <20180103082555.14592-1-mhocko@kernel.org> <20180103082555.14592-2-mhocko@kernel.org> <8ECFD324-D8A0-47DC-A6FD-B9F7D29445DC@cs.rutgers.edu> <20180129143522.68a5332ae80d28461441a6be@linux-foundation.org> <07425013-A7A9-4BB8-8FAA-9581D966A29B@cs.rutgers.edu> X-Mailer: Sylpheed 3.4.1 (GTK+ 2.24.23; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 29 Jan 2018 18:39:01 -0500 "Zi Yan" wrote: > On 29 Jan 2018, at 17:35, Andrew Morton wrote: > > > On Mon, 29 Jan 2018 17:06:14 -0500 "Zi Yan" wrote: > > > >> I discover that this patch does not hold mmap_sem while migrating pages in > >> do_move_pages_to_node(). > >> > >> A simple fix below moves mmap_sem from add_page_for_migration() > >> to the outmost do_pages_move(): > > > > I'm not surprised. Why does do_move_pages_to_node() need mmap_sem > > and how is a reader to discover that fact??? > > do_move_pages_to_node() calls migrate_pages(), which requires down_read(&mmap_sem). > > In the outmost do_pages_move(), both add_page_for_migration() and > do_move_pages_to_node() inside it need to hold read lock of mmap_sem. > > Do we need to add comments for both functions? Just for migrate_pages(), I guess. Let's include a description of *why* mmap_sem is needed. What it is protecting.