From patchwork Thu Jan 25 08:57:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13530266 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 A5D0EC47258 for ; Thu, 25 Jan 2024 08:58:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3E9808D000C; Thu, 25 Jan 2024 03:58:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 39ADB280001; Thu, 25 Jan 2024 03:58:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 212538D0020; Thu, 25 Jan 2024 03:58:49 -0500 (EST) 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 0D3B08D000C for ; Thu, 25 Jan 2024 03:58:49 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id D08A8140BBE for ; Thu, 25 Jan 2024 08:58:48 +0000 (UTC) X-FDA: 81717233136.17.454B1F5 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf04.hostedemail.com (Postfix) with ESMTP id 434304000B for ; Thu, 25 Jan 2024 08:58:47 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=YsqWm1Ve; dmarc=none; spf=none (imf04.hostedemail.com: domain of BATV+b97a0fc658bf3e588113+7459+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+b97a0fc658bf3e588113+7459+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=1706173127; 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=rQ/YR9r2MVXaLcMH7BH4MVX5/bfeEJP3+H7ANF9U6Gk=; b=nYD0lo9LWq+xILqgqqCAAIBGSz6tTbimeUBjr3hK0LGPp/GQFqi5Alo3LtqM1PuOvhFmfp pMzKD4/npFsFLKYVy5EQ0oCf5C59Ga882MRHCOXaAXZYe1co5hi3q9/N5xVK1hmfr0GVEF yhWm/r3czX1Anyc832Z2VP1ACECUEIQ= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=YsqWm1Ve; dmarc=none; spf=none (imf04.hostedemail.com: domain of BATV+b97a0fc658bf3e588113+7459+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+b97a0fc658bf3e588113+7459+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706173127; a=rsa-sha256; cv=none; b=h/aAefhzoUozhx1qyL3moeDCRn+WfHo28XURP1D1pj61bI82RT+RBSaIoNKzP9P01371+e yVrzfImp0l308Gkp+tXE9T3Nq9kxwS8gcfqtaaSkWeee2DchL0OPNuB1YolyJeEn8GuOvw Y+eAHkCjFsYJe+THdvbzQ5a+DMYPeXQ= 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=rQ/YR9r2MVXaLcMH7BH4MVX5/bfeEJP3+H7ANF9U6Gk=; b=YsqWm1VeZ/5woXx1pI6UQ82TBP jEo9O0uC5yGJGqt3juo+7kF4mK/ojbfOCnOR2XsQzaQJLlCKWT7zXgQwChqWQVMoR+KVflOoSaRP7 WB1v6Ey5oqMI8hnNAL6t2AogyLtpByE7CzERscH+mKXtkULkp+e/lu+PFXcpjTSbEsSvoWB9NA27w DqyAEQS+XubKd67++tgTszn8Qzdx1vq/+tvzgi8MCg9x+i0doBASfAZ24YVnBQdvGOAqCRDiT5uDS LKjx14CAuf2dWanDl9/1HMpUHDgBzTBxeTmgpjLoQ1Ajc0T+IPmA78Cczi8TsIyZJAJNiJ9SkroZH vOyN5jMA==; 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 1rSvZM-007QOH-1U; Thu, 25 Jan 2024 08:58:46 +0000 From: Christoph Hellwig To: linux-mm@kvack.org Cc: Matthew Wilcox , Jan Kara , David Howells , Brian Foster , Christian Brauner , "Darrick J. Wong" , linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Jan Kara , Dave Chinner Subject: [PATCH 11/19] writeback: Use the folio_batch queue iterator Date: Thu, 25 Jan 2024 09:57:50 +0100 Message-Id: <20240125085758.2393327-12-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240125085758.2393327-1-hch@lst.de> References: <20240125085758.2393327-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: 434304000B X-Stat-Signature: iazwpz8gootje4w5j6dywowzbstzk191 X-HE-Tag: 1706173127-710471 X-HE-Meta: U2FsdGVkX1/0X9CHfbHL3qUCBDG6UDl+tvaz/v5iIHTDWiluVzXYAqYdRZ0vmfYar3u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JD6PqiLGX8eOJcPN2Koep2yJyJhpjTrpJ+ca5lzjVquWBJCoaE3Eh4BY68HYEcDLsASedtw37cUxRxVHd/P7ULXqx+EWZizK5J9dawdcg3DTNV/xvj8/ZtcgZbRCBAr9iOOb8kWC30JhmPZ6r0WigWrpjTxQiN53eBuWfO6lHGPbty1XpfaQjo8pocB/Qf4+n7QUww/Q6ZTGq/cTaq81J6e+SOaB2O9gOGZxALGmno8WPTWLq4TuF7dnnVv/eFuKuo3/aUhb1Rr0ySWQatpU/oKpSJLLrLbLW9mkNdMp/lfFmDsi6Ea6zRcpiqkSXEG5t75ZYNCARAglv5NkABVOHxz/aGyC8wIkof8UW9LFKkMkiEWxHu/A9U1KomVyXMjkgtli 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 d6ac414ddce9ca..432bb42d0829d1 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);