From 0bbc882680ceece07eb134ddeb7fceffb59ea018 Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Tue, 11 Dec 2001 23:33:44 +0000 Subject: Overhaul the per-CPU support a bit: - The MI portions of struct globaldata have been consolidated into a MI struct pcpu. The MD per-CPU data are specified via a macro defined in machine/pcpu.h. A macro was chosen over a struct mdpcpu so that the interface would be cleaner (PCPU_GET(my_md_field) vs. PCPU_GET(md.md_my_md_field)). - All references to globaldata are changed to pcpu instead. In a UP kernel, this data was stored as global variables which is where the original name came from. In an SMP world this data is per-CPU and ideally private to each CPU outside of the context of debuggers. This also included combining machine/globaldata.h and machine/globals.h into machine/pcpu.h. - The pointer to the thread using the FPU on i386 was renamed from npxthread to fpcurthread to be identical with other architectures. - Make the show pcpu ddb command MI with a MD callout to display MD fields. - The globaldata_register() function was renamed to pcpu_init() and now init's MI fields of a struct pcpu in addition to registering it with the internal array and list. - A pcpu_destroy() function was added to remove a struct pcpu from the internal array and list. Tested on: alpha, i386 Reviewed by: peter, jake --- sys/alpha/include/asm.h | 2 +- sys/alpha/include/globaldata.h | 74 ------------------------------------------ sys/alpha/include/globals.h | 51 ----------------------------- sys/alpha/include/mutex.h | 2 +- sys/alpha/include/pcb.h | 1 - sys/alpha/include/pcpu.h | 50 ++++++++-------------------- sys/alpha/include/proc.h | 3 -- 7 files changed, 16 insertions(+), 167 deletions(-) delete mode 100644 sys/alpha/include/globaldata.h delete mode 100644 sys/alpha/include/globals.h (limited to 'sys/alpha/include') diff --git a/sys/alpha/include/asm.h b/sys/alpha/include/asm.h index 4a9963c5a40b9..782505cfae45c 100644 --- a/sys/alpha/include/asm.h +++ b/sys/alpha/include/asm.h @@ -91,7 +91,7 @@ /* In the kernel, we use t7 to point at the per-cpu globals. */ #ifdef _KERNEL -#define globalp $8 +#define pcpup $8 #endif /* Floating point registers (XXXX VERIFY THIS) */ diff --git a/sys/alpha/include/globaldata.h b/sys/alpha/include/globaldata.h deleted file mode 100644 index d0ba7064cad78..0000000000000 --- a/sys/alpha/include/globaldata.h +++ /dev/null @@ -1,74 +0,0 @@ -/*- - * Copyright (c) 1999 Luoqi Chen - * Copyright (c) Peter Wemm - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_GLOBALDATA_H_ -#define _MACHINE_GLOBALDATA_H_ - -#ifdef _KERNEL - -#include - -/* - * This structure maps out the global data that needs to be kept on a - * per-cpu basis. genassym uses this to generate offsets for the assembler - * code, which also provides external symbols so that C can get at them as - * though they were really globals. This structure is pointed to by - * the per-cpu system value (see alpha_pal_rdval() and alpha_pal_wrval()). - * Inside the kernel, the globally reserved register t7 is used to - * point at the globaldata structure. - */ -struct globaldata { - struct alpha_pcb gd_idlepcb; /* pcb for idling */ - struct thread *gd_curthread; /* current thread */ - struct thread *gd_idlethread; /* idle thread */ - struct thread *gd_fpcurthread; /* fp state owner */ - struct pcb *gd_curpcb; /* current pcb */ - struct timeval gd_switchtime; - int gd_switchticks; - u_int gd_cpuid; /* this cpu number */ - u_int gd_other_cpus; /* all other cpus */ - u_int64_t gd_idlepcbphys; /* pa of gd_idlepcb */ - u_int64_t gd_pending_ipis; /* pending IPI events */ - u_int32_t gd_next_asn; /* next ASN to allocate */ - u_int32_t gd_current_asngen; /* ASN rollover check */ - - SLIST_ENTRY(globaldata) gd_allcpu; - struct lock_list_entry *gd_spinlocks; -#ifdef KTR_PERCPU - int gd_ktr_idx; /* Index into trace table */ - char *gd_ktr_buf; - char gd_ktr_buf_data[0]; -#endif -}; - -void globaldata_init(struct globaldata *pcpu, int cpuid, size_t sz); - -#endif /* _KERNEL */ - -#endif /* !_MACHINE_GLOBALDATA_H_ */ diff --git a/sys/alpha/include/globals.h b/sys/alpha/include/globals.h deleted file mode 100644 index a6a87f26a3783..0000000000000 --- a/sys/alpha/include/globals.h +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 1999 Luoqi Chen - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_GLOBALS_H_ -#define _MACHINE_GLOBALS_H_ - -#ifdef _KERNEL -#include - -register struct globaldata *globalp __asm__("$8"); - -#define GLOBALP globalp - -#define PCPU_GET(member) (GLOBALP->gd_ ## member) -#define PCPU_PTR(member) (&GLOBALP->gd_ ## member) -#define PCPU_SET(member,value) (GLOBALP->gd_ ## member = (value)) - -#define curthread PCPU_GET(curthread) -#define CURPROC (curthread->td_proc) -#define curproc (curthread->td_proc) -#define curksegrp (curthread->td_ksegrp) -#define curkse (curthread->td_kse) - -#endif /* _KERNEL */ - -#endif /* !_MACHINE_GLOBALS_H_ */ diff --git a/sys/alpha/include/mutex.h b/sys/alpha/include/mutex.h index 9192bb2b0c3c7..970049bda0bdd 100644 --- a/sys/alpha/include/mutex.h +++ b/sys/alpha/include/mutex.h @@ -58,7 +58,7 @@ extern struct mtx clock_lock; 1: ldq_l a0, lck+MTX_LOCK; \ cmpeq a0, MTX_UNOWNED, a1; \ beq a1, 1b; \ - ldq a0, PC_CURTHREAD(globalp); \ + ldq a0, PC_CURTHREAD(pcpup); \ stq_c a0, lck+MTX_LOCK; \ beq a0, 1b; \ mb; \ diff --git a/sys/alpha/include/pcb.h b/sys/alpha/include/pcb.h index 18c4c13de0866..cfbdfdf74b9d7 100644 --- a/sys/alpha/include/pcb.h +++ b/sys/alpha/include/pcb.h @@ -33,7 +33,6 @@ #include #include -#include #include /* diff --git a/sys/alpha/include/pcpu.h b/sys/alpha/include/pcpu.h index d0ba7064cad78..807f259f56148 100644 --- a/sys/alpha/include/pcpu.h +++ b/sys/alpha/include/pcpu.h @@ -27,48 +27,26 @@ * $FreeBSD$ */ -#ifndef _MACHINE_GLOBALDATA_H_ -#define _MACHINE_GLOBALDATA_H_ +#ifndef _MACHINE_PCPU_H_ +#define _MACHINE_PCPU_H_ #ifdef _KERNEL -#include +#define PCPU_MD_FIELDS \ + struct alpha_pcb pc_idlepcb; /* pcb for idling */ \ + u_int64_t pc_idlepcbphys; /* pa of pc_idlepcb */ \ + u_int64_t pc_pending_ipis; /* pending IPI's */ \ + u_int32_t pc_next_asn; /* next ASN to alloc */ \ + u_int32_t pc_current_asngen /* ASN rollover check */ -/* - * This structure maps out the global data that needs to be kept on a - * per-cpu basis. genassym uses this to generate offsets for the assembler - * code, which also provides external symbols so that C can get at them as - * though they were really globals. This structure is pointed to by - * the per-cpu system value (see alpha_pal_rdval() and alpha_pal_wrval()). - * Inside the kernel, the globally reserved register t7 is used to - * point at the globaldata structure. - */ -struct globaldata { - struct alpha_pcb gd_idlepcb; /* pcb for idling */ - struct thread *gd_curthread; /* current thread */ - struct thread *gd_idlethread; /* idle thread */ - struct thread *gd_fpcurthread; /* fp state owner */ - struct pcb *gd_curpcb; /* current pcb */ - struct timeval gd_switchtime; - int gd_switchticks; - u_int gd_cpuid; /* this cpu number */ - u_int gd_other_cpus; /* all other cpus */ - u_int64_t gd_idlepcbphys; /* pa of gd_idlepcb */ - u_int64_t gd_pending_ipis; /* pending IPI events */ - u_int32_t gd_next_asn; /* next ASN to allocate */ - u_int32_t gd_current_asngen; /* ASN rollover check */ +struct pcpu; - SLIST_ENTRY(globaldata) gd_allcpu; - struct lock_list_entry *gd_spinlocks; -#ifdef KTR_PERCPU - int gd_ktr_idx; /* Index into trace table */ - char *gd_ktr_buf; - char gd_ktr_buf_data[0]; -#endif -}; +register struct pcpu *pcpup __asm__("$8"); -void globaldata_init(struct globaldata *pcpu, int cpuid, size_t sz); +#define PCPU_GET(member) (pcpup->pc_ ## member) +#define PCPU_PTR(member) (&pcpup->pc_ ## member) +#define PCPU_SET(member,value) (pcpup->pc_ ## member = (value)) #endif /* _KERNEL */ -#endif /* !_MACHINE_GLOBALDATA_H_ */ +#endif /* !_MACHINE_PCPU_H_ */ diff --git a/sys/alpha/include/proc.h b/sys/alpha/include/proc.h index 16cf1d5b59a59..eb1772a1128a4 100644 --- a/sys/alpha/include/proc.h +++ b/sys/alpha/include/proc.h @@ -31,9 +31,6 @@ #ifndef _MACHINE_PROC_H_ #define _MACHINE_PROC_H_ -#include -#include - /* * Machine-dependent part of the proc struct for the Alpha. */ -- cgit v1.3