Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp392387imu; Wed, 12 Dec 2018 19:37:04 -0800 (PST) X-Google-Smtp-Source: AFSGD/XLsrpFq8QFCFejsRc3y8dt/10H8GHxifo6RuPVXgMjwoE4L2JBw/0qvzLVvtYIbfGSXgH9 X-Received: by 2002:a62:1c7:: with SMTP id 190mr22681305pfb.46.1544672224380; Wed, 12 Dec 2018 19:37:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544672224; cv=none; d=google.com; s=arc-20160816; b=PYM5/85DddMv/Yh8RphTDgHkvH2h94Fz0NpYKcA1x373iwDtylocUEkPr62u2RuZay CO9+/IbYOO3CEd7wTd3Y/hWxeOinCopJ02YHFSFoMUxrndCULmJVqzSLnJPXTNAnZrjn 7BddLs/0f2Y+04jiL4L2qZ3mGv5ziBUJzv0fOrBjsglzHaxNex7+7ysTUI9o3gZp+6n/ I1DVVDS9e6B3v168hwwOPFZI0mw6fIoS6iUdY8ZIdKHH08kqaKk1BX+4e3cDcqRValBD RAT3/9rO9iPlP/Ysdd4jSojQV5uJO1yHmPLZa/IYxQvXTKnZ7lkg3SAg87gnGNDzlLSc Fduw== 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:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=ATxVsXmKOc9ecKzsrlaylUCb933sEk3JnZMUUraQ50k=; b=0UzDuoWdOEg6jxBHb/zBzFMi88/+aEEZiAOQcTjZ/JScyexeWOkR0jMBoxYrIEzWlk upmwLkWcvw/UKihIHsHDfFYXOy14i+9483ybOdlqmiQYTwnMC4fi0F9/rpgrDqbB83qD NMg+IpvopEMLLo29axskEg1pBnOhl8/+/sWJn3rIIH+Hqri+rmVgypT2GjeyBhaeEO0O mX4p2syGb5LuWQ/AvRlV9YM6V9II35Ir+o5Dh5zH15yyuXovKPuXXhiukDy8ZDB2D6Fh qLJlPdNmCn8sSYDoxg6DjADuYKAtthVz8Lfw0YkK6zrHfUvQyQqMEMGU/R9Re2FIbOHn 36rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="LgLOf/JO"; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c4si542471pfi.110.2018.12.12.19.36.49; Wed, 12 Dec 2018 19:37:04 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b="LgLOf/JO"; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726729AbeLMDf6 (ORCPT + 99 others); Wed, 12 Dec 2018 22:35:58 -0500 Received: from mail-ed1-f67.google.com ([209.85.208.67]:39839 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726298AbeLMDf5 (ORCPT ); Wed, 12 Dec 2018 22:35:57 -0500 Received: by mail-ed1-f67.google.com with SMTP id b14so823573edt.6 for ; Wed, 12 Dec 2018 19:35:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:reply-to:references:mime-version :content-disposition:in-reply-to:user-agent; bh=ATxVsXmKOc9ecKzsrlaylUCb933sEk3JnZMUUraQ50k=; b=LgLOf/JOFWCT6W9JlbUY1nFwUCQBbhndulfw2//NiRfh27wRul4HS6L5tlgJWVX/qR vm6DqQdv0YxOcJxXC3PRh4VaEixJWjYgRvL/HXG7N+TSI+4CJOl8MfFEQbEFJ2GGsYCl OTg9lybUo6MHX4GU5c/IrQIGN0Rr9CIeP6hYpdSyH5E4DS315eDNmiGnv+iyndiyzR3u o7UBN6+VRT9zkIFWWS+Q8mr+jW4VTYVc5P0XEM0lEll6kJmVdWJs1+CiRPjs0j5L+djN Ts0TmUfUCJw1oMec3ezvgnlVr0wYaeEzS97rQt0fyRmTs36npq/KvRra3TH23aropNS0 oltA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:reply-to :references:mime-version:content-disposition:in-reply-to:user-agent; bh=ATxVsXmKOc9ecKzsrlaylUCb933sEk3JnZMUUraQ50k=; b=EXuaQgEDAQ0g2JpmCw8f4DYcjpSlgUcBQPdEnwLcWOmkXZHim35BSfU/AQOOvQsNw+ XUCsQ6HeU9VdFeI1bK3xSFdUgf7wjxgomsnWMwSiOJUf3C2dPwjIqXWS0cpHFxTHlsrO UJQa+eb6lSa+kZowAoHwIsaejIB0XhlcOBtH8d3nxFXA8CV2WLKX29H77fjzGuot8PuF SBDunad7b23LDqolE2QZGGXhFHzDhXQXbMf6jk95ifaA6k+RptPPxauRIjjv2dbkW/nc WElOpuYQRQj7bD+Qlw78qAeR8JHOz+C1ap5So79AcPnPFbFM8EF5i9WV/EMO+KWI3eaQ IDCw== X-Gm-Message-State: AA+aEWYi4e285bJaFMDNlp4YZCUxqQpNmbwhjUrRLe8Alc4EL51xnmIk Ox+9f8OsfdjyxjbaCvT5wvU= X-Received: by 2002:a50:b1db:: with SMTP id n27mr21585285edd.65.1544672155774; Wed, 12 Dec 2018 19:35:55 -0800 (PST) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id gp22-v6sm144899ejb.4.2018.12.12.19.35.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 12 Dec 2018 19:35:55 -0800 (PST) Date: Thu, 13 Dec 2018 03:35:54 +0000 From: Wei Yang To: Oscar Salvador Cc: akpm@linux-foundation.org, mhocko@suse.com, david@redhat.com, pasha.tatashin@soleen.com, dan.j.williams@gmail.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v2] mm, memory_hotplug: Don't bail out in do_migrate_range prematurely Message-ID: <20181213033554.7qbaakvedccqmfq5@master> Reply-To: Wei Yang References: <20181211135312.27034-1-osalvador@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181211135312.27034-1-osalvador@suse.de> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 11, 2018 at 02:53:12PM +0100, Oscar Salvador wrote: >v1 -> v2: > - Keep branch to decrease refcount and print out > the failed pfn/page > - Modified changelog per Michal's feedback > - move put_page() out of the if/else branch > >--- >>From f81da873be9a5b7845249d1e62a423f054c487d5 Mon Sep 17 00:00:00 2001 >From: Oscar Salvador >Date: Tue, 11 Dec 2018 11:45:19 +0100 >Subject: [PATCH] mm, memory_hotplug: Don't bail out in do_migrate_range > prematurely > >do_migrate_ranges() takes a memory range and tries to isolate the >pages to put them into a list. >This list will be later on used in migrate_pages() to know >the pages we need to migrate. > >Currently, if we fail to isolate a single page, we put all already >isolated pages back to their LRU and we bail out from the function. >This is quite suboptimal, as this will force us to start over again >because scan_movable_pages will give us the same range. >If there is no chance that we can isolate that page, we will loop here >forever. > >Issue debugged in [1] has proved that. >During the debugging of that issue, it was noticed that if >do_migrate_ranges() fails to isolate a single page, we will >just discard the work we have done so far and bail out, which means >that scan_movable_pages() will find again the same set of pages. > >Instead, we can just skip the error, keep isolating as much pages >as possible and then proceed with the call to migrate_pages(). > >This will allow us to do as much work as possible at once. > >[1] https://lkml.org/lkml/2018/12/6/324 > >Signed-off-by: Oscar Salvador >--- > mm/memory_hotplug.c | 18 ++---------------- > 1 file changed, 2 insertions(+), 16 deletions(-) > >diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c >index 86ab673fc4e3..68e740b1768e 100644 >--- a/mm/memory_hotplug.c >+++ b/mm/memory_hotplug.c >@@ -1339,7 +1339,6 @@ do_migrate_range(unsigned long start_pfn, unsigned long end_pfn) > unsigned long pfn; > struct page *page; > int move_pages = NR_OFFLINE_AT_ONCE_PAGES; >- int not_managed = 0; > int ret = 0; > LIST_HEAD(source); > >@@ -1388,7 +1387,6 @@ do_migrate_range(unsigned long start_pfn, unsigned long end_pfn) > else > ret = isolate_movable_page(page, ISOLATE_UNEVICTABLE); > if (!ret) { /* Success */ >- put_page(page); > list_add_tail(&page->lru, &source); > move_pages--; > if (!__PageMovable(page)) >@@ -1398,22 +1396,10 @@ do_migrate_range(unsigned long start_pfn, unsigned long end_pfn) > } else { > pr_warn("failed to isolate pfn %lx\n", pfn); > dump_page(page, "isolation failed"); >- put_page(page); >- /* Because we don't have big zone->lock. we should >- check this again here. */ >- if (page_count(page)) { >- not_managed++; >- ret = -EBUSY; >- break; >- } > } >+ put_page(page); > } > if (!list_empty(&source)) { >- if (not_managed) { >- putback_movable_pages(&source); >- goto out; >- } >- > /* Allocate a new page from the nearest neighbor node */ > ret = migrate_pages(&source, new_node_page, NULL, 0, > MIGRATE_SYNC, MR_MEMORY_HOTPLUG); >@@ -1426,7 +1412,7 @@ do_migrate_range(unsigned long start_pfn, unsigned long end_pfn) > putback_movable_pages(&source); I may not get a full understanding, while I am wondering whether we can remote this putback_movable_pages()? > } > } >-out: >+ > return ret; > } > >-- >2.13.7 -- Wei Yang Help you, Help me