From patchwork Mon Sep 9 06:17:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Song Chen X-Patchwork-Id: 13795916 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 79FBACD4F4C for ; Mon, 9 Sep 2024 06:17:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D4A0E6B0111; Mon, 9 Sep 2024 02:17:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CFA5C6B0112; Mon, 9 Sep 2024 02:17:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BE9286B0113; Mon, 9 Sep 2024 02:17:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id A2BC86B0111 for ; Mon, 9 Sep 2024 02:17:45 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id EB2A841DCC for ; Mon, 9 Sep 2024 06:17:44 +0000 (UTC) X-FDA: 82544193648.14.6FFE71D Received: from 189.cn (ptr.189.cn [183.61.185.101]) by imf21.hostedemail.com (Postfix) with ESMTP id C65971C000E for ; Mon, 9 Sep 2024 06:17:40 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=none; spf=pass (imf21.hostedemail.com: domain of chensong_2000@189.cn designates 183.61.185.101 as permitted sender) smtp.mailfrom=chensong_2000@189.cn; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725862561; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references; bh=F+aqMAMSIercueDlAVcS7Xpl3rthCwVKnHilXgXqvJ4=; b=v/xQ/lVhVvlHrOYWJRatF6RJ2kJaAUSwfNCVEvhRK7irENHxJJWSiPyDCfrtoMiRjv2q5b MNgTKVV0EBmBWXU2Ackf4fnJUUY31JpYFN4KKYBZnP19gFwUWXcQbCT77GHlL/i/7D1RDo 7MpV/0SxaPIK/UD8TFfb50j+wTI4luo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725862561; a=rsa-sha256; cv=none; b=IxLQOYHe3H+hzq1ym19Pkj75no0c3Xznf625bqJm+WSH6PFLXsBunI9yX5P9VnqPiEN+KY 0pcoTAiaIi7CDZbFJOsvhqLoKbn1R40jTg12kL6e2Z7OYbI8MNApetngMrR3jxyL+ZzHM0 FfXWFp7LSXfgu18MqxlYsKga+Cv0qkM= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=none; spf=pass (imf21.hostedemail.com: domain of chensong_2000@189.cn designates 183.61.185.101 as permitted sender) smtp.mailfrom=chensong_2000@189.cn; dmarc=none HMM_SOURCE_IP: 10.158.243.220:8405.744959442 HMM_ATTACHE_NUM: 0000 HMM_SOURCE_TYPE: SMTP Received: from clientip-123.150.8.42 (unknown [10.158.243.220]) by 189.cn (HERMES) with SMTP id E365C1002BE; Mon, 9 Sep 2024 14:17:37 +0800 (CST) Received: from ([123.150.8.42]) by gateway-153622-dep-68cfdf7599-nkmwn with ESMTP id e80b8439e6f344f8b2eb94403cb88e37 for willy@infradead.org; Mon, 09 Sep 2024 14:17:37 CST X-Transaction-ID: e80b8439e6f344f8b2eb94403cb88e37 X-Real-From: chensong_2000@189.cn X-Receive-IP: 123.150.8.42 X-MEDUSA-Status: 0 From: chensong_2000@189.cn To: willy@infradead.org, akpm@linux-foundation.org Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Song Chen Subject: [PATCH] mm/filemap: introduce local helper for_each_folio Date: Mon, 9 Sep 2024 14:17:35 +0800 Message-Id: <20240909061735.152421-1-chensong_2000@189.cn> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Stat-Signature: 3c3it4w3f3x94n97bpzrye73qypcbyyg X-Rspamd-Queue-Id: C65971C000E X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1725862660-812532 X-HE-Meta: U2FsdGVkX1+WppasHwO9KnS4s2RjA6HEu3rlGHmJIHzuR6oXnfMfPOLMHPY9cR8D1BujbKRK7Wf1484EiHt0Swy4djHEP8dyGRvX23C+eL9NxUmrdZJm49XREnDKTFZGLNEe+EAzffM4+mVqw0N5ygX0KKNpe0M2Zh5f8OXDqRSRdukCQbA3XLtZpgyT9RTvZvpJSx09oyrWBiuC8liOpH8Darp96QKfZbbf0srUdYlCLMP3Yezj5AaHmAFJ8MnQHABtBB6V1rlmoGkTuJViLxOVHhdGXEeSkyz9iUt7/Vq9Db+22SZzSOs8gZB0u1vNeoBbeNhde1GP7sgam5vasmdjJyHYwjs3b+NdAyah9voDbskVaxQJSrXFENw+fAkY+w4TJy2HF1/Fxmx4WNWb1SdqX8WJMPMBm3np81yr2KqIl67x5ezGUbg3IIUL2N6aKeSva0Js9T8cTt6PqxM7PlCCVirQMWuo90nOMf4saJYW6l3shTEw5uEIeJDX+WWdiPVBSlfgd82MgW/4cbh48sEHjf7xgmb4JprKcuBfz+N6XtLlpG+nTDyP8xw+s4Y/sJSSXPwIN6A3Zia/0SqNfmWjh/y+qVMkiRPieHt6HUkB2t/ulYCN+XF9LR65+8MVNMkmT9qPtRo+vuc3zEzCgoXceC53vj2tOKxWiBe8bs/MpU5BUue1009OTZwFk1G0JVjR7NqbngknRI/BuyRT4lojPj8NVQ3YJoPo5Ej2dulSYCjM4bzFS/im9GudJn2azWPGdsHdi53wHIjopqHJRK1jWdMK6LWbQVZhPXz6cUB35aPOTJAChojbcYnZpURf0EZnbSZhI/mcYJuByz46dgf4onjALSenFsdQPtp9NzEO0ip8224x/64V4/xgvwe/o/pry4Fa8xrbHMIYwEO+k6VMYbCcGTSw2YO1+Y8sOktj1H5LluroGxFvQ7zZeCaT7QO5p8f1XATMTuG+Vu4 mAUqs/7S pft74I5mx5XPBJ5hcrK6zLBOPsmpH8DyMMWUEXN4HuWUa7HUpO8PbGyhCyJg7vo3m5AIqN8ry5mZNFoiNIORGz6ktmUpVaDImu7Y8BRSTOKssEnmpmWV4dM7XZQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.015785, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Song Chen Introduce for_each_folio to iterate folios in xarray for code style compliance and better readability. Signed-off-by: Song Chen --- mm/filemap.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index d62150418b91..5386348acacd 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -62,6 +62,9 @@ #include "swap.h" +#define for_each_folio(folio, xas, max) \ + for (folio = xas_load(&xas); \ + folio && xas.xa_index <= max; folio = xas_next(&xas)) /* * Shared mappings implemented 30.11.1994. It's not fully working yet, * though. @@ -2170,8 +2173,7 @@ unsigned filemap_get_folios_contig(struct address_space *mapping, rcu_read_lock(); - for (folio = xas_load(&xas); folio && xas.xa_index <= end; - folio = xas_next(&xas)) { + for_each_folio(folio, xas, end) { if (xas_retry(&xas, folio)) continue; /* @@ -2306,7 +2308,7 @@ static void filemap_get_read_batch(struct address_space *mapping, struct folio *folio; rcu_read_lock(); - for (folio = xas_load(&xas); folio; folio = xas_next(&xas)) { + for_each_folio(folio, xas, ULONG_MAX) { if (xas_retry(&xas, folio)) continue; if (xas.xa_index > max || xa_is_value(folio))