Messages in this thread | | | Date | Wed, 22 Dec 2021 18:06:25 +0100 | Subject | Re: [PATCH] ipc/sem: do not sleep with a spin lock held | From | Manfred Spraul <> |
| |
Hi Vasily,
On 12/22/21 16:50, Vasily Averin wrote: > On 22.12.2021 18:31, Vasily Averin wrote: >> On 22.12.2021 14:45, Manfred Spraul wrote: >>> Hi Minghao, >>> >>> On 12/22/21 09:10, cgel.zte@gmail.com wrote: >>>> From: Minghao Chi <chi.minghao@zte.com.cn> >>>> >>>> We can't call kvfree() with a spin lock held, so defer it. >> I'm sorry, but I do not understand why exactly we cannot use kvfree? >> Could you explain it in more details? > Got it, > there is cond_resched() called in __vfree() -> __vunmap() > > However I'm still not sure that in_interrupt() is used correctly here.
I see three different topics:
- is the current code violating the API? I think yes, thus there is a bug that needs to be fixed.
- Where is __vunmap() sleeping? Would it be possible to make __vunmap() safe to be called when owning a spinlock?
- should kvfree() use vfree() [i.e. unsafe when owning a spinlock] or vfree_atomic [i.e. a bit slower, but safe]
As we did quite many s/kfree/kvfree/ changes, perhaps just switching to vfree_atomic() is the best solution.
@Andrew: What would you prefer?
In addition, if we do not use vfree_atomic(): Then I would propose to copy the might_sleep_if() from vfree() into kvfree()
--
Manfred
| |