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
This commit is contained in:
parent
73a30b035e
commit
83dc49beaf
@ -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 */ \
|
||||
|
@ -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; \
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user