Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp598974img; Fri, 22 Mar 2019 04:54:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqz/Q0LyWsCbyouSBH79ABM6LnVWslidL8+oz8m/U5IFXa3EA6wsUXvMvRa/N/vvEFc0k9ks X-Received: by 2002:aa7:87c5:: with SMTP id i5mr8766021pfo.20.1553255662417; Fri, 22 Mar 2019 04:54:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553255662; cv=none; d=google.com; s=arc-20160816; b=GcELxxWVrDhNFnBOJOg0CF5+QDW/Muc2bF2/1+5MM4vLZbqB0khjs/5AhIVYGd3iAu J0egtEMb8k3lzfenKfehdvvX1XVjrhGOQdvkZ0OA/6PJRUYchGAHBb4pz5jvQEExDcmu +RUyvOjSz9ZZ937YKqtSJscZXCLp30CTbS4Dx4s43D4H9RvYsqZXmyEkkl8mCy6dlDk2 skT4hbun/7G4Lsn32XD2zEA4hu6ipZjO4cyom6JB9zcJtvA6tHnB9RuOve5xWe2RE+u2 in/BcqOVqEneC0e9qlJJ3vXExd09CAMUkLg6m2aKYL5wlFKkpb2XXI7eLs28mJcPPPWN UjBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=zhtbE9oRECp+6xVEvd9dm2I2xfGKglUoH95Qs4Q5Ttk=; b=wWvgvoMu8Haj3c81f20LLFTuGiQeI+b4HVxsgH20jdsLLTJxODjCb+TXuVyyC1SAvA I1H+UI88rN/ZwQzqm56N2nQgbKYetJkWTx/qnbxQQY1yDuRG2cC31Z6RAMGNYV4oQWHF KIL8f66+tMD+YtDee7RHqbp/ISK9PWKHieddyTCWfLp99eKsvUu7W2zOBYPHwkZc5qyn X3cMcuh7zDO4/uj+mfBAEoJuqsI6E1HTH4TxP5x459V8ToTgA/IBs1kQVuZ7Q9NlSw8i wvcP28UmeRjrS5R4mIxW61p+CA2qge4l3D+ylPqHgkWM0DwJOgWylOaWe6OA8dgMuX40 6XWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=oZdDdXW7; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bd6si6725080plb.56.2019.03.22.04.54.07; Fri, 22 Mar 2019 04:54:22 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b=oZdDdXW7; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732492AbfCVLwV (ORCPT + 99 others); Fri, 22 Mar 2019 07:52:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:56252 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732683AbfCVLwT (ORCPT ); Fri, 22 Mar 2019 07:52:19 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E313721916; Fri, 22 Mar 2019 11:52:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553255538; bh=2/ZDDQu6+75AQRY9jyAv0tOXJa4d8eW4HxFyVzLI12U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oZdDdXW7Ngpo0qKa02V25JCTMoQx5soOnIzo3mKCF+AYGf5qObZ3qHW+8QR4DkbCy VmnER6D++rC6mABUa/rjbBNwEls8/g00/8hhmP+Yqvt5jPgRvLEXU58zeTQF7vDY4m yZJZa10+8z5DG49CAylL4A1zhDSAF/8rvkzeFvtM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, zhongjiang , Naoya Horiguchi , Michal Hocko , Hugh Dickins , "Kirill A. Shutemov" , Andrea Arcangeli , Andrew Morton , Linus Torvalds Subject: [PATCH 4.14 122/183] mm: hwpoison: fix thp split handing in soft_offline_in_use_page() Date: Fri, 22 Mar 2019 12:15:50 +0100 Message-Id: <20190322111250.543180785@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190322111241.819468003@linuxfoundation.org> References: <20190322111241.819468003@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: zhongjiang commit 46612b751c4941c5c0472ddf04027e877ae5990f upstream. When soft_offline_in_use_page() runs on a thp tail page after pmd is split, we trigger the following VM_BUG_ON_PAGE(): Memory failure: 0x3755ff: non anonymous thp __get_any_page: 0x3755ff: unknown zero refcount page type 2fffff80000000 Soft offlining pfn 0x34d805 at process virtual address 0x20fff000 page:ffffea000d360140 count:0 mapcount:0 mapping:0000000000000000 index:0x1 flags: 0x2fffff80000000() raw: 002fffff80000000 ffffea000d360108 ffffea000d360188 0000000000000000 raw: 0000000000000001 0000000000000000 00000000ffffffff 0000000000000000 page dumped because: VM_BUG_ON_PAGE(page_ref_count(page) == 0) ------------[ cut here ]------------ kernel BUG at ./include/linux/mm.h:519! soft_offline_in_use_page() passed refcount and page lock from tail page to head page, which is not needed because we can pass any subpage to split_huge_page(). Naoya had fixed a similar issue in c3901e722b29 ("mm: hwpoison: fix thp split handling in memory_failure()"). But he missed fixing soft offline. Link: http://lkml.kernel.org/r/1551452476-24000-1-git-send-email-zhongjiang@huawei.com Fixes: 61f5d698cc97 ("mm: re-enable THP") Signed-off-by: zhongjiang Acked-by: Naoya Horiguchi Cc: Michal Hocko Cc: Hugh Dickins Cc: Kirill A. Shutemov Cc: Andrea Arcangeli Cc: [4.5+] Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- mm/memory-failure.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1701,19 +1701,17 @@ static int soft_offline_in_use_page(stru struct page *hpage = compound_head(page); if (!PageHuge(page) && PageTransHuge(hpage)) { - lock_page(hpage); - if (!PageAnon(hpage) || unlikely(split_huge_page(hpage))) { - unlock_page(hpage); - if (!PageAnon(hpage)) + lock_page(page); + if (!PageAnon(page) || unlikely(split_huge_page(page))) { + unlock_page(page); + if (!PageAnon(page)) pr_info("soft offline: %#lx: non anonymous thp\n", page_to_pfn(page)); else pr_info("soft offline: %#lx: thp split failed\n", page_to_pfn(page)); - put_hwpoison_page(hpage); + put_hwpoison_page(page); return -EBUSY; } - unlock_page(hpage); - get_hwpoison_page(page); - put_hwpoison_page(hpage); + unlock_page(page); } if (PageHuge(page))