Message ID | 20230707201904.953262-2-jiaqiyan@google.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp3524189vqx; Fri, 7 Jul 2023 13:33:40 -0700 (PDT) X-Google-Smtp-Source: APBJJlHN5qjdDpykPRhPlRcKQeYt5xoOA5FNbRK/ptFL0iBIogF2eg1nRGSblDzaPsFHYE+/jmiX X-Received: by 2002:a17:90a:a613:b0:263:a966:7a75 with SMTP id c19-20020a17090aa61300b00263a9667a75mr4239780pjq.49.1688762020193; Fri, 07 Jul 2023 13:33:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688762020; cv=none; d=google.com; s=arc-20160816; b=hjyGOgbX4ZDo+eH/PJqyGGdbBw4furHr6Cc28W4cUghnNhoG3ZzpxlwyEJO3Oq7amk DTUH2vJpmhwiMhBr8lCDi3tdtiZw0QZt3CNTNppdE0c9Ytllu3BVeK9gcRgtmbQVywgZ rxtJOUTGgSK4DvKplrnImMkQ2lRFjmj4KS1X1jy/nqgZzrFtXxU5pDKu846OuP9Ac2Vk qPKFn6KPyUILDjM+KLJ0ThQXxqgDf6RxCdUoE7l1clRAK6hAVsHOW1Zg6HPsTln7GehF MEenYJFWYALXnhyi/ucyBHc2wQ64G7pV4SRwCwUySzETEJgOF8UnDdiPuoKcnXuB9Ene ifbQ== 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=8FNetjBnnWs4aWcoESXEPv5EQNod9M4H8ra/lwVlWng=; fh=dXuKmv+n+4RrXbgVwL2QlK4VwZMBf3WumGals2t2WtM=; b=ofmSEb250iAp8RFCFqvLnZvlwvpjPiATMPFy08YS8+S4X9dKsjCFOo4Qzt0iv45Yyv HtdFdhUA06EglEr4ScM9fLctSaSC3aC/aNh3LXKW9uSJIUxGgMkpld832RIrxzbkS/C3 ePV02qJZzNpPdpfKkDn5S9zKyptdS5N1vUAVOa5PJWbnJnp4f64pwka0vLauTGcOYzYi zx9ZnP1y1GJEXQLEd94M4sNMVD6xuNXhaB+md+Wbd5AobAGF253MKBaDZQLXH3a0hq18 gAQqSz6yoB6GMVaBntuH2cZuwvCsufz5F1BnQOrKKPoZdt05sNrKf902N289LPMtZwxU LA4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=VqyQmTQk; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l6-20020a17090a598600b0024e5ed38294si2728866pji.66.2023.07.07.13.33.26; Fri, 07 Jul 2023 13:33:40 -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=VqyQmTQk; 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 S232747AbjGGUTZ (ORCPT <rfc822;tebrre53rla2o@gmail.com> + 99 others); Fri, 7 Jul 2023 16:19:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232740AbjGGUTU (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 7 Jul 2023 16:19:20 -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 C01382114 for <linux-kernel@vger.kernel.org>; Fri, 7 Jul 2023 13:19:16 -0700 (PDT) Received: by mail-pl1-x64a.google.com with SMTP id d9443c01a7336-1b8130aceefso30900095ad.2 for <linux-kernel@vger.kernel.org>; Fri, 07 Jul 2023 13:19:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1688761156; x=1691353156; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=8FNetjBnnWs4aWcoESXEPv5EQNod9M4H8ra/lwVlWng=; b=VqyQmTQkCzL2+2WReICnzA6BIm0pcsZl2UxgOC96YeMxOiWjK9NhMMsd6sh9vgNsyp l48aVL+YSen8q6QehXxVJmNvqqI169EdhdJF1wP18IrISpvNJpDmE8qvdh8iCozeWtb6 JHgOCmY5zsqIie6UwoBTIJKIq84brRDTo5Ou4o4qfUOH/nsVpBgCFa70jcSCS8JQjRGc YPkr1zj/Al/4tkKYO5OxobtQsE4XPWag4pb/fMTB6fXhhvDh+IoKStTY4VGEtEBkAolL +GRm79XEsc5P3ls1k+A19D7pSp5BkV+9M69nyu7mjSupo4UAMKBhqh3ZJivJ7t7YjP3Z tU8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688761156; x=1691353156; 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=8FNetjBnnWs4aWcoESXEPv5EQNod9M4H8ra/lwVlWng=; b=VpV0Qg/ynk+7W2KX8qdFPvY1s1EMr4qx7aNSKou0Pf3Q9hUO3ZtI1lvPATg/jcI+iP ZMvBunc6qKVx+uKdmGS8z2ni7Z5sVyc34rtAgQxCpRKD5O5FbiujJWjZhnHbaBExYGDr MB5GaOBPrl3CJ0Sbnk0WQKd95CQ+sVoE4ogLBN7fbWAMGrB4gh67/CnQBsQevhGwnTtB kclM1NkA0HHWG7CtDjdVKOTZKdOaMRDoQHiN+eJHRA4HXS9qZ3rGDxwPHKoxETYJ6XX2 xCpqxYObfefOE47FrqrURMjCpASsYEYZapuc7A+wE2kLGVcwFtWioxMN7tO6GNiarWzj GIDQ== X-Gm-Message-State: ABy/qLYoHPihWsJupAghCCLQmRZxTIv6ZeZ7b0nzEvr8Rt9xS8IioGaf 3sslkk4f0eyVunuZRGg8/BM+GFPsNkm3Hg== X-Received: from yjq3.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:272f]) (user=jiaqiyan job=sendgmr) by 2002:a17:902:ec88:b0:1b7:fa05:e0c7 with SMTP id x8-20020a170902ec8800b001b7fa05e0c7mr5745441plg.13.1688761156325; Fri, 07 Jul 2023 13:19:16 -0700 (PDT) Date: Fri, 7 Jul 2023 20:19:01 +0000 In-Reply-To: <20230707201904.953262-1-jiaqiyan@google.com> Mime-Version: 1.0 References: <20230707201904.953262-1-jiaqiyan@google.com> X-Mailer: git-send-email 2.41.0.255.g8b1d071c50-goog Message-ID: <20230707201904.953262-2-jiaqiyan@google.com> Subject: [PATCH v3 1/4] mm/hwpoison: delete all entries before traversal in __folio_free_raw_hwp From: Jiaqi Yan <jiaqiyan@google.com> To: akpm@linux-foundation.org, mike.kravetz@oracle.com, naoya.horiguchi@nec.com Cc: songmuchun@bytedance.com, shy828301@gmail.com, linmiaohe@huawei.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, duenwen@google.com, axelrasmussen@google.com, jthoughton@google.com, Jiaqi Yan <jiaqiyan@google.com> 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770795324215715821?= X-GMAIL-MSGID: =?utf-8?q?1770795324215715821?= |
Series |
Improve hugetlbfs read on HWPOISON hugepages
|
|
Commit Message
Jiaqi Yan
July 7, 2023, 8:19 p.m. UTC
Traversal on llist (e.g. llist_for_each_safe) is only safe AFTER entries are deleted from the llist. Correct the way __folio_free_raw_hwp deletes and frees raw_hwp_page entries in raw_hwp_list: first llist_del_all, then kfree within llist_for_each_safe. As of today, concurrent adding, deleting, and traversal on raw_hwp_list from hugetlb.c and/or memory-failure.c are fine with each other. Note this is guaranteed partly by the lock-free nature of llist, and partly by holding hugetlb_lock and/or mf_mutex. For example, as llist_del_all is lock-free with itself, folio_clear_hugetlb_hwpoison()s from __update_and_free_hugetlb_folio and memory_failure won't need explicit locking when freeing the raw_hwp_list. New code that manipulates raw_hwp_list must be careful to ensure the concurrency correctness. Acked-by: Mike Kravetz <mike.kravetz@oracle.com> Acked-by: Naoya Horiguchi <naoya.horiguchi@nec.com> Signed-off-by: Jiaqi Yan <jiaqiyan@google.com> --- mm/memory-failure.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/mm/memory-failure.c b/mm/memory-failure.c index e245191e6b04..a08677dcf953 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1829,12 +1829,11 @@ static inline struct llist_head *raw_hwp_list_head(struct folio *folio) static unsigned long __folio_free_raw_hwp(struct folio *folio, bool move_flag) { - struct llist_head *head; - struct llist_node *t, *tnode; + struct llist_node *t, *tnode, *head; unsigned long count = 0; - head = raw_hwp_list_head(folio); - llist_for_each_safe(tnode, t, head->first) { + head = llist_del_all(raw_hwp_list_head(folio)); + llist_for_each_safe(tnode, t, head) { struct raw_hwp_page *p = container_of(tnode, struct raw_hwp_page, node); if (move_flag) @@ -1844,7 +1843,6 @@ static unsigned long __folio_free_raw_hwp(struct folio *folio, bool move_flag) kfree(p); count++; } - llist_del_all(head); return count; }