From: Alexandr Nedvedicky Subject: Re: net lock kernel lock order To: Alexander Bluhm Cc: tech@openbsd.org Date: Fri, 5 Jan 2024 14:03:14 +0100 Hello, On Fri, Jan 05, 2024 at 01:26:15PM +0100, Alexander Bluhm wrote: > Hi, > > We have code that takes kernel lock just before net lock. As net > lock is a rwlock that releases kernel lock while sleeping, there > is never deadlock due to lock ordering. > > The order kernel lock -> net lock is suboptimal. If net lock is > held by another thread the following happens: > > take kernel lock -> try net lock -> release kernel lock -> sleep > -> take net lock -> take kernel lock > > If we change the order we get a less expensive sequence: > > try net lock -> sleep -> take net lock -> take kernel lock > > ok? yes, the change makes sense to me. OK sashan