From patchwork Wed Apr 27 04:28:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 12828279 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 DD987C433F5 for ; Wed, 27 Apr 2022 04:29:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 72E566B007B; Wed, 27 Apr 2022 00:29:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6B42C6B007D; Wed, 27 Apr 2022 00:29:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 52E316B007E; Wed, 27 Apr 2022 00:29:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.27]) by kanga.kvack.org (Postfix) with ESMTP id 3E74E6B007B for ; Wed, 27 Apr 2022 00:29:07 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id 1B4C11216BB for ; Wed, 27 Apr 2022 04:29:07 +0000 (UTC) X-FDA: 79401379134.18.57BEFF2 Received: from out2.migadu.com (out2.migadu.com [188.165.223.204]) by imf14.hostedemail.com (Postfix) with ESMTP id 8856110004D for ; Wed, 27 Apr 2022 04:29:05 +0000 (UTC) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1651033745; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7e1Yfv3+WJ1fxThypP2QZLDZeirFxR4HqHmaF3bZjlA=; b=aUCORwS68E5McyVQBtJuE1xfpGbKspsKYsA73An8M7dgGg2jXwmKaxOfBHK+vTh+Ybuqhm RbYaDMhrg8Ct30WsJQL40gpZQwRucwVZpbA7tc/YJM5KcxB8RJas6h7m2r4YWw5haVrxkp PhWnKc6fmlZthsdkoh80jU3Mjzcbvys= From: Naoya Horiguchi To: linux-mm@kvack.org Cc: Andrew Morton , Miaohe Lin , David Hildenbrand , Mike Kravetz , Yang Shi , Oscar Salvador , Muchun Song , Naoya Horiguchi , linux-kernel@vger.kernel.org Subject: [RFC PATCH v1 3/4] mm, hwpoison: add parameter unpoison to get_hwpoison_huge_page() Date: Wed, 27 Apr 2022 13:28:40 +0900 Message-Id: <20220427042841.678351-4-naoya.horiguchi@linux.dev> In-Reply-To: <20220427042841.678351-1-naoya.horiguchi@linux.dev> References: <20220427042841.678351-1-naoya.horiguchi@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev X-Stat-Signature: qhhpb1t894qx53ta1w78pbwwo7mbxo3x Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=aUCORwS6; spf=pass (imf14.hostedemail.com: domain of naoya.horiguchi@linux.dev designates 188.165.223.204 as permitted sender) smtp.mailfrom=naoya.horiguchi@linux.dev; dmarc=pass (policy=none) header.from=linux.dev X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 8856110004D X-HE-Tag: 1651033745-28892 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: From: Naoya Horiguchi Now hwpoisoned hugepage is expected to be !HPageMigratable, so grabbing hugepage for unpoison should negate the check from that for poisoning. This patch implements it by logical XOR. Signed-off-by: Naoya Horiguchi --- include/linux/hugetlb.h | 5 +++-- mm/hugetlb.c | 4 ++-- mm/memory-failure.c | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index 689e69cb556b..99b7ded651f6 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -171,7 +171,7 @@ bool hugetlb_reserve_pages(struct inode *inode, long from, long to, long hugetlb_unreserve_pages(struct inode *inode, long start, long end, long freed); bool isolate_huge_page(struct page *page, struct list_head *list); -int get_hwpoison_huge_page(struct page *page, bool *hugetlb); +int get_hwpoison_huge_page(struct page *page, bool *hugetlb, bool unpoison); int get_huge_page_for_hwpoison(unsigned long pfn, int flags); void putback_active_hugepage(struct page *page); void move_hugetlb_state(struct page *oldpage, struct page *newpage, int reason); @@ -377,7 +377,8 @@ static inline bool isolate_huge_page(struct page *page, struct list_head *list) return false; } -static inline int get_hwpoison_huge_page(struct page *page, bool *hugetlb) +static inline int get_hwpoison_huge_page(struct page *page, bool *hugetlb, + bool unpoison) { return 0; } diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 95b1db852ca9..0fbdfa753b54 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -6788,7 +6788,7 @@ bool isolate_huge_page(struct page *page, struct list_head *list) return ret; } -int get_hwpoison_huge_page(struct page *page, bool *hugetlb) +int get_hwpoison_huge_page(struct page *page, bool *hugetlb, bool unpoison) { int ret = 0; @@ -6798,7 +6798,7 @@ int get_hwpoison_huge_page(struct page *page, bool *hugetlb) *hugetlb = true; if (HPageFreed(page)) ret = 0; - else if (HPageMigratable(page)) + else if (!unpoison != !HPageMigratable(page)) ret = get_page_unless_zero(page); else ret = -EBUSY; diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 4a2e22bf0983..b5ee3cbc7fbc 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1190,7 +1190,7 @@ static int __get_hwpoison_page(struct page *page, unsigned long flags) int ret = 0; bool hugetlb = false; - ret = get_hwpoison_huge_page(head, &hugetlb); + ret = get_hwpoison_huge_page(head, &hugetlb, false); if (hugetlb) return ret; @@ -1283,7 +1283,7 @@ static int __get_unpoison_page(struct page *page) int ret = 0; bool hugetlb = false; - ret = get_hwpoison_huge_page(head, &hugetlb); + ret = get_hwpoison_huge_page(head, &hugetlb, true); if (hugetlb) return ret;