Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp859841rdb; Fri, 22 Dec 2023 07:11:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IFgVPZWhn5gzz2wmlEpsjBUze/9osyVrti5pycFCGpfU75u6ARliZbGRlY5Kd6bWWLzwR8b X-Received: by 2002:a05:6102:6683:b0:466:82ed:1112 with SMTP id gw3-20020a056102668300b0046682ed1112mr1045901vsb.70.1703257907847; Fri, 22 Dec 2023 07:11:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703257907; cv=none; d=google.com; s=arc-20160816; b=qOEbH0TVbh6A4ApvcGTfTx7oYTgKYVRwk4R02m0Rqd4ZMs603k9UUhMyZoFlw0U+9l sMYj4r/wmNGzl+oRwJpR2qY9AMC8RhHNm5EcyzYOy082jz6vz0LtmIUlFcBil6o4Pn/S 3n7ooWg0af9s3l3IPw93unZgVifjzRpsvMKt9fw/9RYGP0epHMyFXWcNVsablVyes7tb MZU6c9dinyLibtRNQH2g3DHt7nJJhxT+2RnemQ3oa56d5zAWnJe1ThlRq9sItyF93mK5 tTxgxaqMEDYRbgDj5QJIsO2G/VbzMfxg/lhrSRwCKvh8O0bNpuLKm6qY6D0f6rZ0M+RM lqpg== 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=dVreMySeIHkVOAtpz+bbvTB1WjeCUE+T6e0OUt9+4gE=; fh=hzpEVxJ05G9gyZL9WVyKgOEGxITvmFSuTcKyr2ByStg=; b=TjHrm7uJqLWU/j/qvIhJ+DGOTF6/6L3lyMRN7l/Sz+hwTEappW4ENP8GH6NL7vfXrE 9WL3R1dIML0Nlez7Tv6Y8mIBtBFrPIQ+6uYEHMCU1Z0bw/dASHA5WEaNx/VhTavIpn7T 7OeEVrx2R5iop9wge9er1go7mVICPGXYhd3UC9Eavc2C9pdkuxrlqPDUndaZ0bEI0uB7 uJFJlWh4vMfMzlZ1M5PPpZGLiNC9fJtBbIv5hknYqYR2P2LIgMJIvJ9XrR/HkUSPYJYp 3app/5peUtIG88SJbS/wHpytgRwk5cL78WyTtnoIqYFae8kOtGKUMZFDAUPpSwKC9iTd +6xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=JaAkdqZm; spf=pass (google.com: domain of linux-kernel+bounces-9821-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9821-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id e5-20020a67eb85000000b00466e6d5f5e7si120716vso.187.2023.12.22.07.11.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Dec 2023 07:11:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-9821-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=JaAkdqZm; spf=pass (google.com: domain of linux-kernel+bounces-9821-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9821-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 8E1191C2131C for ; Fri, 22 Dec 2023 15:11:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 59F052D627; Fri, 22 Dec 2023 15:08:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="JaAkdqZm" 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 6B8B12CCD9; Fri, 22 Dec 2023 15:08:55 +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=dVreMySeIHkVOAtpz+bbvTB1WjeCUE+T6e0OUt9+4gE=; b=JaAkdqZmOduEeNKqFX4Ku2J7NE ZUlndRMyXJVHVpS3YBp+6lZQe4Hb/Oea/LNWPgl4QZ3Yd8ECfM3p5l6Uct6A8zEfAoOe+Z0jwyHJ7 0fm91BwTHShgOIQMcILm75blc7XQRH49G/JVXgOxWXo0dVFsqXpRBaEdyrPs0quk5x729W9gXmb98 e255UWRmLzkFgEPdttgBQuUTeEySgAg3MR6Ea+qCXmLfCd4NzBC6vD2F7y56dqROKEg04RYOnnN0N lEHwOMZeqBxD5fPkSLKirvNRdxdMaUp/A77YEni/edJFRZ5TA6D0gHH4uUlkwB64Jons6MuMIPqUz RJn1Yl1w==; 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 1rGh8u-006BUd-1I; Fri, 22 Dec 2023 15:08:52 +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 10/17] pagevec: Add ability to iterate a queue Date: Fri, 22 Dec 2023 16:08:20 +0100 Message-Id: <20231222150827.1329938-11-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 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)" Add a loop counter inside the folio_batch to let us iterate from 0-nr instead of decrementing nr and treating the batch as a stack. It would generate some very weird and suboptimal I/O patterns for page writeback to iterate over the batch as a stack. Signed-off-by: Matthew Wilcox (Oracle) Signed-off-by: Christoph Hellwig Reviewed-by: Jan Kara Acked-by: Dave Chinner --- include/linux/pagevec.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/linux/pagevec.h b/include/linux/pagevec.h index 87cc678adc850b..fcc06c300a72c3 100644 --- a/include/linux/pagevec.h +++ b/include/linux/pagevec.h @@ -27,6 +27,7 @@ struct folio; */ struct folio_batch { unsigned char nr; + unsigned char i; bool percpu_pvec_drained; struct folio *folios[PAGEVEC_SIZE]; }; @@ -40,12 +41,14 @@ struct folio_batch { static inline void folio_batch_init(struct folio_batch *fbatch) { fbatch->nr = 0; + fbatch->i = 0; fbatch->percpu_pvec_drained = false; } static inline void folio_batch_reinit(struct folio_batch *fbatch) { fbatch->nr = 0; + fbatch->i = 0; } static inline unsigned int folio_batch_count(struct folio_batch *fbatch) @@ -75,6 +78,21 @@ static inline unsigned folio_batch_add(struct folio_batch *fbatch, return folio_batch_space(fbatch); } +/** + * folio_batch_next - Return the next folio to process. + * @fbatch: The folio batch being processed. + * + * Use this function to implement a queue of folios. + * + * Return: The next folio in the queue, or NULL if the queue is empty. + */ +static inline struct folio *folio_batch_next(struct folio_batch *fbatch) +{ + if (fbatch->i == fbatch->nr) + return NULL; + return fbatch->folios[fbatch->i++]; +} + void __folio_batch_release(struct folio_batch *pvec); static inline void folio_batch_release(struct folio_batch *fbatch) -- 2.39.2