Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2391973rdb; Mon, 12 Feb 2024 03:30:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IEyS+g+Rk7mvs0MlNnAROaC1NpvAfAGuoGag1p43JiQ/35dHJ8lEHy4tF0Mtq9IaQIFROaV X-Received: by 2002:a17:903:44c:b0:1da:34f5:57a3 with SMTP id iw12-20020a170903044c00b001da34f557a3mr859880plb.42.1707737411744; Mon, 12 Feb 2024 03:30:11 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707737411; cv=pass; d=google.com; s=arc-20160816; b=z7/auD+Xxk3YKw9O+vmPwHdmfqUFB7wznOOAujbgtHJkI6mbyaMo+wyQ4JNnudU3k8 4ja/ReL2p0Z3SqSfGtH+RCbnxmltVz8jnfuH0cxOA7FtQJqXH+iV4mdwSlvDsptkrxSO YIy1CTetKQVYYEu/qHlkiaCkwWgN/dyggV4awAQRH9eh5X29kHW3mQypM6CKVQCQWLdY 4jdUPb4cxlclhQ68aVIobcOVZVsAI3MkyVWNMBYgv/OnSRPbpomkcKP0VMpC+YLww44e PjJxG11v1fHO88de9MKoNWmXZK7RyDAhIrAJJou0qDAcQ2vsJQlK85hN1aanVLvQdNjt K+BQ== 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=M5Qvp5zNKGHXjXReg58hQjrWh/GgxzXP5maEkxrO/YI=; fh=BZWNX4LF6+zNQfDF9lWuUtgadWUlaJZQ0dLT8L3w5EU=; b=nIxBWp6uTEypL3OhxWURSw5jzmyU5D9v0Wa8Et9pxDfakLA7WDGnIAoTaoQ9apM3SW fqUwYuT/czvhidPFepJN6KwuLQNjxMzdtX4qGLcbU3Zij2WP0Dc4FqgG5CWNkbDO/+vI AQkq2w5hDgyiSsIqvjBPRMueQApZScs3cpCgJvEB4NIrz3HtF+yW7IMIlLqFeZ/anGS4 R6Cl+TVM0zXxPKEeQUEGj4HjrJDSzRFdixxJw0pyRM5K3ZcV46NyCiumuZeBJjwPn9Vj eVJpH+IURPpNeTkwpUi3wEbpmHMwTH+ZNJJiMZerZhVGV+efqddoQuhbQ/dwMM1w+tpz LiRQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=KSEDHvnP; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-61137-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61137-linux.lists.archive=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCX4i0SLw/P8h0PWDSVhvksltNW8wcW2StVlNtQpiB43ENRcmxbqODdN3geh6XqnsVqYWyDHR48rvM+0mJEmDIDjN23GanzQivKOCXvGRg== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id f17-20020a170902ce9100b001d9d4629bc1si107954plg.456.2024.02.12.03.30.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 03:30:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61137-linux.lists.archive=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=KSEDHvnP; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-61137-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61137-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 6FDE8287A55 for ; Mon, 12 Feb 2024 07:17:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BDD571CAA3; Mon, 12 Feb 2024 07:14:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="KSEDHvnP" 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 B0A39182CA; Mon, 12 Feb 2024 07:14:28 +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=1707722070; cv=none; b=J5/r/PKfFYcGCZUrdiUgM3ccg87gzx+EmbfjLoA/+iFgfbms+Gpk9T6sgTek5RT/euW3xI+loW5P83LofyV7JUFp2eVgV8pKM73+ro1CiSWJ8JguEilA1TheywMWU5EMpaJ9Yf+qZKdnQYkuL2SKCTOr4RNRmOyF+lXYzz6Yi0c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707722070; c=relaxed/simple; bh=8YXecWRICYuMcNttDcOnWW490EjFn6keh2I4C8IPcyw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=cyYN/JNykp3geZanS03QWyQZqSKl3W+QXTfVomlmiDoKZjx43WGtbulkj5ftbD2rVVxwPFXL93xlZCibZApzBmF2q8qJY0y1mDcNLOl+6cSOd6mduFkxOx5rafVSnStzZjdk4gUdXXp65C/FnuBSbrDRFmjsFZ2pmiQ7XhxYLBs= 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=KSEDHvnP; 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=M5Qvp5zNKGHXjXReg58hQjrWh/GgxzXP5maEkxrO/YI=; b=KSEDHvnPO53cQSe7AW5PkM179C 0DYoyalxcn+DwuyW53dr955k4BfksGs0A/fvdpCrNU2v6RfJcoVVHZgjOJDRQSk6SLZW/h09KIfpl zmaOnPgCKkPSDxEUIpzJ5N6UpKlyouOnZ7yV02DDBXSQT4lDJFXjCuR22l7N5IlG95PluhMT+qC/E uMHRsQ+YRZRTuyzoAzCxKP4glZ3VsabLC+VtyKBS2vW4d6FWVD4CNp1cJ42IhVaHxcR3TMwfZ8W55 oRAplzCHTEm8E2EJI6uaS6wt3snHiqfPsgSmTI4PE/NgzauQVCyCcIuyvEnFJmHKKBXtr8ffw1NUB z92qXtog==; Received: from [2001:4bb8:190:6eab:75e9:7295:a6e3:c35d] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rZQWI-00000004T1W-297p; Mon, 12 Feb 2024 07:14:26 +0000 From: Christoph Hellwig To: linux-mm@kvack.org Cc: Matthew Wilcox , Jan Kara , David Howells , Brian Foster , Christian Brauner , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Jan Kara , Dave Chinner Subject: [PATCH 10/14] pagevec: Add ability to iterate a queue Date: Mon, 12 Feb 2024 08:13:44 +0100 Message-Id: <20240212071348.1369918-11-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240212071348.1369918-1-hch@lst.de> References: <20240212071348.1369918-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: Brian Foster 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