From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1D5CFC433EF for ; Mon, 27 Jun 2022 12:24:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A32C76B0071; Mon, 27 Jun 2022 08:24:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9E0F28E0001; Mon, 27 Jun 2022 08:24:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8D1276B0073; Mon, 27 Jun 2022 08:24:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 7E35F6B0071 for ; Mon, 27 Jun 2022 08:24:18 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 4F90A34F91 for ; Mon, 27 Jun 2022 12:24:18 +0000 (UTC) X-FDA: 79623933396.18.39DC6DF Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf22.hostedemail.com (Postfix) with ESMTP id D232CC0015 for ; Mon, 27 Jun 2022 12:24:16 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4LWn2B6f5Cz9swb; Mon, 27 Jun 2022 20:23:30 +0800 (CST) Received: from [10.174.177.76] (10.174.177.76) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 27 Jun 2022 20:24:09 +0800 Subject: Re: [PATCH v2 8/9] mm, hwpoison: skip raw hwpoison page in freeing 1GB hugepage To: Naoya Horiguchi , CC: Andrew Morton , David Hildenbrand , Mike Kravetz , Liu Shixin , Yang Shi , Oscar Salvador , Muchun Song , Naoya Horiguchi , References: <20220623235153.2623702-1-naoya.horiguchi@linux.dev> <20220623235153.2623702-9-naoya.horiguchi@linux.dev> From: Miaohe Lin Message-ID: Date: Mon, 27 Jun 2022 20:24:08 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <20220623235153.2623702-9-naoya.horiguchi@linux.dev> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.177.76] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=none; spf=pass (imf22.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656332657; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dwaacyKFq4NUVWxPpxKlJGDmXH040UMnM9BbeHJr3i4=; b=mKVNkFaOMfvIRw7SwKm1qNQrzrCiFmNpoD6G+oXbQbo70561voSZw9NDrg28/4LM8i5Kar ZO+iuhuUpPFJ5lTtgSXgm/aoA9LUPPfJkh3JfYx9YKDXEpnpt26EHZCt4nNVlhehOyGTEA Wo+rm4N3ndmBh1AIg/YzeOPspbhf0yk= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656332657; a=rsa-sha256; cv=none; b=Ak7SapUgrCJiWi8W+FzcUOajdX3L8wBxHFiyWGKUDIR87OCFXTGa6iAkRG70yug9fzV9Le WKpfUODZ9E3Cx7EZSy/CuhsTuWghl3BxRtDP95xvmBJhdZFL0FPq2hXlqvf2mOoTmJntIu C521aikOqtvf2AI8BaGLXdPaejGMbZQ= X-Stat-Signature: 97mw9afz1o74c3yzeciuey6sy37mwm39 X-Rspamd-Queue-Id: D232CC0015 X-Rspam-User: Authentication-Results: imf22.hostedemail.com; dkim=none; spf=pass (imf22.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Rspamd-Server: rspam02 X-HE-Tag: 1656332656-322864 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: On 2022/6/24 7:51, Naoya Horiguchi wrote: > From: Naoya Horiguchi > > Currently if memory_failure() (modified to remove blocking code with > subsequent patch) is called on a page in some 1GB hugepage, memory error > handling fails and the raw error page gets into leaked state. The impact > is small in production systems (just leaked single 4kB page), but this > limits the testability because unpoison doesn't work for it. > We can no longer create 1GB hugepage on the 1GB physical address range > with such leaked pages, that's not useful when testing on small systems. > > When a hwpoison page in a 1GB hugepage is handled, it's caught by the > PageHWPoison check in free_pages_prepare() because the 1GB hugepage is > broken down into raw error pages before coming to this point: > > if (unlikely(PageHWPoison(page)) && !order) { > ... > return false; > } > > Then, the page is not sent to buddy and the page refcount is left 0. > > Originally this check is supposed to work when the error page is freed from > page_handle_poison() (that is called from soft-offline), but now we are > opening another path to call it, so the callers of __page_handle_poison() > need to handle the case by considering the return value 0 as success. Then > page refcount for hwpoison is properly incremented so unpoison works. > > Signed-off-by: Naoya Horiguchi It seems I misunderstand the commit log in [1]. But I hope I get the point this time. :) Reviewed-by: Miaohe Lin Thanks! [1]https://lore.kernel.org/linux-mm/19981830-a5e6-bdba-4a1c-1cdcea61b93b@huawei.com/ > --- > mm/memory-failure.c | 9 ++++++--- > 1 file changed, 6 insertions(+), 3 deletions(-) > > diff --git a/mm/memory-failure.c b/mm/memory-failure.c > index db85f644a1e3..fc7b83cb6468 100644 > --- a/mm/memory-failure.c > +++ b/mm/memory-failure.c > @@ -1046,7 +1046,6 @@ static int me_huge_page(struct page_state *ps, struct page *p) > res = truncate_error_page(hpage, page_to_pfn(p), mapping); > unlock_page(hpage); > } else { > - res = MF_FAILED; > unlock_page(hpage); > /* > * migration entry prevents later access on error hugepage, > @@ -1054,9 +1053,11 @@ static int me_huge_page(struct page_state *ps, struct page *p) > * subpages. > */ > put_page(hpage); > - if (__page_handle_poison(p) > 0) { > + if (__page_handle_poison(p) >= 0) { > page_ref_inc(p); > res = MF_RECOVERED; > + } else { > + res = MF_FAILED; > } > } > > @@ -1704,9 +1705,11 @@ static int try_memory_failure_hugetlb(unsigned long pfn, int flags, int *hugetlb > */ > if (res == 0) { > unlock_page(head); > - if (__page_handle_poison(p) > 0) { > + if (__page_handle_poison(p) >= 0) { > page_ref_inc(p); > res = MF_RECOVERED; > + } else { > + res = MF_FAILED; > } > action_result(pfn, MF_MSG_FREE_HUGE, res); > return res == MF_RECOVERED ? 0 : -EBUSY; >