Received: by 2002:ac0:8845:0:0:0:0:0 with SMTP id g63csp589607img; Tue, 26 Feb 2019 05:26:44 -0800 (PST) X-Google-Smtp-Source: AHgI3IayzU4eVHbKMGSEJqeS97ZOEePLQ1/pylGENlmQwm86IyaS0DzDRu8ovI/7LpZaj2P/WNRC X-Received: by 2002:a17:902:380c:: with SMTP id l12mr25758310plc.326.1551187604397; Tue, 26 Feb 2019 05:26:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551187604; cv=none; d=google.com; s=arc-20160816; b=KG3djWgbGWUSOcl8cVpQld6lPD9deZPNoAyO6jrfvM1QTGX/+jcxc0VuutuTAe3AuW S8NnK441kqiqkYWixbpYVY6HV1e34WzV6Bh+kXpeNrCyjbSjH/z1Nb/6e1YYOjt+v4+M HCSuS4oZnUJhERU9oBPAA0xwj1wDiSODrcFtuF92l+BJHcE59iO0iMY0J0YvjJbYFQmi mUVdq2MEzg+Xf4rF52NND4CS87+apznnGcDoJCcn8Qqs68EvpxUIAOCz5zweFNv2bBJj OuVbgKbXRgfktyPHsFgLPIg+6YliG9ms9xaBSQmhZt0vU+D/cNT3y/FqZv1owlBzwkhC j/1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=KPbIIVxQ2UyzAFO6IzPSI+9d4ATJf7SWXlpnkYUXrQM=; b=V2sgPUtrNjT8fVt9Ci+PkbDKMr9Dve/TgL0qhKt7lWK2jKK2TUrejsqQ5Dl1xjX3Ab 49MpWe355cnOgebLMjqu+RY5PsqQBi/+dxZsJFyqAn38wpuVljYJPW/JRxaAvHR4xLVF F1pWhsQHyfOG5C1HU2CebLjVPJNX3fWZraD64UKKT3gJdBk5EI0SWkw0w9tqBJ2Di9yx dVHLZ7+PiwQ7QJy8UzGp78Vg7xeEofrD7iVSoPY1TM+JCWYBAzGMl8pCkMgPH+EYy9OM twzAd3LFrU0z5GLSC1A/DR1m1gS6cS1dPCRWeN98O/FBhEvq/HWusGI3kzGJwvnVXJyu aolg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 61si12519205plc.364.2019.02.26.05.26.28; Tue, 26 Feb 2019 05:26:44 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726810AbfBZNZp (ORCPT + 99 others); Tue, 26 Feb 2019 08:25:45 -0500 Received: from mx2.suse.de ([195.135.220.15]:50008 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725954AbfBZNZo (ORCPT ); Tue, 26 Feb 2019 08:25:44 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 87974ACB7; Tue, 26 Feb 2019 13:25:43 +0000 (UTC) Date: Tue, 26 Feb 2019 14:25:42 +0100 From: Michal Hocko To: zhong jiang Cc: n-horiguchi@ah.jp.nec.com, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, hughd@google.com, "Kirill A. Shutemov" Subject: Re: [PATCH] mm: hwpoison: fix thp split handing in soft_offline_in_use_page() Message-ID: <20190226132542.GB10588@dhcp22.suse.cz> References: <1551179880-65331-1-git-send-email-zhongjiang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1551179880-65331-1-git-send-email-zhongjiang@huawei.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [Cc Kirril for the THP side] On Tue 26-02-19 19:18:00, zhong jiang wrote: > 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 > -- Michal Hocko SUSE Labs