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: 182691 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp1127295dyi; Fri, 22 Dec 2023 07:12:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IFpyjNSjcVVepxnAlvRay9UBs0fAx0wRlv9+RpmvAD4cO/RaZghE4w60ydzHggxrfoOvn9t X-Received: by 2002:a17:90a:8d11:b0:28c:1161:5202 with SMTP id c17-20020a17090a8d1100b0028c11615202mr425696pjo.71.1703257944935; Fri, 22 Dec 2023 07:12:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703257944; cv=none; d=google.com; s=arc-20160816; b=dcwkeO2+EZO3A3Qr7IXDV+2l/CerG+WVdi8iVUcG3UCIfdwFeMiSb58h9Urt3CxqYC OQG8GSIFNQbfJojog5u/Z2e3U51TIPTLNuZaJm+A9Lz1xcNQGGMYdNsOtQpHqiaRfY3O byB8UtQXu8ugVqvlz0GufWJnazdFavQ+gjwvI96eDt+EWld7k1c7OCLGxP+16imrfVkG UizXC9j5FDP3G3G4ukRcAoVfIABAbWSoC7KReN0L84FTbUZ9X354WrHS7BBQu9U0S3lH vLyuJVEHjdzv81MyY5dkhCnBsba/S7El26oLhtU987c8XLixr+Lh++4/sZCoVywN/O8y B69g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=o5H/XSwme7xEQtHV3m+ZJ3LCmsROSQ4hprrOJy3ayZQ=; fh=hzpEVxJ05G9gyZL9WVyKgOEGxITvmFSuTcKyr2ByStg=; b=ciTWQf8dow/cPZbk7LC0WspMdQTch22Ql5eU4KPUbtChbCTIqTjM67EbTQgAYOddOv 1B3Yj2E4TSyyVPYeFhaKVvXWTzUame+LUWSPpsuo04Jk5P+jEP0u11qqmlZs8TPgnHw3 UmUqzuDIoJl7+gJ7aNP19jownTWNJOjPkLLdt/2j3U/9rLl7HrcZaJEjIVACWgeDIBLM ligLmzk6M4hp/yvv9RYvD2ntETt3Pd62RbZVMlvK2CJ0OoLpeh0B+reaXgNw2JNDBtwR n1zkJn5L6yrYQotmduVeEDfbxZvxfblZTRM+jGZyTzDJtzKFO7t2Rm52EEZwYZHXUAqR jUWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=1fWeY1tU; spf=pass (google.com: domain of linux-kernel+bounces-9823-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9823-ouuuleilei=gmail.com@vger.kernel.org" Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id c12-20020a17090a8d0c00b0028c01af5d75si1854641pjo.113.2023.12.22.07.12.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Dec 2023 07:12:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-9823-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=1fWeY1tU; spf=pass (google.com: domain of linux-kernel+bounces-9823-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9823-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id B4A81282D4C for ; Fri, 22 Dec 2023 15:12:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BD69F2E651; Fri, 22 Dec 2023 15:09:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="1fWeY1tU" X-Original-To: linux-kernel@vger.kernel.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 164942D794; Fri, 22 Dec 2023 15:08:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785995402793149310 X-GMAIL-MSGID: 1785995402793149310 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);