From patchwork Tue Dec 11 13:53:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 10723849 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0744615A6 for ; Tue, 11 Dec 2018 13:53:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E76E22AE42 for ; Tue, 11 Dec 2018 13:53:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D779E2AE4B; Tue, 11 Dec 2018 13:53:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BC9AC2AE42 for ; Tue, 11 Dec 2018 13:53:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BAD018E008D; Tue, 11 Dec 2018 08:53:25 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B5AAE8E004D; Tue, 11 Dec 2018 08:53:25 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A4A4D8E008D; Tue, 11 Dec 2018 08:53:25 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by kanga.kvack.org (Postfix) with ESMTP id 4CD6B8E004D for ; Tue, 11 Dec 2018 08:53:25 -0500 (EST) Received: by mail-ed1-f70.google.com with SMTP id d41so6814724eda.12 for ; Tue, 11 Dec 2018 05:53:25 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id; bh=CqbXK53yndyQThWULsBEgjVfSZN9kixDN/r6ofVr2gI=; b=bSwls5ZzluvkNVjg1z9Z+Vmt3ojNmLHVDBZEnv+siS5gFmLD24OJ0IRVuloxU3PlCu 6pZFTp/RRCrztQfjq38chdTi17GnqtV4VLriPBlu3r0EUmnPpG/vLmw0viHEESCV7xZJ CHcyrETcE30jkfzuzUawgPj0k9Y7QtJgb2bOk7VxbA9kF7eE5Pzur8a7qeQ0unTT32iv cxIGm3McGE0sQ3eZzLFXLkaBmzPclkVnP9Ab5UxjQSKrqSVnDdnuGEnjXYAfK35xQ7ha uI55qvACTvzbfb01pYqbIT0V8qF8yHN/O6FjgwsI4caLJE/iGyaqzCcBEZH5OFuVv3nl 10pw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of osalvador@suse.de designates 195.135.221.5 as permitted sender) smtp.mailfrom=osalvador@suse.de X-Gm-Message-State: AA+aEWZo9t0Rh00kak0uzhKH2WvnS44Uw9/cFsUYxrd5CkvenKw4fPEz VOdLlfCjoIQnrTEeFoSW7u4in4wQPd8xLp7xTJ902hk3zviErB7Uz2LZA7WBtmI5CDbfT1zOPHW cnZt5QFdChXlmHYX5cr679AwS5UdzCiXPQEk+ewrxDyBjTMDgsrIAnb3TvCB4K2Gq9A== X-Received: by 2002:a50:8f86:: with SMTP id y6mr15554680edy.131.1544536404800; Tue, 11 Dec 2018 05:53:24 -0800 (PST) X-Google-Smtp-Source: AFSGD/U51z7TscS4WDN3Lzg8kV/H7p87TjFgMn0sB8SSg/kDwFRPj0CxP6tyLt1uaPMW8z8T4tin X-Received: by 2002:a50:8f86:: with SMTP id y6mr15554634edy.131.1544536403954; Tue, 11 Dec 2018 05:53:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544536403; cv=none; d=google.com; s=arc-20160816; b=NOfDKD9tiKv+3b7HJq1NmWvTHcSZxTr1A3+70v4fFUKtZdOF/38+/yFZBUSz9vV2VE 1Ffqwb/tZn32cC0uf2b6jCKaShi2ukufIw0YwZWCma3pr++2/caglEopGWDo4rnUhKmO oiUeG30z8XZEeToJ+slruSAG0ApM+21WMlQuSAMdw83q4AechlJK99DmQMNDpYgqG8ax S3TjZzhx+2YUQBBnJ27KaIE8U4iRvMtIV9Aedt3tV5Eg7Yn+KPl28V1BpqbkRQmR3lQn 8THJ8o8+uCFQS42UIP8siLTvjatY3KIacSwQMWBkB1luzEzA9qpSxgdDmJuYbsOemxOS eHeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from; bh=CqbXK53yndyQThWULsBEgjVfSZN9kixDN/r6ofVr2gI=; b=adaQ0uLuQV8ml+mhAJTW5L5z1f2T/Gbr7JumofmMPn7oX5LGfywTrdMQvDvzluCYc4 kQZHu42LothSC3a1HGjKrbY+tMzq4D4NE84AfLlCDr+69z050lZuMwWko58X3i4RxCeg qT6lrKjD28l1kZCeNl0prQY3b3Kr//ffOqwdzaavtxOqZhHxFwFpM5Ye+Icra1cci/Pz b+4SMn9EdZc0ExIOjD8/s5vjtCnvricY5R4wfARzxgxGN0dXA+/JIq+9DhddzL9t8Ktc /nT1c3yWzF0KzNoX+xZZK0UhbNznHjy4hDpZgFk1KMubYZK6l8kRZ0ImHrSgjR7fSSHB WyGQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of osalvador@suse.de designates 195.135.221.5 as permitted sender) smtp.mailfrom=osalvador@suse.de Received: from smtp.nue.novell.com (smtp.nue.novell.com. [195.135.221.5]) by mx.google.com with ESMTPS id gf7-v6si1060003ejb.92.2018.12.11.05.53.23 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Dec 2018 05:53:23 -0800 (PST) Received-SPF: pass (google.com: domain of osalvador@suse.de designates 195.135.221.5 as permitted sender) client-ip=195.135.221.5; Authentication-Results: mx.google.com; spf=pass (google.com: domain of osalvador@suse.de designates 195.135.221.5 as permitted sender) smtp.mailfrom=osalvador@suse.de 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:23 +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 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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 Acked-by: Michal Hocko --- 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; }