Page MenuHomeFreeBSD

kern: malloc: fix panic on M_WAITOK during THREAD_NO_SLEEPING()
ClosedPublic

Authored by kevans on Mar 8 2021, 6:19 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Apr 3, 7:21 AM
Unknown Object (File)
Mar 7 2024, 8:15 PM
Unknown Object (File)
Jan 12 2024, 2:50 AM
Unknown Object (File)
Nov 14 2023, 7:35 AM
Unknown Object (File)
Nov 9 2023, 5:14 AM
Unknown Object (File)
Nov 4 2023, 9:44 PM
Unknown Object (File)
Oct 31 2023, 1:12 AM
Unknown Object (File)
Oct 30 2023, 4:52 AM
Subscribers

Details

Summary

Simple condition flip; we wanted to panic here after epoch_trace_list().

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kevans requested review of this revision.Mar 8 2021, 6:19 AM
markj added inline comments.
sys/kern/kern_malloc.c
535

BTW, I am not sure why this assertion is predicated on M_WAITOK being set. It should always be true, I'd think.

This revision is now accepted and ready to land.Mar 8 2021, 5:14 PM
sys/kern/kern_malloc.c
535

I'm not necessarily seeing where this assertion is useful at all, to be honest. I know nothing about the different kinds of interrupt handlers, but almost everywhere that touches td_intr_nesting_level[0] also puts us in a critical section to hit the KASSERT just below this block.

[0] the exception seems to be that ipi_bitmap_handler() over in x86/x86/mp_x86.c will only do so for hardclock. Again, not familiar, but that seems to lead to an inconsistency in expectations for all of the other ipi handlers w.r.t. malloc(9) (and maybe others?), but I would suspect that it doesn't matter at all in practice as they shouldn't be allocating anything.

sys/kern/kern_malloc.c
535

There is also smp_rendezvous_action(), which gets called from an interrupt handler without bumping intr_nesting_level but enters a critical section.

In general I wouldn't assume that td_intr_nesting_level != 0 implies that td_critnest != 0. IMO we should simply add this condition to the assertion below, i.e., (curthread->td_critnest != 0 && td->td_intr_nesting_level) || SCHEDULER_STOPPED().

But of course this isn't directly related to the diff at hand.