Date: Mon, 15 Sep 2014 11:17:36 +0000 (UTC) From: Alexander Motin <mav@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r271616 - head/sys/kern Message-ID: <201409151117.s8FBHatX029967@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mav Date: Mon Sep 15 11:17:36 2014 New Revision: 271616 URL: http://svnweb.freebsd.org/changeset/base/271616 Log: Add comments describing r271604 change. MFC after: 3 days Modified: head/sys/kern/sched_ule.c Modified: head/sys/kern/sched_ule.c ============================================================================== --- head/sys/kern/sched_ule.c Mon Sep 15 11:14:23 2014 (r271615) +++ head/sys/kern/sched_ule.c Mon Sep 15 11:17:36 2014 (r271616) @@ -1037,7 +1037,14 @@ tdq_notify(struct tdq *tdq, struct threa ctd = pcpu_find(cpu)->pc_curthread; if (!sched_shouldpreempt(pri, ctd->td_priority, 1)) return; + + /* + * Make sure that tdq_load updated before calling this function + * is globally visible before we read tdq_cpu_idle. Idle thread + * accesses both of them without locks, and the order is important. + */ mb(); + if (TD_IS_IDLETHREAD(ctd)) { /* * If the MD code has an idle wakeup routine try that before @@ -2641,6 +2648,11 @@ sched_idletd(void *dummy) /* Run main MD idle handler. */ tdq->tdq_cpu_idle = 1; + /* + * Make sure that tdq_cpu_idle update is globally visible + * before cpu_idle() read tdq_load. The order is important + * to avoid race with tdq_notify. + */ mb(); cpu_idle(switchcnt * 4 > sched_idlespinthresh); tdq->tdq_cpu_idle = 0;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201409151117.s8FBHatX029967>