Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp6701929rdb; Fri, 15 Dec 2023 06:15:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IFl72aIDWDQG1ZRugJDLGqpoOUI6lNabOexbe+aG3UNfjPnZ29Yr/mZlu1To8Ms5uz8GzKk X-Received: by 2002:a05:6a20:f381:b0:190:fca:72df with SMTP id qr1-20020a056a20f38100b001900fca72dfmr6308512pzb.93.1702649707474; Fri, 15 Dec 2023 06:15:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702649707; cv=none; d=google.com; s=arc-20160816; b=zzVQuOuCijZg1x7pfZxxYil2S30EajlWnIlEEAhpM8TDdmJ6XXSCuqTiGyGwMMifXc Jigx2re5lmTFHkTAL/zIuI8fhypemIUdt4wP9mFsbp/ecE+MgxP+l0VqFRqnbAj+/td4 FMopcBXB35/UFLVawu0/H3OwwGch9Of2oYZBmcYKUN6g1PvXeAsJWjhvRMYrG3XcJ+pN j65SUQxl3dzwFShzdy3KD3ZRJg7ZluAa+0adBOI/gj+yW89lsHt2Seru1CbwBMQZ5XOb rUAttWnr3oyF97LgPN/f5RATIeNUK1DPztTj8C45bhWP69Z27zPXRyb9oWMzTXFBL3m4 mD7Q== 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=9rGIZBAj/ZudqVVlhby5XQEzqLM1rUnhm0PltEExyhg=; fh=/w0dc2O7V6smQOgU7WkICsW4zuan5V76Fq7j5x7mZ4o=; b=LkFV7UuWea0sHa45BWCFcUFXS9HXdCpenPizPVp/UEZSy8kR3xwnE8QVo21+mYJ44a ueoTuIwT9R1d+rfdKvXUzL2NEeFkRGic5E+LQSZZ0lZCHknheWBo70Yw2VA6d3ShsETB McsZpCLDDWs5UF8LWXb+t1Iue5qexzd3XUwexnou46bVcCe6LG9bgXKX5dcvDkIB5eY9 qrML/aZT5SbUVNEgP/a5qe2OutZisBWwd/4s3qN469bCuNMMyOFB8eurHHEDLe7jj576 /r/s7sxVYt9Q46YM7/f33zJY+5KpcmzoWTTTNPXldUm68a+JlSoYBy//viGw4pRWbHna SWZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=So1itEuk; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=iBS8k4A1; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=So1itEuk; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-kernel+bounces-1093-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1093-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id fi42-20020a056a0039aa00b006d0d8f1628asi4140136pfb.284.2023.12.15.06.15.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 06:15:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-1093-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=@suse.cz header.s=susede2_rsa header.b=So1itEuk; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=iBS8k4A1; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=So1itEuk; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-kernel+bounces-1093-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1093-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 E3EC6285FA2 for ; Fri, 15 Dec 2023 14:15:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C9D0C3032F; Fri, 15 Dec 2023 14:14:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="So1itEuk"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="iBS8k4A1"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="So1itEuk"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="iBS8k4A1" 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 6680B2C6B0; Fri, 15 Dec 2023 14:14:56 +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 imap2.dmz-prg2.suse.org (imap2.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:98]) (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 1C5DB2261D; Fri, 15 Dec 2023 14:14:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1702649694; 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=9rGIZBAj/ZudqVVlhby5XQEzqLM1rUnhm0PltEExyhg=; b=So1itEuk4cbDq4+Z0ytr67lbZSZry+Rf/RAe0VItXQP/eJy0gkb6CeQTjreGZ21VtIwW50 gl4HQjZQwzUSI9NneszNKnOHkASy87D2psWUPKKZZKrvDwYpg+p56YmZg0HvQ7BMuyWSEa fSfr6et83NHGYzGoS3Z4kG10gWczMQw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1702649694; 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=9rGIZBAj/ZudqVVlhby5XQEzqLM1rUnhm0PltEExyhg=; b=iBS8k4A1ecJteXNNcdGaAUieR+sg8z0/4Af6fS3MLLLEJISwLF3Mipz7JN1o3n6DS+MzlD 1WskMnjSntUL29Aw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1702649694; 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=9rGIZBAj/ZudqVVlhby5XQEzqLM1rUnhm0PltEExyhg=; b=So1itEuk4cbDq4+Z0ytr67lbZSZry+Rf/RAe0VItXQP/eJy0gkb6CeQTjreGZ21VtIwW50 gl4HQjZQwzUSI9NneszNKnOHkASy87D2psWUPKKZZKrvDwYpg+p56YmZg0HvQ7BMuyWSEa fSfr6et83NHGYzGoS3Z4kG10gWczMQw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1702649694; 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=9rGIZBAj/ZudqVVlhby5XQEzqLM1rUnhm0PltEExyhg=; b=iBS8k4A1ecJteXNNcdGaAUieR+sg8z0/4Af6fS3MLLLEJISwLF3Mipz7JN1o3n6DS+MzlD 1WskMnjSntUL29Aw== Received: from imap2.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 imap2.dmz-prg2.suse.org (Postfix) with ESMTPS id 0AB0D13BA0; Fri, 15 Dec 2023 14:14:54 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id T8eYAl5ffGXRZwAAn2gu4w (envelope-from ); Fri, 15 Dec 2023 14:14:54 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 63C54A07E0; Fri, 15 Dec 2023 15:14:45 +0100 (CET) Date: Fri, 15 Dec 2023 15:14:45 +0100 From: Jan Kara To: Christoph Hellwig Cc: linux-mm@kvack.org, "Matthew Wilcox (Oracle)" , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Jan Kara , David Howells Subject: Re: [PATCH 02/11] writeback: Factor writeback_get_batch() out of write_cache_pages() Message-ID: <20231215141445.rnt34v6emxulezde@quack3> References: <20231214132544.376574-1-hch@lst.de> <20231214132544.376574-3-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: <20231214132544.376574-3-hch@lst.de> X-Spam-Level: X-Spam-Level: Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=So1itEuk; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=iBS8k4A1 X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-1.01 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; 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]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.cz:+]; MX_GOOD(-0.01)[]; RCPT_COUNT_SEVEN(0.00)[7]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; MID_RHS_NOT_FQDN(0.50)[]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-0.00)[35.36%] X-Spam-Score: -1.01 X-Rspamd-Queue-Id: 1C5DB2261D X-Spam-Flag: NO On Thu 14-12-23 14:25:35, Christoph Hellwig wrote: > From: "Matthew Wilcox (Oracle)" > > This simple helper will be the basis of the writeback iterator. > To make this work, we need to remember the current index > and end positions in writeback_control. > > Signed-off-by: Matthew Wilcox (Oracle) > Signed-off-by: Christoph Hellwig Just some nits: > --- a/include/linux/writeback.h > +++ b/include/linux/writeback.h > @@ -81,6 +81,8 @@ struct writeback_control { > > /* internal fields used by the ->writepages implementation: */ > struct folio_batch fbatch; > + pgoff_t index; > + pgoff_t end; /* inclusive */ > pgoff_t done_index; I don't think we need to cache 'end' since it isn't used that much. In writeback_get_batch() we can just compute it locally as: if (wbc->range_cyclic) end = -1; else end = wbc->range_end >> PAGE_SHIFT; and in the termination condition of the loop we can have it like: while (wbc->range_cyclic || index <= wbc->range_end >> PAGE_SHIFT) Also I don't think we need both done_index and index since they are closely related and when spread over several functions it gets a bit confusing what's for what. So I'd just remove done_index, use index instead for setting writeback_index and just reset 'index' to the desired value in those two cases where we break out of the loop early and thus index != done_index. I'm sorry for nitpicking about these state variables but IMO reducing their amount actually makes things easier to verify (and thus maintain) when they are spread over several functions. Honza -- Jan Kara SUSE Labs, CR