From owner-svn-soc-all@FreeBSD.ORG Tue Jul 26 11:17:57 2011 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id ECE11106564A for ; Tue, 26 Jul 2011 11:17:54 +0000 (UTC) (envelope-from rudot@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Tue, 26 Jul 2011 11:17:54 +0000 Date: Tue, 26 Jul 2011 11:17:54 +0000 From: rudot@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20110726111754.ECE11106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r224644 - soc2011/rudot/kern X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Jul 2011 11:17:57 -0000 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;