Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2392059rwd; Wed, 17 May 2023 09:17:39 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6oJFZvXSZhevhUzPBklylePj2c5Hu7Ew2xesmjwnIgFmuvtZsXSPxwAbG60SSs9xPod49F X-Received: by 2002:a05:6a00:21c2:b0:645:ac97:52a4 with SMTP id t2-20020a056a0021c200b00645ac9752a4mr369658pfj.8.1684340259141; Wed, 17 May 2023 09:17:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684340259; cv=none; d=google.com; s=arc-20160816; b=BacztGQm5JIfBtQm2jGwE8N3ANLcD3YSnibNckTqt1UckuiYP+JY30HgMC1xnBzD4L RkUfkqVNjQuoAbMJzni70haXqlxG/bgJkCH2MfT7Jna3xpC7CKlnDnNbEngTUWaxJYGh lJ8T11KdNsXutDiMxuPlsGuRd9KtX2wlDmmnidP7q+JzQGqbb0furNmlLqaY6yZpNRw4 p5adA49gqE2KgGyrrZhf7owmrCng/uaSye/iPDBpwju9b5vJjPdzUesX+s5A8NAO9YfV xdnPgZ+QKNvGx/lcqt9xaJA5oQ9xYKdNiT5KYZUCwIpzl2HVRJe0GlcHRCSvrwbWaswZ HC6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=woRAdaWYV8FD8vab19hJA4MPyBeuK73rImQoSJfr/I0=; b=HS6WYS77LvXVbJJssDPEaA01160yBD4Q+9X/Ckl0gLYhtpIdVwO99TRk8MafPhZq/8 eWc9NYdUeiJccb1K54oI+gA7Gooosgq//cXWVlwyAl7T8Yu15OM4z2P9k1G3uQDXC8p4 gs71yVD/Ch9FJjTHHW3Y6HWfKh4NNpDnlh4PYvPwi+hQybeNqG1/5P3VRtKHPAxp5Grg G5h0jhjzQvzZuyqlQ9tc+L1A5rcBTw3cQXLob5qxWQK6MGnOZ1yYu0H7jiQH4RkJ0zxL zSGeLBf3PuvNa1/bkf/oqo+6ZDr0whS3p3V1LLTKmT5mqlzFJSNz2Fp3+rOnRtPsnt99 UBzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b="YE1b/zym"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x29-20020aa7957d000000b0063b5875dd22si22108136pfq.308.2023.05.17.09.17.26; Wed, 17 May 2023 09:17:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b="YE1b/zym"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231866AbjEQQKH (ORCPT + 99 others); Wed, 17 May 2023 12:10:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231331AbjEQQKC (ORCPT ); Wed, 17 May 2023 12:10:02 -0400 Received: from mail-pl1-x64a.google.com (mail-pl1-x64a.google.com [IPv6:2607:f8b0:4864:20::64a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1D24268C for ; Wed, 17 May 2023 09:10:01 -0700 (PDT) Received: by mail-pl1-x64a.google.com with SMTP id d9443c01a7336-1ae515ff6a9so976625ad.0 for ; Wed, 17 May 2023 09:10:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1684339801; x=1686931801; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=woRAdaWYV8FD8vab19hJA4MPyBeuK73rImQoSJfr/I0=; b=YE1b/zymZ9vc5qJrU2yZ6Y6Sk4upJCBRZPNMxGSUkSJ4NmR9re5sc7FtxyFCA6op5Z NYFItdPqItmJDGSzZeWAH3tLZk1Wm8Afz5r3LdakqUg7OhhCWIIdGn7UMn0FZjneF7a+ bisIrHgG+Aut0UuT0TMLzqNQqD7aRu51rTrV0uDZzw1l+caeFdr0GilMHPWzBABPv15M X4eJsAFnhsiuhrdvQNPjyZTVUft46X+7oX5ruBdVoJ1jwWqEudjOGdVLWk0A5g6E9K6h emxl51IemdopSKTESt1Ud6k+QmEevHfSkIuOBN+uVG3cweipz2hw8QLMUNEJwvHVbkK9 kVdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684339801; x=1686931801; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=woRAdaWYV8FD8vab19hJA4MPyBeuK73rImQoSJfr/I0=; b=V7I39NxV/JDfIKRP7L5B8O6aKctKzU03tqiUZpReGw4Ttpwm2YMXKTDPvwReIitHAn bnvsvjKZITUUyDRtw4fJ1lZeD5KyzqWpN1Y2IQMU6zEY3XeLDmswGwfuzj5dGWdnWU/8 FKyolGnQB9LprcjQifwYdFwr3/xBYGt2/G24K76ysGTYw2LCyqEr5g3ZQlu2NnqwooMY C0lC7E4VUL5fHmXrvgbVo2LVdE4lscbihOgN0IgTkPe/tQTYEYWS+VyFVPQAIploebub ZzKMX1egvfOoxNc6+hdkkmQGVmRFUpMUmkO5+fsJPsVnskziBaY9bENrWvIyqyhFVez+ iTbw== X-Gm-Message-State: AC+VfDw8L3KXjrqtayPVq7bob6eEa65tn6rXr+QCVPFtMIuj+xFvPuas 7wDz9d3DP+kfa5f7jOkFi/92digLXIcCvA== X-Received: from yjq3.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:272f]) (user=jiaqiyan job=sendgmr) by 2002:a17:903:334f:b0:1ae:531f:366a with SMTP id ka15-20020a170903334f00b001ae531f366amr637380plb.5.1684339801269; Wed, 17 May 2023 09:10:01 -0700 (PDT) Date: Wed, 17 May 2023 16:09:46 +0000 In-Reply-To: <20230517160948.811355-1-jiaqiyan@google.com> Mime-Version: 1.0 References: <20230517160948.811355-1-jiaqiyan@google.com> X-Mailer: git-send-email 2.40.1.606.ga4b1b128d6-goog Message-ID: <20230517160948.811355-2-jiaqiyan@google.com> Subject: [PATCH v1 1/3] mm/hwpoison: find subpage in hugetlb HWPOISON list From: Jiaqi Yan To: mike.kravetz@oracle.com, songmuchun@bytedance.com, naoya.horiguchi@nec.com, shy828301@gmail.com, linmiaohe@huawei.com Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, duenwen@google.com, axelrasmussen@google.com, jthoughton@google.com, Jiaqi Yan Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=ham 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 Adds the functionality to search a subpage's corresponding raw_hwp_page in hugetlb page's HWPOISON list. This functionality can also tell if a subpage is a raw HWPOISON page. Exports this functionality to be immediately used in the read operation for hugetlbfs. Signed-off-by: Jiaqi Yan --- include/linux/mm.h | 23 +++++++++++++++++++++++ mm/memory-failure.c | 26 ++++++++++++++++---------- 2 files changed, 39 insertions(+), 10 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 27ce77080c79..f191a4119719 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3683,6 +3683,29 @@ enum mf_action_page_type { */ extern const struct attribute_group memory_failure_attr_group; +#ifdef CONFIG_HUGETLB_PAGE +/* + * Struct raw_hwp_page represents information about "raw error page", + * constructing singly linked list from ->_hugetlb_hwpoison field of folio. + */ +struct raw_hwp_page { + struct llist_node node; + struct page *page; +}; + +static inline struct llist_head *raw_hwp_list_head(struct folio *folio) +{ + return (struct llist_head *)&folio->_hugetlb_hwpoison; +} + +/* + * Given @subpage, a raw page in a hugepage, find its location in @folio's + * _hugetlb_hwpoison list. Return NULL if @subpage is not in the list. + */ +struct raw_hwp_page *find_raw_hwp_page(struct folio *folio, + struct page *subpage); +#endif + #if defined(CONFIG_TRANSPARENT_HUGEPAGE) || defined(CONFIG_HUGETLBFS) extern void clear_huge_page(struct page *page, unsigned long addr_hint, diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 5b663eca1f29..c49e6c2d1f07 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1818,18 +1818,24 @@ EXPORT_SYMBOL_GPL(mf_dax_kill_procs); #endif /* CONFIG_FS_DAX */ #ifdef CONFIG_HUGETLB_PAGE -/* - * Struct raw_hwp_page represents information about "raw error page", - * constructing singly linked list from ->_hugetlb_hwpoison field of folio. - */ -struct raw_hwp_page { - struct llist_node node; - struct page *page; -}; -static inline struct llist_head *raw_hwp_list_head(struct folio *folio) +struct raw_hwp_page *find_raw_hwp_page(struct folio *folio, + struct page *subpage) { - return (struct llist_head *)&folio->_hugetlb_hwpoison; + struct llist_node *t, *tnode; + struct llist_head *raw_hwp_head = raw_hwp_list_head(folio); + struct raw_hwp_page *hwp_page = NULL; + struct raw_hwp_page *p; + + llist_for_each_safe(tnode, t, raw_hwp_head->first) { + p = container_of(tnode, struct raw_hwp_page, node); + if (subpage == p->page) { + hwp_page = p; + break; + } + } + + return hwp_page; } static unsigned long __folio_free_raw_hwp(struct folio *folio, bool move_flag) -- 2.40.1.606.ga4b1b128d6-goog