From patchwork Mon Dec 3 10:03:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 10709045 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 E740C13BF for ; Mon, 3 Dec 2018 10:03:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D574F2AF9A for ; Mon, 3 Dec 2018 10:03:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C9B992AFA4; Mon, 3 Dec 2018 10:03:24 +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 5159E2AFA4 for ; Mon, 3 Dec 2018 10:03:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 227C76B687B; Mon, 3 Dec 2018 05:03:23 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 1AFBC6B687C; Mon, 3 Dec 2018 05:03: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 079186B687D; Mon, 3 Dec 2018 05:03:23 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by kanga.kvack.org (Postfix) with ESMTP id 9FA456B687B for ; Mon, 3 Dec 2018 05:03:22 -0500 (EST) Received: by mail-ed1-f69.google.com with SMTP id c34so3896557edb.8 for ; Mon, 03 Dec 2018 02:03: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:mime-version:content-transfer-encoding; bh=jPdQ2xohPGQO5/youIzdD6XhrzLSdiPyktb/A7gR3XQ=; b=TC0MTXRtkbO9uxmifzpmOjh6Yvbj8NAfV02TaJ2KVYVBCWas7OW+ZhTMWPmoueAfN/ dO1C+5GWjnPTF4dHH1BxfLCYXDDtsguFINwpK9/uz9KPxQrCL6Q/oNth67bEBd1jkQsO tJqpfNyfupoo73Pw/0an+9NbcORCyGOGk3MY3JKwfDvaL2g/koXqeMmmm1nCeE+SZJnw qcrdYzNJAlBUMBfdH4gXkSBo0BfMBoArabcVso4UaMs5bC2e1Znq1R8Bjawlk9vohstY GnOOski3+9Fo1mPmsLqoof8eu+0uJyYIk6Px/S0aL3DAfJT3rP469ugijLmBt/du/Z4U TIJg== 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: AA+aEWaaGlngKhLOppq49VYJrRVCqIhFiNOU/pWTk+BwPbrilnH8FQdi Z/xFxCLaC1VlHwaoEDZTIGhP+vRxxHteulLbu0OALmu4UWnYyKPtIyjj1gdqdhrJ+SAZhdWO6En jiSs0/TGkqugINb9UXEMbstcaFqDaHSNbb28L1GTR6Sasur0Ilzipnpgk2Y+pvrt5POh/Qzy502 Q42il+mmK7eiEZhkvu+sQLsHqDUBViOya5ASt0ybjJU8cnquBgcJbBP7SHRyrZWAUOQjhRQgkCj yyKvgy1BZORhSUaAn8+Zto+VYFDIdCLraf4nQxCXAgrKnWveWaJ1o90qjwRnBN7KtdG3rSmDOff xpFnmD/HG+xmxcqaQa4qiXXmb33Z61fZ0c1Hz+izLtUYcdwtFPFCGQOjhWkaseOJGYIHYlNUVg= = X-Received: by 2002:a17:906:59d6:: with SMTP id m22-v6mr12413108ejs.20.1543831402113; Mon, 03 Dec 2018 02:03:22 -0800 (PST) X-Received: by 2002:a17:906:59d6:: with SMTP id m22-v6mr12413067ejs.20.1543831400943; Mon, 03 Dec 2018 02:03:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543831400; cv=none; d=google.com; s=arc-20160816; b=eab0Y7fEccS/fSYdzznDDc+mvNqCGggfjexpBIClP0gwTQFUBtR7sDx4/VG1KBroId jKWpFXuraWdv1zkoReO88cYe+xkLMtazoCnSckwRWEGSxN1sBQ1CVnDbn/Fc59z8Ag+q LfzFnKQmJYP95tVolpiAHAmYkQfn9LuZSz6CLOFwBcl6Qay65u1HbCjkfpPKEDSDoJE6 Fzm10Id+gnE1BidC+pumLH6NCvpdozEotfc+GNuVDN6kyUZRft327EtAbeSMnG5M+YYa UoELeg53/WZVaS2PjZKBSgTRdy49YQNP9TYOjYNLh+vYMF4YpqLVcwuCGPN+JpoFQPkJ /rlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from; bh=jPdQ2xohPGQO5/youIzdD6XhrzLSdiPyktb/A7gR3XQ=; b=VPcno0RUIMkhs/v+5NAojJa8J5DtPMHF3FxuMVrw16D/ZPH/PrvjdS1EPf8r+YTOF1 2N3cbjU6lwHsfPmFbkqD1EM5Sx+catUf4lEOybmP+A8BUalASuiDqlPVqADC111WbqJy m0O4o7Snq5puhSdl3ixcVt8zrUd45NA+NS8OT+uzdArxdNWguE5QV7rXUzkVrHPCLs7q 6vfe/+eULPgB+oOKppewENiMr4Fya0tNUKnHAwSlwwUe3bCZjPkBpgZ5JdL5nH14o95z p5TJvh9F2mzbBDmNFmd+AySOt4RDEOppniK7PP/oOWGRIWcfJQ4+Xu0QDhtgJgzo0uTi Ir0A== 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 l22-v6sor3277405ejr.15.2018.12.03.02.03.20 for (Google Transport Security); Mon, 03 Dec 2018 02:03:20 -0800 (PST) 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: AFSGD/UFvc0nAOOz+A9P/ainnX0MOvW1MEMDO0U2Zi9/O/8F4j//xH+y6i/ZxE0x54J2PFR9kNfbdw== X-Received: by 2002:a17:906:279a:: with SMTP id j26-v6mr12480469ejc.112.1543831400455; Mon, 03 Dec 2018 02:03:20 -0800 (PST) Received: from tiehlicka.suse.cz (prg-ext-pat.suse.com. [213.151.95.130]) by smtp.gmail.com with ESMTPSA id w13sm3719321edl.54.2018.12.03.02.03.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Dec 2018 02:03:19 -0800 (PST) From: Michal Hocko To: Naoya Horiguchi , Oscar Salvador Cc: Andrew Morton , Dan Williams , Pavel Tatashin , , LKML , Michal Hocko , Stable tree Subject: [RFC PATCH] hwpoison, memory_hotplug: allow hwpoisoned pages to be offlined Date: Mon, 3 Dec 2018 11:03:09 +0100 Message-Id: <20181203100309.14784-1-mhocko@kernel.org> X-Mailer: git-send-email 2.19.1 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 We have received a bug report that an injected MCE about faulty memory prevents memory offline to succeed. The underlying reason is that the HWPoison page has an elevated reference count and the migration keeps failing. There are two problems with that. First of all it is dubious to migrate the poisoned page because we know that accessing that memory is possible to fail. Secondly it doesn't make any sense to migrate a potentially broken content and preserve the memory corruption over to a new location. Oscar has found out that it is the elevated reference count from memory_failure that is confusing the offlining path. HWPoisoned pages are isolated from the LRU list but __offline_pages might still try to migrate them if there is any preceding migrateable pages in the pfn range. Such a migration would fail due to the reference count but the migration code would put it back on the LRU list. This is quite wrong in itself but it would also make scan_movable_pages stumble over it again without any way out. This means that the hotremove with hwpoisoned pages has never really worked (without a luck). HWPoisoning really needs a larger surgery but an immediate and backportable fix is to skip over these pages during offlining. Even if they are still mapped for some reason then try_to_unmap should turn those mappings into hwpoison ptes and cause SIGBUS on access. Nobody should be really touching the content of the page so it should be safe to ignore them even when there is a pending reference count. Debugged-by: Oscar Salvador Cc: stable Signed-off-by: Michal Hocko Reviewed-by: Naoya Horiguchi Acked-by: David Hildenbrand Reviewed-by: Oscar Salvador Signed-off-by: Michal Hocko Reviewed-by: Oscar Salvador Tested-by: Oscar Salvador Acked-by: David Hildenbrand Acked-by: Naoya Horiguchi --- Hi, I am sending this as an RFC now because I am not fully sure I see all the consequences myself yet. This has passed a testing by Oscar but I would highly appreciate a review from Naoya about my assumptions about hwpoisoning. E.g. it is not entirely clear to me whether there is a potential case where the page might be still mapped. I have put try_to_unmap just to be sure. It would be really great if I could drop that part because then it is not really great which of the TTU flags to use to cover all potential cases. I have marked the patch for stable but I have no idea how far back it should go. Probably everything that already has hotremove and hwpoison code. Thanks in advance! mm/memory_hotplug.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index c6c42a7425e5..08c576d5a633 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -34,6 +34,7 @@ #include #include #include +#include #include @@ -1366,6 +1367,17 @@ do_migrate_range(unsigned long start_pfn, unsigned long end_pfn) pfn = page_to_pfn(compound_head(page)) + hpage_nr_pages(page) - 1; + /* + * HWPoison pages have elevated reference counts so the migration would + * fail on them. It also doesn't make any sense to migrate them in the + * first place. Still try to unmap such a page in case it is still mapped. + */ + if (PageHWPoison(page)) { + if (page_mapped(page)) + try_to_unmap(page, TTU_IGNORE_MLOCK | TTU_IGNORE_ACCESS); + continue; + } + if (!get_page_unless_zero(page)) continue; /*