Re: Understanding locking for buf

From: Alexander Lochmann <alexander.lochmann_at_tu-dortmund.de>
Date: Thu, 16 Mar 2023 09:03:15 UTC

On 09.03.23 01:40, Konstantin Belousov wrote:
>> In our log, I see the following:
>> - Kernel tries to mount the rootfs via readsuper(). The thread id is 100002.
>> - 100002 allocates an instance of struct buf.
>> - The b_lock is acquired by 100002 in buf_alloc().
>> - Various accesses to buf by 100002.
>> - Various accesses to buf by 100033 during g_vfs_done().
>> - Again various accesses to buf by 100002.
>> - The instances is unlocked and freed by 100002. (readsuper() ->
>> ffs_use_bread() -> brelse() -> buf_free()[ -> BUF_UNLOCK()])
> I said that sometimes it is still subject to change even with sync ops.
Ok. Thx.

Is the following correct?
The aforementioned accesses by 100033 in g_vfs_done() are no violations 
with respect to the locking rule because from a global perspective the 
buf is locked. It is the only concurrent access at that moment.

- 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