From patchwork Sat Feb 3 07:11:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13543905 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 DAD3CC4828F for ; Sat, 3 Feb 2024 07:12:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 69E9E6B0083; Sat, 3 Feb 2024 02:12:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 625886B0085; Sat, 3 Feb 2024 02:12:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4C4CD6B0087; Sat, 3 Feb 2024 02:12:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 356486B0083 for ; Sat, 3 Feb 2024 02:12:48 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 11D8D8091D for ; Sat, 3 Feb 2024 07:12:48 +0000 (UTC) X-FDA: 81749625216.09.B566371 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf22.hostedemail.com (Postfix) with ESMTP id 71575C0012 for ; Sat, 3 Feb 2024 07:12:46 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=UVZT0U8O; spf=none (imf22.hostedemail.com: domain of BATV+a0ed29cff9639d748e7e+7468+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+a0ed29cff9639d748e7e+7468+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706944366; 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=vMuVWuEQ40U143WWo2Ps+rfcdCaB4a+PakD93tsqYPU=; b=irDXfDiOUakKDv2437zJccWASpMoPB/S+lvAf4XNqXzbb5ei7RrzyuOkkutsGJPV5cTkrd P1ZLMop2gWrFv3zvjZj+gRTOB/tB/FB5i311Cqj4aAFHw9NxEmjsP9Lm6x/3DqLNbLwRn6 tmt0FszAq1ufz72ZKBKc74ERnf/hVTA= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=UVZT0U8O; spf=none (imf22.hostedemail.com: domain of BATV+a0ed29cff9639d748e7e+7468+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+a0ed29cff9639d748e7e+7468+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706944366; a=rsa-sha256; cv=none; b=x4TVpWb0YPQzcHKQy0tzqpy3LjDL8MjneXkSDl5b8ssPt7GRPgNvmU0KnQic2vDOaCsSmG 6Hz6AibdrSD4dhzRBhPkaQc3szgdfSghafOO2uJ5W26wIh6oK52y2Q+9aAOwq3KSpyxVTn XAWah8KRDRueYMqkpXaF4CiobKwdFRw= 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=vMuVWuEQ40U143WWo2Ps+rfcdCaB4a+PakD93tsqYPU=; b=UVZT0U8O/OGsWBbA5J5L5DbkUG SmurBjpTmleDtvpw2bIr/rnEVzN8rjTX/aNoUn+C4KAtED42DW3RQVqwlvQC/yzmqGqoWaZxdSYXM GVzgszHwHO9An1ZeyUqAzpxJTAG+W+qouZ7Lgp9GpZyziDRqZHuPHOYf4ID+oxozldM2iGP1P+N6g tf9vH/pqi0+xMruv51PFKnq0+WgjmlKuqh4BdJMW/fNaqPe/lMFUsojx+nfiOqL87BxG6SMlcW+Pv OROo1W/J6KtBHth1yL+GCwFdhJuuVYMDmvSY6cBYYXdtFAjwyr5JEiYBZFU9qWweuDv9rL9io0lsI YA2ZqZhQ==; Received: from [89.144.222.32] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rWACi-0000000FkF5-2eII; Sat, 03 Feb 2024 07:12:45 +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 10/13] writeback: Use the folio_batch queue iterator Date: Sat, 3 Feb 2024 08:11:44 +0100 Message-Id: <20240203071147.862076-11-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240203071147.862076-1-hch@lst.de> References: <20240203071147.862076-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: 71575C0012 X-Rspam-User: X-Stat-Signature: r3sq45ya5pcqzhggz1yos1ddn9kpcs8j X-Rspamd-Server: rspam01 X-HE-Tag: 1706944366-340217 X-HE-Meta: U2FsdGVkX1+eZqp80cKqLixon9op44K2UE6dmNEvegG0NeZ/KiXgDtjxhHPcMCCDlCZ+mVfcCrNUWhCX81SV8d9RfY4C3u8ymB7XzizEca8geFg6kraK0+Nl/gTtiuSn9Pb5G+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UdW/B8/Na0JpXvw8ZZK7vuH06kU5exNrcg3MMhUba8csBsPPIYpiZMiecTPcobU29qozN9ow/pzGeCWJ1M2nMPf5bBM4klATyTMIWE0lMKT/gf0TTIsEkOofh8qMPuZD3BC+EwHki3A1vkyjbVgdFR0sKHjH6Ei7HW9u/zD9Eo0a5jYYGywmhx8CFxf5w+1EHujcRXW+OmuRHMf0PzTSBYfGN9Itzgv5UENoJAfPf9n2B7GX6HV4fiz1f2qMB6jFSyZ61jCNWXNSorRYTi1kkYqeGxTjsdM+C2ps= 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 d7ab42def43035..095ba4db9dcc17 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);