tech-kern archive

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

Re: Making bpf MPSAFE (was Re: struct ifnet and ifaddr handling ...)



Darren Reed <darrenr%netbsd.org@localhost> wrote:
> Looking at the use of pserialze functions, you've got a single
> data structure (bpf_iflist) that is at some times covered by
> bpf_iflist_mtx and others not. That's a bad design. Ideally the
> data structure should only be covered by one locking mechanism
> so you need to choose whether it is pserialize or mutex. Most
> of the work seems easy enough to do with mutex - except for the
> copyout section: that will take more thought. If you can't make
> it work with just one locking mechanism then ensure that you
> always use the same constructs for all of the code paths that
> work with bpf_iflist (none are time critical.)

Generally yes, but it is worth to note that using multiple mechanisms for
lockless data structures can be perfectly fine approach.  For example, the
design of a data structure will usually be much simpler if you do not need
concurrent writers (i.e. just serialise them using a mutex).

-- 
Mindaugas


Home | Main Index | Thread Index | Old Index