Revise cpu_need_resched and cpu_signotify, then make them like x86's ones.

This can avoid sending IPI to myself.
This commit is contained in:
nakayama 2008-04-03 10:34:45 +00:00
parent 8843b0cbbb
commit b1253edf64
3 changed files with 28 additions and 10 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: cpu.h,v 1.77 2008/03/17 04:04:00 nakayama Exp $ */
/* $NetBSD: cpu.h,v 1.78 2008/04/03 10:34:45 nakayama Exp $ */
/*
* Copyright (c) 1992, 1993
@ -288,10 +288,9 @@ void setsoftnet(void);
#define cpu_need_proftick(l) ((l)->l_pflag |= LP_OWEUPC, want_ast = 1)
/*
* Notify the current process (l) that it has a signal pending,
* process as soon as possible.
* Notify an LWP that it has a signal pending, process as soon as possible.
*/
#define cpu_signotify(l) (want_ast = 1)
void cpu_signotify(struct lwp *);
/*
* Interrupt handler chains. Interrupt handlers should return 0 for

View File

@ -1,4 +1,4 @@
/* $NetBSD: ipifuncs.c,v 1.19 2008/03/27 15:20:47 martin Exp $ */
/* $NetBSD: ipifuncs.c,v 1.20 2008/04/03 10:34:46 nakayama Exp $ */
/*-
* Copyright (c) 2004 The NetBSD Foundation, Inc.
@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ipifuncs.c,v 1.19 2008/03/27 15:20:47 martin Exp $");
__KERNEL_RCSID(0, "$NetBSD: ipifuncs.c,v 1.20 2008/04/03 10:34:46 nakayama Exp $");
#include "opt_ddb.h"
@ -200,6 +200,7 @@ sparc64_send_ipi(int upaid, ipifunc_t func, uint64_t arg1, uint64_t arg2)
int i, ik;
uint64_t intr_func;
KASSERT(upaid != curcpu()->ci_cpuid);
if (ldxa(0, ASR_IDSR) & IDSR_BUSY)
panic("recursive IPI?");

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.217 2008/03/14 15:39:18 nakayama Exp $ */
/* $NetBSD: machdep.c,v 1.218 2008/04/03 10:34:46 nakayama Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@ -78,7 +78,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.217 2008/03/14 15:39:18 nakayama Exp $");
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.218 2008/04/03 10:34:46 nakayama Exp $");
#include "opt_ddb.h"
#include "opt_multiprocessor.h"
@ -1969,9 +1969,27 @@ cpu_need_resched(struct cpu_info *ci, int flags)
ci->ci_want_resched = 1;
ci->ci_want_ast = 1;
#if defined(MULTIPROCESSOR)
#ifdef MULTIPROCESSOR
if (ci == curcpu())
return;
/* Just interrupt the target CPU, so it can notice its AST */
if ((flags & RESCHED_IMMED) || ci->ci_index != cpu_number())
if ((flags & RESCHED_IMMED) != 0 &&
ci->ci_data.cpu_onproc != ci->ci_data.cpu_idlelwp)
sparc64_send_ipi(ci->ci_cpuid, sparc64_ipi_nop, 0, 0);
#endif
}
/*
* Notify an LWP that it has a signal pending, process as soon as possible.
*/
void
cpu_signotify(struct lwp *l)
{
struct cpu_info *ci = l->l_cpu;
ci->ci_want_ast = 1;
#ifdef MULTIPROCESSOR
if (ci != curcpu())
sparc64_send_ipi(ci->ci_cpuid, sparc64_ipi_nop, 0, 0);
#endif
}