Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp597704imu; Thu, 13 Dec 2018 00:49:15 -0800 (PST) X-Google-Smtp-Source: AFSGD/WO3kCx9KFeq0w9NWkVC1SaqIPhw11zW1j83elknVmeDSy2CuL2eeuR93Cq1ThpQuBFIw8y X-Received: by 2002:a63:5a08:: with SMTP id o8mr20952048pgb.185.1544690955442; Thu, 13 Dec 2018 00:49:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544690955; cv=none; d=google.com; s=arc-20160816; b=yCHRwJVm8/w++7+6jc78ZcOEjf1ULCchP1+OuZ7JN4gkYPGQnj+vdWyMOr4e/7ObyB OahwujwgOFxJdlN6l2VwVjvT7P99jItymHMrWi6ygc2TC2+M56PraJI80hDRP3OIzv/b VKmAXiQqS+rBnqXQZLABm45qw/8cyUlc4c/xXQBpSZy3hwQzqY9oGXvJW4ZR1s/sz1QH vNTGS3Vjn5lDbH0oZsqehCSX5mCVauyAvCTEjfeeOKYiyV5fxVIb/hZX8r7Nn9jQ+TO4 6gAgMyByjDMQFF6GOJBSRsASbS5zRLgS+19SiH7Zy+pnExv0TwyG6P8E421BhgK0jhkQ m89Q== 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=Ev5Nxg7HJ+yixtXZfBTRSF3QCrYwEC0Li7O+00MZRe0=; b=TE7uB+hugpxckmJQCRDEPCvns9Tqe7vhovTTEi0UiTQKQJ+fI7NejZsGwo0xNyGZLR 5inpbUAkA5iwhfYrPV/v5cshyItZfc2EyzPYO/kp3cwXkqGwQpxrMTU2k9GcWFbiWUcz fLA3hs3DrskTgXtJa/3JesYuc/EqMp2WcCI4az/yB79kwE12dybyeaXrgiKpHJUdIvPo EEXRcjO2y0zx562kA1Fry/BZUKPmKo630nTN4O33R9N5Mu1CDBbO6VybSl9Tb1VTLua6 VLEU3w8i8Zi9xv1rj/D8IoAhrr+hvLLLlaH67sjjWhlaL+7fz50mmpaP9J8FlynJPmmp iUjQ== 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 10si1119109pgl.30.2018.12.13.00.48.59; Thu, 13 Dec 2018 00:49:15 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727427AbeLMIsE (ORCPT + 99 others); Thu, 13 Dec 2018 03:48:04 -0500 Received: from mx2.suse.de ([195.135.220.15]:48118 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725949AbeLMIsD (ORCPT ); Thu, 13 Dec 2018 03:48:03 -0500 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 23902AE4B; Thu, 13 Dec 2018 08:48:01 +0000 (UTC) Date: Thu, 13 Dec 2018 09:48:00 +0100 From: Michal Hocko To: Oscar Salvador Cc: akpm@linux-foundation.org, 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: <20181213084800.GV1286@dhcp22.suse.cz> 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: 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 11-12-18 14:53:12, 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. I still think that this doesn't give us a whole picture. Looping for ever is a bug. Failing the isolation is quite possible and it should be a ephemeral condition (e.g. a race with freeing the page or somebody else isolating the page for whatever reason). And here comes the disadvantage of the current implementation. We simply throw everything on the floor just because of a ephemeral condition. The racy page_count check is quite dubious to prevent from that. > 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 lkml.org tends to have broken archives over time. Please use http://lkml.kernel.org/r/ instead > Signed-off-by: Oscar Salvador Acked-by: Michal Hocko > --- > 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 -- Michal Hocko SUSE Labs