Page MenuHomeFreeBSD

powerpc/ofw: Fix malloc inside lock
ClosedPublic

Authored by breno.leitao_gmail.com on Apr 3 2018, 8:09 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Nov 21, 2:28 PM
Unknown Object (File)
Thu, Nov 21, 12:02 PM
Unknown Object (File)
Sun, Nov 10, 6:41 AM
Unknown Object (File)
Oct 19 2024, 7:02 AM
Unknown Object (File)
Oct 1 2024, 12:46 AM
Unknown Object (File)
Sep 27 2024, 9:34 AM
Unknown Object (File)
Sep 24 2024, 4:40 AM
Unknown Object (File)
Sep 15 2024, 9:06 PM
Subscribers

Details

Summary

Currently ofw_real_bounce_alloc() is requesting memory, using WAITOK, holding a
non-sleepable locks, called 'OF Bounce Page'.

Since the request is inside the a lock, it should not sleep and return
immediately using the NOWAIT flag.

If you enable witness option, you see:

vmem_alloc with the following non-sleepable locks held:
exclusive sleep mutex OF Bounce Page (OF Bounce Page) r = 0 (0xc0000000016f0d28) locked @ /root/kernel/freebsd/sys/powerpc/ofw/ofw_real.c:212
stack backtrace:
#0 0xc0000000006a1db0 at ??+0
#1 0xc0000000006a4448 at ??+0
#2 0xc00000000069ee6c at ??+0
#3 0xc00000000094db00 at ??+0
#4 0xc00000000094de80 at ??+0
#5 0xc0000000005fbcb0 at ??+0
#6 0xc00000000099ae98 at ??+0
#7 0xc0000000005adf14 at ??+0
#8 0xc000000000102744 at ??+0
vmem_xalloc with the following non-sleepable locks held:
exclusive sleep mutex OF Bounce Page (OF Bounce Page) r = 0 (0xc0000000016f0d28) locked @ /root/kernel/freebsd/sys/powerpc/ofw/ofw_real.c:212
stack backtrace:
#0 0xc0000000006a1db0 at ??+0
#1 0xc0000000006a4448 at ??+0
#2 0xc00000000069e4a4 at ??+0
#3 0xc00000000069eef8 at ??+0
#4 0xc00000000094db00 at ??+0
#5 0xc00000000094de80 at ??+0
#6 0xc0000000005fbcb0 at ??+0
#7 0xc00000000099ae98 at ??+0
#8 0xc0000000005adf14 at ??+0
#9 0xc000000000102744 at ??+0

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

This looks odd. of_bounc_mtx is initialized MTX_DEF, which is a sleepable mutex. Are there other locking changes made that make this not the case?

This revision is now accepted and ready to land.Apr 5 2018, 8:50 PM

Updating the patch to remove the mem alloc from outside the lock section.

This revision now requires review to proceed.Apr 5 2018, 9:00 PM
This revision is now accepted and ready to land.Apr 5 2018, 9:01 PM
mjg requested changes to this revision.Apr 5 2018, 10:33 PM
mjg added a subscriber: mjg.
mjg added inline comments.
sys/powerpc/ofw/ofw_real.c
217 ↗(On Diff #41152)

this does not indicate *who* tried to allocate it. at the very least this should also contain func

223 ↗(On Diff #41152)

i don't see any added value of this comment

This revision now requires changes to proceed.Apr 5 2018, 10:33 PM

Updating the patch with mjg's suggestions. Thanks for the review.

This revision is now accepted and ready to land.Apr 6 2018, 5:55 PM
This revision was automatically updated to reflect the committed changes.