Discussion:
bnx_tick and the kernel lock
(too old to reply)
Greg Troxel
2012-04-17 20:00:05 UTC
Permalink
I have some systems where the bnx driver seems to lose mbuf clusters
under heavy load.

Looking at the code, I see bnx_tick called by a callout, and it does
splnet but does not seem to take the KERNEL_LOCK. It seems like the
rule for the rest of the driver is to be at splnet and have the kernel
lock, so this seems wrong.

Are callouts automatically invoked with the big lock? It seems like
they aren't (and shouldn't be) since they can be used in mpsafe code.
Manuel Bouyer
2012-04-17 20:12:22 UTC
Permalink
Post by Greg Troxel
I have some systems where the bnx driver seems to lose mbuf clusters
under heavy load.
Looking at the code, I see bnx_tick called by a callout, and it does
splnet but does not seem to take the KERNEL_LOCK. It seems like the
rule for the rest of the driver is to be at splnet and have the kernel
lock, so this seems wrong.
Are callouts automatically invoked with the big lock? It seems like
they aren't (and shouldn't be) since they can be used in mpsafe code.
They are called with the big lock, for thoses which have been initialized
with CALLOUT_MPSAFE (which AFAIK bnx(4) does not).
--
Manuel Bouyer <***@antioche.eu.org>
NetBSD: 26 ans d'experience feront toujours la difference
--

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Thor Lancelot Simon
2012-04-17 20:23:07 UTC
Permalink
Post by Manuel Bouyer
Post by Greg Troxel
I have some systems where the bnx driver seems to lose mbuf clusters
under heavy load.
Looking at the code, I see bnx_tick called by a callout, and it does
splnet but does not seem to take the KERNEL_LOCK. It seems like the
rule for the rest of the driver is to be at splnet and have the kernel
lock, so this seems wrong.
Are callouts automatically invoked with the big lock? It seems like
they aren't (and shouldn't be) since they can be used in mpsafe code.
They are called with the big lock, for thoses which have been initialized
with CALLOUT_MPSAFE (which AFAIK bnx(4) does not).
"Those which have *not* been initialized with..." I think you mean?

Thor

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Manuel Bouyer
2012-04-17 20:35:15 UTC
Permalink
Post by Thor Lancelot Simon
Post by Manuel Bouyer
Post by Greg Troxel
I have some systems where the bnx driver seems to lose mbuf clusters
under heavy load.
Looking at the code, I see bnx_tick called by a callout, and it does
splnet but does not seem to take the KERNEL_LOCK. It seems like the
rule for the rest of the driver is to be at splnet and have the kernel
lock, so this seems wrong.
Are callouts automatically invoked with the big lock? It seems like
they aren't (and shouldn't be) since they can be used in mpsafe code.
They are called with the big lock, for thoses which have been initialized
with CALLOUT_MPSAFE (which AFAIK bnx(4) does not).
"Those which have *not* been initialized with..." I think you mean?
Yes, I got things reversed, sorry. To make it clear:
a callout initialized with CALLOUT_MPSAFE will be called without the
KERNEL_LOCK
a callout initialized without CALLOUT_MPSAFE will be called with the
KERNEL_LOCK held.

bnx(4) doesn't initialize its callout with CALLOUT_MPSAFE, so the
callout callback is called with the KERNEL_LOCK held.
--
Manuel Bouyer <***@antioche.eu.org>
NetBSD: 26 ans d'experience feront toujours la difference
--

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Loading...