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)
Tue, Apr 16, 11:24 PM
Unknown Object (File)
Mar 16 2024, 6:04 PM
Unknown Object (File)
Feb 1 2024, 3:14 PM
Unknown Object (File)
Dec 20 2023, 1:11 AM
Unknown Object (File)
Dec 12 2023, 5:56 AM
Unknown Object (File)
Nov 27 2023, 2:58 AM
Unknown Object (File)
Nov 27 2023, 2:58 AM
Unknown Object (File)
Sep 6 2023, 5:22 AM
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.