Module Name: src Committed By: thorpej Date: Sat Aug 29 19:06:33 UTC 2020
Modified Files: src/sys/arch/alpha/alpha: machdep.c src/sys/arch/alpha/include: cpu.h Log Message: - 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. To generate a diff of this commit: cvs rdiff -u -r1.360 -r1.361 src/sys/arch/alpha/alpha/machdep.c cvs rdiff -u -r1.87 -r1.88 src/sys/arch/alpha/include/cpu.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/alpha/alpha/machdep.c diff -u src/sys/arch/alpha/alpha/machdep.c:1.360 src/sys/arch/alpha/alpha/machdep.c:1.361 --- src/sys/arch/alpha/alpha/machdep.c:1.360 Thu Jun 11 19:20:42 2020 +++ src/sys/arch/alpha/alpha/machdep.c Sat Aug 29 19:06:32 2020 @@ -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 @@ cpu_setmcontext(struct lwp *l, const mco 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 @@ cpu_setmcontext(struct lwp *l, const mco 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); } Index: src/sys/arch/alpha/include/cpu.h diff -u src/sys/arch/alpha/include/cpu.h:1.87 src/sys/arch/alpha/include/cpu.h:1.88 --- src/sys/arch/alpha/include/cpu.h:1.87 Mon Aug 17 00:57:37 2020 +++ src/sys/arch/alpha/include/cpu.h Sat Aug 29 19:06:33 2020 @@ -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 @@ struct clockframe { */ #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 */ /*