Understanding locking for buf
- Reply: Konstantin Belousov : "Re: Understanding locking for buf"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 24 Feb 2023 14:00:57 UTC
Hi Konstantin! I'm sorry. I'm still struggling to understand locking of struct buf. As far as I know, a struct buf is (mostly) protected by b_lock. You already explained the concept of LK_KERNPROC. I, however, have an instance of struct buf. That particular one is mostly accessed from just one context (aka thread) -- assuming synchronous IO. The other, unprotected accesses come from just one other context. Those accesses originate from 'g_vfs_done' [1]. Why don't you release b_lock when buf goes further down the io stack, and acquire it again in g_vfs_done? This way the context of g_vfs_done would own the b_lock. Viewing it from a different angle: Are accesses in g_vfs_done safe because the buf instance is already locked from a global perspective? Hence, other code paths would block on BUF_LOCK(). Regards, Alex [1] https://iris.cs.tu-dortmund.de/freebsd-lockdoc/latest/source/sys/geom/geom_vfs.c#L96 -- 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