Page MenuHomeFreeBSD

Implement get_pcpu() for i386
ClosedPublic

Authored by jah on Jan 29 2017, 3:20 AM.

Details

Summary

get_pcpu() already exists for arm/arm64/risc-v
as a more direct alternative to pcpu_find(curcpu).
The curcpu macro already loads the per-cpu data
pointer as its first step, so the following steps
of loading the cpuid field and using that to index
the per-cpu data array via pcpu_find() are circular.

Replace pcpu_find(curcpu) with get_pcpu() in i386
pmap. My plan is to implement get_pcpu() for the
remaining architectures and use it to replace
instances of pcpu_find(curcpu) in MI code.

Diff Detail

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

jah updated this revision to Diff 24531.Jan 29 2017, 3:20 AM
jah retitled this revision from to Implement get_pcpu() for i386.
jah updated this object.
jah edited the test plan for this revision. (Show Details)
jah added a reviewer: kib.Jan 29 2017, 3:20 AM
kib edited edge metadata.Jan 29 2017, 10:26 AM

Overall, it looks good.

sys/i386/i386/pmap.c
4209 ↗(On Diff #24531)

There seems to be a stray space after the ';' in each such line.

sys/i386/include/pcpu.h
79 ↗(On Diff #24531)

Use <tab> after #define.

200 ↗(On Diff #24531)

Why is this not

static inline struct pcpu *
get_pcpu(void)
{}

?

jah added inline comments.Jan 29 2017, 4:15 PM
sys/i386/include/pcpu.h
200 ↗(On Diff #24531)

struct pcpu isn't a complete type at the point the MD pcpu.h is included, so offsetof(pc_prvspace) doesn't work in an inline function. That's why the subsequent inline functions curthread and curpcb use hardcoded offsets OFFSETOF_CURTHREAD and OFFSETOF_CURPCB. I'd rather not do that in case the struct layout changes.

jah updated this revision to Diff 24538.Jan 29 2017, 4:26 PM
jah edited edge metadata.

Whitespace fixes

kib accepted this revision.Jan 29 2017, 4:31 PM
kib edited edge metadata.
This revision is now accepted and ready to land.Jan 29 2017, 4:31 PM
This revision was automatically updated to reflect the committed changes.