1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-21 11:13:30 +00:00

Implement get_pcpu() for i386 and use it to replace pcpu_find(curcpu)

in the i386 pmap.

The curcpu macro loads the per-cpu data pointer as its first step,
so the remaining steps of pcpu_find(curcpu) are circular.

get_pcpu() is already implemented for arm, arm64, and risc-v.
My plan is to implement it for the remaining architectures and use
it to replace several instances of pcpu_find(curcpu) in MI code.

Reviewed by:	kib
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D9370
This commit is contained in:
Jason A. Harmening 2017-01-29 16:54:55 +00:00
parent 4943dc2d2c
commit d986450859
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=312952
2 changed files with 16 additions and 6 deletions

View File

@ -440,7 +440,7 @@ pmap_bootstrap(vm_paddr_t firstaddr)
* CMAP1/CMAP2 are used for zeroing and copying pages.
* CMAP3 is used for the boot-time memory test.
*/
pc = pcpu_find(curcpu);
pc = get_pcpu();
mtx_init(&pc->pc_cmap_lock, "SYSMAPS", NULL, MTX_DEF);
SYSMAP(caddr_t, pc->pc_cmap_pte1, pc->pc_cmap_addr1, 1)
SYSMAP(caddr_t, pc->pc_cmap_pte2, pc->pc_cmap_addr2, 1)
@ -4206,7 +4206,7 @@ pmap_zero_page(vm_page_t m)
struct pcpu *pc;
sched_pin();
pc = pcpu_find(curcpu);
pc = get_pcpu();
cmap_pte2 = pc->pc_cmap_pte2;
mtx_lock(&pc->pc_cmap_lock);
if (*cmap_pte2)
@ -4237,7 +4237,7 @@ pmap_zero_page_area(vm_page_t m, int off, int size)
struct pcpu *pc;
sched_pin();
pc = pcpu_find(curcpu);
pc = get_pcpu();
cmap_pte2 = pc->pc_cmap_pte2;
mtx_lock(&pc->pc_cmap_lock);
if (*cmap_pte2)
@ -4264,7 +4264,7 @@ pmap_copy_page(vm_page_t src, vm_page_t dst)
struct pcpu *pc;
sched_pin();
pc = pcpu_find(curcpu);
pc = get_pcpu();
cmap_pte1 = pc->pc_cmap_pte1;
cmap_pte2 = pc->pc_cmap_pte2;
mtx_lock(&pc->pc_cmap_lock);
@ -4299,7 +4299,7 @@ pmap_copy_pages(vm_page_t ma[], vm_offset_t a_offset, vm_page_t mb[],
int cnt;
sched_pin();
pc = pcpu_find(curcpu);
pc = get_pcpu();
cmap_pte1 = pc->pc_cmap_pte1;
cmap_pte2 = pc->pc_cmap_pte2;
mtx_lock(&pc->pc_cmap_lock);
@ -5288,7 +5288,7 @@ pmap_flush_page(vm_page_t m)
useclflushopt = (cpu_stdext_feature & CPUID_STDEXT_CLFLUSHOPT) != 0;
if (useclflushopt || (cpu_feature & CPUID_CLFSH) != 0) {
sched_pin();
pc = pcpu_find(curcpu);
pc = get_pcpu();
cmap_pte2 = pc->pc_cmap_pte2;
mtx_lock(&pc->pc_cmap_lock);
if (*cmap_pte2)

View File

@ -76,6 +76,7 @@
extern struct pcpu *pcpup;
#define get_pcpu() (pcpup)
#define PCPU_GET(member) (pcpup->pc_ ## member)
#define PCPU_ADD(member, val) (pcpup->pc_ ## member += (val))
#define PCPU_INC(member) PCPU_ADD(member, 1)
@ -196,6 +197,15 @@ extern struct pcpu *pcpup;
} \
} while (0)
#define get_pcpu() __extension__ ({ \
struct pcpu *__pc; \
\
__asm __volatile("movl %%fs:%1,%0" \
: "=r" (__pc) \
: "m" (*(struct pcpu *)(__pcpu_offset(pc_prvspace)))); \
__pc; \
})
#define PCPU_GET(member) __PCPU_GET(pc_ ## member)
#define PCPU_ADD(member, val) __PCPU_ADD(pc_ ## member, val)
#define PCPU_INC(member) __PCPU_INC(pc_ ## member)