From patchwork Tue Dec 11 08:50:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 10723207 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 B43DA159A for ; Tue, 11 Dec 2018 08:51:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A333B2A590 for ; Tue, 11 Dec 2018 08:51:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 947962A59D; Tue, 11 Dec 2018 08:51:25 +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 203FC2A590 for ; Tue, 11 Dec 2018 08:51:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5669B8E005F; Tue, 11 Dec 2018 03:51:23 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 511BB8E004D; Tue, 11 Dec 2018 03:51:23 -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 401748E005F; Tue, 11 Dec 2018 03:51:23 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by kanga.kvack.org (Postfix) with ESMTP id E6A0B8E004D for ; Tue, 11 Dec 2018 03:51:22 -0500 (EST) Received: by mail-pf1-f199.google.com with SMTP id 68so12134429pfr.6 for ; Tue, 11 Dec 2018 00:51:22 -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=/9hNHdGPE7KB2t7fE4xN2IIOggKE+Yqiy/e0AESIFGw=; b=VSN1lfcFn7CEQozobOsajlY4tRxOp8WNHEvFWEbUSPdpgWq4g9mFCVxiwzXDT780RB HXWgSlG2o7v589KOiJzzWaZkc+DLtuZEtlZgoOs3oxcb6kFdB7vVj2H6gcLJI5Y/Er5w ym9flGi82Qnr+ZhUcFcSKltNAE7TM3lszr2QlwkWa92ClJAUxGDCThtB3z5EtKvShda8 eKnsqxNcxTq44QLc0a0F3cBr6ZFl61F2fKdeUf8hYKIkqwaImYOiKIpi2SV+zvWKIQl0 zJDu5w3e31+b+GBwWDJYhri5Y0sYOVO55iKTfxpcva55fju3mv59Q8ruaejK8/p8B41r ESaQ== 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+aEWZHePPSnjmQJlB0LjDZCWhxy4pp0r5hGnmyiH5dixssp/l5F2tt lyqNIIL+9BLf/HXGRUwqBc+AGdxXBoCr6uO2hQREGcLa2iRaPRWnhDxah4UmU193FTDglgmqCn/ 7/+V+bEYWBt4czWOTjYm/0en9wcWqQDb26dltBBWIXRnipIC7U/0k+FeecTubLE5lEg== X-Received: by 2002:a17:902:12b:: with SMTP id 40mr14946056plb.72.1544518282470; Tue, 11 Dec 2018 00:51:22 -0800 (PST) X-Google-Smtp-Source: AFSGD/U7KAoMenYR0wT72h4zSlC2SyvX64FVKFXGguS3gH+/pbtydmKUVPH52x9zg1+2IFA4HlMG X-Received: by 2002:a17:902:12b:: with SMTP id 40mr14946028plb.72.1544518281659; Tue, 11 Dec 2018 00:51:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544518281; cv=none; d=google.com; s=arc-20160816; b=NI6OI6pB9I9MS9XG2JmyJE5t3/ZG4Nq75XfhYUCv40IITFByNkUBpbXOO6Z2Vr+pMX fp2oF6HTmdvIWYsRx6Q+J1ePHfryxY/LrSBJy0lNjzy9K64G9d442v4sTyhR5bqalc1Q PHIbhwbAFTEpSxgBxIvvspeVP23YSGdN2IdZaFx+cv3OnhriNQI+cJWjKZCvttEy2Moz Q4+m5Q48WUqr01kaEPONEAsKpnY4OYqwFvZK1w6bdsmqRSJ/qIvq6jhTSjFI02aIgNfb wt+sv4/dCZJkBBAQxejyWxEGiaBn0rOMcTc+t0aXCKclud0SHGWspQCcdQYBP7RHUxxD xL5A== 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=/9hNHdGPE7KB2t7fE4xN2IIOggKE+Yqiy/e0AESIFGw=; b=Ru+qOgWaonulh7Bd0cbx0xTmekR8rQf6jIJf/i2pG7KT/qCLKan9AFrjm1V1u8wVqK q8cEcyG4pksfpHV+dtN/WBbtXL8k3rgmIKEi4REhZVGqPljdV4NjCOBKtEWFF8ghVCFZ 65JSDqYAn7g6gfT6qJoFQ0fElSTuLH07i55UGiE/A3a+UwGIaRG6s+aiLu6Fitv1CRMV 1ox4NWxTNclmEgeP0CJerDYeGU4G4W6vA13jlUYGXaQPhY58lmxQ6HLdaSYXfS8k2JXD rxm78Wxw7UY/UrL7nu/BQ6CMB6qsijEMsJg1A3F5JoStfqbDNgQh/+OqK0TWAhajik/0 9YjA== 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 i6si11326633pgq.207.2018.12.11.00.51.20 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Dec 2018 00:51:21 -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 09:51:19 +0100 Received: from d104.suse.de (nwb-a10-snat.microfocus.com [10.120.13.201]) by emea4-mta.ukb.novell.com with ESMTP (NOT encrypted); Tue, 11 Dec 2018 08:50:48 +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] mm, memory_hotplug: Don't bail out in do_migrate_range prematurely Date: Tue, 11 Dec 2018 09:50:42 +0100 Message-Id: <20181211085042.2696-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 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 4d0c7db96 ("hwpoison, memory_hotplug: allow hwpoisoned pages to be offlined") 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 some work at least. There is no danger in the skipped pages to be lost, because scan_movable_pages() will give us them as they could not be isolated and therefore migrated. Although this patch has proved to be useful when dealing with 4d0c7db96 because it allows us to move forward as long as the page is not in LRU, we still need 4d0c7db96 ("hwpoison, memory_hotplug: allow hwpoisoned pages to be offlined") to handle the LRU case and the unmapping of the page if needed. So, this is just a follow-up cleanup. Signed-off-by: Oscar Salvador --- mm/memory_hotplug.c | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 86ab673fc4e3..804d0280d2ab 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); @@ -1395,25 +1394,9 @@ do_migrate_range(unsigned long start_pfn, unsigned long end_pfn) inc_node_page_state(page, NR_ISOLATED_ANON + page_is_file_cache(page)); - } 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; - } } } 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 +1409,7 @@ do_migrate_range(unsigned long start_pfn, unsigned long end_pfn) putback_movable_pages(&source); } } -out: + return ret; }