| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: subr_xcall.c,v 1.9 2008/04/28 20:24:04 martin Exp $ */ | | 1 | /* $NetBSD: subr_xcall.c,v 1.9.10.1 2009/03/15 19:53:45 snj Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2007, 2008 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2007, 2008 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Andrew Doran. | | 8 | * by Andrew Doran. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -64,27 +64,27 @@ | | | @@ -64,27 +64,27 @@ |
64 | * CPU, and so has exclusive access to the CPU. Since this facility | | 64 | * CPU, and so has exclusive access to the CPU. Since this facility |
65 | * is heavyweight, it's expected that it will not be used often. | | 65 | * is heavyweight, it's expected that it will not be used often. |
66 | * | | 66 | * |
67 | * Cross calls must not allocate memory, as the pagedaemon uses | | 67 | * Cross calls must not allocate memory, as the pagedaemon uses |
68 | * them (and memory allocation may need to wait on the pagedaemon). | | 68 | * them (and memory allocation may need to wait on the pagedaemon). |
69 | * | | 69 | * |
70 | * Future directions | | 70 | * Future directions |
71 | * | | 71 | * |
72 | * Add a low-overhead mechanism to run cross calls in interrupt | | 72 | * Add a low-overhead mechanism to run cross calls in interrupt |
73 | * context (XC_HIGHPRI). | | 73 | * context (XC_HIGHPRI). |
74 | */ | | 74 | */ |
75 | | | 75 | |
76 | #include <sys/cdefs.h> | | 76 | #include <sys/cdefs.h> |
77 | __KERNEL_RCSID(0, "$NetBSD: subr_xcall.c,v 1.9 2008/04/28 20:24:04 martin Exp $"); | | 77 | __KERNEL_RCSID(0, "$NetBSD: subr_xcall.c,v 1.9.10.1 2009/03/15 19:53:45 snj Exp $"); |
78 | | | 78 | |
79 | #include <sys/types.h> | | 79 | #include <sys/types.h> |
80 | #include <sys/param.h> | | 80 | #include <sys/param.h> |
81 | #include <sys/xcall.h> | | 81 | #include <sys/xcall.h> |
82 | #include <sys/mutex.h> | | 82 | #include <sys/mutex.h> |
83 | #include <sys/condvar.h> | | 83 | #include <sys/condvar.h> |
84 | #include <sys/evcnt.h> | | 84 | #include <sys/evcnt.h> |
85 | #include <sys/kthread.h> | | 85 | #include <sys/kthread.h> |
86 | #include <sys/cpu.h> | | 86 | #include <sys/cpu.h> |
87 | | | 87 | |
88 | static void xc_thread(void *); | | 88 | static void xc_thread(void *); |
89 | static uint64_t xc_lowpri(u_int, xcfunc_t, void *, void *, struct cpu_info *); | | 89 | static uint64_t xc_lowpri(u_int, xcfunc_t, void *, void *, struct cpu_info *); |
90 | | | 90 | |
| @@ -163,27 +163,27 @@ xc_unicast(u_int flags, xcfunc_t func, v | | | @@ -163,27 +163,27 @@ xc_unicast(u_int flags, xcfunc_t func, v |
163 | } | | 163 | } |
164 | } | | 164 | } |
165 | | | 165 | |
166 | /* | | 166 | /* |
167 | * xc_lowpri: | | 167 | * xc_lowpri: |
168 | * | | 168 | * |
169 | * Trigger a low priority call on one or more CPUs. | | 169 | * Trigger a low priority call on one or more CPUs. |
170 | */ | | 170 | */ |
171 | static uint64_t | | 171 | static uint64_t |
172 | xc_lowpri(u_int flags, xcfunc_t func, void *arg1, void *arg2, | | 172 | xc_lowpri(u_int flags, xcfunc_t func, void *arg1, void *arg2, |
173 | struct cpu_info *ci) | | 173 | struct cpu_info *ci) |
174 | { | | 174 | { |
175 | CPU_INFO_ITERATOR cii; | | 175 | CPU_INFO_ITERATOR cii; |
176 | u_int where; | | 176 | uint64_t where; |
177 | | | 177 | |
178 | mutex_enter(&xc_lock); | | 178 | mutex_enter(&xc_lock); |
179 | while (xc_headp != xc_tailp) | | 179 | while (xc_headp != xc_tailp) |
180 | cv_wait(&xc_busy, &xc_lock); | | 180 | cv_wait(&xc_busy, &xc_lock); |
181 | xc_arg1 = arg1; | | 181 | xc_arg1 = arg1; |
182 | xc_arg2 = arg2; | | 182 | xc_arg2 = arg2; |
183 | xc_func = func; | | 183 | xc_func = func; |
184 | if (ci == NULL) { | | 184 | if (ci == NULL) { |
185 | xc_broadcast_ev.ev_count++; | | 185 | xc_broadcast_ev.ev_count++; |
186 | for (CPU_INFO_FOREACH(cii, ci)) { | | 186 | for (CPU_INFO_FOREACH(cii, ci)) { |
187 | if ((ci->ci_schedstate.spc_flags & SPCF_RUNNING) == 0) | | 187 | if ((ci->ci_schedstate.spc_flags & SPCF_RUNNING) == 0) |
188 | continue; | | 188 | continue; |
189 | xc_headp += 1; | | 189 | xc_headp += 1; |