Received: by 2002:a05:7412:3290:b0:fa:6e18:a558 with SMTP id ev16csp79968rdb; Thu, 25 Jan 2024 08:46:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IFVKu/s+7s+jqS53AmXxWKkrEfTxa+GW5pLP+Ks/GCGvXw+XNTMBHSXu0ZdBu2ZqvP7bA7o X-Received: by 2002:a05:6512:358a:b0:50e:a08d:174 with SMTP id m10-20020a056512358a00b0050ea08d0174mr41039lfr.95.1706201188880; Thu, 25 Jan 2024 08:46:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706201188; cv=pass; d=google.com; s=arc-20160816; b=BTKQwgUJTXHW7JHC2d7OaelrxrNOeeYXlxCOfRhseW/SYBQ+eeM0P4sqraHt/yHEyE gPAnckJFl5Slvy91dVCXR8vauSDhWtH1Sc1pFgSka+h8yWxJFAhwB6sPMhgJjNB1F4c+ 2C/dqjEKdp183Okeumc8OxhkMyhVsYxs8erRWjwKgCR+RiWUadq3x4P53xveDSJ6SkFK TYXdDfOs66ynwh6WgIr5WoiQAC9P7b9SziW/v6f6DykFBwtWGg7bDN3B5ZOZ79Wr0fSz 2a8N2+EM+wOHuzvrfZmu0+397x6k15zx6zB8sXrZYC1+m4ePI/mWgpvYY75gYN1qcyGd d5OA== 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=dVreMySeIHkVOAtpz+bbvTB1WjeCUE+T6e0OUt9+4gE=; fh=4n+2OJvAjB92nIDNIVn6PB+TJURVaRmLWxWqLJknBpc=; b=mrH5oAISZH1fuafIQkAZo+emP7Rfu5i85p6yPHZQVPcR7N/VAH0ngc9GRR9lC375Dc 7LldHc5coEKOalfJKPbQRrprg+qYHRroijYmhZAH8pjMG0R0kiJxPZyAinQ330RnlPO0 E6jTrIuWYJox4ufT6NjDGMUhEQBMeVaeIbSKNM2NBNb2lEkIQq2OFUnCJSiyJm+ZX1p9 Spks8uC+jEXxRJqsZqPTSsTtQvhavaKlx1Nx1dbS7jIS2Ee2a/iD1Zqv3/7yhCoojrQF Zva0qUmoPsHkkrchl5Zyr49Ul9tMFajUfrqgKJBbdLo8pF/n1JAkk9K1izDjR070mNeJ GokQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=fJTltGtB; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-38211-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38211-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id u17-20020a170906409100b00a317ce4d317si760415ejj.802.2024.01.25.08.46.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 08:46:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-38211-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=fJTltGtB; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-38211-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38211-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 4CA581F29121 for ; Thu, 25 Jan 2024 09:02:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9D7EB1D53C; Thu, 25 Jan 2024 08:58:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="fJTltGtB" 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 8A43A1CD3F; Thu, 25 Jan 2024 08:58:50 +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=1706173131; cv=none; b=Q1WoSbDxtf75HBFQd8sEoOvHts5EblzAPyZaQ5DepbGZ7GAFlW/Mdn89AwE72RRPb+PG3GQ0iY9SiFdoa3lW+5KJjJH+4cEl2jtmcKRWrGfsEiqVOVxIEWtPCkP7jd9K1RtPq/5nmlGSzPpQnDNInDNnBzZtAaaSHLHNkQV0H7Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706173131; c=relaxed/simple; bh=fTLYVjDIeoVCfke4N2sWaubK5MF1WA6AHuRJJL/gcbk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=EFB0+Ny1P2IgLKf5acTWRIKERftrHF4laOqwE2XPfoMZ5by8RoOcoUpVcWgTZRaKbzeMwQCqcr791SfByUlHXoc9h7HWeXLf7dIUmNCkF4TgENsMhSvv0pHl14kd1hK5URP241zwceWmAvvmtSgneqlZLiQWQ+L2+i0SHY/upIo= 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=fJTltGtB; 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=dVreMySeIHkVOAtpz+bbvTB1WjeCUE+T6e0OUt9+4gE=; b=fJTltGtBkzo7VMXaXfEGU0S2qs Y3TXmX4Qw3Kb87AMBLFpKxAN9cRUSTRyhiiLisdvt3e15LemYDbHh8CX9oVaTrWkT5WcI5gqltSre gtXc3Rz3jEWxdX3UHPaeOS3Hb7hZHyiBx9CArSuas0VLj+Ee0BTXrEiRRZLHn1rJ0hvNfPCacQIwi 4w22mSTaXwIpKlSsPKZRSg8yGpeIFN3eeGaHzY2sIVQdKILOhUE8l7UQQW7gIheMp4DibuLjTg2lA lkMK3uinulqtVqUk1ihMf4BxEx5sAZjWCGzuhRZUixA07JrSrTkRKRTb4na0D7Pg3JVqopLmucgfQ J05KCISQ==; 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 1rSvZJ-007QNR-2E; Thu, 25 Jan 2024 08:58:42 +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/19] pagevec: Add ability to iterate a queue Date: Thu, 25 Jan 2024 09:57:49 +0100 Message-Id: <20240125085758.2393327-11-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)" 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