Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/alpha - cpu_need_resched(): Explicitly cover each R...



details:   https://anonhg.NetBSD.org/src/rev/ecfc03442f83
branches:  trunk
changeset: 937986:ecfc03442f83
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Sat Aug 29 19:06:32 2020 +0000

description:
- cpu_need_resched(): Explicitly cover each RESCHED_* case, and add a
  comment explaining why we don't need to act on IDLE+REMOTE.
- cpu_signotify(): Move to machdep.c, and if we're asked to notify
  an LWP running on another CPU, send an AST IPI to that CPU.  Add some
  assertions.
- cpu_need_proftick(): Move to machdep.c, add some assertions.

diffstat:

 sys/arch/alpha/alpha/machdep.c |  71 ++++++++++++++++++++++++++++++++++++-----
 sys/arch/alpha/include/cpu.h   |  28 ++--------------
 2 files changed, 65 insertions(+), 34 deletions(-)

diffs (141 lines):

diff -r 0aa690ddd392 -r ecfc03442f83 sys/arch/alpha/alpha/machdep.c
--- a/sys/arch/alpha/alpha/machdep.c    Sat Aug 29 19:06:17 2020 +0000
+++ b/sys/arch/alpha/alpha/machdep.c    Sat Aug 29 19:06:32 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.360 2020/06/11 19:20:42 ad Exp $ */
+/* $NetBSD: machdep.c,v 1.361 2020/08/29 19:06:32 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2019 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.360 2020/06/11 19:20:42 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.361 2020/08/29 19:06:32 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1862,6 +1862,14 @@
        return (0);
 }
 
+static void
+cpu_kick(struct cpu_info * const ci)
+{
+#if defined(MULTIPROCESSOR)
+       alpha_send_ipi(ci->ci_cpuid, ALPHA_IPI_AST);
+#endif /* MULTIPROCESSOR */
+}
+
 /*
  * Preempt the current process if in interrupt from user mode,
  * or after the current trap/syscall if in system mode.
@@ -1869,13 +1877,56 @@
 void
 cpu_need_resched(struct cpu_info *ci, struct lwp *l, int flags)
 {
-       if ((flags & RESCHED_IDLE) == 0) {
-               if ((flags & RESCHED_REMOTE) != 0) {
-#if defined(MULTIPROCESSOR)
-                       alpha_send_ipi(ci->ci_cpuid, ALPHA_IPI_AST);
-#endif /* defined(MULTIPROCESSOR) */
-               } else {
-                       aston(l);
-               }
+
+       KASSERT(kpreempt_disabled());
+
+       if ((flags & RESCHED_IDLE) != 0) {
+               /*
+                * Nothing to do here; we are not currently using WTINT
+                * in cpu_idle().
+                */
+               return;
+       }
+
+       /* XXX RESCHED_KPREEMPT XXX */
+
+       KASSERT((flags & RESCHED_UPREEMPT) != 0);
+       if ((flags & RESCHED_REMOTE) != 0) {
+               cpu_kick(ci);
+       } else {
+               aston(l);
        }
 }
+
+/*
+ * Notify the current lwp (l) that it has a signal pending,
+ * process as soon as possible.
+ */
+void
+cpu_signotify(struct lwp *l)
+{
+       
+       KASSERT(kpreempt_disabled());
+
+       if (l->l_cpu != curcpu()) {
+               cpu_kick(l->l_cpu);
+       } else {
+               aston(l);
+       }
+}
+
+/*
+ * Give a profiling tick to the current process when the user profiling
+ * buffer pages are invalid.  On the alpha, request an AST to send us
+ * through trap, marking the proc as needing a profiling tick.
+ */
+void
+cpu_need_proftick(struct lwp *l)
+{
+
+       KASSERT(kpreempt_disabled());
+       KASSERT(l->l_cpu == curcpu());
+
+       l->l_pflag |= LP_OWEUPC;
+       aston(l);
+}
diff -r 0aa690ddd392 -r ecfc03442f83 sys/arch/alpha/include/cpu.h
--- a/sys/arch/alpha/include/cpu.h      Sat Aug 29 19:06:17 2020 +0000
+++ b/sys/arch/alpha/include/cpu.h      Sat Aug 29 19:06:32 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.h,v 1.87 2020/08/17 00:57:37 thorpej Exp $ */
+/* $NetBSD: cpu.h,v 1.88 2020/08/29 19:06:33 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -210,30 +210,10 @@
  */
 #define        LWP_PC(p)               ((l)->l_md.md_tf->tf_regs[FRAME_PC])
 
-/*
- * Give a profiling tick to the current process when the user profiling
- * buffer pages are invalid.  On the alpha, request an AST to send us
- * through trap, marking the proc as needing a profiling tick.
- */
-#define        cpu_need_proftick(l)                                            \
-do {                                                                   \
-       (l)->l_pflag |= LP_OWEUPC;                                      \
-       aston(l);                                                       \
-} while (/*CONSTCOND*/0)
+void   cpu_need_proftick(struct lwp *);
+void   cpu_signotify(struct lwp *);
 
-/*
- * Notify the current process (p) that it has a signal pending,
- * process as soon as possible.
- */
-#define        cpu_signotify(l)        aston(l)
-
-/*
- * XXXSMP
- * Should we send an AST IPI?  Or just let it handle it next time
- * it sees a normal kernel entry?  I guess letting it happen later
- * follows the `asynchronous' part of the name...
- */
-#define        aston(l)        ((l)->l_md.md_astpending = 1)
+#define        aston(l)                ((l)->l_md.md_astpending = 1)
 #endif /* _KERNEL */
 
 /*



Home | Main Index | Thread Index | Old Index