Date: Tue, 26 Jul 2011 11:17:54 +0000 From: rudot@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r224644 - soc2011/rudot/kern Message-ID: <20110726111754.ECE11106564A@hub.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: rudot Date: Tue Jul 26 11:17:54 2011 New Revision: 224644 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=224644 Log: check if the per-cpu current thread ptr is a valid pointer. If not then do not use it. Modified: soc2011/rudot/kern/sched_fbfs.c Modified: soc2011/rudot/kern/sched_fbfs.c ============================================================================== --- soc2011/rudot/kern/sched_fbfs.c Tue Jul 26 10:50:33 2011 (r224643) +++ soc2011/rudot/kern/sched_fbfs.c Tue Jul 26 11:17:54 2011 (r224644) @@ -149,7 +149,6 @@ SYSCTL_INT(_kern_sched, OID_AUTO, slice, CTLFLAG_RW, &sched_slice, 0, "Slice size for timeshare threads"); - static __inline void sched_load_add(void) { @@ -613,28 +612,32 @@ struct pcpu * pcpu; struct td_sched *ts; struct td_sched *tsc; + struct thread *pcpu_thr; u_char c; c = td->td_lastcpu; if (c == NOCPU) return (0); pcpu = pcpu_find(c); - if (pcpu->pc_curthread == pcpu->pc_idlethread) { + pcpu_thr = pcpu->pc_curthread; + if (pcpu_thr == NULL) + return (0); + if (pcpu_thr == pcpu->pc_idlethread) { if (PCPU_GET(cpuid) != c) ipi_cpu(c, IPI_AST); return (1); } - cpri = pcpu->pc_curthread->td_priority; + cpri = pcpu_thr->td_priority; if (cpri < td->td_priority) return (0); if (cpri > td->td_priority) { - pcpu->pc_curthread->td_flags |= TDF_NEEDRESCHED; + pcpu_thr->td_flags |= TDF_NEEDRESCHED; if (PCPU_GET(cpuid) != c) ipi_cpu(c, IPI_AST); return (1); } ts = td->td_sched; - tsc = pcpu->pc_curthread->td_sched; + tsc = pcpu_thr->td_sched; if ((td->td_pri_class == PRI_TIMESHARE) || (td->td_pri_class == PRI_IDLE)) { if (ts->ts_vdeadline >= tsc->ts_vdeadline) @@ -647,7 +650,7 @@ * Further, the virtual deadline of td is lower. Therefore we * reschedule the td_lastcpu. */ - pcpu->pc_curthread->td_flags |= TDF_NEEDRESCHED; + pcpu_thr->td_flags |= TDF_NEEDRESCHED; if (PCPU_GET(cpuid) != c) ipi_cpu(c, IPI_AST); @@ -667,6 +670,9 @@ ts = max_thread->td_sched; SLIST_FOREACH(pc, &cpuhead, pc_allcpu) { cthr = pc->pc_curthread; + if (cthr == NULL) { + continue; + } if (max_prio < cthr->td_priority) { max_thread = cthr; max_prio = max_thread->td_priority;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20110726111754.ECE11106564A>