Date: Fri, 08 Jul 2011 19:08:43 +0000 From: rudot@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r224057 - soc2011/rudot/kern Message-ID: <20110708190843.0C31E106566C@hub.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: rudot Date: Fri Jul 8 19:08:42 2011 New Revision: 224057 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=224057 Log: added cpu topology information Modified: soc2011/rudot/kern/sched_fbfs.c Modified: soc2011/rudot/kern/sched_fbfs.c ============================================================================== --- soc2011/rudot/kern/sched_fbfs.c Fri Jul 8 18:06:53 2011 (r224056) +++ soc2011/rudot/kern/sched_fbfs.c Fri Jul 8 19:08:42 2011 (r224057) @@ -91,6 +91,9 @@ #endif }; +static struct cpu_group * cpu_top; +static struct cpu_group * cpu_topology[MAXCPU]; + /* flags kept in td_flags */ #define TDF_DIDRUN TDF_SCHED0 /* thread actually ran. */ #define TDF_BOUND TDF_SCHED1 /* Bound to one CPU. */ @@ -186,6 +189,15 @@ { int i; + cpu_top = smp_topo(); + for (i = 0; i < MAXCPU; i++) { + if (CPU_ABSENT(i)) + continue; + cpu_topology[i] = smp_topo_find(cpu_top, i); + if (cpu_topology[i] == NULL) + panic("Can't find cpu group for %d\n", i); + } + realstathz = hz; sched_slice = (realstathz/10); @@ -609,7 +621,7 @@ pcpu = pcpu_find(c); if (pcpu->pc_curthread == pcpu->pc_idlethread) { if (PCPU_GET(cpuid) != c) - ipi_cpu(c, IPI_AST); + ipi_cpu(c, IPI_PREEMPT); return (1); } cpri = pcpu->pc_curthread->td_priority; @@ -676,6 +688,7 @@ { struct td_sched *ts; struct thread *thr_worst; + struct cpu_group *cg; cpumask_t dontuse, map, me; u_char c; @@ -696,16 +709,26 @@ */ if (preempt_lastcpu(td)) { if (map) - ipi_selected(map, IPI_AST); + ipi_selected(map, IPI_PREEMPT); return; } - + /* + * Is there any idle cpu ? + */ if (map) { - ipi_selected(map, IPI_AST); + cg = cpu_topology[td->td_lastcpu]; + while ((cg != NULL) && ((map & cg->cg_mask) == 0)) + cg = cg->cg_parent; + if (map & cg->cg_mask) { + ipi_selected(map & cg->cg_mask, IPI_PREEMPT); + return; + } + ipi_selected(map, IPI_PREEMPT); return; } - - /* We did not wake lastcpu and there is no suitable idle cpu */ + /* + * We did not wake lastcpu and there is no suitable idle cpu + */ thr_worst = worst_running_thread(); c = thr_worst->td_oncpu; if (thr_worst->td_priority < td->td_priority) @@ -716,8 +739,9 @@ ipi_cpu(c, IPI_AST); return; } - - /* thr_worst->td_priority == td->td_priority */ + /* + * thr_worst->td_priority == td->td_priority + */ if (ts->ts_vdeadline < thr_worst->td_sched->ts_vdeadline) { thr_worst->td_flags |= TDF_NEEDRESCHED; if ((thr_worst != curthread) && (c != NOCPU))
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20110708190843.0C31E106566C>