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: 13344000 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 70506EB64DD for ; Mon, 7 Aug 2023 11:41:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 862EE6B0072; Mon, 7 Aug 2023 07:41:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 813858D0005; Mon, 7 Aug 2023 07:41:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 701C68D0003; Mon, 7 Aug 2023 07:41:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 63ECE6B0072 for ; Mon, 7 Aug 2023 07:41:56 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 104C41A0A7B for ; Mon, 7 Aug 2023 11:41:56 +0000 (UTC) X-FDA: 81097119432.21.37DD830 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf01.hostedemail.com (Postfix) with ESMTP id 1C88F40021 for ; Mon, 7 Aug 2023 11:41:51 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=none; spf=pass (imf01.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1691408513; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references; bh=7aRqB+UgAaTNdvIIPrrK/ZPlcLRwbB8T/HcLV3ADVps=; b=soxpheiw5AMjYYjM4EcVrzSB0/ykKxI3B5sF45EAm6DySr5F5m38SKz/zPWiWRwgErG71P 0l09qkfH10PuNXJG3puITB/22UcqJLRET0JPheP0ojq1KZlahPJakf9CCKZBcJPGxCUA5n zwzUReARLj3RMjbIQAAjdahOHkAYYow= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=none; spf=pass (imf01.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1691408513; a=rsa-sha256; cv=none; b=C4r9+4XBou5jwqFUAUWR92dZiapgUCtkv8h9XIasnu5mgQtUkX+UJLSC1qA+mu+lZJuR2R 1Yu26sSHbSn8grn42Zq2hHxxcaPAnXYA+xaMUFGnkoI5VuGMVUUGIpt3unXoD95sVh+dAe J8GFFJYgNipxu9Yc/XRdYalRMO8ydvo= 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-Rspamd-Queue-Id: 1C88F40021 X-Rspam-User: X-Stat-Signature: dc8mubnd9sid8myw5ndz5bqkd8fy7k1n X-Rspamd-Server: rspam01 X-HE-Tag: 1691408511-158402 X-HE-Meta: U2FsdGVkX19UNac26deRQjw6ImLlVkzeYDcq/aAZy7l7oDhHDUeNLDDKOq/4QW+etxtfw7WP7qWR39F1QPdVkZhfFTO3EosUQklyUzIWSAQCSyOS5ZnTh8Vhop3VTbjB1wqbBfYaOvV7l9gOJMiTGAbNBWeR13V5YProUVtP1g+OfiPJTDJ/R/J0beZ2kgsn6nVyu/RcYRwQHyM1GLuTlQIn6oGrNO+LVNz+4I265/SHO73b3JZtd0HuLjTbcp7eEvztCbZhQTs5aWjtNiUAWa5FAjOQeefnvwOidRt2T+C77CanLe+YY+mOD6ySOB1DAYoCzphOxfXdcxudtt6uFyEgy14rXnSS1U7DjbwLshQr/1RQ1Sp1uEY9ZD2PJlDGtGphmLy1fc31LG1kYfYr0PbYGPfa/c8DNX3x9+Orr+ne42YWy8FboV8/Jc3B0S0m1w3SIa0ltZKmDgGYBJ5JlJx/2vto7fHFSim5gdjgPWAP5SlRM4lWhaaKQ9Hm6GL0VGolCyoNZm6myScYPiXJohl6KjaVJluv+4+94EWVioSu5zyZf5PA/bjW+mOZ1gWEwtHGYSdWgzTi/BIPZKcA78QD3Bu+tXQzL7yzhsh2koRhiqQ3e0ORhw4LTuQBeOxXu/lwaCzrGAyrHnBxJwlNTZkAJh5kp0p9I3AdBiWRGcngkXWN4EAZs27qJlGJ1RZY8Z8HQhXpY039X0/kGpM58/Pl6cO2QTiA6OVfpBtCg64RkRYuFNOCMuez3v7dffaAMUR7QJmoskfL2Ix+kmkrFMomnoopCfupuY02jvWeW8ZIaon8aUKLCqeemmV8WNjATYdX1B0+PkNVP1uUZYumYi+Zqj+yiqou0uTAcgxZZr27hZlXyz6SEs6McpwESrJAKpDhW/rE6dicfZoySyr5930HeaIuWDthkzq5oYM4CiIzsDyDRAbveYtWEMCFpMuOe8ikw8I2P2ZNnYYr0A8 /lLZrlzB fq4hvAJSGOKW/R6JwZp22gvM8NNnpRVwhJE3pLiy+DahQIttpPrgn5OgLJXrOxZlzU4K1K3Ap3ZERFj50PCh9AbNv7fYxP3Fv//15Hmt+bK0OD+RStO0dznMSOhmm3ZT2NKwjEJyNcRUXQdRoKo7Zx4Kq89KBdNufc4UvA9N7wq2I00+IraBmbkv9RYbHXTR0mKSV 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: 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; }