Skip to contentSkip to conversation

Prefetch macros for PA-RISC

parisc-linux Matthew Wilcox 4 participants 12 messages Feb 21, 2001

lore
Share & tools
lore
#0 lore raw

on PA, we have prefetch for read and prefetch for write. They're encoded as loads to the 0 register. prefetch read is ldd (load 64-bit quantity) and prefetch-write is ldw (load 32-bit quantity).

Off the top of my head, untested (and someone on the list please correct me if I'm wrong):

#define prefetch_read(addr) __asm__("ldd 0(%%sr0, %0), %%r0" : : "r" (addr)) #define prefetch_write(addr) __asm__("ldw 0(%%sr0, %0), %%r0" : : "r" (addr))

i think these are only defined for PA 2.0, so we might need to be more clever than this.

Signature · 1 line
Revolutions do not require corporate support.
#1 lore raw
Quoted 10 lines · Matthew Wilcox

on PA, we have prefetch for read and prefetch for write. They're encoded as loads to the 0 register. prefetch read is ldd (load 64-bit quantity) and prefetch-write is ldw (load 32-bit quantity).

Off the top of my head, untested (and someone on the list please correct me if I'm wrong):

#define prefetch_read(addr) __asm__("ldd 0(%%sr0, %0), %%r0" : : "r" (addr)) #define prefetch_write(addr) __asm__("ldw 0(%%sr0, %0), %%r0" : : "r" (addr))

Will assuming SR0 work for user space?
Will assuming SR0 work for zero-copy patch in the (near?) future?

"addr" has alignment restrictions. Not sure if you want to encode those as runtime checks or not.

Quoted 2 lines

i think these are only defined for PA 2.0, so we might need to be more clever than this.

My reading of the "PA 2.0 Enhancements" in the "PA-RISC 2.0 Architecture" is pretty clear this is for PA2.0 CPU's only. #ifdef __LP64__ is needed.

I'd like to encourage use prefetching on bcopy/checksum type loops. It will help perf *alot*.

grant

Grant Grundler
parisc-linux {PCI|IOMMU|SMP} hacker
+1.408.447.7253

#2 lore raw
Quoted 5 lines

My reading of the "PA 2.0 Enhancements" in the "PA-RISC 2.0 Architecture" is pretty clear this is for PA2.0 CPU's only. #ifdef __LP64__ is needed.

I'd like to encourage use prefetching on bcopy/checksum type loops. It will help perf *alot*.

Can the prefetch on the hppa fault ?

#3 lore raw
Quoted 1 line · Alan Cox

Can the prefetch on the hppa fault ?

"PARISC 2.0 Arch" page 6-11 says:
If one of those exceptions would occur, the prefetch is simply ignored, but any base register modification specified by the instruction still occurs.

I haven't checked if the errata contradicts this.
The whole point of prefetch which be undermined if it could fault.

Grant Grundler
parisc-linux {PCI|IOMMU|SMP} hacker
+1.408.447.7253

#4 lore raw
Quoted 10 lines · Grant Grundler
Quoted 1 line · Alan Cox

Can the prefetch on the hppa fault ?

"PARISC 2.0 Arch" page 6-11 says:
If one of those exceptions would occur, the prefetch is simply ignored, but any base register modification specified by the instruction still occurs.

I haven't checked if the errata contradicts this.
The whole point of prefetch which be undermined if it could fault.

The errata only covers which way around the LDD/LDW instructions are.

Signature · 1 line
Revolutions do not require corporate support.
#5 lore raw
In reply to Grant Grundler
Quoted 6 lines

If one of those exceptions would occur, the prefetch is simply ignored, but any base register modification specified by the instruction still occurs.

I haven't checked if the errata contradicts this.
The whole point of prefetch which be undermined if it could fault.

Excellent, our proposed list walking uses kind of depend on being able to prefetch off the end of lists and stuff. Also I assume its prefetching a cache line and the prefetch for write prefetches it exclusive ?

#6 lore raw
Quoted 3 lines · Alan Cox

Excellent, our proposed list walking uses kind of depend on being able to prefetch off the end of lists and stuff. Also I assume its prefetching a cache line and the prefetch for write prefetches it exclusive ?

Yes.

#7 lore raw
In reply to Grant Grundler
Quoted 2 lines · Grant Grundler

Will assuming SR0 work for user space?
Will assuming SR0 work for zero-copy patch in the (near?) future?

It'll have to. If you want to prefetch userspace, we need different macros. Given an address, we have no way of telling whether it's user or kernel.

Quoted 2 lines

"addr" has alignment restrictions. Not sure if you want to encode those as runtime checks or not.

Um.. Kane, page 6-11: ``The prefetch address is never unaligned -- the low-order bits are ignored and the cache line containing the address is fetched.''

Quoted 2 lines

My reading of the "PA 2.0 Enhancements" in the "PA-RISC 2.0 Architecture" is pretty clear this is for PA2.0 CPU's only. #ifdef __LP64__ is needed.

But that stops 32-bit kernels on 64-bit architecture from taking advantage of the optimisation. perhaps we need some funky runtime patching...

Quoted 2 lines

I'd like to encourage use prefetching on bcopy/checksum type loops. It will help perf *alot*.

I believe arjan's patch uses prefetches for list walking, which helps the scheduler a lot.

Signature · 1 line
Revolutions do not require corporate support.
#8 lore raw
Quoted 6 lines · Matthew Wilcox
Quoted 2 lines

"addr" has alignment restrictions. Not sure if you want to encode those as runtime checks or not.

Um.. Kane, page 6-11: ``The prefetch address is never unaligned -- the low-order bits are ignored and the cache line containing the address is fetched.''

Right. I was reading the LDD/LDW pages (which don't discuss prefetching) since I couldn't find the "Data Prefetch Instructions" section on page 6-11 on my own.

Quoted 2 lines

But that stops 32-bit kernels on 64-bit architecture from taking advantage of the optimisation. perhaps we need some funky runtime patching...

That's evil. I'd rather introduce a CONFIG flag that says "build me a 32-bit kernel with PA2.0 optimizations/support". We've already made this tradeoff in a few other places as well.

Quoted 2 lines

I believe arjan's patch uses prefetches for list walking, which helps the scheduler a lot.

Certainly. Anytime we know we will touch more than a few cachelines, I think it'll help.

grant

Grant Grundler
parisc-linux {PCI|IOMMU|SMP} hacker
+1.408.447.7253

#9 lore raw
Quoted 6 lines · Grant Grundler
Quoted 2 lines

But that stops 32-bit kernels on 64-bit architecture from taking advantage of the optimisation. perhaps we need some funky runtime patching...

That's evil. I'd rather introduce a CONFIG flag that says "build me a 32-bit kernel with PA2.0 optimizations/support". We've already made this tradeoff in a few other places as well.

This sounds like a good idea. x86 has a `processor' section. We could select PA1.1, PA2.0 or PA2.0Wide at that point.

Signature · 1 line
Revolutions do not require corporate support.
#10 lore raw
In reply to Matthew Wilcox
Quoted 3 lines · you

on PA, we have prefetch for read and prefetch for write. They're encoded as loads to the 0 register. prefetch read is ldd (load 64-bit quantity) and prefetch-write is ldw (load 32-bit quantity).

Actually, Table 6-10 in the PA-RISC 2.0 book is wrong -- LDW is prefetch for read, LDD is prefetch for write. See this erratum description:

http://devresource.hp.com/devresource/Docs/Refs/PA2_0/updates/e1.html

-- Jim