Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp79142rdb; Thu, 21 Dec 2023 03:27:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IFt3GBdjmrtxyUzdvfFPVs7FeGlA5kLGXtdXyAlPitf/+Cb4OcDrf/Kx0QCPWXbHNHTLU5B X-Received: by 2002:a17:903:2446:b0:1d4:e4a:2672 with SMTP id l6-20020a170903244600b001d40e4a2672mr313234pls.15.1703158044055; Thu, 21 Dec 2023 03:27:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703158044; cv=none; d=google.com; s=arc-20160816; b=qOuaos+Kxg1hJqUhn/vio/pun/yFNUVIGhY/AYP0v1hYcbw81B3K24AMj3QpyOPchW aqJgB+6GKB5ZCSzbIBJ+pQ+YgHxfbHLX9MKNUpC4NDvHs+GAsjnvrFqIoPfdu5v5k3Os iPrOfYnvjmz1zPCmVcvxY5zhZbdcG5c+BH2yJAHw9q2bZPXkDHhCBKnBa7+jla/UNuBz xqDl/MZPHOJT+p0j0nfRSYk2zlBgGZupMCuynxNm8QNi44fwn1YhxNa9uvIYm6Efgp6/ N6mqPLhS/8RP6C/r0Fnkve8xkQc/Evt/3eaQAewjDO9n6rI9wKFR8NfVp6L63PJy1OlW jkGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature:dkim-signature:dkim-signature :dkim-signature; bh=E/mUSHSfPZ+Yf1KncGnQnYY22sxHKtN68QzA+lLUhQY=; fh=i6rGHk/clC1f9Y4mpJyYVOWW6p98QflrI/jjeassMJc=; b=T4zZUpUrHdX1hyjlxPTN007SXquYmcZcetgnvSTns1xBrFuTqtdt2CheKYpHBvC3Xv JIw2P5VY32SVpDQPgcEB3ebYFLoCqtprhOyoVMabMEi0A/NL6CUnYhmBMIkPjsigPjlV IFEZTeaqNbbHnSNLUzskQL214Xne2kwsL0hb0ZrSU5Dv5wO0a43BGNG8jZN8SM1QFCCk XirRUjxRqZj1cS84keS722jrvvicFd8A1fdteAE2HvBHVF1TXGunWBhKLojyavrW8+n5 QCh/K2+pbb2h1CQcVLKX+9IGEjd9zxcy727nr4JL3DxrJW7IyazXJYcWHm+8d00bPonD OI0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=o5lLzhrY; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=VeHvaUqg; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=o5lLzhrY; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; spf=pass (google.com: domain of linux-kernel+bounces-8282-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8282-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id u6-20020a170903124600b001d066271702si1351410plh.318.2023.12.21.03.27.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 03:27:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-8282-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=o5lLzhrY; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=VeHvaUqg; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=o5lLzhrY; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; spf=pass (google.com: domain of linux-kernel+bounces-8282-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8282-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 52F43B22081 for ; Thu, 21 Dec 2023 11:26:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E969A6D1A4; Thu, 21 Dec 2023 11:26:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="o5lLzhrY"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="VeHvaUqg"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="o5lLzhrY"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="VeHvaUqg" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AEDDB6AB8F; Thu, 21 Dec 2023 11:26:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id C4FB821DBA; Thu, 21 Dec 2023 11:26:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1703158004; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=E/mUSHSfPZ+Yf1KncGnQnYY22sxHKtN68QzA+lLUhQY=; b=o5lLzhrYii6N3XBAgFNGNvhIXrHIy+LED3XqlesuqOKrq78YFXepc+WmeA7FHD4RuEIcgD 012odl2yj28G3yt/AeLEIE9nT+TyoU4feyI9lOJTP9GiSpPX/B9lpINRVsRexs0T1Vq9Ba ShFRkETV0td7baTLVFi1rpOXr2wv3LM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1703158004; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=E/mUSHSfPZ+Yf1KncGnQnYY22sxHKtN68QzA+lLUhQY=; b=VeHvaUqgMwgDvtJgqZqQ6+tExelDFer+HiKSJmXtH/rCR6jchWLO8pZHK2j70Hh85PKTmc hFtAGU0zEKY1a+CQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1703158004; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=E/mUSHSfPZ+Yf1KncGnQnYY22sxHKtN68QzA+lLUhQY=; b=o5lLzhrYii6N3XBAgFNGNvhIXrHIy+LED3XqlesuqOKrq78YFXepc+WmeA7FHD4RuEIcgD 012odl2yj28G3yt/AeLEIE9nT+TyoU4feyI9lOJTP9GiSpPX/B9lpINRVsRexs0T1Vq9Ba ShFRkETV0td7baTLVFi1rpOXr2wv3LM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1703158004; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=E/mUSHSfPZ+Yf1KncGnQnYY22sxHKtN68QzA+lLUhQY=; b=VeHvaUqgMwgDvtJgqZqQ6+tExelDFer+HiKSJmXtH/rCR6jchWLO8pZHK2j70Hh85PKTmc hFtAGU0zEKY1a+CQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id B695E13725; Thu, 21 Dec 2023 11:26:44 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id D3FCLPQghGXHWgAAD6G6ig (envelope-from ); Thu, 21 Dec 2023 11:26:44 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 69F04A07E3; Thu, 21 Dec 2023 12:26:44 +0100 (CET) Date: Thu, 21 Dec 2023 12:26:44 +0100 From: Jan Kara To: Christoph Hellwig Cc: linux-mm@kvack.org, "Matthew Wilcox (Oracle)" , Jan Kara , David Howells , Brian Foster , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 10/17] pagevec: Add ability to iterate a queue Message-ID: <20231221112644.2ijv6c5zooclcqtm@quack3> References: <20231218153553.807799-1-hch@lst.de> <20231218153553.807799-11-hch@lst.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231218153553.807799-11-hch@lst.de> X-Spam-Level: Authentication-Results: smtp-out1.suse.de; none X-Spam-Level: X-Spam-Score: -0.82 X-Spamd-Result: default: False [-0.82 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-0.998]; RCPT_COUNT_SEVEN(0.00)[8]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.cz:email,lst.de:email,infradead.org:email,suse.com:email]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; MID_RHS_NOT_FQDN(0.50)[]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-0.02)[52.12%] X-Spam-Flag: NO On Mon 18-12-23 16:35:46, Christoph Hellwig wrote: > 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 Looks good. Feel free to add: Reviewed-by: Jan Kara Honza > --- > 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 > -- Jan Kara SUSE Labs, CR