[PATCH 4/4] rhashtable: fix vmalloc() deadlock in atomic rehash
Uladzislau Rezki
urezki at gmail.com
Mon Nov 2 03:18:09 PST 2026
Hello, Matthew!
> On Fri, Oct 30, 2026 at 10:52:37AM +0100, Uladzislau Rezki wrote:
> > The problem with spin_lock_irqsave() is that vmalloc() path can take
> > time to alloc and map pages. I am not sure this is worth to switch to
> > irq-save locking primitive. So this is the "heaviest" allocator in the
> > kernel. Callers have to be careful how the call vmalloc().
> >
> > IMO, this caller has to be fixed.
>
> Which caller, though? Are you saying rhashtable_insert_rehash()
> needs to call kmalloc() instead of kvmalloc()?
>
The problem is that we used to BUG_ON() in vmalloc if soft-irq or BH
is disabled, i.e. for vmalloc it is incorrect state.
See https://lore.kernel.org/all/69ff8c7c.050a0220.1036b8.000b.GAE@google.com/
Two patches to address this:
1. https://lore.kernel.org/all/20260515153009.2296191-1-urezki@gmail.com/
2. https://lore.kernel.org/all/20261026102503.30860-1-urezki@gmail.com/
second can be updated and resent as it checks if the context does soft
irq processing whereas it allows:
bh-disable;
vmalloc();
forbidding this will address the rhashtable deadlock(discussed here) but
this will just fail allocation because it is incorrect state for vmalloc
and calling kvmalloc() for rhashtable will not succeed.
i.e. rhashtable context should be fixed also. This is what i meant by
saying: this caller has to be fixed.
--
Uladzislau Rezki
More information about the maple-tree
mailing list