Download raw body.
net lock kernel lock order
Hello,
On Fri, Jan 05, 2024 at 03:24:44PM +0100, Alexander Bluhm wrote:
> On Fri, Jan 05, 2024 at 03:05:44PM +0100, Claudio Jeker wrote:
> > 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
> >
> > this is incorrect. the kernel lock is aquired before the rwlock in a sleep
> > call.
>
> Yes. The kernel lock dance is done in mi_switch(). So the correct
> old sequence is:
>
> take kernel lock -> try net lock -> release kernel lock -> sleep
> -> take kernel lock -> take net lock
>
> But that does not change my argument that the sequence with my diff
> is cheaper.
>
I think the new sequence rather supports your diff. that's
at least my understanding.
regards
sashan
net lock kernel lock order