Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp674173imu; Tue, 11 Dec 2018 05:54:33 -0800 (PST) X-Google-Smtp-Source: AFSGD/WXu1eIWnn/yYYB725zd7fOFdOWa4oS/suKvlQaFZQpi6lRkawJSS4jLNFRXKeYukJ8t8b8 X-Received: by 2002:a63:5a57:: with SMTP id k23mr14587368pgm.5.1544536473384; Tue, 11 Dec 2018 05:54:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544536473; cv=none; d=google.com; s=arc-20160816; b=XQGzVkG2/ZG2CaFF4bbRcEmLgeVYzAqaFYAchg7gXmF5G4mhYbUrJ95xgac62oMT2j se3S4nLtk8h9H231wXoHfjo0zPnYpkHXCOzBGmHUipuvU2jO5yCwNEzBmae/EbUQJYny QeJmdGXM98ebq42bbp03/CG3OumOQhNZGN62uPZspf2Bg3K3p7nGHCgOqeFcdZLsjbr2 zpRdBt7BENpAvqhcmxCiDZNCTi/5Fjdx2ZKxlPExg5qOJSZAeOg/nNevlRpGM1fURFE3 R7LbYxKu5UqxIbzPETNuZMHxTevPT8JBgZNGxhVdD56fAZPmzIojBv4zcF8pQKvO66v9 bxtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=CqbXK53yndyQThWULsBEgjVfSZN9kixDN/r6ofVr2gI=; b=vD6Jatk39Wyhp4jk47zWRj6CenQvzuM8Fkg7nxCe20Oz83pWiZeCk2ao5SpU+YTbcU naIlMkA+lusF74SOvjf98wLfDTtEDhI8Od1suKo6QCU+cFrvl/UjArZHfwnXepAJd4NN k3Bt607EvdpEU9F7AAh62pUkklxoKhlYY+4Fw8AcnfQMyRpQVtJScna5WeYP+CzWa4yw wptC8pruYYPy3cmVYFz+CYJX+Ys9jVtxZp/Z0mgDzNPpw3EZglUbDA7kjPLecw5zveff eheegvwoS0seP2GgPTKjTdu0R8HflLjvA//YuPotwJZ46K7tdUz+t9cAKP24IzJIZCLZ sf6Q== 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 w32si9117126pga.337.2018.12.11.05.54.17; Tue, 11 Dec 2018 05:54:33 -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 S1726623AbeLKNx1 (ORCPT + 99 others); Tue, 11 Dec 2018 08:53:27 -0500 Received: from smtp.nue.novell.com ([195.135.221.5]:58188 "EHLO smtp.nue.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726286AbeLKNx0 (ORCPT ); Tue, 11 Dec 2018 08:53:26 -0500 Received: from emea4-mta.ukb.novell.com ([10.120.13.87]) by smtp.nue.novell.com with ESMTP (TLS encrypted); Tue, 11 Dec 2018 14:53:24 +0100 Received: from d104.suse.de (nwb-a10-snat.microfocus.com [10.120.13.202]) by emea4-mta.ukb.novell.com with ESMTP (NOT encrypted); Tue, 11 Dec 2018 13:53:20 +0000 From: Oscar Salvador To: akpm@linux-foundation.org Cc: mhocko@suse.com, david@redhat.com, pasha.tatashin@soleen.com, dan.j.williams@gmail.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Oscar Salvador Subject: [PATCH v2] mm, memory_hotplug: Don't bail out in do_migrate_range prematurely Date: Tue, 11 Dec 2018 14:53:12 +0100 Message-Id: <20181211135312.27034-1-osalvador@suse.de> X-Mailer: git-send-email 2.13.7 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); } } -out: + return ret; } -- 2.13.7