tech-net archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Making global variables of if.c MPSAFE

On 31 Jul, 2014, at 18:35 , Ryota Ozaki <> wrote:

> On Wed, Jul 30, 2014 at 11:47 AM, Ryota Ozaki <> 
> wrote:
>> We may be able to use pserialize(9) instead of rwlock(9)
>> for lockless read accesses. Can we simply replace rwlock
>> with pserialize?
> Self-answer: no
> pserialize(9) requires that we don't block (sleep) in
> a critical section while rwlock(9) allows to do so.
> And there is another undocumented constraint of pserialize,
> IIUC. It requires lockless operations on data shared
> between readers and a writer. (Correct me if I'm wrong.)
> In the case of ifnet_list, both requirements are not
> satisfied as it is. Adapting ifnet_list is not so easy
> task, and so I think using rwlock(9) is reasonable
> at this point.

?? I'm confused.  Which data shared between readers and writers
are you trying to protect, and were is it stored?  ifnet_list is
the head of a linked list.  About the only thing a reader can do
with a linked list is walk it, and about the only thing a writer
can do to a list is add something to it or delete something from
it.  I can't think of anything that would block any of those
operations.  How would a sleep happen?

Or is it the case that what you are trying to do is keep anyone
from modifying anything in a struct ifnet while someone else
is reading it?  If this is the problem you are trying to address
then I guess you would have to protect all struct ifnet readers,
not just those who found the ifnet structure from via the ifnet_list.
Readers mostly find ifnet structures via the pointers to them
stored in packet mbufs and in routes.

I thought I understood what it is you wanted to accomplish, but
I think I was mistaken.

Dennis Ferguson

Home | Main Index | Thread Index | Old Index