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 DD50CC19F29 for ; Thu, 4 Aug 2022 02:08:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 44D768E0006; Wed, 3 Aug 2022 22:08:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3D4D88E0001; Wed, 3 Aug 2022 22:08:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 24E678E0006; Wed, 3 Aug 2022 22:08:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 127728E0001 for ; Wed, 3 Aug 2022 22:08:40 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id D60901A12C7 for ; Thu, 4 Aug 2022 02:08:39 +0000 (UTC) X-FDA: 79760276358.05.31BCAC7 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf06.hostedemail.com (Postfix) with ESMTP id 1ABF5180007 for ; Thu, 4 Aug 2022 02:08:37 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.55]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4LysYb6ZGmzTgY3; Thu, 4 Aug 2022 10:07:15 +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; Thu, 4 Aug 2022 10:08:33 +0800 Subject: Re: [PATCH] mm, hwpoison, hugetlb: Free hwpoison huge page to list tail and dissolve hwpoison huge page first To: Mike Kravetz , luofei CC: Naoya Horiguchi , , , , References: <20220802100711.2425644-1-luofei@unicloud.com> From: Miaohe Lin Message-ID: <1191d45b-fece-659b-1dd1-8cf4ce89c2f1@huawei.com> Date: Thu, 4 Aug 2022 10:08:33 +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: 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-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1659578918; 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=5hMUKcX83ZQin3Mk/yuqh+syzlg5VGLdzkb2OXH0JOE=; b=7q/o+mWFXbUnokWY8hPBlV4tfzgS9PhZf5blhW4Xp2wlke1UNbgpeGlqWiKX9nQ30lJofN c7dh0/Or7j0b/f0sdGcPboM13Yiy7Fi04hi3+OMHOPBpZ9qELKAg3dVXtzMG/5c85umZwB XhAe6ybFMjALB8ksxuTkyWR2BRoHX/0= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf06.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1659578918; a=rsa-sha256; cv=none; b=cd/++qBjIEDKY5aG5QyNUOOg28aXDW4Xz5X0hl1dy4R40HzsFCU4sYXhQhenqj46BlVYmj G250WsMZ4XwIzBtG0Kqk5CX1M/lj76v7yPMccn/H7PNaa1CffbRwlkOLlpltD+7u6H+/6L 9fRIMMpXgsUi78UIjhd800VP+ujMDRQ= X-Stat-Signature: k4jmontp3pho5q4xu9kc6yh3h11kon6d X-Rspamd-Queue-Id: 1ABF5180007 X-Rspamd-Server: rspam01 Authentication-Results: imf06.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf06.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Rspam-User: X-HE-Tag: 1659578917-364641 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/8/3 0:58, Mike Kravetz wrote: > On 08/02/22 06:07, luofei wrote: >> If free hwpoison huge page to the end of hugepage_freelists, the >> loop can exit directly when the hwpoison huge page is traversed, >> which can effectively reduce the repeated traversal of the hwpoison >> huge page. Meanwhile, when free the free huge pages to lower level >> allocators, if hwpoison ones are released first, this can improve >> the effecvive utilization rate of huge page. > > In general, I think this is a good idea. Although, it seems that with > recent changes to hugetlb poisioning code we are even less likely to > have a poisioned page on hugetlb free lists. > > Adding Naoya and Miaohe as they have been looking at page poison of hugetlb > pages recently. > >> Signed-off-by: luofei >> --- >> mm/hugetlb.c | 13 ++++++++----- >> 1 file changed, 8 insertions(+), 5 deletions(-) >> >> diff --git a/mm/hugetlb.c b/mm/hugetlb.c >> index 28516881a1b2..ca72220eedd9 100644 >> --- a/mm/hugetlb.c >> +++ b/mm/hugetlb.c >> @@ -1116,7 +1116,10 @@ static void enqueue_huge_page(struct hstate *h, struct page *page) >> lockdep_assert_held(&hugetlb_lock); >> VM_BUG_ON_PAGE(page_count(page), page); >> >> - list_move(&page->lru, &h->hugepage_freelists[nid]); >> + if (unlikely(PageHWPoison(page))) >> + list_move_tail(&page->lru, &h->hugepage_freelists[nid]); >> + else >> + list_move(&page->lru, &h->hugepage_freelists[nid]); >> h->free_huge_pages++; >> h->free_huge_pages_node[nid]++; >> SetHPageFreed(page); >> @@ -1133,7 +1136,7 @@ static struct page *dequeue_huge_page_node_exact(struct hstate *h, int nid) >> continue; >> >> if (PageHWPoison(page)) >> - continue; >> + break; > > IIRC, it is 'possible' to unpoison a page via the debug/testing interfaces. > If so, then we could end up with free unpoisioned page(s) at the end of > the list that would never be used because we quit when encountering a > poisioned page. IIUC, above scene will actually happen. What's more, dissolve_free_huge_page might fail after hugetlb page is hwpoisoned due to e.g. all hugetlb pages are reserved. In that case, the hwpoisoned hugetlb page is not moved to the tail of hugepage_freelists and thus cause problems. Thanks both. > > Naoya and Miaohe would know for sure. > > Same possible issue in demote_pool_huge_page(). >