Module Name: src
Committed By: ad
Date: Sun Dec 1 13:20:42 UTC 2019
Modified Files:
src/sys/kern: kern_runq.c sched_4bsd.c sched_m2.c
Log Message:
PR port-sparc/54718 (sparc install hangs since recent scheduler changes)
- sched_tick: cpu_need_resched is no longer the correct thing to do here.
All we need to do is OR the request into the local ci_want_resched.
- sched_resched_cpu: we need to set RESCHED_UPREEMPT even on softint LWPs,
especially in the !__HAVE_FAST_SOFTINTS case, because the LWP with the
LP_INTR flag could be running via softint_overlay() - i.e. it has been
temporarily borrowed from a user process, and it needs to notice the
resched after it has stopped running softints.
To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sys/kern/kern_runq.c
cvs rdiff -u -r1.38 -r1.39 src/sys/kern/sched_4bsd.c
cvs rdiff -u -r1.34 -r1.35 src/sys/kern/sched_m2.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/kern/kern_runq.c
diff -u src/sys/kern/kern_runq.c:1.50 src/sys/kern/kern_runq.c:1.51
--- src/sys/kern/kern_runq.c:1.50 Wed Nov 27 20:31:13 2019
+++ src/sys/kern/kern_runq.c Sun Dec 1 13:20:42 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_runq.c,v 1.50 2019/11/27 20:31:13 ad Exp $ */
+/* $NetBSD: kern_runq.c,v 1.51 2019/12/01 13:20:42 ad Exp $ */
/*-
* Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -56,7 +56,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_runq.c,v 1.50 2019/11/27 20:31:13 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_runq.c,v 1.51 2019/12/01 13:20:42 ad Exp $");
#include "opt_dtrace.h"
@@ -381,13 +381,8 @@ sched_resched_cpu(struct cpu_info *ci, p
l = ci->ci_data.cpu_onproc;
if ((l->l_flag & LW_IDLE) != 0) {
f = RESCHED_IDLE | RESCHED_UPREEMPT;
- } else if ((l->l_pflag & LP_INTR) != 0) {
- /* We can't currently preempt interrupt LWPs - should do. */
- if (__predict_true(unlock)) {
- spc_unlock(ci);
- }
- return;
- } else if (pri >= sched_kpreempt_pri) {
+ } else if (pri >= sched_kpreempt_pri && (l->l_pflag & LP_INTR) == 0) {
+ /* We can't currently preempt softints - should be able to. */
#ifdef __HAVE_PREEMPTION
f = RESCHED_KPREEMPT;
#else
Index: src/sys/kern/sched_4bsd.c
diff -u src/sys/kern/sched_4bsd.c:1.38 src/sys/kern/sched_4bsd.c:1.39
--- src/sys/kern/sched_4bsd.c:1.38 Fri Nov 29 18:29:45 2019
+++ src/sys/kern/sched_4bsd.c Sun Dec 1 13:20:42 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: sched_4bsd.c,v 1.38 2019/11/29 18:29:45 ad Exp $ */
+/* $NetBSD: sched_4bsd.c,v 1.39 2019/12/01 13:20:42 ad Exp $ */
/*
* Copyright (c) 1999, 2000, 2004, 2006, 2007, 2008, 2019
@@ -69,7 +69,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sched_4bsd.c,v 1.38 2019/11/29 18:29:45 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sched_4bsd.c,v 1.39 2019/12/01 13:20:42 ad Exp $");
#include "opt_ddb.h"
#include "opt_lockdebug.h"
@@ -130,9 +130,9 @@ sched_tick(struct cpu_info *ci)
/* Force it into mi_switch() to look for other jobs to run. */
#ifdef __HAVE_PREEMPTION
atomic_or_uint(&l->l_dopreempt, DOPREEMPT_ACTIVE);
- cpu_need_resched(ci, l, RESCHED_KPREEMPT);
+ atomic_or_uint(&ci->ci_want_resched, RESCHED_KPREEMPT);
#else
- cpu_need_resched(ci, l, RESCHED_UPREEMPT);
+ atomic_or_uint(&ci->ci_want_resched, RESCHED_UPREEMPT);
#endif
break;
default:
@@ -144,9 +144,9 @@ sched_tick(struct cpu_info *ci)
*/
#ifdef __HAVE_PREEMPTION
atomic_or_uint(&l->l_dopreempt, DOPREEMPT_ACTIVE);
- cpu_need_resched(ci, l, RESCHED_KPREEMPT);
+ atomic_or_uint(&ci->ci_want_resched, RESCHED_KPREEMPT);
#else
- cpu_need_resched(ci, l, RESCHED_UPREEMPT);
+ atomic_or_uint(&ci->ci_want_resched, RESCHED_UPREEMPT);
#endif
} else if (spc->spc_flags & SPCF_SEENRR) {
/*
@@ -155,7 +155,7 @@ sched_tick(struct cpu_info *ci)
* Indicate that the process should yield.
*/
spc->spc_flags |= SPCF_SHOULDYIELD;
- cpu_need_resched(ci, l, RESCHED_UPREEMPT);
+ atomic_or_uint(&ci->ci_want_resched, RESCHED_UPREEMPT);
} else {
spc->spc_flags |= SPCF_SEENRR;
}
Index: src/sys/kern/sched_m2.c
diff -u src/sys/kern/sched_m2.c:1.34 src/sys/kern/sched_m2.c:1.35
--- src/sys/kern/sched_m2.c:1.34 Fri Nov 22 20:07:53 2019
+++ src/sys/kern/sched_m2.c Sun Dec 1 13:20:42 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: sched_m2.c,v 1.34 2019/11/22 20:07:53 ad Exp $ */
+/* $NetBSD: sched_m2.c,v 1.35 2019/12/01 13:20:42 ad Exp $ */
/*
* Copyright (c) 2007, 2008 Mindaugas Rasiukevicius <rmind at NetBSD org>
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sched_m2.c,v 1.34 2019/11/22 20:07:53 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sched_m2.c,v 1.35 2019/12/01 13:20:42 ad Exp $");
#include <sys/param.h>
@@ -330,7 +330,7 @@ sched_tick(struct cpu_info *ci)
*/
if (lwp_eprio(l) <= spc->spc_maxpriority || l->l_target_cpu) {
spc->spc_flags |= SPCF_SHOULDYIELD;
- cpu_need_resched(ci, l, RESCHED_UPREEMPT);
+ atomic_or_uint(&ci->ci_want_resched, RESCHED_UPREEMPT);
} else
spc->spc_ticks = l->l_sched.timeslice;
lwp_unlock(l);