Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1973416ybe; Tue, 3 Sep 2019 06:19:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqyVUrumZYvVlmal69wYBRmHw+ixIOO3FY5DwyXhvqxbD6yyjwOk0LiMDeYzSxY21VPoBdSZ X-Received: by 2002:a17:90a:bd08:: with SMTP id y8mr19251599pjr.89.1567516741898; Tue, 03 Sep 2019 06:19:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567516741; cv=none; d=google.com; s=arc-20160816; b=EiKRBGV5fAb5l03+2h4si5qzXS7HgRp5oiA9XVdfHtWvVMk4Y8kzfBTU1HxIt8YVkP Yn6GdbrjX5YbOivjPGpNBFZPmPmz3wWrBMmGo0gcO8nyxgK15QDRUvN+CrRG6Gyv1O31 MGJv5v7j75WcLtRG3ikiXi6bKDAHpxIGqZZsqmF9M71JiPlKgc1NjnhoSI/vm27dqiq/ UGv7KfmdHb2Jtyrlf1Utll6UKLcEtLMwf3ES0vZOsHs6DFhtCQ6uuqIXlq/xruwtQ52U CN+JhnAkgzSIX9MtuJ8TSkq7zaJ/I7nioKXUKThMUVoKbxXIBL+/awlxeH3lmQjnmC3r vpgg== 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; bh=itNCg/c5TXOzioS2vPBMpQxD0tUDL6RIxfWYZJ2zsMY=; b=hn2+QNHajp0ydRHo/D0e7YwJI2gWSD+Pca+qaPJJbc8GOl0rOHuQ4o0y1yPBLo+ULf +oBOxaumKa3S7uazOsHZQAWvhejr4dC+lFynsPnU0vHFnLiNzrdvqEr4yVfWSjcmNsk8 pmscjegbdYs16ReImE+PSj0rEUKuvwm0lmv0W9OVGjSO4vwbYpiv/BMO8t0vXUshAcYS RZ7Re56+C686TXS5YEZJ0k58h9cDWywSRaIngUKsK85/rV41Igu2j8c4PauIiw0yAwj0 uzA+x89wwYrbrwDDda2q0V3CQbzIUtwVhow6evMlV+jmYhl6HXPmEgIkeRXvbVkYgga9 xH8A== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j15si134272pfd.164.2019.09.03.06.18.46; Tue, 03 Sep 2019 06:19:01 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729343AbfICNRj (ORCPT + 99 others); Tue, 3 Sep 2019 09:17:39 -0400 Received: from mx2.suse.de ([195.135.220.15]:58200 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727005AbfICNRj (ORCPT ); Tue, 3 Sep 2019 09:17:39 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 252E0B116; Tue, 3 Sep 2019 13:17:38 +0000 (UTC) Date: Tue, 3 Sep 2019 15:17:37 +0200 From: Michal Hocko To: sunqiuyang Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH 1/1] mm/migrate: fix list corruption in migration of non-LRU movable pages Message-ID: <20190903131737.GB18939@dhcp22.suse.cz> References: <20190903082746.20736-1-sunqiuyang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190903082746.20736-1-sunqiuyang@huawei.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue 03-09-19 16:27:46, sunqiuyang wrote: > From: Qiuyang Sun > > Currently, after a page is migrated, it > 1) has its PG_isolated flag cleared in move_to_new_page(), and > 2) is deleted from its LRU list (cc->migratepages) in unmap_and_move(). > However, between steps 1) and 2), the page could be isolated by another > thread in isolate_movable_page(), and added to another LRU list, leading > to list_del corruption later. Care to explain the race? Both paths use page_lock AFAICS > > This patch fixes the bug by moving list_del into the critical section > protected by lock_page(), so that a page will not be isolated again before > it has been deleted from its LRU list. > > Signed-off-by: Qiuyang Sun > --- > mm/migrate.c | 11 +++-------- > 1 file changed, 3 insertions(+), 8 deletions(-) > > diff --git a/mm/migrate.c b/mm/migrate.c > index a42858d..c58a606 100644 > --- a/mm/migrate.c > +++ b/mm/migrate.c > @@ -1124,6 +1124,8 @@ static int __unmap_and_move(struct page *page, struct page *newpage, > /* Drop an anon_vma reference if we took one */ > if (anon_vma) > put_anon_vma(anon_vma); > + if (rc != -EAGAIN) > + list_del(&page->lru); > unlock_page(page); > out: > /* > @@ -1190,6 +1192,7 @@ static ICE_noinline int unmap_and_move(new_page_t get_new_page, > put_new_page(newpage, private); > else > put_page(newpage); > + list_del(&page->lru); > goto out; > } > > @@ -1200,14 +1203,6 @@ static ICE_noinline int unmap_and_move(new_page_t get_new_page, > out: > if (rc != -EAGAIN) { > /* > - * A page that has been migrated has all references > - * removed and will be freed. A page that has not been > - * migrated will have kepts its references and be > - * restored. > - */ > - list_del(&page->lru); > - > - /* > * Compaction can migrate also non-LRU pages which are > * not accounted to NR_ISOLATED_*. They can be recognized > * as __PageMovable > -- > 1.8.3.1 -- Michal Hocko SUSE Labs