Date: Sun, 17 Jul 2011 21:53:42 +0000 (UTC) From: Ryan Stone <rstone@FreeBSD.org> To: cvs-src-old@freebsd.org Subject: cvs commit: src/sys/kern kern_linker.c Message-ID: <201107172154.p6HLs0QT098700@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
rstone 2011-07-17 21:53:42 UTC
FreeBSD src repository
Modified files:
sys/kern kern_linker.c
Log:
SVN rev 224156 on 2011-07-17 21:53:42Z by rstone
Fix a LOR between hwpmc and the kernel linker. When a system-wide
sampling mode PMC is allocated, hwpmc calls linker_hwpmc_list_objects()
while already holding an exclusive lock on pmc-sx lock. list_objects()
tries to acquire an exclusive lock on the kld_sx lock. When a KLD module
is loaded or unloaded successfully, kern_kld(un)load calls into the pmc
hook while already holding an exclusive lock on the kld_sx lock. Calling
the pmc hook requires acquiring a shared lock on the pmc-sx lock.
Fix this by only acquiring a shared lock on the kld_sx lock in
linker_hwpmc_list_objects(), and also downgrading to a shared lock on the
kld_sx lock in kern_kld(un)load before calling into the pmc hook. In
kern_kldload this required moving some modifications of the linker_file_t
to happen before calling into the pmc hook.
This fixes the deadlock by ensuring that the hwpmc -> list_objects() case
is always able to proceed. Without this patch, I was able to deadlock a
multicore system within minutes by constantly loading and unloading an KLD
module while I simultaneously started a sampling mode PMC in a loop.
MFC after: 1 month
Revision Changes Path
1.184 +24 -11 src/sys/kern/kern_linker.c
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201107172154.p6HLs0QT098700>
