Skip to contentSkip to conversation

Percpu data in a vsyscall page

DISCUSSION Vojtech Pavlik 2 participants 2 messages Nov 2, 2005 – Nov 3, 2005

lore
Share & tools
lore
#0 lore raw

Hi!

I'm working on a RDTSCP support on x86-64, and for that, I'll need per-cpu time offset table in a vsyscall page. I saw the percpu.h header, and thought - "Hey, I could use that!", but I think I really can't.

The data need to be in a vsyscall page, which is mapped to userspace via linker magic, and the percpu stuff uses a different mapping.

I'm using a simple array instead, because the address will be different in a vsyscall from the one the kernel sees anyway, and RDTSCP will give me an index to that array atomically.

Is there any problem with that approach? Is there any reason using percpu.h would be better?

Signature · 2 lines
Vojtech Pavlik
SuSE Labs, SuSE CR
#1 lore raw
Quoted 8 lines · Vojtech Pavlik

Hi!

I'm working on a RDTSCP support on x86-64, and for that, I'll need per-cpu time offset table in a vsyscall page. I saw the percpu.h header, and thought - "Hey, I could use that!", but I think I really can't.

The data need to be in a vsyscall page, which is mapped to userspace via linker magic, and the percpu stuff uses a different mapping.

Yes. The percpu stuff uses a single add to find the local value of a variable. This per-cpu offset can be kept in a register (I think Sparc64 already does this) making it v. fast.

You're going to have to stick with an array I think.

Sorry,
Rusty.

Signature · 1 line
A bad analogy is like a leaky screwdriver -- Richard Braakman