Date: Sat, 4 May 2019 17:35:14 +0000 (UTC) From: Conrad Meyer <cem@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r347129 - in head/sys: amd64/include i386/include x86/x86 Message-ID: <201905041735.x44HZErV035827@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: cem Date: Sat May 4 17:35:13 2019 New Revision: 347129 URL: https://svnweb.freebsd.org/changeset/base/347129 Log: x86: Define pc_monitorbuf as a logical structure Rather than just accessing it via pointer cast. No functional change intended. Discussed with: kib (earlier version) Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D20135 Modified: head/sys/amd64/include/pcpu.h head/sys/i386/include/pcpu.h head/sys/x86/x86/cpu_machdep.c Modified: head/sys/amd64/include/pcpu.h ============================================================================== --- head/sys/amd64/include/pcpu.h Sat May 4 16:27:58 2019 (r347128) +++ head/sys/amd64/include/pcpu.h Sat May 4 17:35:13 2019 (r347129) @@ -36,6 +36,13 @@ #endif #define PC_PTI_STACK_SZ 16 + +struct monitorbuf { + int idle_state; /* Used by cpu_idle_mwait. */ + char padding[128 - (1 * sizeof(int))]; +}; +_Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line"); + /* * The SMP parts are setup in pmap.c and locore.s for the BSP, and * mp_machdep.c sets up the data for the AP's to "see" when they awake. @@ -44,7 +51,7 @@ * other processors" */ #define PCPU_MD_FIELDS \ - char pc_monitorbuf[128] __aligned(128); /* cache line */ \ + struct monitorbuf pc_monitorbuf __aligned(128); /* cache line */\ struct pcpu *pc_prvspace; /* Self-reference */ \ struct pmap *pc_curpmap; \ struct amd64tss *pc_tssp; /* TSS segment active on CPU */ \ Modified: head/sys/i386/include/pcpu.h ============================================================================== --- head/sys/i386/include/pcpu.h Sat May 4 16:27:58 2019 (r347128) +++ head/sys/i386/include/pcpu.h Sat May 4 17:35:13 2019 (r347129) @@ -41,6 +41,12 @@ #include <sys/_lock.h> #include <sys/_mutex.h> +struct monitorbuf { + int idle_state; /* Used by cpu_idle_mwait. */ + char padding[128 - (1 * sizeof(int))]; +}; +_Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line"); + /* * The SMP parts are setup in pmap.c and machdep.c for the BSP, and * pmap.c and mp_machdep.c sets up the data for the AP's to "see" when @@ -50,7 +56,7 @@ */ #define PCPU_MD_FIELDS \ - char pc_monitorbuf[128] __aligned(128); /* cache line */ \ + struct monitorbuf pc_monitorbuf __aligned(128); /* cache line */\ struct pcpu *pc_prvspace; /* Self-reference */ \ struct pmap *pc_curpmap; \ struct segment_descriptor pc_common_tssd; \ Modified: head/sys/x86/x86/cpu_machdep.c ============================================================================== --- head/sys/x86/x86/cpu_machdep.c Sat May 4 16:27:58 2019 (r347128) +++ head/sys/x86/x86/cpu_machdep.c Sat May 4 17:35:13 2019 (r347129) @@ -164,7 +164,7 @@ acpi_cpu_idle_mwait(uint32_t mwait_hint) * but all Intel CPUs provide hardware coordination. */ - state = (int *)PCPU_PTR(monitorbuf); + state = &PCPU_PTR(monitorbuf)->idle_state; KASSERT(atomic_load_int(state) == STATE_SLEEPING, ("cpu_mwait_cx: wrong monitorbuf state")); atomic_store_int(state, STATE_MWAIT); @@ -422,7 +422,7 @@ cpu_idle_acpi(sbintime_t sbt) { int *state; - state = (int *)PCPU_PTR(monitorbuf); + state = &PCPU_PTR(monitorbuf)->idle_state; atomic_store_int(state, STATE_SLEEPING); /* See comments in cpu_idle_hlt(). */ @@ -441,7 +441,7 @@ cpu_idle_hlt(sbintime_t sbt) { int *state; - state = (int *)PCPU_PTR(monitorbuf); + state = &PCPU_PTR(monitorbuf)->idle_state; atomic_store_int(state, STATE_SLEEPING); /* @@ -473,7 +473,7 @@ cpu_idle_mwait(sbintime_t sbt) { int *state; - state = (int *)PCPU_PTR(monitorbuf); + state = &PCPU_PTR(monitorbuf)->idle_state; atomic_store_int(state, STATE_MWAIT); /* See comments in cpu_idle_hlt(). */ @@ -498,7 +498,7 @@ cpu_idle_spin(sbintime_t sbt) int *state; int i; - state = (int *)PCPU_PTR(monitorbuf); + state = &PCPU_PTR(monitorbuf)->idle_state; atomic_store_int(state, STATE_RUNNING); /* @@ -598,9 +598,11 @@ SYSCTL_INT(_machdep, OID_AUTO, idle_apl31, CTLFLAG_RW, int cpu_idle_wakeup(int cpu) { + struct monitorbuf *mb; int *state; - state = (int *)pcpu_find(cpu)->pc_monitorbuf; + mb = &pcpu_find(cpu)->pc_monitorbuf; + state = &mb->idle_state; switch (atomic_load_int(state)) { case STATE_SLEEPING: return (0);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201905041735.x44HZErV035827>