Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp80729rdb; Thu, 21 Dec 2023 03:30:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IFCK6HG1SaD3JcAprfSu84PH/y6YNAh+Yt4u6ZwLPsrSHdBSZBXV2f1z2wlSnoCYUqg8dqQ X-Received: by 2002:a17:902:fc45:b0:1d3:6da5:3009 with SMTP id me5-20020a170902fc4500b001d36da53009mr17896664plb.79.1703158227253; Thu, 21 Dec 2023 03:30:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703158227; cv=none; d=google.com; s=arc-20160816; b=0n9hLJ9c0Hz2J91JwOtBWzVFtHWl6X3kijXjDiDptSpt7Arg/Zsj3nGM3UHVvcnvhf qntBOnsaWJ2T45yiMR0S7rAkc/ZuarU+Ap0mnH1y7WsDFONwcfOBguaP3i5pKzG8RcL/ +hNWevle6iP4JxXo0FErfj5xrN4j6nOB8QH4m5AXzDY5XPJ5UeINP+jHG8EQHfjUVLIC wASH3GlBn/e4nxN51VzPpXMXLt9W7CkRi6jXBLd1H8mJf4eJOOkWAEo2dYqb4JWB+xQo t/BJ4LZnjGJ0HRRmV18gmO2IYwGRjDOGFBHsbDdi4OOPQlM77BKR6NiR9aKWyDFWKtb0 Bccw== 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=collHDGGumjW8qJbYtol2//lRSPeWpd6YSa6qeEokGw=; fh=i6rGHk/clC1f9Y4mpJyYVOWW6p98QflrI/jjeassMJc=; b=oglNJYVYpvMxLw2HS+QDm+ikq4IG2a8gsC80n5KcholXiCA50EbcErUmgKNc2XgCIT Szl5pC4A+4VK8CmEckoXEhqvh6jZKUKuQphTzW5ehGJgZjTaEUrS9R0geeGuJ8fU/EnX gVh64VlfvHhigvOgYu5U31ZlmwDcwzEMRYnZ8UaGk/k0L3iH/9/hRywcNifR8M01lYCh obzwV1ojKSIuupNt38Tv3XOTLj7BjEzKoJlTXPkzq79T4XNnGCrz10olpG0nOhUzjnc6 eTNo2wa3BztPB0/FHWm/gJqO+cYEWMPVsekFhs2E5n+LQlCsQnBZT0Xx3TsJo+a5WOkQ bfKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=R5hSwd5l; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=bSqK6InS; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; spf=pass (google.com: domain of linux-kernel+bounces-8285-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8285-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 f3-20020a170902e98300b001d07c2a582dsi1334690plb.507.2023.12.21.03.30.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 03:30:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-8285-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=R5hSwd5l; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=bSqK6InS; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; spf=pass (google.com: domain of linux-kernel+bounces-8285-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8285-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 90F25B228F7 for ; Thu, 21 Dec 2023 11:30:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8E6256D1AF; Thu, 21 Dec 2023 11:30:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="R5hSwd5l"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="aBv5zKwx"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="bSqK6InS"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="KAYg9i7z" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (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 539EF6A34B; Thu, 21 Dec 2023 11:30:06 +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 [IPv6:2a07:de40:b281:104: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-out2.suse.de (Postfix) with ESMTPS id 78E901FDAA; Thu, 21 Dec 2023 11:30:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1703158204; 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=collHDGGumjW8qJbYtol2//lRSPeWpd6YSa6qeEokGw=; b=R5hSwd5ljiBreUag5bpe26RA2Dib9xWRSV/QlS/3nrZjR3YvcP5lqg0EKSpmh0aXFdPdFC jNQnjf4KAlEnJVvKa+FKM+XVUasXG4un0cpuI3bD7XNao3NCIzDzIazds9JSISDvWluSyY ePYN6JLvZWw1EmfLOEj+fZ14TxWc0kQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1703158204; 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=collHDGGumjW8qJbYtol2//lRSPeWpd6YSa6qeEokGw=; b=aBv5zKwxXGp22hWnr06AJDGuNmzdxlk6VCN5FWEIT8F6L8UdmTiy/pcZN8ezyLfo8GO07Q g1wSq6RJMSKIeBCQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1703158203; 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=collHDGGumjW8qJbYtol2//lRSPeWpd6YSa6qeEokGw=; b=bSqK6InSzvg37MNHX9AIIVbyuK05c1VwhItUctNBqWE0yoPGIAEAnMDcteL0MLv+bbKc/z e+ODmi4h6YvZtwWPsrAYX03/RKcam2FBLV/i3D36KVY7Cdt1LcEdd8tNEP8L07zjPqp7of KZvAnEgWO/KYXCt/Qankm1sAxyQ6tZI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1703158203; 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=collHDGGumjW8qJbYtol2//lRSPeWpd6YSa6qeEokGw=; b=KAYg9i7zFcAH75mXRS/00Q5UnZXz80vQjKHM4zwbrMdKc8EPSx5zheHSAbZYlae6RSCeyt dcFNZ9qVnFAOW4AA== 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 6D47E13725; Thu, 21 Dec 2023 11:30:03 +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 Bu+uGrshhGXdWwAAD6G6ig (envelope-from ); Thu, 21 Dec 2023 11:30:03 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 1FE0EA07E3; Thu, 21 Dec 2023 12:29:59 +0100 (CET) Date: Thu, 21 Dec 2023 12:29:59 +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 12/17] writeback: Factor writeback_iter_init() out of write_cache_pages() Message-ID: <20231221112959.du2lplmxa2uquuf6@quack3> References: <20231218153553.807799-1-hch@lst.de> <20231218153553.807799-13-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-13-hch@lst.de> X-Spam-Level: * X-Spam-Level: Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=bSqK6InS; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=KAYg9i7z X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-1.24 / 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]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; MIME_GOOD(-0.10)[text/plain]; NEURAL_HAM_LONG(-1.00)[-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)[8]; DBL_BLOCKED_OPENRESOLVER(0.00)[lst.de:email,suse.cz:dkim,suse.cz:email,infradead.org:email,suse.com:email]; NEURAL_HAM_SHORT(-0.20)[-1.000]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; MID_RHS_NOT_FQDN(0.50)[]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-0.23)[72.50%]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from] X-Spam-Score: -1.24 X-Rspamd-Queue-Id: 78E901FDAA X-Spam-Flag: NO On Mon 18-12-23 16:35:48, Christoph Hellwig wrote: > From: "Matthew Wilcox (Oracle)" > > Make it return the first folio in the batch so that we can use it > in a typical for() pattern. > > Signed-off-by: Matthew Wilcox (Oracle) > Signed-off-by: Christoph Hellwig Looks good. Feel free to add: Reviewed-by: Jan Kara Honza > --- > mm/page-writeback.c | 39 ++++++++++++++++++++------------------- > 1 file changed, 20 insertions(+), 19 deletions(-) > > diff --git a/mm/page-writeback.c b/mm/page-writeback.c > index 70f42fd9a95b5d..efcfffa800884d 100644 > --- a/mm/page-writeback.c > +++ b/mm/page-writeback.c > @@ -2442,6 +2442,22 @@ static bool should_writeback_folio(struct address_space *mapping, > return true; > } > > +static struct folio *writeback_iter_init(struct address_space *mapping, > + struct writeback_control *wbc) > +{ > + if (wbc->range_cyclic) > + wbc->index = mapping->writeback_index; /* prev offset */ > + else > + wbc->index = wbc->range_start >> PAGE_SHIFT; > + > + if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages) > + tag_pages_for_writeback(mapping, wbc->index, wbc_end(wbc)); > + > + wbc->err = 0; > + folio_batch_init(&wbc->fbatch); > + return writeback_get_next(mapping, wbc); > +} > + > /** > * write_cache_pages - walk the list of dirty pages of the given address space and write all of them. > * @mapping: address space structure to write > @@ -2477,29 +2493,14 @@ int write_cache_pages(struct address_space *mapping, > struct writeback_control *wbc, writepage_t writepage, > void *data) > { > + struct folio *folio; > int error; > - pgoff_t end; /* Inclusive */ > > - if (wbc->range_cyclic) { > - wbc->index = mapping->writeback_index; /* prev offset */ > - end = -1; > - } else { > - wbc->index = wbc->range_start >> PAGE_SHIFT; > - end = wbc->range_end >> PAGE_SHIFT; > - } > - if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages) > - tag_pages_for_writeback(mapping, wbc->index, end); > - > - folio_batch_init(&wbc->fbatch); > - wbc->err = 0; > - > - for (;;) { > - struct folio *folio = writeback_get_next(mapping, wbc); > + for (folio = writeback_iter_init(mapping, wbc); > + folio; > + folio = writeback_get_next(mapping, wbc)) { > unsigned long nr; > > - if (!folio) > - break; > - > folio_lock(folio); > if (!should_writeback_folio(mapping, wbc, folio)) { > folio_unlock(folio); > -- > 2.39.2 > -- Jan Kara SUSE Labs, CR