From patchwork Mon Feb 12 07:13:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13552752 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 B73B3C48297 for ; Mon, 12 Feb 2024 07:14:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4A3076B0072; Mon, 12 Feb 2024 02:14:32 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 42D268D0001; Mon, 12 Feb 2024 02:14:32 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2F3A56B0088; Mon, 12 Feb 2024 02:14:32 -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 1FFD96B0072 for ; Mon, 12 Feb 2024 02:14:32 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id E486AA0950 for ; Mon, 12 Feb 2024 07:14:31 +0000 (UTC) X-FDA: 81782288742.28.34C4953 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf29.hostedemail.com (Postfix) with ESMTP id 57F33120002 for ; Mon, 12 Feb 2024 07:14:30 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=PPFKGKFd; dmarc=none; spf=none (imf29.hostedemail.com: domain of BATV+56c964bc8172c8a9ee6e+7477+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+56c964bc8172c8a9ee6e+7477+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=1707722070; 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=+Lom8uD40NGvlqisQyOK8nFLP+lWD9RUXEqKKIbGSn4=; b=7bdbVjDRrYx/Q8QWJjd8yYH46UR3fxpmVGtdt0uTnRMOfm+lR/zuk4FMe38WOYEXOd1mtY b1EOtQYxbPZXITVInX7pWf2fJyWeZrU4BQPaIQ+gttAUTWSLOqBitV/I860IyQPeuN3ihC U28isTunrdX6Nl038QCeNumSiUVi7lY= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=PPFKGKFd; dmarc=none; spf=none (imf29.hostedemail.com: domain of BATV+56c964bc8172c8a9ee6e+7477+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+56c964bc8172c8a9ee6e+7477+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707722070; a=rsa-sha256; cv=none; b=x2LkgQNj6Y+HnCtS9II3Up4WFqho1fmjhifIoZxRcOGH9fq70ohNTo4SqmYyyOnGmEy7wt obtL9Zc882o2DC9wGag4OQznQhi/JY0eX6DwFhT4ePIMZXk5ned5MH1vnjBtSc8Rx+31o5 u0BbjvTpJYAgVoIPwHAizAzqTyfTut0= 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=+Lom8uD40NGvlqisQyOK8nFLP+lWD9RUXEqKKIbGSn4=; b=PPFKGKFdog+pRhtnYVX3WRltrB ikV+4bwKtUpdsZ8JyPWOpR/eCx2IumzP/5BsTgIlB2axxAYRuMgIlbeJvtoS9crUEwioqaAVLIEy9 qe68HPx2+QSYY3d4+4EaLCUNFTjf6H5EsJ+Pf6Aic0UDbxShZgMHL2WP23oVmHjAD1RQyq5rOpy8j f90sfKpTzUAuob0zsJ8hcHxrSwQIiE9b6alk7Q0pmRALR7/PqiH3FBss+f4aY6y6jZnvQs41cJoJv PVW8Uvg/YNsq8/zUd6e/H02sDTt5aQbaw1r/Wu4Y+ATBQVVma61LebMzf/d0G6ueSwnLc0neemdyr lgavjWNQ==; Received: from [2001:4bb8:190:6eab:75e9:7295:a6e3:c35d] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rZQWL-00000004T2h-0GbS; Mon, 12 Feb 2024 07:14:29 +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: Mon, 12 Feb 2024 08:13:45 +0100 Message-Id: <20240212071348.1369918-12-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240212071348.1369918-1-hch@lst.de> References: <20240212071348.1369918-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-Queue-Id: 57F33120002 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: tx7yaykc8pxoepo96mbmocwxcybnj9z4 X-HE-Tag: 1707722070-171314 X-HE-Meta: U2FsdGVkX18E2vmjIAXnuTbScr9aYeHT99wkrbMUxcMJl7/ypMOaQconS98do1KoaKydjWuaaAOdpQp4iviH0NHMs2f+k+S3g7u1WiQ5nQN2BnywIEkPBVWjjVqk35kzq/0Zf4zEb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KAyX7JXPolRtydDkZ/C90goroKC8n7w11h/K2nlzI0IQgutksEXiK3ha2K5OM9Gf2lAKumEhT3PCyVMnHOTOtEOHtx6FqqUI+/dWvrTW7iS042xuet1nahB6B1M9LrraKtVETVtke4LmcCjTikVYd92S+XdGMYbf11HeibMvF/Eiv98n/mT9oH+oyQd160bfqSM6xjnvSvp5VKibtNq8z00uiam/J+dSkUajA0NF2y/lprE8r1+tQ9Z7hC1UVIs0U+lYaX2oPyvYznmX2z2KyiI6ps80FOnNlh5mmuBgp9GRQM3WrUucOPRUrNld9AVvzg4bN6JH3f7bPjMqPum 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 a94a77b1805969..62b663debe713b 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);