Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4429074ioa; Wed, 27 Apr 2022 03:47:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxZI1NFlQSZntjAb/6f3U0H6+4IwxYFgBvEAL8VebOJkjInd1ssoIDBr3QAX57BYlrIiSln X-Received: by 2002:a63:2209:0:b0:3ab:113b:9a2b with SMTP id i9-20020a632209000000b003ab113b9a2bmr16169637pgi.235.1651056459138; Wed, 27 Apr 2022 03:47:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651056459; cv=none; d=google.com; s=arc-20160816; b=cAEnk27I7L/OqeQzngVUClfl+lAcb6OIhzhnrGFhY0KKVwlHHjEeF54Q32jkd01iii HUsxTWj74o1ck7JkLKzPe/wU/XJlsovD4yodGrj4WtzWv0s6oH5V6hBUCQNOFKnENvmj EPd0ZSbKIr7/CmJNDpRgO+J3kWLUSHDC9F0Ti9ULTuPoZdZWuP6ZoA5dp0BnFpU0U+aG jSMmOjxc81OPOQByYgPRkTzoyETj8sq23twGj37DjIga2rsNJF5Sh/ysNyNgEnKTF72S aqvP024KJ8n/Yw8M8/H7TaGA2DGFuP8/vSNIeAp8e3AWYhCbcnUn+mtbo3/hSfW1IiB3 2GzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7e1Yfv3+WJ1fxThypP2QZLDZeirFxR4HqHmaF3bZjlA=; b=di/uEX9K2LWjvLHGxNNPkb2Nrc3H97Kt/iO9FwwmsZN62aw6IoOHgP3ogiaCzhhvLV +pE6YQqLn7puZnNniAhqJ3T+neuMkJWw7TUIG4d33gduA3yFYpGIqBnIfetTag8xdwZC 7M4aGVF1wg4eJyZnrR7P/udYV9PWcO4Xxb8EZVtmL381aLUzaSYnKbPQ5xBS99UzjJKl eaXAV36V+A1aDwLM0IBUj1kCaPx2/ocmbJYK5KNdJo0lrPy+LGBxIu6qoXNEN87+bSZn vWy5W4EnBDkOBE7vAA+hC4JX/+MpnnX+v9MqfH3+9epBNflfMqmdv00wBXE6hxaeV5H1 OwSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=aUCORwS6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id g21-20020a056a000b9500b0050a96ba4e5esi1181318pfj.290.2022.04.27.03.47.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 03:47:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=aUCORwS6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2DC7D40D0F9; Wed, 27 Apr 2022 02:54:55 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357675AbiD0Ec2 (ORCPT + 99 others); Wed, 27 Apr 2022 00:32:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357694AbiD0EcW (ORCPT ); Wed, 27 Apr 2022 00:32:22 -0400 Received: from out2.migadu.com (out2.migadu.com [188.165.223.204]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB159156E03 for ; Tue, 26 Apr 2022 21:29:06 -0700 (PDT) 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 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; -- 2.25.1