Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern preempt_needed(), preempt_point(): simplify the def...
details: https://anonhg.NetBSD.org/src/rev/b0702f13ffb9
branches: trunk
changeset: 1008868:b0702f13ffb9
user: ad <ad%NetBSD.org@localhost>
date: Sat Apr 04 20:21:53 2020 +0000
description:
preempt_needed(), preempt_point(): simplify the definition of these and
key on ci_want_resched in the interests of interactive response.
diffstat:
sys/kern/kern_synch.c | 47 ++++++++++++++++++-----------------------------
1 files changed, 18 insertions(+), 29 deletions(-)
diffs (81 lines):
diff -r aa51172a4dd1 -r b0702f13ffb9 sys/kern/kern_synch.c
--- a/sys/kern/kern_synch.c Sat Apr 04 20:21:26 2020 +0000
+++ b/sys/kern/kern_synch.c Sat Apr 04 20:21:53 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_synch.c,v 1.345 2020/03/26 19:42:39 ad Exp $ */
+/* $NetBSD: kern_synch.c,v 1.346 2020/04/04 20:21:53 ad Exp $ */
/*-
* Copyright (c) 1999, 2000, 2004, 2006, 2007, 2008, 2009, 2019, 2020
@@ -69,7 +69,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_synch.c,v 1.345 2020/03/26 19:42:39 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_synch.c,v 1.346 2020/04/04 20:21:53 ad Exp $");
#include "opt_kstack.h"
#include "opt_dtrace.h"
@@ -317,46 +317,35 @@
}
/*
- * A breathing point for long running code in kernel.
+ * Return true if the current LWP should yield the processor. Intended to
+ * be used by long-running code in kernel.
*/
-void
-preempt_point(void)
-{
- lwp_t *l = curlwp;
- int needed;
-
- KPREEMPT_DISABLE(l);
- needed = l->l_cpu->ci_schedstate.spc_flags & SPCF_SHOULDYIELD;
-#ifndef __HAVE_FAST_SOFTINTS
- needed |= l->l_cpu->ci_data.cpu_softints;
-#endif
- KPREEMPT_ENABLE(l);
-
- if (__predict_false(needed)) {
- preempt();
- }
-}
-
-/*
- * Check the SPCF_SHOULDYIELD flag.
- */
-bool
+inline bool
preempt_needed(void)
{
lwp_t *l = curlwp;
int needed;
KPREEMPT_DISABLE(l);
- needed = l->l_cpu->ci_schedstate.spc_flags & SPCF_SHOULDYIELD;
-#ifndef __HAVE_FAST_SOFTINTS
- needed |= l->l_cpu->ci_data.cpu_softints;
-#endif
+ needed = l->l_cpu->ci_want_resched;
KPREEMPT_ENABLE(l);
return (bool)needed;
}
/*
+ * A breathing point for long running code in kernel.
+ */
+void
+preempt_point(void)
+{
+
+ if (__predict_false(preempt_needed())) {
+ preempt();
+ }
+}
+
+/*
* Handle a request made by another agent to preempt the current LWP
* in-kernel. Usually called when l_dopreempt may be non-zero.
*
Home |
Main Index |
Thread Index |
Old Index