Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1405088imu; Tue, 11 Dec 2018 19:36:42 -0800 (PST) X-Google-Smtp-Source: AFSGD/XBzPLwxohD5CzkayVV8eTwxy59fn83mLJtqeSbU7qcROwCGgz0S4x94ToVoZtySqugfo9l X-Received: by 2002:a63:4706:: with SMTP id u6mr16017971pga.95.1544585802753; Tue, 11 Dec 2018 19:36:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544585802; cv=none; d=google.com; s=arc-20160816; b=gDmlC4x6G7LE144+e+tqw8JXwvwwBSZ5j7SKc6SiV/0Z1sdf1Byh0FppiqPR4cF+xi 451IKLEDB7WlnkKms0hscbnFaAPcrmsoK44OCj9AV5Mi1+ICRVGRDSY0xg1eyAkRrRRn b2f9W1h8g0wwr/AuobG34zhBtXhTF4ERtvPnuZBXFxrVsM29XZGqATiiypPDIpCuJBlC asHTUGHMlmeA5ahHFrKEyGwZaDQ7t4ZOdwWZyl3RmZs5dAaubaxtaGjo2fSV8n5HXcIb uAv8wxgGG9fXqcaArtx9jCMc/Yb3ASabVhHWOvOYkP5Lxg0UlXq3aOgTDCqWoz2c/Dnp paUA== 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=6boLxkCk1IUbRHwGnVlHMUbKszobMYWeXJ40Akpp/hY=; b=oUbMpomj1dgkpq0b9KuS5T5WhkE9Mudm7QDiQljQrsgSHVYNaeqsrkV76U7lbQfR1t Jt1/irq6gu1veG2Xn0At6Ev+gdVvWHXj2Axgs7857csgSHG0MXf4MJpk/3nyeGXRomsH 7XxFvD2UIrMWs2gVpPqvL4zk5gV41riD8Th2ShZv5nXf/CC08kF2XH5sa7aBe1QL87K+ IILC5N8f1DE311qgCekCFjvbaWqATczE7ONYtMQMkMsptT6DJ9M6pvjZC+zpN9vvUiw0 WU56IUb2mk7+CrObAeJih+efdEwpz2JIHwR8N57zX/NMCyx50Lry+B72EeC4gvnY/MK4 +Byg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=BPP8oa2x; 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 p22si13289769pgl.340.2018.12.11.19.36.07; Tue, 11 Dec 2018 19:36:42 -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=BPP8oa2x; 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 S1726251AbeLLDfK (ORCPT + 99 others); Tue, 11 Dec 2018 22:35:10 -0500 Received: from mail-ed1-f65.google.com ([209.85.208.65]:39813 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726218AbeLLDfK (ORCPT ); Tue, 11 Dec 2018 22:35:10 -0500 Received: by mail-ed1-f65.google.com with SMTP id b14so14334921edt.6 for ; Tue, 11 Dec 2018 19:35:08 -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=6boLxkCk1IUbRHwGnVlHMUbKszobMYWeXJ40Akpp/hY=; b=BPP8oa2x8eEjY+ZEuN67NQrObn36fJVrVUX3d1AzkKPc7BqtyYxL1vuPLUZujEhMqN EHK6lBASaV4szqsP/fTm4wwmvD0dcVcMsM2zZZhbJdqzH53/6FAhhYzWsG/Jan4VtnKt OPbBNThIyuDogcU4G0nQvIeTY1p9h8pBhmFyr5XSMZehFKXN0udjuTotssr484j8WoYA +Y1pIBoYMmbuVP+FmvnmwsAfnORfsxK0oWf6m6bfxTHGnOdwIbQJfpgr1+Yw9A6E4VsL 3msw8Ye1G6TdMlnb+EJ1hl/z7wB/XZQqi7OXmqQXHgomSqhVD8rQ5FhAdbUwRRnYs0Lh UtcA== 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=6boLxkCk1IUbRHwGnVlHMUbKszobMYWeXJ40Akpp/hY=; b=Vm3xKpb9bNcmszObuyh4fo9wgv3grrgAOtwj5FjxieV51ENSnuyNbikFw+b/KVbK/5 YGxJKmKDct4ajoPWTWGyNHsTa04YauZHf5Nw7cFT3XyeS5n67/h0zFnu6YYIsmKqHdvI Pj0Ed7AuJ0PTnh4G0AQjbVpvjkb/BST/m6QLJj8js3xKCi+j7prOM7HK8p5aQT3bPM2U AGWS8YU3reyC8mIQIV7NTUTggdJ4XY/dNCdhmMVBeAe51KPIASh2jX8Q+et+xMBqzz25 9twjAD7FWS1HEzX+qoOCbjrTbneA/PjUU4jknUlU2CXjgT8wZU1IKnZB7bq0kJYKFZwJ EiJg== X-Gm-Message-State: AA+aEWY8AXtGitJkqrkf39E7Ikq7HT+v+61vS5yar4Jk7dg0CmkWJgtQ 23hZWnn7zbTBnAB/YF397nI= X-Received: by 2002:a17:906:22ca:: with SMTP id q10-v6mr14091155eja.66.1544585708197; Tue, 11 Dec 2018 19:35:08 -0800 (PST) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id c53sm4654017ede.26.2018.12.11.19.35.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 11 Dec 2018 19:35:07 -0800 (PST) Date: Wed, 12 Dec 2018 03:35:06 +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: <20181212033506.tyj747b7kzyvsp4c@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"); I see the above code is wrapped with CONFIG_DEBUG_VM on current Linus tree. This is removed by someone else? >- 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); > } > } >-out: >+ > return ret; > } > >-- >2.13.7 -- Wei Yang Help you, Help me