Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp1280356rdb; Fri, 2 Feb 2024 23:15:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IEPZJUpZZ4EiLbFAr0vKSilLmX0WQnD5KRZzEUwI2A+n8orRoFX0k/foss9PXVHPt7B2TRv X-Received: by 2002:aa7:df82:0:b0:55f:8c38:36a9 with SMTP id b2-20020aa7df82000000b0055f8c3836a9mr1114014edy.42.1706944530857; Fri, 02 Feb 2024 23:15:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706944530; cv=pass; d=google.com; s=arc-20160816; b=ACBAoaY/2U5Xtk9Cg4EQpIVHLrLexhg+P8TP7583XD4YaS8dzRRiBKe9efRh3ea9EJ 5TboAsHOB9Cq5M2cOu5xYN1FU6ps+6AzSzrDycdtVS+UL/6yNhcnPROYo9qrzk7LkSmW NHWc5lnePUUnRToIHqaxF0O8+t7xarYW6MqGS9uuTGHad4XiEXNArKJViK9Xo0NcTdLp 88ovi6ImS1F4CFMgrdzBQpLdQAcPbPmXgc4mdTbhud8ORC76JL+G3o3yzI65+5VEmHs0 5E0omHwx/iZjiLbILso3O3OH7a+O4Fupl6wCBuq0QJcN8/6Dl9J5M+xJIU7WZiRSwL7P Xdug== 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=vMuVWuEQ40U143WWo2Ps+rfcdCaB4a+PakD93tsqYPU=; fh=lDch01XV1YjxRAzoPCXubmeA6Zux6J3OVKwNFJgvSWA=; b=zxtF0/9xbE/feicyk4PxQQiJPNbZyRqKKgIqNJ9A+S7BpLziNIFyRvzCDpbOLvbpOd DG6YKgp8Is2t0D6KxZq5tHJZKUoZmlmOmIhMwJufBkvkG053K8oEBMQghzFOKjze6U1P OfeYvzBe2maMG7PeHr298sPxHTWZuZ1N+VaAH1qJsV13109etYV8cDBOH8SA4unxJBAl DNoJ94MuXUtHgDMp2EeH96svWIf1mXdHV0YEeddZ4VycFS5tlVefj0Q0WW/s3RLaqa57 FJr3L/7OZ/WFZ01pCFquouKQHy+IQBBi64n9HAiIgAMB32XpElTsuK4tqDPGIEXmCxGc KILw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=UVZT0U8O; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-50959-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50959-linux.lists.archive=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCUJMN0zYQyb/oIGJgAg4E+x5eUMta0mXXa75EZ5p6gGGVEBFjjsbhP/V3RNafPa3TtUaPrZO4mxkepggQVOqmLBGZG1iMlgIHhdCcLfcg== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id y7-20020a056402270700b0055ee0392fa7si1608966edd.670.2024.02.02.23.15.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 23:15:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50959-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=UVZT0U8O; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-50959-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50959-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 62A371F2B6F6 for ; Sat, 3 Feb 2024 07:15:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1B93155E40; Sat, 3 Feb 2024 07:12:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="UVZT0U8O" 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 E271A5578E; Sat, 3 Feb 2024 07:12:47 +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=1706944369; cv=none; b=ILCKOpQzGRhTeA4O+urGC1yShOTjvefCSYRREov7SQ5r3KR4d7P4J952Crvcai1gQe5VgJLgraIRSt5TdNn0glLfo16ObMl0OAcKgn9KAgYPEx1Gc2Xz9kFmZ5yl0HYRNDBvV1Y0gm5VPVVwaKVCWyc2GwR52KQC8ZYgir3gifA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706944369; c=relaxed/simple; bh=SGRAuVhJI7Lth/Gasz34I52NDhUw1SIUQLUzjXA01lc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=YwktG1dEtbnEssTk28TZeU+hb4LKX6pAhVToh3/uHDDWwbX7yYv4Bqyui/l12V9XqKUtResfeQhF3aDQPl5EXy/fHH2D6fVEPLDHDmPUu9L//I6RdBoRaVaoHxXG6oTP/x43XX+176FfDumcfa5di17k+BlKA8gi3Ws7mwtwGbI= 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=UVZT0U8O; 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=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> 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: 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); -- 2.39.2