Recursion in non-recursive mutex when using the grant table free callbacks

Pratyush Yadav pratyush at freebsd.org
Mon Jul 30 10:36:49 UTC 2018


On Mon, Jul 30, 2018 at 4:00 AM Akshay Jaggi <jaggi at freebsd.org> wrote:
>
> Roger would be a better person to answer this and I would wait for him to respond, but here are my 2 cents.
>
> First let's finalize and record the semantics of the callbacks. What guarantee do we want to provide callbacks about locks held (no locks held OR x,y,z locks held)? This is mostly a product decision. Usually callbacks are called with no locks held.
> Post this problem is simple. If the list_lock would be held during callbacks, we need to provide a lock-free function (which assumes lock would be held before function is called and use that) and if the lock would not be held we should fix the locking to ensure the case you mentioned should not happen.
>
> WDYT?

The guarantee we want to provide the callback is that the allocation
of grant references can not fail inside the callback (unless they try
to allocate more refs than initially specified). This means that we
can't call the callback without the lock held otherwise during the
execution of the callback it is possible for some other thread to get
the grant references, and the grant refs the callbacks needs would not
be available. So a change in the locking has to be done.

On Mon, Jul 30, 2018 at 3:02 PM Roger Pau Monné <royger at freebsd.org> wrote:
> I agree in the analysis, however I think the proper solution is to use
> a recursive lock.

All right. I'll send in the patch.

--
Regards,
Pratyush Yadav


More information about the freebsd-xen mailing list