Date: Wed, 24 Aug 2016 16:49:14 +0000 (UTC) From: Nathan Whitehorn <nwhitehorn@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r304756 - head/sys/powerpc/pseries Message-ID: <201608241649.u7OGnECp017563@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: nwhitehorn Date: Wed Aug 24 16:49:14 2016 New Revision: 304756 URL: https://svnweb.freebsd.org/changeset/base/304756 Log: Close a race when making the CPU idle under pHyp. If an interrupt occurs between the beginning of the idle function and actually going idle, the CPU could go to sleep with pending work. MFC after: 1 month Modified: head/sys/powerpc/pseries/platform_chrp.c Modified: head/sys/powerpc/pseries/platform_chrp.c ============================================================================== --- head/sys/powerpc/pseries/platform_chrp.c Wed Aug 24 16:44:27 2016 (r304755) +++ head/sys/powerpc/pseries/platform_chrp.c Wed Aug 24 16:49:14 2016 (r304756) @@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$"); #include <sys/bus.h> #include <sys/pcpu.h> #include <sys/proc.h> +#include <sys/sched.h> #include <sys/smp.h> #include <vm/vm.h> #include <vm/pmap.h> @@ -492,7 +493,18 @@ chrp_reset(platform_t platform) static void phyp_cpu_idle(sbintime_t sbt) { - phyp_hcall(H_CEDE); + register_t msr; + + msr = mfmsr(); + + mtmsr(msr & ~PSL_EE); + if (sched_runnable()) { + mtmsr(msr); + return; + } + + phyp_hcall(H_CEDE); /* Re-enables interrupts internally */ + mtmsr(msr); } static void
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201608241649.u7OGnECp017563>