--- a/usr/src/uts/common/Makefile.files Fri Feb 17 10:51:31 2006 -0800
+++ b/usr/src/uts/common/Makefile.files Fri Feb 17 17:24:21 2006 -0800
@@ -58,6 +58,7 @@
rctl_proc.o \
rwlock.o \
seg_kmem.o \
+ thread_intr.o \
vm_page.o \
vm_pagelist.o
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/uts/common/disp/thread_intr.c Fri Feb 17 17:24:21 2006 -0800
@@ -0,0 +1,115 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/*
+ * FILE NOTICE BEGIN
+ *
+ * This file should not be modified. If you wish to modify it or have it
+ * modified, please contact Sun Microsystems at <[email protected]>
+ * (without anti-spam dashes)
+ *
+ * FILE NOTICE END
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <sys/cpuvar.h>
+#include <sys/stack.h>
+#include <vm/seg_kp.h>
+#include <sys/proc.h>
+#include <sys/pset.h>
+#include <sys/sysmacros.h>
+
+/*
+ * Create and initialize an interrupt thread.
+ */
+static void
+thread_create_intr(cpu_t *cp)
+{
+ kthread_t *tp;
+
+ tp = thread_create(NULL, 0,
+ (void (*)())thread_create_intr, NULL, 0, &p0, TS_ONPROC, 0);
+
+ /*
+ * Set the thread in the TS_FREE state. The state will change
+ * to TS_ONPROC only while the interrupt is active. Think of these
+ * as being on a private free list for the CPU. Being TS_FREE keeps
+ * inactive interrupt threads out of debugger thread lists.
+ *
+ * We cannot call thread_create with TS_FREE because of the current
+ * checks there for ONPROC. Fix this when thread_create takes flags.
+ */
+ THREAD_FREEINTR(tp, cp);
+
+ /*
+ * Nobody should ever reference the credentials of an interrupt
+ * thread so make it NULL to catch any such references.
+ */
+ tp->t_cred = NULL;
+ tp->t_flag |= T_INTR_THREAD;
+ tp->t_cpu = cp;
+ tp->t_bound_cpu = cp;
+ tp->t_disp_queue = cp->cpu_disp;
+ tp->t_affinitycnt = 1;
+ tp->t_preempt = 1;
+
+ /*
+ * Don't make a user-requested binding on this thread so that
+ * the processor can be offlined.
+ */
+ tp->t_bind_cpu = PBIND_NONE; /* no USER-requested binding */
+ tp->t_bind_pset = PS_NONE;
+
+#if defined(__i386) || defined(__amd64)
+ tp->t_stk -= STACK_ALIGN;
+ *(tp->t_stk) = 0; /* terminate intr thread stack */
+#endif
+
+ /*
+ * Link onto CPU's interrupt pool.
+ */
+ tp->t_link = cp->cpu_intr_thread;
+ cp->cpu_intr_thread = tp;
+}
+
+/*
+ * Allocate a given number of interrupt threads for a given CPU.
+ * These threads will get freed by cpu_destroy_bound_threads()
+ * when CPU gets unconfigured.
+ */
+void
+cpu_intr_alloc(cpu_t *cp, int n)
+{
+ int i;
+
+ for (i = 0; i < n; i++)
+ thread_create_intr(cp);
+
+ cp->cpu_intr_stack = (caddr_t)segkp_get(segkp, INTR_STACK_SIZE,
+ KPD_HASREDZONE | KPD_NO_ANON | KPD_LOCKED) +
+ INTR_STACK_SIZE - SA(MINFRAME);
+}
--- a/usr/src/uts/common/sys/cpuvar.h Fri Feb 17 10:51:31 2006 -0800
+++ b/usr/src/uts/common/sys/cpuvar.h Fri Feb 17 17:24:21 2006 -0800
@@ -20,7 +20,7 @@
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -572,6 +572,7 @@
int cpu_intr_on(cpu_t *cp); /* CPU taking I/O interrupts? */
void cpu_intr_enable(cpu_t *cp); /* enable I/O interrupts */
int cpu_intr_disable(cpu_t *cp); /* disable I/O interrupts */
+void cpu_intr_alloc(cpu_t *cp, int n); /* allocate interrupt threads */
/*
* Routines for checking CPU states.
--- a/usr/src/uts/common/sys/proc.h Fri Feb 17 10:51:31 2006 -0800
+++ b/usr/src/uts/common/sys/proc.h Fri Feb 17 17:24:21 2006 -0800
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -667,7 +666,6 @@
extern void exitpctx(proc_t *);
extern void freepctx(proc_t *, int);
extern kthread_t *thread_unpin(void);
-extern void thread_create_intr(struct cpu *);
extern void thread_init(void);
extern void thread_load(kthread_t *, void (*)(), caddr_t, size_t);
--- a/usr/src/uts/i86pc/os/intr.c Fri Feb 17 10:51:31 2006 -0800
+++ b/usr/src/uts/i86pc/os/intr.c Fri Feb 17 17:24:21 2006 -0800
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -627,24 +626,6 @@
#endif /* __amd64 */
/*
- * Allocate threads and stacks for interrupt handling.
- */
-#define NINTR_THREADS (LOCK_LEVEL-1) /* number of interrupt threads */
-
-void
-init_intr_threads(struct cpu *cp)
-{
- int i;
-
- for (i = 0; i < NINTR_THREADS; i++)
- thread_create_intr(cp);
-
- cp->cpu_intr_stack = (caddr_t)segkp_get(segkp, INTR_STACK_SIZE,
- KPD_HASREDZONE | KPD_NO_ANON | KPD_LOCKED) +
- INTR_STACK_SIZE - SA(MINFRAME);
-}
-
-/*
* Create interrupt kstats for this CPU.
*/
void
--- a/usr/src/uts/i86pc/os/mp_startup.c Fri Feb 17 10:51:31 2006 -0800
+++ b/usr/src/uts/i86pc/os/mp_startup.c Fri Feb 17 17:24:21 2006 -0800
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -232,7 +231,6 @@
int size;
proc_t *procp;
extern void idle();
- extern void init_intr_threads(struct cpu *);
struct cpu_tables *tablesp;
rm_platter_t *real_mode_platter = (rm_platter_t *)rm_platter_va;
@@ -484,7 +482,7 @@
/*
* Initialize the interrupt threads for this CPU
*/
- init_intr_threads(cp);
+ cpu_intr_alloc(cp, NINTR_THREADS);
/*
* Add CPU to list of available CPUs. It'll be on the active list
* after mp_startup().
--- a/usr/src/uts/i86pc/os/startup.c Fri Feb 17 10:51:31 2006 -0800
+++ b/usr/src/uts/i86pc/os/startup.c Fri Feb 17 17:24:21 2006 -0800
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -430,8 +429,6 @@
* of kernelbase to balance out the need of user applications.
*/
-void init_intr_threads(struct cpu *);
-
/* real-time-clock initialization parameters */
long gmt_lag; /* offset in seconds of gmt to local time */
extern long process_rtc_config_file(void);
@@ -1806,7 +1803,7 @@
* support.
*/
setx86isalist();
- init_intr_threads(CPU);
+ cpu_intr_alloc(CPU, NINTR_THREADS);
psm_install();
/*
--- a/usr/src/uts/i86pc/sys/machcpuvar.h Fri Feb 17 10:51:31 2006 -0800
+++ b/usr/src/uts/i86pc/sys/machcpuvar.h Fri Feb 17 17:24:21 2006 -0800
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -100,6 +99,8 @@
#endif
};
+#define NINTR_THREADS (LOCK_LEVEL-1) /* number of interrupt threads */
+
#endif /* _ASM */
#define cpu_nodeid cpu_m.mcpu_nodeid
--- a/usr/src/uts/i86pc/sys/machsystm.h Fri Feb 17 10:51:31 2006 -0800
+++ b/usr/src/uts/i86pc/sys/machsystm.h Fri Feb 17 17:24:21 2006 -0800
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -55,9 +54,6 @@
extern int Cpudelay;
extern void setcpudelay(void);
-extern void init_intr_threads(struct cpu *);
-extern void init_clock_thread(void);
-
extern void send_dirint(int, int);
extern void siron(void);
--- a/usr/src/uts/sun4/os/intr.c Fri Feb 17 10:51:31 2006 -0800
+++ b/usr/src/uts/sun4/os/intr.c Fri Feb 17 17:24:21 2006 -0800
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -362,19 +361,6 @@
xt_one(cpuix, setsoftint_tl1, intr_id, 0);
}
-void
-init_intr_threads(struct cpu *cp)
-{
- int i;
-
- for (i = 0; i < NINTR_THREADS; i++)
- thread_create_intr(cp);
-
- cp->cpu_intr_stack = (caddr_t)segkp_get(segkp, INTR_STACK_SIZE,
- KPD_HASREDZONE | KPD_NO_ANON | KPD_LOCKED) +
- INTR_STACK_SIZE - SA(MINFRAME);
-}
-
/*
* Take the specified CPU out of participation in interrupts.
* Called by p_online(2) when a processor is being taken off-line.
--- a/usr/src/uts/sun4/os/mp_startup.c Fri Feb 17 10:51:31 2006 -0800
+++ b/usr/src/uts/sun4/os/mp_startup.c Fri Feb 17 17:24:21 2006 -0800
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -305,7 +304,6 @@
#endif /* TRAPTRACE */
extern void idle();
- extern void init_intr_threads(struct cpu *);
ASSERT(MUTEX_HELD(&cpu_lock));
ASSERT(cpu[cpuid] == NULL);
@@ -411,7 +409,7 @@
* Initialize the interrupt threads for this CPU
*/
init_intr_pool(cp);
- init_intr_threads(cp);
+ cpu_intr_alloc(cp, NINTR_THREADS);
/*
* Add CPU to list of available CPUs.
--- a/usr/src/uts/sun4/os/startup.c Fri Feb 17 10:51:31 2006 -0800
+++ b/usr/src/uts/sun4/os/startup.c Fri Feb 17 17:24:21 2006 -0800
@@ -3,7 +3,7 @@
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
- * You may not use this file except in compliance *with the License.
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -2124,7 +2124,7 @@
/*
* Initialize interrupt related stuff
*/
- init_intr_threads(CPU);
+ cpu_intr_alloc(CPU, NINTR_THREADS);
(void) splzs(); /* allow hi clock ints but not zs */
--- a/usr/src/uts/sun4/sys/intr.h Fri Feb 17 10:51:31 2006 -0800
+++ b/usr/src/uts/sun4/sys/intr.h Fri Feb 17 17:24:21 2006 -0800
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 1994, 1997-2002 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -42,11 +41,6 @@
#define INTR_POOL_SIZE (sizeof (struct intr_req) * INTR_PENDING_MAX)
/*
- * Allocate threads and stacks for interrupt handling.
- */
-#define NINTR_THREADS (LOCK_LEVEL) /* number of interrupt threads */
-
-/*
* Each cpu allocates two arrays, intr_head[] and intr_tail[], with the size of
* PIL_LEVELS each.
*
--- a/usr/src/uts/sun4u/sys/machcpuvar.h Fri Feb 17 10:51:31 2006 -0800
+++ b/usr/src/uts/sun4u/sys/machcpuvar.h Fri Feb 17 17:24:21 2006 -0800
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -135,6 +134,7 @@
typedef struct machcpu machcpu_t;
#define cpu_startup_thread cpu_m.startup_thread
+#define NINTR_THREADS (LOCK_LEVEL) /* number of interrupt threads */
/*
* Macro to access the "cpu private" data structure.
--- a/usr/src/uts/sun4u/sys/machsystm.h Fri Feb 17 10:51:31 2006 -0800
+++ b/usr/src/uts/sun4u/sys/machsystm.h Fri Feb 17 17:24:21 2006 -0800
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -213,7 +212,6 @@
extern struct intr_req *intr_add_tail;
extern struct scb *set_tbr(struct scb *);
-extern void init_intr_threads(struct cpu *);
extern uint_t disable_vec_intr(void);
extern void enable_vec_intr(uint_t);
extern void setintrenable(int);
--- a/usr/src/uts/sun4v/sys/machcpuvar.h Fri Feb 17 10:51:31 2006 -0800
+++ b/usr/src/uts/sun4v/sys/machcpuvar.h Fri Feb 17 17:24:21 2006 -0800
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -164,6 +163,7 @@
typedef struct machcpu machcpu_t;
#define cpu_startup_thread cpu_m.startup_thread
+#define NINTR_THREADS (LOCK_LEVEL) /* number of interrupt threads */
/*
* Macro to access the "cpu private" data structure.
--- a/usr/src/uts/sun4v/sys/machsystm.h Fri Feb 17 10:51:31 2006 -0800
+++ b/usr/src/uts/sun4v/sys/machsystm.h Fri Feb 17 17:24:21 2006 -0800
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -213,7 +212,6 @@
extern struct intr_req *intr_add_tail;
extern struct scb *set_tbr(struct scb *);
-extern void init_intr_threads(struct cpu *);
extern uint_t disable_vec_intr(void);
extern void enable_vec_intr(uint_t);
extern void setintrenable(int);