subr_pcpu.c (217265) | subr_pcpu.c (222531) |
---|---|
1/*- 2 * Copyright (c) 2001 Wind River Systems, Inc. 3 * All rights reserved. 4 * Written by: John Baldwin <jhb@FreeBSD.org> 5 * 6 * Copyright (c) 2009 Jeffrey Roberson <jeff@freebsd.org> 7 * All rights reserved. 8 * --- 32 unchanged lines hidden (view full) --- 41 * gaps in the mappings. 42 * - The platform sets the value of MAXCPU in <machine/param.h>. 43 * - It is suggested, but not required, that in the non-SMP case, the 44 * platform define MAXCPU to be 1 and define the logical ID of the 45 * sole CPU as 0. 46 */ 47 48#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2001 Wind River Systems, Inc. 3 * All rights reserved. 4 * Written by: John Baldwin <jhb@FreeBSD.org> 5 * 6 * Copyright (c) 2009 Jeffrey Roberson <jeff@freebsd.org> 7 * All rights reserved. 8 * --- 32 unchanged lines hidden (view full) --- 41 * gaps in the mappings. 42 * - The platform sets the value of MAXCPU in <machine/param.h>. 43 * - It is suggested, but not required, that in the non-SMP case, the 44 * platform define MAXCPU to be 1 and define the logical ID of the 45 * sole CPU as 0. 46 */ 47 48#include <sys/cdefs.h> |
49__FBSDID("$FreeBSD: head/sys/kern/subr_pcpu.c 217265 2011-01-11 13:59:06Z jhb $"); | 49__FBSDID("$FreeBSD: head/sys/kern/subr_pcpu.c 222531 2011-05-31 15:11:43Z nwhitehorn $"); |
50 51#include "opt_ddb.h" 52 53#include <sys/param.h> 54#include <sys/systm.h> 55#include <sys/sysctl.h> 56#include <sys/lock.h> 57#include <sys/malloc.h> --- 11 unchanged lines hidden (view full) --- 69 TAILQ_ENTRY(dpcpu_free) df_link; 70}; 71 72static DPCPU_DEFINE(char, modspace[DPCPU_MODMIN]); 73static TAILQ_HEAD(, dpcpu_free) dpcpu_head = TAILQ_HEAD_INITIALIZER(dpcpu_head); 74static struct sx dpcpu_lock; 75uintptr_t dpcpu_off[MAXCPU]; 76struct pcpu *cpuid_to_pcpu[MAXCPU]; | 50 51#include "opt_ddb.h" 52 53#include <sys/param.h> 54#include <sys/systm.h> 55#include <sys/sysctl.h> 56#include <sys/lock.h> 57#include <sys/malloc.h> --- 11 unchanged lines hidden (view full) --- 69 TAILQ_ENTRY(dpcpu_free) df_link; 70}; 71 72static DPCPU_DEFINE(char, modspace[DPCPU_MODMIN]); 73static TAILQ_HEAD(, dpcpu_free) dpcpu_head = TAILQ_HEAD_INITIALIZER(dpcpu_head); 74static struct sx dpcpu_lock; 75uintptr_t dpcpu_off[MAXCPU]; 76struct pcpu *cpuid_to_pcpu[MAXCPU]; |
77struct cpuhead cpuhead = SLIST_HEAD_INITIALIZER(cpuhead); | 77struct cpuhead cpuhead = STAILQ_HEAD_INITIALIZER(cpuhead); |
78 79/* 80 * Initialize the MI portions of a struct pcpu. 81 */ 82void 83pcpu_init(struct pcpu *pcpu, int cpuid, size_t size) 84{ 85 86 bzero(pcpu, size); 87 KASSERT(cpuid >= 0 && cpuid < MAXCPU, 88 ("pcpu_init: invalid cpuid %d", cpuid)); 89 pcpu->pc_cpuid = cpuid; 90 pcpu->pc_cpumask = 1 << cpuid; 91 cpuid_to_pcpu[cpuid] = pcpu; | 78 79/* 80 * Initialize the MI portions of a struct pcpu. 81 */ 82void 83pcpu_init(struct pcpu *pcpu, int cpuid, size_t size) 84{ 85 86 bzero(pcpu, size); 87 KASSERT(cpuid >= 0 && cpuid < MAXCPU, 88 ("pcpu_init: invalid cpuid %d", cpuid)); 89 pcpu->pc_cpuid = cpuid; 90 pcpu->pc_cpumask = 1 << cpuid; 91 cpuid_to_pcpu[cpuid] = pcpu; |
92 SLIST_INSERT_HEAD(&cpuhead, pcpu, pc_allcpu); | 92 STAILQ_INSERT_TAIL(&cpuhead, pcpu, pc_allcpu); |
93 cpu_pcpu_init(pcpu, cpuid, size); 94 pcpu->pc_rm_queue.rmq_next = &pcpu->pc_rm_queue; 95 pcpu->pc_rm_queue.rmq_prev = &pcpu->pc_rm_queue; 96#ifdef KTR 97 snprintf(pcpu->pc_name, sizeof(pcpu->pc_name), "CPU %d", cpuid); 98#endif 99} 100 --- 139 unchanged lines hidden (view full) --- 240 241/* 242 * Destroy a struct pcpu. 243 */ 244void 245pcpu_destroy(struct pcpu *pcpu) 246{ 247 | 93 cpu_pcpu_init(pcpu, cpuid, size); 94 pcpu->pc_rm_queue.rmq_next = &pcpu->pc_rm_queue; 95 pcpu->pc_rm_queue.rmq_prev = &pcpu->pc_rm_queue; 96#ifdef KTR 97 snprintf(pcpu->pc_name, sizeof(pcpu->pc_name), "CPU %d", cpuid); 98#endif 99} 100 --- 139 unchanged lines hidden (view full) --- 240 241/* 242 * Destroy a struct pcpu. 243 */ 244void 245pcpu_destroy(struct pcpu *pcpu) 246{ 247 |
248 SLIST_REMOVE(&cpuhead, pcpu, pcpu, pc_allcpu); | 248 STAILQ_REMOVE(&cpuhead, pcpu, pcpu, pc_allcpu); |
249 cpuid_to_pcpu[pcpu->pc_cpuid] = NULL; 250 dpcpu_off[pcpu->pc_cpuid] = 0; 251} 252 253/* 254 * Locate a struct pcpu by cpu id. 255 */ 256struct pcpu * --- 142 unchanged lines hidden --- | 249 cpuid_to_pcpu[pcpu->pc_cpuid] = NULL; 250 dpcpu_off[pcpu->pc_cpuid] = 0; 251} 252 253/* 254 * Locate a struct pcpu by cpu id. 255 */ 256struct pcpu * --- 142 unchanged lines hidden --- |