From patchwork Fri Nov 2 15:55:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 10665759 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 14C1D14BD for ; Fri, 2 Nov 2018 15:55:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 00D262C19B for ; Fri, 2 Nov 2018 15:55:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E70D72C2A5; Fri, 2 Nov 2018 15:55:41 +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 6DAE92C19B for ; Fri, 2 Nov 2018 15:55:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5DBC46B0010; Fri, 2 Nov 2018 11:55:40 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 58A196B0266; Fri, 2 Nov 2018 11:55:40 -0400 (EDT) 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 4A13C6B0269; Fri, 2 Nov 2018 11:55:40 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by kanga.kvack.org (Postfix) with ESMTP id 0A1C16B0010 for ; Fri, 2 Nov 2018 11:55:40 -0400 (EDT) Received: by mail-pg1-f198.google.com with SMTP id z13-v6so2018662pgv.18 for ; Fri, 02 Nov 2018 08:55:40 -0700 (PDT) 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:in-reply-to:references:mime-version :content-transfer-encoding; bh=NBhzy/S34A7on+K+3b8oAVAcy3NIhz+CjCrdYxmOkqg=; b=DhTStbHPGpBFM4lh+Xo/H34zvDHIHoA6E8eyvKFG3itNdylhPOFrU6PN1KsiKK1qr4 g+2+cNMiP1Hl5vjC4P36jvFt3eMQHu07C9Tv7jaH0vGD7YGPPXV8qA+dHY9wRSo5R+OY aGHqCTQG9UbQ35I0KT3NPXgWFgNie4pJLdTQ3plFmgjG8MkByug+4DOAnZ4V1sbWuo4o CXbIvHiAxpdp0ZVPdMCd3AhMd1zjhoM/JasSniFdZECBTXCFCfcemMmYBn2NfG5M+Oen dvWw+rmJAEwhEpAjhIxHOvv5Erfq3QKNsz2NWprSIoQWcL1jiRtXUzeFqw/z/IiKHuqs X4tQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of mstsxfx@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=mstsxfx@gmail.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Gm-Message-State: AGRZ1gK0MBriqa2oAxy7nH2ADEun9XT/obuQBZ3lK0NHxI36ow2Zpnob f3hkezVc23/RSNlmwgN9NBTMBBfEDZSXv11SJ7eg35ZeaWtouWN0UD+SZFDsU8JG+QZ3qj9ZR9d pn4OlzTEDm7i4lO+cLGD+iffWLDaUJlMHjoFpozvOU4DE3Iievas8dEgrI84hseQbl/98lSTzdw z8ZGUzXHJJtwIZkYquP0A5RKcumoP8quFNWw3OeyTR63tWxk24yd/ZKyXkdgWhI2VMXbBuGvyOL kdYSn5ZL/ehWWsvIfAfN8XVOQjyUUQHQNY+xK/l6bd8wOcWiJehfDB2hcX78wn67NqQ1J5HxRtA LfunVOye9CPcrXUVOvjH2Rds+Vv4psor0Zb0IvuEL6bOLikn6huVjAREVDdhK+WxMm1A1H7hqg= = X-Received: by 2002:a17:902:8c86:: with SMTP id t6-v6mr12402004plo.55.1541174139703; Fri, 02 Nov 2018 08:55:39 -0700 (PDT) X-Received: by 2002:a17:902:8c86:: with SMTP id t6-v6mr12401962plo.55.1541174138617; Fri, 02 Nov 2018 08:55:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541174138; cv=none; d=google.com; s=arc-20160816; b=oWE24A491CgrY4rwfwq2Dge3lOfB+0eURe6PyhS306ePEU0HP3B3d/gDAE4WRjlRdy 3dM+qd6Ib0DuL7y9DOhJ8l7jO9EgM5rYdxEZxtgdO6Zh+u5xZTFy7o1VLVwQdaEFaxKq sce0aIud8RtxBx1/rRPvsxPiLobK64fxixDhbfzZjeaDHtY0+buLjKSknFUkQc3WE+jc gEO0WaH3W5Vy9bzWUM0zb4+Vo7R9efGzqYgiYo7jkzjJSspW8NGwnT06DbjFSxg14YAH T5ForZfTMThHkFS/nlVWkDUJHXPRVy55B3snVVo6si1mP1qL+OzWLx9WU0glGYiX5UL5 RyyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=NBhzy/S34A7on+K+3b8oAVAcy3NIhz+CjCrdYxmOkqg=; b=sQ00k/dCiteB3xJDlZsJPlL0wH17t2VjQhZelrS+G9YBgXO/l0MJYPPZRmJpAzN6qs 9ZQcQQWoqIif4p6pzJ5omRSIyvnAG/Y31fol9oiTckzPYzKDi4EOaq8xvFVU+5xXnHJD lclSy/hy4ihmJp8w4ZU9TynhbrbXtYCv4ehKSTFK+ox/a0i5jagCQ3JGMfsgc4jh1/aj 5DjsXnt1SmKC8j3f/G7TlsJz3QhHrm3FYFSvqEOcGv4wqPZm3QZadbOkao1R86BC6Zoe uDuu7EcbyOFUgZUxTv5iiYfGr1lXeTLxlO7kMfj3J7Oh9RcFMM4wtSua5H7emfDmnxW0 iL0A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of mstsxfx@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=mstsxfx@gmail.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id i21-v6sor33730839pgb.24.2018.11.02.08.55.38 for (Google Transport Security); Fri, 02 Nov 2018 08:55:38 -0700 (PDT) Received-SPF: pass (google.com: domain of mstsxfx@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; spf=pass (google.com: domain of mstsxfx@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=mstsxfx@gmail.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Google-Smtp-Source: AJdET5dN98hD68jh8474F3d1oQmmUomdIhwgXklv8G5Yd3IgkRqmnBdRbm94PuJaH/khaEiactycgQ== X-Received: by 2002:a63:9343:: with SMTP id w3-v6mr11202938pgm.343.1541174137963; Fri, 02 Nov 2018 08:55:37 -0700 (PDT) Received: from tiehlicka.microfocus.com (prg-ext-pat.suse.com. [213.151.95.130]) by smtp.gmail.com with ESMTPSA id 27-v6sm55208581pfm.36.2018.11.02.08.55.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Nov 2018 08:55:36 -0700 (PDT) From: Michal Hocko To: Andrew Morton Cc: Baoquan He , , LKML , Michal Hocko , Stable tree Subject: [PATCH] mm, memory_hotplug: teach has_unmovable_pages about of LRU migrateable pages Date: Fri, 2 Nov 2018 16:55:28 +0100 Message-Id: <20181102155528.20358-1-mhocko@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181101091055.GA15166@MiWiFi-R3L-srv> References: <20181101091055.GA15166@MiWiFi-R3L-srv> MIME-Version: 1.0 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 From: Michal Hocko Baoquan He has noticed that 15c30bc09085 ("mm, memory_hotplug: make has_unmovable_pages more robust") is causing memory offlining failures on a movable node. After a further debugging it turned out that has_unmovable_pages fails prematurely because it stumbles over off-LRU pages. Nevertheless those pages are not on LRU because they are waiting on the pcp LRU caches (an example of __dump_page added by a debugging patch) [ 560.923297] page:ffffea043f39fa80 count:1 mapcount:0 mapping:ffff880e5dce1b59 index:0x7f6eec459 [ 560.931967] flags: 0x5fffffc0080024(uptodate|active|swapbacked) [ 560.937867] raw: 005fffffc0080024 dead000000000100 dead000000000200 ffff880e5dce1b59 [ 560.945606] raw: 00000007f6eec459 0000000000000000 00000001ffffffff ffff880e43ae8000 [ 560.953323] page dumped because: hotplug [ 560.957238] page->mem_cgroup:ffff880e43ae8000 [ 560.961620] has_unmovable_pages: pfn:0x10fd030d, found:0x1, count:0x0 [ 560.968127] page:ffffea043f40c340 count:2 mapcount:0 mapping:ffff880e2f2d8628 index:0x0 [ 560.976104] flags: 0x5fffffc0000006(referenced|uptodate) [ 560.981401] raw: 005fffffc0000006 dead000000000100 dead000000000200 ffff880e2f2d8628 [ 560.989119] raw: 0000000000000000 0000000000000000 00000002ffffffff ffff88010a8f5000 [ 560.996833] page dumped because: hotplug The issue could be worked around by calling lru_add_drain_all but we can do better than that. We know that all swap backed pages are migrateable and the same applies for pages which do implement the migratepage callback. Reported-by: Baoquan He Fixes: 15c30bc09085 ("mm, memory_hotplug: make has_unmovable_pages more robust") Cc: stable Signed-off-by: Michal Hocko Reported-by: Baoquan He Signed-off-by: Michal Hocko Tested-by: Baoquan He Acked-by: Baoquan He --- Hi, we have been discussing issue reported by Baoquan [1] mostly off-list and he has confirmed the patch solved failures he is seeing. I believe that has_unmovable_pages begs for a much better implementation and/or substantial pages isolation design rethinking but let's close the bug which can be really annoying first. [1] http://lkml.kernel.org/r/20181101091055.GA15166@MiWiFi-R3L-srv mm/page_alloc.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 863d46da6586..48ceda313332 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -7824,8 +7824,22 @@ bool has_unmovable_pages(struct zone *zone, struct page *page, int count, if (__PageMovable(page)) continue; - if (!PageLRU(page)) - found++; + if (PageLRU(page)) + continue; + + /* + * Some LRU pages might be temporarily off-LRU for all + * sort of different reasons - reclaim, migration, + * per-cpu LRU caches etc. + * Make sure we do not consider those pages to be unmovable. + */ + if (PageSwapBacked(page)) + continue; + + if (page->mapping && page->mapping->a_ops && + page->mapping->a_ops->migratepage) + continue; + /* * If there are RECLAIMABLE pages, we need to check * it. But now, memory offline itself doesn't call @@ -7839,7 +7853,7 @@ bool has_unmovable_pages(struct zone *zone, struct page *page, int count, * is set to both of a memory hole page and a _used_ kernel * page at boot. */ - if (found > count) + if (++found > count) goto unmovable; } return false;