From patchwork Mon Aug 7 11:41:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 131906 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp1412611vqr; Mon, 7 Aug 2023 05:30:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFTOBmQWhqifR+IONGHRAGMVsCueWuE/vesY1H1Jpo9DFTFwgcgM92nCP76ClbDn2rnMi1Y X-Received: by 2002:a17:906:9bec:b0:99c:3bb:fd96 with SMTP id de44-20020a1709069bec00b0099c03bbfd96mr8717406ejc.52.1691411429538; Mon, 07 Aug 2023 05:30:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691411429; cv=none; d=google.com; s=arc-20160816; b=jDxFBMZpmni4ibVMyERYwl0Nac9BKuxZTTBVWWBiYozvX1+D7DRNK9QdVpxCCq9vu7 X4KKLO6FGj86DeCGYGe46Ph7GfQW2KC6is1+xk62ulTnBzQmokcoQ4XFwgFZk0B1UjGT ADDQged53pfyaZxL0onbTAYfSdyYLPMwtesS60MRF9MQeW8S88BwRlmjaCV3AyWAA+8B TNLBeDdHzeCvblbddQIH53+TjHMouSxemqcpVpNsbrRFrIfY675HR3TTL//mwLXHNeFj AfO40vAkiu2+ncezSuJTScFvR1OungrIzb3cLSmG5cbzTS4Z/AG/GU6cty3Xf1puoZKI UI+w== 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 :message-id:date:subject:cc:to:from; bh=7aRqB+UgAaTNdvIIPrrK/ZPlcLRwbB8T/HcLV3ADVps=; fh=4o7DIXI/66oHEW09L3854GeQKXh9nrvBy5ZxENMFBvA=; b=qHej6ewONbFbd/K3cp1GW/ffqjf/ejwSjQCS4TowaItA5jOndxjklqQDKU8VhUpx6P N93gvEcusqozj3g9mSyR6mBnI/p8cl7rlqVaSnZ4Y8QMctzOzeDEWgaY509604VoRkyx SMVZejvA7lc3jN2H92vwuUCmWFn4qxQANOqibqplor2Qjaiwa0IiMcZ07s4ZXOmxqBId 0S8lkQlQjacEDvqnTUgJ6SzHD0++qpofTt/yOTXoaBerYR+u6HnudtupbyRYOWBKo6Lu aV3K7aRNGtZ4sc3wBpBmwbzt/MZa6ih7SO0mS+55F2/ghTv0u9UypfwB+VSdiLlyMqwQ JIjg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f17-20020a1709062c5100b00994936a6f11si5834681ejh.957.2023.08.07.05.30.05; Mon, 07 Aug 2023 05:30:29 -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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232991AbjHGLom (ORCPT + 99 others); Mon, 7 Aug 2023 07:44:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233139AbjHGLo2 (ORCPT ); Mon, 7 Aug 2023 07:44:28 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B38E210C for ; Mon, 7 Aug 2023 04:42:43 -0700 (PDT) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RKDph3QRhztRxT; Mon, 7 Aug 2023 19:38:20 +0800 (CST) Received: from huawei.com (10.174.151.185) 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.2507.27; Mon, 7 Aug 2023 19:41:47 +0800 From: Miaohe Lin To: , CC: , , Subject: [PATCH] mm: memory-failure: use helper macro llist_for_each_entry_safe() Date: Mon, 7 Aug 2023 19:41:25 +0800 Message-ID: <20230807114125.3440802-1-linmiaohe@huawei.com> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 X-Originating-IP: [10.174.151.185] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773573431232847395 X-GMAIL-MSGID: 1773573431232847395 It's more convenient to use helper macro llist_for_each_entry_safe(). No functional change intended. Signed-off-by: Miaohe Lin Acked-by: Naoya Horiguchi --- mm/memory-failure.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 6781bb0c5eb2..7b01fffe7a79 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1869,13 +1869,12 @@ bool is_raw_hwpoison_page_in_hugepage(struct page *page) static unsigned long __folio_free_raw_hwp(struct folio *folio, bool move_flag) { - struct llist_node *t, *tnode, *head; + struct llist_node *head; + struct raw_hwp_page *p, *next; unsigned long count = 0; 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); - + llist_for_each_entry_safe(p, next, head, node) { if (move_flag) SetPageHWPoison(p->page); else @@ -1890,7 +1889,7 @@ static int folio_set_hugetlb_hwpoison(struct folio *folio, struct page *page) { struct llist_head *head; struct raw_hwp_page *raw_hwp; - struct llist_node *t, *tnode; + struct raw_hwp_page *p, *next; int ret = folio_test_set_hwpoison(folio) ? -EHWPOISON : 0; /* @@ -1901,9 +1900,7 @@ static int folio_set_hugetlb_hwpoison(struct folio *folio, struct page *page) if (folio_test_hugetlb_raw_hwp_unreliable(folio)) return -EHWPOISON; head = raw_hwp_list_head(folio); - llist_for_each_safe(tnode, t, head->first) { - struct raw_hwp_page *p = container_of(tnode, struct raw_hwp_page, node); - + llist_for_each_entry_safe(p, next, head->first, node) { if (p->page == page) return -EHWPOISON; }