[ofa-general] Re: multiple threads posting to the same QP

Roland Dreier rdreier at cisco.com
Mon Oct 1 13:46:07 PDT 2007


 > So the locking should be provided by the low-level per device library?

Yes.

 > if this is the case, I fail to see this documented anywhere.

I don't believe anyone has actually written it down anywhere.

 > Also do we actually want locking in the fast posting path? for example
 > is it legal to call send(2) on the same socket fd from two threads?

Yes, I think every call must be fully thread safe, for a few reasons.
First, if we try to make some calls not thread safe then we will
undoubtedly has application authors creating races and reporting
strange bugs.  Second, pushing the locking to the low-level driver
actually allows smarter locking to be used -- cf the slightly tricky
way that mthca/mlx4 lock CQs during QP destroy to avoid taking the QP
table lock during poll CQ operations.

I guess it would be possible to compile a special driver library with
all pthread calls stubbed out, for use in single-threaded
applications, but I'm not convinced it's worth it.

(And BTW, yes, it is possible to call send(2) in any racy way you want
on the same FD, and the kernel's internal state will not get messed
up)

 - R.



More information about the general mailing list