Received: by 2002:ac0:8845:0:0:0:0:0 with SMTP id g63csp468314img; Tue, 26 Feb 2019 03:19:29 -0800 (PST) X-Google-Smtp-Source: AHgI3Iacy2QdIhVOwuxC3yrV/40OAdMaIDtbj212RDHeMoGJva3pWv2fAo+Pbq+a7+1K+jUIV431 X-Received: by 2002:a17:902:14e:: with SMTP id 72mr25665679plb.287.1551179968960; Tue, 26 Feb 2019 03:19:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551179968; cv=none; d=google.com; s=arc-20160816; b=HTH1fZ2IMjEKmu0Xr+I4QFvbvrSQzcQakCegKJ8ZJMCoYR0CCvZEOK0X5uQ181hCv+ 70g2LCf27bHT/gqgeIB7djBThJx+1O7gpnsWlyC4h9jEBkyzHXRYGyXj2SQNvJC+Gnsf I2tAyspN4evsUWt3BoSMMiIByXeoOFPTE8GKfWcXplkB+fOphjwvxaeppW85ktQGXo9E XHFHlXJxYkaMUgRMPBwx3MqslW5k6Ewy/IlnAmmEL7TGUeI7VhWx2oV84sxACOvxS9oe LJuRcrqTjnsYmENW+NoTDN5ty+tmGNh7Mdu/n7cAediaNzR5362Lfo7LQ1B/3BL5m2kc DZeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=EICjkiEY8XeRLtx1X9VlU1I6jq925nWk8+f5DRquXRM=; b=c4lPu52KCCMyl72kFr1M6c0yG31hWgEpgdZbdKqv7wvOm1705/XTZjqdYTC0Jlwd9d LOpxJ+eazOvTRR36grjjWsRJNeuCrIm/1CXVbrghg7SC+5YAmJn4QeBCIA0u+WII9JOD H/X0VodWDfWcTvbnBBcn0TO2Qfgf7rNSVHw7W78pRG3/QOW23JghEjtsQ7TRgfvpG5s2 fb6ec7cNFRs/sC8BCvx6wO4QXPpT6sSAi3OGVE3HxzkUEtAat0AgKXFN76gcOD4ARJV0 quatVEKqONA6aH+4SYzlpbEtNKSSD/QONPAp92pcdR94Uy5CBSlNrUd/5mvHKtJmuq2z AixQ== ARC-Authentication-Results: i=1; mx.google.com; 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 o5si12668601pfi.22.2019.02.26.03.19.13; Tue, 26 Feb 2019 03:19:28 -0800 (PST) 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; 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 S1727663AbfBZLSt (ORCPT + 99 others); Tue, 26 Feb 2019 06:18:49 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:36210 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726194AbfBZLSt (ORCPT ); Tue, 26 Feb 2019 06:18:49 -0500 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 9E33340D3053976F4C99; Tue, 26 Feb 2019 19:18:46 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.408.0; Tue, 26 Feb 2019 19:18:41 +0800 From: zhong jiang To: , CC: , , , , Subject: [PATCH] mm: hwpoison: fix thp split handing in soft_offline_in_use_page() Date: Tue, 26 Feb 2019 19:18:00 +0800 Message-ID: <1551179880-65331-1-git-send-email-zhongjiang@huawei.com> X-Mailer: git-send-email 1.7.12.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: zhongjiang When soft_offline_in_use_page() runs on a thp tail page after pmd is plit, 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(). Cc: [4.5+] Signed-off-by: zhongjiang --- mm/memory-failure.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index d9b8a24..6edc6db 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1823,19 +1823,17 @@ static int soft_offline_in_use_page(struct page *page, int flags) 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); } /* -- 1.7.12.4