Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp631653img; Fri, 22 Mar 2019 05:32:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqzzXRy0ZjisOzIbGJi/FO99Njp7EB8HEuWrXjPCDf+Zu/qKWlGcplBSx3QfXAi71DBzOeWS X-Received: by 2002:a63:5415:: with SMTP id i21mr8653218pgb.106.1553257950010; Fri, 22 Mar 2019 05:32:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553257950; cv=none; d=google.com; s=arc-20160816; b=FbwCWHzu+QUZF4BcNm7CEB+O/moCQUWfFH8C+Ad9af4mgfRn1/iA0YOpk2Xjd/NXAq OSupiDezlEC1vppay5ckENxCQ1q3vESvl607aQul3/dey6Fh7Hk19ZTYRBYMJgXDhy/H V0t3uOagkmRzixvaLOcfh9GVbnQFsmzwPejRYSrUcbtvLbLrlxb1L7MCiOKaaDRutuFt YSxlzH7II3oGUCLbKvxLScInB2KqhsNry/T5ZgrpVdkdb4b3Azo9KRGdNe2aGLgpmeBR 1js7/xj7gBubl9CGs7hOsYGTC8o+CcqWqZorKAgH3IJ+E2YL73LTykcYkhmhsxTYtzjP q1Ng== 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=F4LTbzyR2z17dFii0WJtmDMdu1hsvLbRv/UzuWE6a44=; b=i8X4tHUIRQ0FJOpMkjaPj693FhuUwsI/VeoZw9msOcWewB1EM9Z7jXo0lxAjOLzg7l imSefuMG+LXDyvLgDPOZsy6qUQvAZbsjJU11zuLCQrFgkxjXYNP8YwcZ7braEJLQyiIm xX1sC+RQcsH1eRSJxZr0SOZYsJgcCKGLqm5/rIBez3I+xkStoFh2XiwizHWQXvMLNKCu 1WPV4vq7Y0V9zoW842Y0a+rpXF1f+FALT4QyjkGfLWJ3UI+jfaH06uYVsw2LqFcQgb+Z kzZ7e5LUGDI7zaQzyQjnddbaXaRavDHJBv0Iu0Ydq4jrUnvZ5ZyG5UsvH3Qd7S/juCMv B8nA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=G9N7cpT8; 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 m6si6920622pls.436.2019.03.22.05.32.12; Fri, 22 Mar 2019 05:32:29 -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=G9N7cpT8; 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 S2389904AbfCVMRK (ORCPT + 99 others); Fri, 22 Mar 2019 08:17:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:55948 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390068AbfCVMRH (ORCPT ); Fri, 22 Mar 2019 08:17:07 -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 790752083D; Fri, 22 Mar 2019 12:17:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553257026; bh=Xiadh1m8iofDT40wQNvmLVAYQ0TtKFCPcQw1CIWeJK0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G9N7cpT86Idk2XPXWoVOFgMpsiYYryEiJ9qICyMyb2r3p/L9nXGmWgi/GRW81hSBT FeLn1pnccpuBbDfKZhatFRHwua98eu0vaH6SL2rtLZeMsrXAJD/2pwkHqiC+JLHE+j rJCOVyienI/1lAhE7v9bQqQNTbgK/29UpQHN8XNw= 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 5.0 109/238] mm: hwpoison: fix thp split handing in soft_offline_in_use_page() Date: Fri, 22 Mar 2019 12:15:28 +0100 Message-Id: <20190322111304.956938608@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190322111258.383569278@linuxfoundation.org> References: <20190322111258.383569278@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 5.0-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 @@ -1825,19 +1825,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); } /*