Re: Understanding locking for buf

From: Alexander Lochmann <alexander.lochmann_at_tu-dortmund.de>
Date: Wed, 01 Mar 2023 18:03:47 UTC

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++;'.

- Alex

-- 
Technische Universität Dortmund
Computer Science XII - System Software Group
Alexander Lochmann                PGP key: 0xBC3EF6FD
Otto-Hahn-Str. 16                 phone:  +49.231.7556141
D-44227 Dortmund                  fax:    +49.231.7556116
https://sys.cs.tu-dortmund.de/al