Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp1741701rdb; Thu, 25 Jan 2024 05:02:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IF2sbKJV7gqyiyWRxBZUVm+PXW0JcMeLfhU4KsgsMiQVJ8XzePaasjs1z2zHBzkJhI2wSkz X-Received: by 2002:a17:902:d588:b0:1d5:dfc6:c32d with SMTP id k8-20020a170902d58800b001d5dfc6c32dmr1357452plh.63.1706187757401; Thu, 25 Jan 2024 05:02:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706187757; cv=pass; d=google.com; s=arc-20160816; b=DkOApEQJ7Q42cxtwxl73XAt/SQjW1Lduf3Kc3FwOB35DoWgWgJmeHGNEVCs2w9nNsF 2xKzsT/w3mJ1pv8/vp7VZvVKJIIKuNxcoE/CATpKQDqt+rqE+7Muv4RVSTekBO6oOxRh sYAHZm2n3tw+rw6o+CEmVKL1pVyG2+ccJdl5g49co/H484DHKkwqjP6kgSY5eThAoDZ7 epPGEoK2kNUjXXDLbcvDGm5KfVoQ+t0ypVPOFFVGS9aW5QUiR0gjGvSlVEf58V3R2Gy2 qdQYPobGrCazvIFDZFQhQiFG/2oCQlP4za350UqNGPjPtuTBclhju7hivlMecC2+XQhU V11w== ARC-Message-Signature: i=2; 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=rQ/YR9r2MVXaLcMH7BH4MVX5/bfeEJP3+H7ANF9U6Gk=; fh=4n+2OJvAjB92nIDNIVn6PB+TJURVaRmLWxWqLJknBpc=; b=hd4sGGW2HL7MCvhnS7kjI+pMpfLUPchr1mdDzsSJt3CMK8QtgQpENhSYvjOIGVjbO4 c7tkrvGWI3dQoGIcHOAWHWtroYjjY/jLpo0aHUK0Iww3eymmgmBCpocKvJGKVaFKMBr5 rmMP6Xfdtg67MZDzHPVTUmWMRiHz+qU74RAmiIbUZgIXPebZXLznqQNWkdMVP5v+YfY5 zHDBpNHOzKnwNVmJo9z3kajoInIUpBGwKUo2nan3/K6oZNHMh4sYhh3uy8v2JynEmDUl 8j3HVLUwt2gqMRee1Ck2v0uZ6vBw0MadsyfTyfqR7g7AH3Ds0CwQXYWMOHRoxpDKiIL5 dbxw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=YsqWm1Ve; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-38213-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38213-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id v24-20020a1709028d9800b001d75eef04f4si5793061plo.104.2024.01.25.05.02.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 05:02:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-38213-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=YsqWm1Ve; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-38213-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38213-linux.lists.archive=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 07CBD28AFF2 for ; Thu, 25 Jan 2024 09:03:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2E7FE20B3D; Thu, 25 Jan 2024 08:58:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="YsqWm1Ve" 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 156552030B; Thu, 25 Jan 2024 08:58:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706173137; cv=none; b=JCBkWg9yYoK9rfm/sUHGVXuHx8P5DHEgiW6fiAxpvIXJQ1g3MrWbWkPVBZWam23rfMVcsttG8Kvp96HsNaHOmGd/CdikgB7C8zJKinCOQ7TUhXfEcki9y/WmaMY94FPx7u1ockuW06rSKo8qcZOqRC8UJyTGilueO32h6cWWoPE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706173137; c=relaxed/simple; bh=uGpduE64O2itYfQErOAsBg9JL2y9u+Xu+dfFoF1ZhrM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=HWX14xpgvr/93yjnj9ZCoRwv4VvBMrxmfpc6PkbW/guUuqGPFZ1eMI/Z/SLWaBVrIVpzuP+lkhbjdNqJj8waKCULxYVnr1dYU9VPt8thM9KUwMhf/W6LkyNfYWMN3dWdfuoBoiVw9vaqvCsblJ2XPS+cXJu/+Ye69Fax12Yg/Pk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de; spf=none smtp.mailfrom=bombadil.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=YsqWm1Ve; arc=none smtp.client-ip=198.137.202.133 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=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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html 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); -- 2.39.2