From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98FABE77187 for ; Wed, 18 Dec 2024 20:05:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 076C96B007B; Wed, 18 Dec 2024 15:05:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0261A6B0082; Wed, 18 Dec 2024 15:05:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E57DA6B0083; Wed, 18 Dec 2024 15:05:41 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id C6E696B007B for ; Wed, 18 Dec 2024 15:05:41 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 68B9B1C81A1 for ; Wed, 18 Dec 2024 20:05:41 +0000 (UTC) X-FDA: 82909158528.01.A9B132A Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf10.hostedemail.com (Postfix) with ESMTP id 2D00FC0019 for ; Wed, 18 Dec 2024 20:05:23 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=R7NGvB9n; spf=none (imf10.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734552324; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=EbdwqBnCPnMA30/eAen6jZBripOiH8JSBeZk3CDGHT0=; b=C0dhBrrCknWjfUsppkr9SgwjySEzTAsu+/bFye5MMD+miQaRyenq3BCtzNg1p6ixSDnjeC mLkBVlBcUshieDomuHnquOV7iH8LW4hAjTPhBk/xg+z0rrp8leI3uPBiKUCzq9IVf4EDRk rCGgGOARhB3G0Z3qcQZlgGDaNPGzt6I= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=R7NGvB9n; spf=none (imf10.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734552324; a=rsa-sha256; cv=none; b=22kRJsYvxmXHDM3d8Povk9cVo+eDiOFbmWIVzhSJB1DtNufn9lIZ0HC0F5V5xObhk1KcVF M4akM0h/2G9x6YM4Wo6h9MO9EjLihimIh4ri/BZcZ39+IDL8nTJ5d02HSHbZpyPoPhYweg c+pVyx0lKKBsSw1BW7muqpPbQdGkOUY= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=EbdwqBnCPnMA30/eAen6jZBripOiH8JSBeZk3CDGHT0=; b=R7NGvB9nGB2rbrdZXVCuILMXRe 6fmvKr1WgwvzkZhMhJW1PJzMTyEuJsnWTFwEK82TXW4t5hUGJW7Nexip8W/K1+F1Q12BIglQCnyLF SDx+wVu5qUHUgTrgTQ3/tpdPfrIJwQfnAs6JA8eaPfbn+wXalYMY7TLJYsX/0+C6Xc9wMc1dear2s 7qLxZ9KeymLgW3g3D3K53JGnUkcByEVsfIwGZI/BKzd72GsLBSC+/mVU3RFnOp7NYUUaJqqnJ+4Cr Ut9cfQZtp12r2GmgXhlExf2I0wmGOetu+44l4rJptA1C0p/kKg0nEKarItbjCDFvxbUpLQexaLluF il4EFXSg==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tO0IT-00000000ZPU-10Y0; Wed, 18 Dec 2024 20:05:29 +0000 Date: Wed, 18 Dec 2024 20:05:29 +0000 From: Matthew Wilcox To: Luis Chamberlain Cc: hare@suse.de, dave@stgolabs.net, david@fromorbit.com, djwong@kernel.org, kbusch@kernel.org, john.g.garry@oracle.com, hch@lst.de, ritesh.list@gmail.com, linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-block@vger.kernel.org, gost.dev@samsung.com, p.raghav@samsung.com, da.gomez@samsung.com, kernel@pankajraghav.com Subject: Re: [PATCH 0/5] fs/buffer: strack reduction on async read Message-ID: References: <20241218022626.3668119-1-mcgrof@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20241218022626.3668119-1-mcgrof@kernel.org> X-Rspamd-Queue-Id: 2D00FC0019 X-Stat-Signature: fzy16a34gn9e7ewgq74m6das8htgwy6c X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1734552323-82063 X-HE-Meta: U2FsdGVkX18H0Ts58BwQao6PrYGj4Wiphdxy2a8AqxKuXpVJp1bEDQ14c3uhIRaWyNrgOq7VsVsn43+nARGJjomV9UoIqAWRaibpSOwl/fFo5H/85HJXeJGduCWpfrDpPe3xftefThZ3sE6pheFtvpalv/5Yu9GhibMmnVA7pWwfdYEXPYJAL+pUxsYajKgjjxD3bgwdNulDUZzZVJtpZvMw6EwTr24dzfr0avXNRqYhqtPf2IjgSfUA+2cNWkuFWrxSgXeYgf19+gZ6I0/yGhj44jMe+3Hd3HFc5n08qZFvrpdPNLYcCok/1GvJ1kFJ0mrvFosvgRub1eeooTFfYRYiwfxkaX/Dvv5iDEDv8yODJioOCk/eIxTj5pKMcBch+oGsTtQk3z4c5xuiwjGnv695GvciBNHRJVs3mzQR5+TfIquhztGZGO7/kOWOdsOQgO7nJjIwIggVC0G4gnvCwD+TZs2N5KskZU/24TvbsfPgAAoF4w8hLUqKRNjN7cuiz5LOiYlNVIu/wQs1+s3Bt1hwhNTtVawrJGarrvU6OEwnmKYdgrUrzX9YpEJtRU/cGYzRr3DfkvKwEhtFwyxJTFuGuEIJkvZoNgQ8deBDbOvJNFLHWpMRPiyDuuCzwwanduOoEJLiKgolWmdmjrd2jS2XiczXq4QfEmoevhCdxwXDsaD4AkUSYypGhA8QYZgZRk5X2TiM7Gp/iDL1A34zWeBNBj2F9eu0qflZ3oE4Jo64YF9tvHfUE20kZpF7pwOXpY0htpx1iaPjDN0uFHDiHB0LuzfNOT9vO5dEajeCNZEEoelAHbi9Dr3WjOGm5y6RQFTJ1I42GT1UjQjJkW2hh1SKeXcuuVHmDPTdQR/b04cf0hLBL1Mggn85WtDyqqDl68DiHz370ToYPTgD1dNHufIFBFKMtBv2ZIP1zTMlVFfeVVCPoyvCyN3YWCc9zKcCaxIpCLM5PVCH0YdZv6U 1Nt3Y4Op RPQpAs+VjEsczsRifpBm6Nq31lD85VgbQEVP/3SzGOArcWYByLuAfH1rrCmRYer1d4jV3P3Su2OBsZzy8E0w/ZUiJd5uTfOFKaXbzUk1KiOAnJDBhe1W0YHa47i6pQzFRxq7oPm7LuCvFbWd6XCZQBK9Z34wGxSBprvUlrW6xTtRQhVa0YixMwcYHAiD0eR+PeHXnpQ+sy3UQ8dhPvRe0OBDGYgsfV7xOmUgmmeRFsFzfOgk1b5EwSYoLhDQmToivx5thHCOlYNdi+8OtSF6cyL9RpM0GDWhfvwFkhNrhjPrxQo0= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Tue, Dec 17, 2024 at 06:26:21PM -0800, Luis Chamberlain wrote: > This splits up a minor enhancement from the bs > ps device support > series into its own series for better review / focus / testing. > This series just addresses the reducing the array size used and cleaning > up the async read to be easier to read and maintain. How about this approach instead -- get rid of the batch entirely? diff --git a/fs/buffer.c b/fs/buffer.c index cc8452f60251..f50ebbc1f518 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -2361,9 +2361,9 @@ int block_read_full_folio(struct folio *folio, get_block_t *get_block) { struct inode *inode = folio->mapping->host; sector_t iblock, lblock; - struct buffer_head *bh, *head, *arr[MAX_BUF_PER_PAGE]; + struct buffer_head *bh, *head; size_t blocksize; - int nr, i; + int i, submitted = 0; int fully_mapped = 1; bool page_error = false; loff_t limit = i_size_read(inode); @@ -2380,7 +2380,6 @@ int block_read_full_folio(struct folio *folio, get_block_t *get_block) iblock = div_u64(folio_pos(folio), blocksize); lblock = div_u64(limit + blocksize - 1, blocksize); bh = head; - nr = 0; i = 0; do { @@ -2411,40 +2410,30 @@ int block_read_full_folio(struct folio *folio, get_block_t *get_block) if (buffer_uptodate(bh)) continue; } - arr[nr++] = bh; + + lock_buffer(bh); + if (buffer_uptodate(bh)) { + unlock_buffer(bh); + continue; + } + + mark_buffer_async_read(bh); + submit_bh(REQ_OP_READ, bh); + submitted++; } while (i++, iblock++, (bh = bh->b_this_page) != head); if (fully_mapped) folio_set_mappedtodisk(folio); - if (!nr) { - /* - * All buffers are uptodate or get_block() returned an - * error when trying to map them - we can finish the read. - */ - folio_end_read(folio, !page_error); - return 0; - } - - /* Stage two: lock the buffers */ - for (i = 0; i < nr; i++) { - bh = arr[i]; - lock_buffer(bh); - mark_buffer_async_read(bh); - } - /* - * Stage 3: start the IO. Check for uptodateness - * inside the buffer lock in case another process reading - * the underlying blockdev brought it uptodate (the sct fix). + * All buffers are uptodate or get_block() returned an error + * when trying to map them - we must finish the read because + * end_buffer_async_read() will never be called on any buffer + * in this folio. */ - for (i = 0; i < nr; i++) { - bh = arr[i]; - if (buffer_uptodate(bh)) - end_buffer_async_read(bh, 1); - else - submit_bh(REQ_OP_READ, bh); - } + if (!submitted) + folio_end_read(folio, !page_error); + return 0; } EXPORT_SYMBOL(block_read_full_folio);