From: Marcelo Tosatti <mtosatti@redhat.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: Dave Chinner <david@fromorbit.com>,
linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
Alexander Viro <viro@zeniv.linux.org.uk>,
Christoph Hellwig <hch@lst.de>, Jens Axboe <axboe@kernel.dk>,
Frederic Weisbecker <frederic@kernel.org>,
Leonardo Bras <leobras@redhat.com>,
Yair Podemsky <ypodemsk@redhat.com>, P J P <ppandit@redhat.com>
Subject: Re: [PATCH v3] fs/buffer.c: update per-CPU bh_lru cache via RCU
Date: Thu, 2 Feb 2023 23:04:11 -0300 [thread overview]
Message-ID: <Y9xrm25NlbEReI7n@tpad> (raw)
In-Reply-To: <Y9w+b1MJ10uPDROI@casper.infradead.org>
On Thu, Feb 02, 2023 at 10:51:27PM +0000, Matthew Wilcox wrote:
> On Fri, Feb 03, 2023 at 09:36:53AM +1100, Dave Chinner wrote:
> > On Wed, Feb 01, 2023 at 01:01:47PM -0300, Marcelo Tosatti wrote:
> > >
> > > umount calls invalidate_bh_lrus which IPIs each
> >
> > via invalidate_bdev(). So this is only triggered on unmount of
> > filesystems that use the block device mapping directly, right?
While executing:
mount -o loop alpine-standard-3.17.1-x86_64.iso /mnt/loop/
mount-170027 [004] ...1 53852.213367: invalidate_bdev <-__invalidate_device
mount-170027 [004] ...1 53852.213468: invalidate_bdev <-bdev_disk_changed.part.0
mount-170027 [000] ...1 53852.222326: invalidate_bh_lrus <-set_blocksize
mount-170027 [000] ...1 53852.222398: invalidate_bh_lrus <-set_blocksize
systemd-udevd-170031 [011] ...1 53852.239794: invalidate_bh_lrus <-blkdev_flush_mapping
systemd-udevd-170029 [004] ...1 53852.240947: invalidate_bh_lrus <-blkdev_flush_mapping
> >
> > Or is the problem that userspace is polling the block device (e.g.
> > udisks, blkid, etc) whilst the filesystem is mounted and populating
> > the block device mapping with cached pages so invalidate_bdev()
> > always does work even when the filesystem doesn't actually use the
> > bdev mapping?
> >
> > > CPU that has non empty per-CPU buffer_head cache:
> > >
> > > on_each_cpu_cond(has_bh_in_lru, invalidate_bh_lru, NULL, 1);
> > >
> > > This interrupts CPUs which might be executing code sensitive
> > > to interferences.
> > >
> > > To avoid the IPI, free the per-CPU caches remotely via RCU.
> > > Two bh_lrus structures for each CPU are allocated: one is being
> > > used (assigned to per-CPU bh_lru pointer), and the other is
> > > being freed (or idle).
> >
> > Rather than adding more complexity to the legacy bufferhead code,
> > wouldn't it be better to switch the block device mapping to use
> > iomap+folios and get rid of the use of bufferheads altogether?
>
> Pretty sure ext4's journalling relies on the blockdev using
> buffer_heads. At least, I did a conversion of blockdev to use
> mpage_readahead() and ext4 stopped working.
And its actually pretty simple: the new invalidate_bh_lrus should be
straightforward use of RCU:
1. for_each_online(cpu)
cpu->bh_lrup = bh_lrus[1] (or 0)
2. synchronize_rcu_expedited() (wait for all previous users of
bh_lrup pointer to stop
referencing it).
3. free bh's in bh_lrus[0] (or 1)
next prev parent reply other threads:[~2023-02-03 12:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-01 16:01 [PATCH v3] fs/buffer.c: update per-CPU bh_lru cache via RCU Marcelo Tosatti
2023-02-02 22:36 ` Dave Chinner
2023-02-02 22:51 ` Matthew Wilcox
2023-02-03 2:04 ` Marcelo Tosatti [this message]
2023-02-03 5:49 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y9xrm25NlbEReI7n@tpad \
--to=mtosatti@redhat.com \
--cc=axboe@kernel.dk \
--cc=david@fromorbit.com \
--cc=frederic@kernel.org \
--cc=hch@lst.de \
--cc=leobras@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ppandit@redhat.com \
--cc=viro@zeniv.linux.org.uk \
--cc=willy@infradead.org \
--cc=ypodemsk@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.