Re: Understanding locking for buf

From: Konstantin Belousov <kostikbel_at_gmail.com>
Date: Fri, 03 Mar 2023 00:19:32 UTC
On Wed, Mar 01, 2023 at 07:03:47PM +0100, Alexander Lochmann wrote:
> 
> 
> On 28.02.23 16:37, Konstantin Belousov wrote:
> > On Mon, Feb 27, 2023 at 04:04:30PM +0100, Alexander Lochmann wrote:
> > > 
> > > 
> > > On 27.02.23 15:23, Konstantin Belousov wrote:
> > > > Not quite.  Sync io (bread()) means that caller performs bufwait() on the
> > > > buffer.  It is still subject to the LK_KERNPROC ownership move.
> > > Ehm. Has this behavior changed recently?
> > > Our kernel version uses LK_KERNPROC to distinguish between sync and async
> > > IO. How would that be possible if ownershipt changes in either case?
> > > https://iris.cs.tu-dortmund.de/freebsd-lockdoc/latest/source/sys/geom/geom_vfs.c#L127
> > I think this is simply not _very_ accurate.  It would still catch some sync
> > operations.
> > 
> I'm sorry. What do you mean? Can you please give more details?
> 
> You said that the buf is still subject to the LK_KERNPROC ownership move
> even for sync IO.
> But why is LK_KERNPROC used to distinguish between sync and async IO?
> Have look at g_vfs_done: https://iris.cs.tu-dortmund.de/freebsd-lockdoc/latest/source/sys/geom/geom_vfs.c#L127
> If you ownership is moved in either case, none of the following lines would
> be executed: 'mp->mnt_stat.f_syncreads++;' 'mp->mnt_stat.f_syncwrites++;'.

All it means it that the statistic output by mount -v would be somewhat off
in the split of io ops by sync/async.  The total count is still correct.