Sat Jul 30 05:24:17 2011 UTC ()
Use kmem(9) to allocate per-cpu softint context.  No functional changes.


(uebayasi)
diff -r1.35 -r1.36 src/sys/kern/kern_softint.c

cvs diff -r1.35 -r1.36 src/sys/kern/kern_softint.c (expand / switch to unified diff)

--- src/sys/kern/kern_softint.c 2011/04/24 18:46:22 1.35
+++ src/sys/kern/kern_softint.c 2011/07/30 05:24:16 1.36
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: kern_softint.c,v 1.35 2011/04/24 18:46:22 rmind Exp $ */ 1/* $NetBSD: kern_softint.c,v 1.36 2011/07/30 05:24:16 uebayasi 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.
@@ -166,36 +166,37 @@ @@ -166,36 +166,37 @@
166 * If a soft interrupt handler blocks and is resumed, it resumes 166 * If a soft interrupt handler blocks and is resumed, it resumes
167 * execution as a normal LWP (kthread) and gains VM context. Only 167 * execution as a normal LWP (kthread) and gains VM context. Only
168 * when it has completed and is ready to fire again will it 168 * when it has completed and is ready to fire again will it
169 * interrupt other threads. 169 * interrupt other threads.
170 * 170 *
171 * Future directions 171 * Future directions
172 * 172 *
173 * Provide a cheap way to direct software interrupts to remote 173 * Provide a cheap way to direct software interrupts to remote
174 * CPUs. Provide a way to enqueue work items into the handler 174 * CPUs. Provide a way to enqueue work items into the handler
175 * record, removing additional spl calls (see subr_workqueue.c).  175 * record, removing additional spl calls (see subr_workqueue.c).
176 */ 176 */
177 177
178#include <sys/cdefs.h> 178#include <sys/cdefs.h>
179__KERNEL_RCSID(0, "$NetBSD: kern_softint.c,v 1.35 2011/04/24 18:46:22 rmind Exp $"); 179__KERNEL_RCSID(0, "$NetBSD: kern_softint.c,v 1.36 2011/07/30 05:24:16 uebayasi Exp $");
180 180
181#include <sys/param.h> 181#include <sys/param.h>
182#include <sys/proc.h> 182#include <sys/proc.h>
183#include <sys/intr.h> 183#include <sys/intr.h>
184#include <sys/mutex.h> 184#include <sys/mutex.h>
185#include <sys/kthread.h> 185#include <sys/kthread.h>
186#include <sys/evcnt.h> 186#include <sys/evcnt.h>
187#include <sys/cpu.h> 187#include <sys/cpu.h>
188#include <sys/xcall.h> 188#include <sys/xcall.h>
 189#include <sys/kmem.h>
189 190
190#include <net/netisr.h> 191#include <net/netisr.h>
191 192
192#include <uvm/uvm_extern.h> 193#include <uvm/uvm_extern.h>
193 194
194/* This could overlap with signal info in struct lwp. */ 195/* This could overlap with signal info in struct lwp. */
195typedef struct softint { 196typedef struct softint {
196 SIMPLEQ_HEAD(, softhand) si_q; 197 SIMPLEQ_HEAD(, softhand) si_q;
197 struct lwp *si_lwp; 198 struct lwp *si_lwp;
198 struct cpu_info *si_cpu; 199 struct cpu_info *si_cpu;
199 uintptr_t si_machdep; 200 uintptr_t si_machdep;
200 struct evcnt si_evcnt; 201 struct evcnt si_evcnt;
201 struct evcnt si_evcnt_block; 202 struct evcnt si_evcnt_block;
@@ -273,28 +274,27 @@ softint_init(struct cpu_info *ci) @@ -273,28 +274,27 @@ softint_init(struct cpu_info *ci)
273 static struct cpu_info *first; 274 static struct cpu_info *first;
274 softcpu_t *sc, *scfirst; 275 softcpu_t *sc, *scfirst;
275 softhand_t *sh, *shmax; 276 softhand_t *sh, *shmax;
276 277
277 if (first == NULL) { 278 if (first == NULL) {
278 /* Boot CPU. */ 279 /* Boot CPU. */
279 first = ci; 280 first = ci;
280 mutex_init(&softint_lock, MUTEX_DEFAULT, IPL_NONE); 281 mutex_init(&softint_lock, MUTEX_DEFAULT, IPL_NONE);
281 softint_bytes = round_page(softint_bytes); 282 softint_bytes = round_page(softint_bytes);
282 softint_max = (softint_bytes - sizeof(softcpu_t)) / 283 softint_max = (softint_bytes - sizeof(softcpu_t)) /
283 sizeof(softhand_t); 284 sizeof(softhand_t);
284 } 285 }
285 286
286 sc = (softcpu_t *)uvm_km_alloc(kernel_map, softint_bytes, 0, 287 sc = kmem_zalloc(softint_bytes, KM_SLEEP);
287 UVM_KMF_WIRED | UVM_KMF_ZERO); 
288 if (sc == NULL) 288 if (sc == NULL)
289 panic("softint_init_cpu: cannot allocate memory"); 289 panic("softint_init_cpu: cannot allocate memory");
290 290
291 ci->ci_data.cpu_softcpu = sc; 291 ci->ci_data.cpu_softcpu = sc;
292 ci->ci_data.cpu_softints = 0; 292 ci->ci_data.cpu_softints = 0;
293 sc->sc_cpu = ci; 293 sc->sc_cpu = ci;
294 294
295 softint_init_isr(sc, "net", PRI_SOFTNET, SOFTINT_NET); 295 softint_init_isr(sc, "net", PRI_SOFTNET, SOFTINT_NET);
296 softint_init_isr(sc, "bio", PRI_SOFTBIO, SOFTINT_BIO); 296 softint_init_isr(sc, "bio", PRI_SOFTBIO, SOFTINT_BIO);
297 softint_init_isr(sc, "clk", PRI_SOFTCLOCK, SOFTINT_CLOCK); 297 softint_init_isr(sc, "clk", PRI_SOFTCLOCK, SOFTINT_CLOCK);
298 softint_init_isr(sc, "ser", PRI_SOFTSERIAL, SOFTINT_SERIAL); 298 softint_init_isr(sc, "ser", PRI_SOFTSERIAL, SOFTINT_SERIAL);
299 299
300 if (first != ci) { 300 if (first != ci) {