From patchwork Fri Dec 22 15:08:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13503419 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 75554C46CD2 for ; Fri, 22 Dec 2023 15:09:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 303508D0005; Fri, 22 Dec 2023 10:08:58 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 23A708D0003; Fri, 22 Dec 2023 10:08:58 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0662E8D0005; Fri, 22 Dec 2023 10:08:58 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id E68168D0003 for ; Fri, 22 Dec 2023 10:08:57 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id BF1701A0CDE for ; Fri, 22 Dec 2023 15:08:57 +0000 (UTC) X-FDA: 81594786714.03.E5A6F33 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf17.hostedemail.com (Postfix) with ESMTP id 1E3C540002 for ; Fri, 22 Dec 2023 15:08:55 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=1fWeY1tU; dmarc=none; spf=none (imf17.hostedemail.com: domain of BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+af923ccb694ecd533eae+7425+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=1703257736; 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=o5H/XSwme7xEQtHV3m+ZJ3LCmsROSQ4hprrOJy3ayZQ=; b=Oouxwt15MstFPPq7ew3kemxWtxKwaxTwTwt+/UQ6glZXh6X6kf+3GNEaFHUSh+qK/IqLvo VrbTgoIhh6yOhWuiCShDLAsn7iSRCWjKKL4jYsmoilL3r09obXKCP7tCy5+VhobH8IQ3GX 48cJST7dNtxiIR8ui/JwQJZuta3+WVg= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=1fWeY1tU; dmarc=none; spf=none (imf17.hostedemail.com: domain of BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703257736; a=rsa-sha256; cv=none; b=JJiZL8uv4gb+1ss4h/VNLfkFGovpVI+4rk86DTjyrn9zf2xpxpTZWhFAijdgvTUEtHT+s0 lIOjpGYnCugg28TW015U88HPlXZGF9WQQBR7Wt3q2YB7NrYqdSV9RO1IE8vhOrSIQPNGJY YUFLEutDwU7wjUeLvZxQ9ELJz4mimVs= 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=o5H/XSwme7xEQtHV3m+ZJ3LCmsROSQ4hprrOJy3ayZQ=; b=1fWeY1tUuYOLXS4fYxt9eNpkZL uPDqWxlQRvE8go0ce8UcYudxrGF1l7Hsi2GJtUTlfsjpr+mucLE+tfcAIVoKgfxQNTLFBiMF7r/DY p038ichTWr69GTwEoBsSaNQuiXLmrhkToyxTmt+UC6O7wN0TyO8qBzkZeaUvRE0kPxYvKDXxGxOYW qHtxgdaRB9TK1g1hTe9EdhIoxKGVVqmmdo87DBp/9uLtiOOZj6aPO9zZLjWLCNCMR4p2Qcq3bJU/Y QrtkzDepUlCDu+3TMC/L214GlcREtVp+DAjwQOMC012XRtoSbmzTX27ToGjrv8hTtpiMxBwlg65sf 8wjZTjvw==; 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.96 #2 (Red Hat Linux)) id 1rGh8w-006BVk-2h; Fri, 22 Dec 2023 15:08:55 +0000 From: Christoph Hellwig To: linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , Jan Kara , David Howells , Brian Foster , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Jan Kara , Dave Chinner Subject: [PATCH 11/17] writeback: Use the folio_batch queue iterator Date: Fri, 22 Dec 2023 16:08:21 +0100 Message-Id: <20231222150827.1329938-12-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231222150827.1329938-1-hch@lst.de> References: <20231222150827.1329938-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-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 1E3C540002 X-Stat-Signature: itc1d6c4ngdban7h5s9ynhk31qsnp48e X-Rspam-User: X-HE-Tag: 1703257735-46327 X-HE-Meta: U2FsdGVkX1/QTua2N86wDl0tg9um+oId6+N4c6pfUQmLvq6N7ju+bc5oqLJ3EyH83o1OnPDDJv5KT5wRW1lG59JZ2Q+XD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l1a9zHheHChPDWt1pplozGuWMqjDEhT5GNANHGCn7G6jsZ7V4WvEeJBP61wVoh+P2fm8loMw44teN1Nj5sGfkTf/1TqUCPJRkmzFI95z/mYIoqx17TiLAlyCIQLMj5Myye2Ush3tgCNvswxyjpRpFmXA+F28AmS1gzzz0/brek/mn9J8I8znYk2yECh9ZYx6C9cKtxa+ds89l4Ws5DihszAY+g2YmCjLYi3uEcXycR1OCRhjvZl1Xo1WQHPJDvWu7+TCxUEMX2k2C6b/bHm+3jyV5z4CuktEaFWT+9fgGCKCwoW/itesV2wAyzvK2ZIwGO71yUgWN9BXmPWawG75f/SjurT09hCO27IO5Ewqle7gu3t1wNa 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: Jan Kara Acked-by: Dave Chinner --- mm/page-writeback.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index d62bc3498ed975..47457895891221 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2429,13 +2429,21 @@ static bool folio_prepare_writeback(struct address_space *mapping, return true; } -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; } /** @@ -2475,7 +2483,6 @@ int write_cache_pages(struct address_space *mapping, { int error; pgoff_t end; /* Inclusive */ - int i = 0; if (wbc->range_cyclic) { wbc->index = mapping->writeback_index; /* prev offset */ @@ -2491,18 +2498,12 @@ int write_cache_pages(struct address_space *mapping, wbc->err = 0; for (;;) { - struct folio *folio; + struct folio *folio = writeback_get_folio(mapping, wbc); unsigned long nr; - if (i == wbc->fbatch.nr) { - writeback_get_batch(mapping, wbc); - i = 0; - } - if (wbc->fbatch.nr == 0) + if (!folio) break; - folio = wbc->fbatch.folios[i++]; - folio_lock(folio); if (!folio_prepare_writeback(mapping, wbc, folio)) { folio_unlock(folio);