From patchwork Thu Feb 15 06:36:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13557445 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 39A55C4829E for ; Thu, 15 Feb 2024 06:37:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4F1FD6B00B6; Thu, 15 Feb 2024 01:37:28 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4523D6B00B8; Thu, 15 Feb 2024 01:37:28 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 280A56B00B9; Thu, 15 Feb 2024 01:37:28 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 1245B6B00B6 for ; Thu, 15 Feb 2024 01:37:28 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id ED86CC01B6 for ; Thu, 15 Feb 2024 06:37:27 +0000 (UTC) X-FDA: 81793081734.07.7CF67E7 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf28.hostedemail.com (Postfix) with ESMTP id 571CBC0011 for ; Thu, 15 Feb 2024 06:37:26 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b="sA9hTm/g"; dmarc=none; spf=none (imf28.hostedemail.com: domain of BATV+a252b21bd4a653ddb6e6+7480+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+a252b21bd4a653ddb6e6+7480+infradead.org+hch@bombadil.srs.infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1707979046; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=cxMaD8CgzKPWpzzBQiYSiO7ZuZ6eZs5SBgKJwTWN/r4=; b=rdOvGX58QK/7NhGs1luYCVjsr0i6mJTntWjvincROB6KqG1yX9gPeUsw/9iK+ZHhMkNh9Q 1pvUALayyajSJ8dAQtoyadp0IpmwEJvSfKQlsEN83T4kUlzUG71RnBm4QC0Z+1cWDyT59Z bJRiToLorVMsJ2hV3c1nTp45jXXlOQw= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b="sA9hTm/g"; dmarc=none; spf=none (imf28.hostedemail.com: domain of BATV+a252b21bd4a653ddb6e6+7480+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+a252b21bd4a653ddb6e6+7480+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707979046; a=rsa-sha256; cv=none; b=InJ9/Vwwp4+WzPPbnXWV2APCWLV1ez1rjOp+PCtJSxX84cnCc491zA6VN/Xq9StRVngOjc nrweHzpdmctpskU+vpj+kRX5t4tbmXgr8IkM6g4BdKLYHMHL0jEEa+VBwZE66WKhYBCOQI s3DRvGe/oyQABQY/uPNDSm6ZphPPV60= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=cxMaD8CgzKPWpzzBQiYSiO7ZuZ6eZs5SBgKJwTWN/r4=; b=sA9hTm/gXewYmu74Y6HKN+nure pK/w8ImihQ8or1SXbOQU1BH8PnFwBJmpIvkG7mc1M4U5tyoniQYrq05Bf/igP3fq+tdtzlcAvRwF5 aKhKqLpa4MTE7ek+bRUa/cWrAwbNaTWZVcuZ4SrcXEE4OeerQG44/4LyCbkIZBfyv83FA41XFpg4w +WlAzXEYKo/bdm3jraGgGMznibtKSzdPgNUAv4zXOdzla+VVoJ7lA7cWDe+tQxf+1kpi1nfeS38o3 mXM2Pa2LbWZG+mZD7u5jlmUOv5hzQPlc3rwSUF+MQxOPauTPE/I5kLQSIeqa8lIjeOCEJ/PUHi/HJ cOHPVvIg==; Received: from 2a02-8389-2341-5b80-39d3-4735-9a3c-88d8.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:39d3:4735:9a3c:88d8] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1raVN7-0000000F6zU-00HA; Thu, 15 Feb 2024 06:37:25 +0000 From: Christoph Hellwig To: linux-mm@kvack.org Cc: Matthew Wilcox , Jan Kara , David Howells , Brian Foster , Christian Brauner , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Jan Kara , Dave Chinner Subject: [PATCH 11/14] writeback: Use the folio_batch queue iterator Date: Thu, 15 Feb 2024 07:36:46 +0100 Message-Id: <20240215063649.2164017-12-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240215063649.2164017-1-hch@lst.de> References: <20240215063649.2164017-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 571CBC0011 X-Stat-Signature: gjsdrufzwxuctrjhazd3pxwxmk7q7psx X-HE-Tag: 1707979046-363105 X-HE-Meta: U2FsdGVkX19HxajkM/w3dM1prTOMbhX4rMRnBavjfoJSDqT4HZxLeQs2mUag55V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8iAYxw0GVrLBXDvjSlVY5xp1ndSrf0Fuhk7H9ReTKLZMEOd1teTpfYDlHohQzQi12g7NyI6RaMFJjpHK6WpXPxt8DJ3PZ3+lr4mbvvD/rweaCjQGhYBilNC/8wB5iQQyG1MG4dtOfiHOFMSNv+eLx7qbIHIM0ALT9FqqMbsmBr/yMdV88m5Io/83GTK1SstmXGMIeFvG/XnET+U9p5+UdLqF02t26md5qsV3wY+QRntUEChoK4wOrYeB5p+8LgrmATV5fpVy+Urok+3/vXgtBT/TbmHsyeh4n6zvoW3wxJfRRBgAHK+2OGnUvCHVGGbaRq9mN8zVQMqj7zEM2M80oDtFHJS6kEcCjGXWYQIaX2qIeLD4KXYBwOcYsE7i9amWdEYN 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: List-Subscribe: List-Unsubscribe: From: "Matthew Wilcox (Oracle)" Instead of keeping our own local iterator variable, use the one just added to folio_batch. Signed-off-by: Matthew Wilcox (Oracle) Signed-off-by: Christoph Hellwig Reviewed-by: Brian Foster Reviewed-by: Jan Kara Acked-by: Dave Chinner --- mm/page-writeback.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 358ce3ade9ad1e..3cbe4a7daa357c 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2406,13 +2406,21 @@ static pgoff_t wbc_end(struct writeback_control *wbc) return wbc->range_end >> PAGE_SHIFT; } -static void writeback_get_batch(struct address_space *mapping, +static struct folio *writeback_get_folio(struct address_space *mapping, struct writeback_control *wbc) { - folio_batch_release(&wbc->fbatch); - cond_resched(); - filemap_get_folios_tag(mapping, &wbc->index, wbc_end(wbc), - wbc_to_tag(wbc), &wbc->fbatch); + struct folio *folio; + + folio = folio_batch_next(&wbc->fbatch); + if (!folio) { + folio_batch_release(&wbc->fbatch); + cond_resched(); + filemap_get_folios_tag(mapping, &wbc->index, wbc_end(wbc), + wbc_to_tag(wbc), &wbc->fbatch); + folio = folio_batch_next(&wbc->fbatch); + } + + return folio; } /** @@ -2454,7 +2462,6 @@ int write_cache_pages(struct address_space *mapping, int error; struct folio *folio; pgoff_t end; /* Inclusive */ - int i = 0; if (wbc->range_cyclic) { wbc->index = mapping->writeback_index; /* prev offset */ @@ -2469,15 +2476,10 @@ int write_cache_pages(struct address_space *mapping, folio_batch_init(&wbc->fbatch); for (;;) { - if (i == wbc->fbatch.nr) { - writeback_get_batch(mapping, wbc); - i = 0; - } - if (wbc->fbatch.nr == 0) + folio = writeback_get_folio(mapping, wbc); + if (!folio) break; - folio = wbc->fbatch.folios[i++]; - folio_lock(folio); if (!folio_prepare_writeback(mapping, wbc, folio)) { folio_unlock(folio);