EAL: An addition of cache line demote (CLDEMOTE) in rte_prefetch.h
PATCH 1/1 EAL: An addition of cache line demote (CLDEMOTE) in rte_prefetch.h
We are including this in rte_prefetch.h since it is the most closely related code location.rte_cldemte is similar to a prefetch hint -in reverse
Omkar Maslekar (1):
EAL: An addition of cache line demote (CLDEMOTE) in rte_prefetch.h
doc/guides/rel_notes/release_20_11.rst | 26 ++++---------------------- lib/librte_eal/arm/include/rte_prefetch_32.h | 5 +++++ lib/librte_eal/arm/include/rte_prefetch_64.h | 5 +++++ lib/librte_eal/include/generic/rte_prefetch.h | 7 +++++++ lib/librte_eal/ppc/include/rte_prefetch.h | 5 +++++ lib/librte_eal/x86/include/rte_prefetch.h | 9 +++++++++ 6 files changed, 35 insertions(+), 22 deletions(-)
Signature · 1 line
1.8.3.1
PATCH 1/1 EAL: An addition of cache line demote (CLDEMOTE) in rte_prefetch.h
rte_cldemote is similar to a prefetch hint - in reverse. cldemote(addr) enables software to hint to hardware that line is likely to be shared. Useful in core-to-core communications where cache-line is likely to be shared. ARM and PPC implementation is provided with NOP and can be added if any equivalent instructions could be used for implementation on those architectures.
--- doc/guides/rel_notes/release_20_11.rst | 26 ++++---------------------- lib/librte_eal/arm/include/rte_prefetch_32.h | 5 +++++ lib/librte_eal/arm/include/rte_prefetch_64.h | 5 +++++ lib/librte_eal/include/generic/rte_prefetch.h | 7 +++++++ lib/librte_eal/ppc/include/rte_prefetch.h | 5 +++++ lib/librte_eal/x86/include/rte_prefetch.h | 9 +++++++++ 6 files changed, 35 insertions(+), 22 deletions(-)
doc/guides/rel_notes/release_20_11.rst +4 -22
@@ -27,29 +27,11 @@ New Features .. This section should contain new features added in this release. Sample format: - * **Add a title in the past tense with a full stop.** +Added new instruction CLDEMOTE in rte_prefetch.h. - Add a short 1-2 sentence description in the past tense. - The description should be enough to allow someone scanning - the release notes to understand the new feature. - - If the feature adds a lot of sub-features you can use a bullet list - like this: - - * Added feature foo to do something. - * Enhanced feature bar to do something else. - - Refer to the previous release notes for examples. - - Suggested order in release notes items: - * Core libs (EAL, mempool, ring, mbuf, buses) - * Device abstraction libs and PMDs - - ethdev (lib, PMDs) - - cryptodev (lib, PMDs) - - eventdev (lib, PMDs) - - etc - * Other libs - * Apps, Examples, Tools (if significant) + Added a hardware hint CLDEMOTE which is similar to prefetch in reverse. + CLDEMOTES moves the cache line to the last shared cache, where it expects + sharing to be efficient. This section is a comment. Do not overwrite or remove it. Also, make sure to start the actual text at the margin.
lib/librte_eal/arm/include/rte_prefetch_32.h +5 -0
@@ -33,6 +33,11 @@ static inline void rte_prefetch_non_temporal(const volatile void *p)rte_prefetch0 (p); } +static inline void rte_cldemote (const volatile void *p) +{ +RTE_SET_USED (p); +} + #ifdef __cplusplus }#endif
lib/librte_eal/arm/include/rte_prefetch_64.h +5 -0
@@ -32,6 +32,11 @@ static inline void rte_prefetch_non_temporal(const volatile void *p) asmvolatile ("PRFM PLDL1STRM, [%0]" : :"r" (p)); } +static inline void rte_cldemote (const volatile void *p) +{ +RTE_SET_USED (p); +} + #ifdef __cplusplus }#endif
lib/librte_eal/include/generic/rte_prefetch.h +7 -0
@@ -51,4 +51,11 @@*/ static inline void rte_prefetch_non_temporal (const volatile void *p); +/** +* Demote a cache line into the last shared cache level. +* @param p +* Address to demote +*/ +static inline void rte_cldemote (const volatile void *p); +#endif /* _RTE_PREFETCH_H_ */
lib/librte_eal/ppc/include/rte_prefetch.h +5 -0
@@ -34,6 +34,11 @@ static inline void rte_prefetch_non_temporal(const volatile void *p)rte_prefetch0 (p); } +static inline void rte_cldemote (const volatile void *p) +{ +RTE_SET_USED (p); +} + #ifdef __cplusplus }#endif
lib/librte_eal/x86/include/rte_prefetch.h +9 -0
@@ -32,6 +32,15 @@ static inline void rte_prefetch_non_temporal(const volatile void *p) asmvolatile ("prefetchnta %[p]" : : [p]"m" (*(const volatile char *)p)); } +/* +* we're using raw byte codes for now as only the newest compiler +* versions support this instruction natively. +*/ +static inline void rte_cldemote (const volatile void *p) +{ + asmvolatile (".byte 0x0f, 0x1c, 0x06" ::"S" (p)); +} + #ifdef __cplusplus }#endif
Signature · 1 line
1.8.3.1
Quoted 9 lines · Omkar Maslekar
rte_cldemoteis similar to a prefetch hint - in reverse. cldemote(addr) enables software to hint to hardware that line is likely to be shared. Useful in core-to-core communications where cache-line is likely to be shared. ARM and PPC implementation is provided with NOP and can be added if any equivalent instructions could be used for implementation on those architectures.Signed-off-by Omkar Maslekar <[email protected]>---
Hi Omkar,
please see some review comments inline below.
Regards,
/Bruce
Quoted 13 lines
doc/guides/rel_notes/release_20_11.rst | 26 ++++---------------------- lib/librte_eal/arm/include/rte_prefetch_32.h | 5 +++++ lib/librte_eal/arm/include/rte_prefetch_64.h | 5 +++++ lib/librte_eal/include/generic/rte_prefetch.h | 7 +++++++ lib/librte_eal/ppc/include/rte_prefetch.h | 5 +++++ lib/librte_eal/x86/include/rte_prefetch.h | 9 +++++++++ 6 files changed, 35 insertions(+), 22 deletions(-)doc/guides/rel_notes/release_20_11.rst +0
-0
doc/guides/rel_notes/release_20_11.rst New Features · line 30
Quoted 5 lines
doc/guides/rel_notes/release_20_11.rst +1
-1@@ -27,29 +27,11 @@ New Features .. This section should contain new features added in this release. Sample format: - * **Add a title in the past tense with a full stop.** +Added new instruction CLDEMOTE in rte_prefetch.h.
You need to prefix this with the library it is in, in this case EAL. Also, since this is C code, you are adding a function, not an instruction.
Quoted 12 lines
doc/guides/rel_notes/release_20_11.rst +0
-11- Add a short 1-2 sentence description in the past tense. - The description should be enough to allow someone scanning - the release notes to understand the new feature. - - If the feature adds a lot of sub-features you can use a bullet list - like this: - - * Added feature foo to do something. - * Enhanced feature bar to do something else. - - Refer to the previous release notes for examples.
doc/guides/rel_notes/release_20_11.rst New Features · line 52
Quoted 10 lines
doc/guides/rel_notes/release_20_11.rst +0
-10- - Suggested order in release notes items: - * Core libs (EAL, mempool, ring, mbuf, buses) - * Device abstraction libs and PMDs - - ethdev (lib, PMDs) - - cryptodev (lib, PMDs) - - eventdev (lib, PMDs) - - etc - * Other libs - * Apps, Examples, Tools (if significant)
Don't remove these lines, they are all also part of the same comment as below where it says "Do not overwrite or remove it" :-)
doc/guides/rel_notes/release_20_11.rst New Features · line 35
Quoted 4 lines
doc/guides/rel_notes/release_20_11.rst +3
-0+ Added a hardware hint CLDEMOTE which is similar to prefetch in reverse. + CLDEMOTES moves the cache line to the last shared cache, where it expects + sharing to be efficient.
Reading the instruction description in the Intel instruction set reference, it says about moving the cache line to a more remote cache-line, rather than guaranteeing that it goes to the last level cache. Therefore, to ensure compatiblity with the current spec and make it more flexible to meet any other hardware implementations, I suggest changing the "last shared cache ..." to "more remote cache where sharing may be more efficient".
Quoted 39 lines
doc/guides/rel_notes/release_20_11.rst +0
-0This section is a comment. Do not overwrite or remove it. Also, make sure to start the actual text at the margin.lib/librte_eal/arm/include/rte_prefetch_32.h +5
-0@@ -33,6 +33,11 @@ static inline void rte_prefetch_non_temporal(const volatile void *p)rte_prefetch0 (p); } +static inline void rte_cldemote (const volatile void *p) +{ +RTE_SET_USED (p); +} + #ifdef __cplusplus }#endif lib/librte_eal/arm/include/rte_prefetch_64.h +5
-0@@ -32,6 +32,11 @@ static inline void rte_prefetch_non_temporal(const volatile void *p) asmvolatile ("PRFM PLDL1STRM, [%0]" : :"r" (p)); } +static inline void rte_cldemote (const volatile void *p) +{ +RTE_SET_USED (p); +} + #ifdef __cplusplus }#endif lib/librte_eal/include/generic/rte_prefetch.h +0
-0
lib/librte_eal/include/generic/rte_prefetch.h line 55
Quoted 5 lines
lib/librte_eal/include/generic/rte_prefetch.h +2
-0@@ -51,4 +51,11 @@*/ static inline void rte_prefetch_non_temporal (const volatile void *p); +/** +* Demote a cache line into the last shared cache level.
Same comment as above. Since this will make it into the official API doxygen documentation, I think a bit fuller of a description would be good also.
Hi Bruce,
Quoted 44 lines
-----Original Message-----
From: Bruce Richardson <[email protected]>
Sent: Thursday, September 10, 2020 1:55 AM
To: Maslekar, Omkar <[email protected]>
Cc: [email protected]; Loftus, Ciara <[email protected]>
Subject: Re: [PATCH] EAL: An addition of cache line demote (CLDEMOTE) inrte_prefetch.hQuoted 2 lines · Omkar Maslekar
rte_cldemoteis similar to a prefetch hint - in reverse. cldemote(addr) enables software to hint to hardware that line is likely to beshared.
Quoted 7 lines
Useful in core-to-core communications where cache-line is likely to be shared. ARM and PPC implementation is provided with NOP and can be added if any equivalent instructions could be used for implementation on those architectures.
Signed-off-by Omkar Maslekar <[email protected]>---
Hi Omkar,
please see some review comments inline below.
Regards,
/BruceQuoted 17 lines
doc/guides/rel_notes/release_20_11.rst | 26 ++++---------------------- lib/librte_eal/arm/include/rte_prefetch_32.h | 5 +++++ lib/librte_eal/arm/include/rte_prefetch_64.h | 5 +++++ lib/librte_eal/include/generic/rte_prefetch.h | 7 +++++++ lib/librte_eal/ppc/include/rte_prefetch.h | 5 +++++ lib/librte_eal/x86/include/rte_prefetch.h | 9 +++++++++ 6 files changed, 35 insertions(+), 22 deletions(-)doc/guides/rel_notes/release_20_11.rst +0
-0@@ -27,29 +27,11 @@ New Features .. This section should contain new features added in this release. Sample format:
Quoted 5 lines
doc/guides/rel_notes/release_20_11.rst New Features · line 30
Quoted 2 lines
doc/guides/rel_notes/release_20_11.rst +1
-1- * **Add a title in the past tense with a full stop.** +Added new instruction CLDEMOTE in rte_prefetch.h.You need to prefix this with the library it is in, in this case EAL. Also, since this is C code, you are adding a function, not an instruction.
[I will fix these release notes]
Quoted 18 lines
Quoted 18 lines
doc/guides/rel_notes/release_20_11.rst +0
-16- Add a short 1-2 sentence description in the past tense. - The description should be enough to allow someone scanning - the release notes to understand the new feature. - - If the feature adds a lot of sub-features you can use a bullet list - like this: - - * Added feature foo to do something. - * Enhanced feature bar to do something else. - - Refer to the previous release notes for examples. - - Suggested order in release notes items: - * Core libs (EAL, mempool, ring, mbuf, buses) - * Device abstraction libs and PMDs - - ethdev (lib, PMDs)
Quoted 8 lines
doc/guides/rel_notes/release_20_11.rst New Features · line 52
Quoted 5 lines
doc/guides/rel_notes/release_20_11.rst +0
-5- - cryptodev (lib, PMDs) - - eventdev (lib, PMDs) - - etc - * Other libs - * Apps, Examples, Tools (if significant)Don't remove these lines, they are all also part of the same comment as below where it says "Do not overwrite or remove it" :-)
[I will revert original comment and add appropriate]
Quoted 8 lines
doc/guides/rel_notes/release_20_11.rst New Features · line 31
Quoted 2 lines
doc/guides/rel_notes/release_20_11.rst +1
-0+ Added a hardware hint CLDEMOTE which is similar to prefetch inreverse.
doc/guides/rel_notes/release_20_11.rst New Features · line 32
Quoted 1 line
doc/guides/rel_notes/release_20_11.rst +1
-0+ CLDEMOTES moves the cache line to the last shared cache, where itexpects
doc/guides/rel_notes/release_20_11.rst New Features · line 35
Quoted 2 lines
doc/guides/rel_notes/release_20_11.rst +1
-0+ sharing to be efficient.
Quoted 6 lines
Reading the instruction description in the Intel instruction set reference, it says about moving the cache line to a more remote cache-line, rather than guaranteeing that it goes to the last level cache. Therefore, to ensure compatiblity with the current spec and make it more flexible to meet any other hardware implementations, I suggest changing the "last shared cache ..." to "more remote cache where sharing may be more efficient".
[I will make these changes as per suggestion and make sure it is in sync with software development manual ]
Quoted 45 lines
lib/librte_eal/arm/include/rte_prefetch_32.h static inline void rte_prefetch_non_temporal(const
Quoted 9 lines
doc/guides/rel_notes/release_20_11.rst +0
-0This section is a comment. Do not overwrite or remove it. Also, make sure to start the actual text at the margin.lib/librte_eal/arm/include/rte_prefetch_32.h +0
-0@@ -33,6 +33,11 @@ static inline void rte_prefetch_non_temporal(constvolatile void *p)
lib/librte_eal/arm/include/rte_prefetch_64.h static inline void rte_prefetch_non_temporal(const
Quoted 16 lines
lib/librte_eal/arm/include/rte_prefetch_32.h +4
-0rte_prefetch0 (p); } +static inline void rte_cldemote (const volatile void *p) { +RTE_SET_USED (p); +} + #ifdef __cplusplus }#endif lib/librte_eal/arm/include/rte_prefetch_64.h +0
-0@@ -32,6 +32,11 @@ static inline void rte_prefetch_non_temporal(constvolatile void *p)
Quoted 18 lines
lib/librte_eal/arm/include/rte_prefetch_64.h +4
-0asmvolatile ("PRFM PLDL1STRM, [%0]" : :"r" (p)); } +static inline void rte_cldemote (const volatile void *p) { +RTE_SET_USED (p); +} + #ifdef __cplusplus }#endif lib/librte_eal/include/generic/rte_prefetch.h +0
-0@@ -51,4 +51,11 @@*/ static inline void rte_prefetch_non_temporal (const volatile void *p);
Quoted 5 lines
lib/librte_eal/include/generic/rte_prefetch.h line 55
Quoted 2 lines
lib/librte_eal/include/generic/rte_prefetch.h +2
-0+/** +* Demote a cache line into the last shared cache level. Same comment as above. Since this will make it into the official API doxygen documentation, I think a bit fuller of a description would be good also.
[I will add more documentation]
Quoted 9 lines · Omkar Maslekar
rte_cldemoteis similar to a prefetch hint - in reverse. cldemote(addr) enables software to hint to hardware that line is likely to be shared. Useful in core-to-core communications where cache-line is likely to be shared. ARM and PPC implementation is provided with NOP and can be added if any equivalent instructions could be used for implementation on those architectures.Signed-off-by Omkar Maslekar <[email protected]>---
...
Quoted 6 lines
lib/librte_eal/ppc/include/rte_prefetch.h +0
-0@@ -34,6 +34,11 @@ static inline void rte_prefetch_non_temporal(const volatile void *p)rte_prefetch0 (p);
lib/librte_eal/ppc/include/rte_prefetch.h static inline void rte_prefetch_non_temporal(const volatile void *p) · line 44
Quoted 10 lines
lib/librte_eal/ppc/include/rte_prefetch.h +5
-0} +static inline void rte_cldemote (const volatile void *p) +{ +RTE_SET_USED (p); +} + #ifdef __cplusplus }#endif
For POWER there's an instruction defined in the ISA which is the most similar, miso (i.e. Make It So), but the instruction is interpreted as a NOP in the POWER8/POWER9 CPUs, so NOP is the right choice for PPC at this time.
Dave
PATCH v2 1/1 EAL: An addition of cache line demote (CLDEMOTE) in rte_prefetch.h
In reply to Omkar MaslekarWe are including this in rte_prefetch.h since it is the most closely related code location.rte_cldemte is similar to a prefetch hint -in reverse
Omkar Maslekar (1):
EAL: An addition of cache line demote (CLDEMOTE) in rte_prefetch.h
doc/guides/rel_notes/release_20_11.rst | 8 +++++++- lib/librte_eal/arm/include/rte_prefetch_32.h | 5 +++++ lib/librte_eal/arm/include/rte_prefetch_64.h | 5 +++++ lib/librte_eal/include/generic/rte_prefetch.h | 13 +++++++++++++ lib/librte_eal/ppc/include/rte_prefetch.h | 5 +++++ lib/librte_eal/x86/include/rte_prefetch.h | 9 +++++++++ 6 files changed, 44 insertions(+), 1 deletion(-)
Signature · 1 line
1.8.3.1
PATCH v2 1/1 EAL: An addition of cache line demote (CLDEMOTE) in rte_prefetch.h
rte_cldemote is similar to a prefetch hint - in reverse. cldemote(addr) enables software to hint to hardware that line is likely to be shared. Useful in core-to-core communications where cache-line is likely to be shared. ARM and PPC implementation is provided with NOP and can be added if any equivalent instructions could be used for implementation on those architectures.
---
v2: documentation updated
---
--- doc/guides/rel_notes/release_20_11.rst | 8 +++++++- lib/librte_eal/arm/include/rte_prefetch_32.h | 5 +++++ lib/librte_eal/arm/include/rte_prefetch_64.h | 5 +++++ lib/librte_eal/include/generic/rte_prefetch.h | 13 +++++++++++++ lib/librte_eal/ppc/include/rte_prefetch.h | 5 +++++ lib/librte_eal/x86/include/rte_prefetch.h | 9 +++++++++ 6 files changed, 44 insertions(+), 1 deletion(-)
doc/guides/rel_notes/release_20_11.rst +7 -1
@@ -26,7 +26,7 @@ New Features .. This section should contain new features added in this release. Sample format: - + * **Add a title in the past tense with a full stop.** Add a short 1-2 sentence description in the past tense.
@@ -55,6 +55,12 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= + EAL: Added new function rte_cldemote in rte_prefetch.h. + + Added a hardware hint CLDEMOTE, which is similar to prefetch in reverse. + CLDEMOTE moves the cache line to the more remote cache, where it expects + sharing to be efficient. Moving the cache line to a level more distant from + the processor helps to accelerate core-to-core communication. Removed Items -------------
lib/librte_eal/arm/include/rte_prefetch_32.h +5 -0
@@ -33,6 +33,11 @@ static inline void rte_prefetch_non_temporal(const volatile void *p)rte_prefetch0 (p); } +static inline void rte_cldemote (const volatile void *p) +{ +RTE_SET_USED (p); +} + #ifdef __cplusplus }#endif
lib/librte_eal/arm/include/rte_prefetch_64.h +5 -0
@@ -32,6 +32,11 @@ static inline void rte_prefetch_non_temporal(const volatile void *p) asmvolatile ("PRFM PLDL1STRM, [%0]" : :"r" (p)); } +static inline void rte_cldemote (const volatile void *p) +{ +RTE_SET_USED (p); +} + #ifdef __cplusplus }#endif
lib/librte_eal/include/generic/rte_prefetch.h +13 -0
@@ -51,4 +51,17 @@*/ static inline void rte_prefetch_non_temporal (const volatile void *p); +/** +* Demote a cache line to a more distant level of cache from the processor. +* +* CLDEMOTE hints to hardware to move (demote) a cache line from the closest to +* the processor to a level more distant from the processor. It is a hint and +* not guarantee. rte_cldemote is intended to speed up things at the producer, +* in the producer-consumer case. +* +* @param p +* Address to demote +*/ +static inline void rte_cldemote (const volatile void *p); +#endif /* _RTE_PREFETCH_H_ */
lib/librte_eal/ppc/include/rte_prefetch.h +5 -0
@@ -34,6 +34,11 @@ static inline void rte_prefetch_non_temporal(const volatile void *p)rte_prefetch0 (p); } +static inline void rte_cldemote (const volatile void *p) +{ +RTE_SET_USED (p); +} + #ifdef __cplusplus }#endif
lib/librte_eal/x86/include/rte_prefetch.h +9 -0
@@ -32,6 +32,15 @@ static inline void rte_prefetch_non_temporal(const volatile void *p) asmvolatile ("prefetchnta %[p]" : : [p]"m" (*(const volatile char *)p)); } +/* +* we're using raw byte codes for now as only the newest compiler +* versions support this instruction natively. +*/ +static inline void rte_cldemote (const volatile void *p) +{ + asmvolatile (".byte 0x0f, 0x1c, 0x06" ::"S" (p)); +} + #ifdef __cplusplus }#endif
Signature · 1 line
1.8.3.1
PATCH v3 1/1 EAL: An addition of cache line demote (CLDEMOTE) in rte_prefetch.h
In reply to Omkar MaslekarWe are including this in rte_prefetch.h since it is the most closely related code location.rte_cldemte is similar to a prefetch hint -in reverse
Omkar Maslekar (1):
EAL: An addition of cache line demote (CLDEMOTE) in rte_prefetch.h
doc/guides/rel_notes/release_20_11.rst | 6 ++++++ lib/librte_eal/arm/include/rte_prefetch_32.h | 5 +++++ lib/librte_eal/arm/include/rte_prefetch_64.h | 5 +++++ lib/librte_eal/include/generic/rte_prefetch.h | 13 +++++++++++++ lib/librte_eal/ppc/include/rte_prefetch.h | 5 +++++ lib/librte_eal/x86/include/rte_prefetch.h | 9 +++++++++ 6 files changed, 43 insertions(+)
Signature · 1 line
1.8.3.1
PATCH v3 1/1 EAL: An addition of cache line demote (CLDEMOTE) in rte_prefetch.h
rte_cldemote is similar to a prefetch hint - in reverse. cldemote(addr) enables software to hint to hardware that line is likely to be shared. Useful in core-to-core communications where cache-line is likely to be shared. ARM and PPC implementation is provided with NOP and can be added if any equivalent instructions could be used for implementation on those architectures.
---
v3: fixed warning regarding whitespace
*
v2: documentation updated
---
--- doc/guides/rel_notes/release_20_11.rst | 6 ++++++ lib/librte_eal/arm/include/rte_prefetch_32.h | 5 +++++ lib/librte_eal/arm/include/rte_prefetch_64.h | 5 +++++ lib/librte_eal/include/generic/rte_prefetch.h | 13 +++++++++++++ lib/librte_eal/ppc/include/rte_prefetch.h | 5 +++++ lib/librte_eal/x86/include/rte_prefetch.h | 9 +++++++++ 6 files changed, 43 insertions(+)
doc/guides/rel_notes/release_20_11.rst +6 -0
@@ -55,6 +55,12 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= + EAL: Added new function rte_cldemote in rte_prefetch.h. + + Added a hardware hint CLDEMOTE, which is similar to prefetch in reverse. + CLDEMOTE moves the cache line to the more remote cache, where it expects + sharing to be efficient. Moving the cache line to a level more distant from + the processor helps to accelerate core-to-core communication. Removed Items -------------
lib/librte_eal/arm/include/rte_prefetch_32.h +5 -0
@@ -33,6 +33,11 @@ static inline void rte_prefetch_non_temporal(const volatile void *p)rte_prefetch0 (p); } +static inline void rte_cldemote (const volatile void *p) +{ +RTE_SET_USED (p); +} + #ifdef __cplusplus }#endif
lib/librte_eal/arm/include/rte_prefetch_64.h +5 -0
@@ -32,6 +32,11 @@ static inline void rte_prefetch_non_temporal(const volatile void *p) asmvolatile ("PRFM PLDL1STRM, [%0]" : :"r" (p)); } +static inline void rte_cldemote (const volatile void *p) +{ +RTE_SET_USED (p); +} + #ifdef __cplusplus }#endif
lib/librte_eal/include/generic/rte_prefetch.h +13 -0
@@ -51,4 +51,17 @@*/ static inline void rte_prefetch_non_temporal (const volatile void *p); +/** +* Demote a cache line to a more distant level of cache from the processor. +* +* CLDEMOTE hints to hardware to move (demote) a cache line from the closest to +* the processor to a level more distant from the processor. It is a hint and +* not guarantee. rte_cldemote is intended to speed up things at the producer, +* in the producer-consumer case. +* +* @param p +* Address to demote +*/ +static inline void rte_cldemote (const volatile void *p); +#endif /* _RTE_PREFETCH_H_ */
lib/librte_eal/ppc/include/rte_prefetch.h +5 -0
@@ -34,6 +34,11 @@ static inline void rte_prefetch_non_temporal(const volatile void *p)rte_prefetch0 (p); } +static inline void rte_cldemote (const volatile void *p) +{ +RTE_SET_USED (p); +} + #ifdef __cplusplus }#endif
lib/librte_eal/x86/include/rte_prefetch.h +9 -0
@@ -32,6 +32,15 @@ static inline void rte_prefetch_non_temporal(const volatile void *p) asmvolatile ("prefetchnta %[p]" : : [p]"m" (*(const volatile char *)p)); } +/* +* we're using raw byte codes for now as only the newest compiler +* versions support this instruction natively. +*/ +static inline void rte_cldemote (const volatile void *p) +{ + asmvolatile (".byte 0x0f, 0x1c, 0x06" ::"S" (p)); +} + #ifdef __cplusplus }#endif
Signature · 1 line
1.8.3.1
PATCH v4 1/1 eal: add cache-line demote support
In reply to Omkar MaslekarWe are including this in rte_prefetch.h since it is the most closely related code location.rte_cldemte is similar to a prefetch hint -in reverse
Omkar Maslekar (1):
EAL: An addition of cache line demote (CLDEMOTE) in rte_prefetch.h
doc/guides/rel_notes/release_20_11.rst | 6 ++++++ lib/librte_eal/arm/include/rte_prefetch_32.h | 5 +++++ lib/librte_eal/arm/include/rte_prefetch_64.h | 5 +++++ lib/librte_eal/include/generic/rte_prefetch.h | 13 +++++++++++++ lib/librte_eal/ppc/include/rte_prefetch.h | 5 +++++ lib/librte_eal/x86/include/rte_prefetch.h | 9 +++++++++ 6 files changed, 43 insertions(+)
Signature · 1 line
1.8.3.1
PATCH v4 1/1 eal: add cache-line demote support
rte_cldemote is similar to a prefetch hint - in reverse. cldemote(addr) enables software to hint to hardware that line is likely to be shared. Useful in core-to-core communications where cache-line is likely to be shared. ARM and PPC implementation is provided with NOP and can be added if any equivalent instructions could be used for implementation on those architectures.
---
v4: updated bold text for title and fixed margin in release notes *
v3: fixed warning regarding whitespace
*
v2: documentation updated
---
--- doc/guides/rel_notes/release_20_11.rst | 6 ++++++ lib/librte_eal/arm/include/rte_prefetch_32.h | 5 +++++ lib/librte_eal/arm/include/rte_prefetch_64.h | 5 +++++ lib/librte_eal/include/generic/rte_prefetch.h | 13 +++++++++++++ lib/librte_eal/ppc/include/rte_prefetch.h | 5 +++++ lib/librte_eal/x86/include/rte_prefetch.h | 9 +++++++++ 6 files changed, 43 insertions(+)
doc/guides/rel_notes/release_20_11.rst +6 -0
@@ -55,6 +55,12 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added new function rte_cldemote in rte_prefetch.h.** + + Added a hardware hint CLDEMOTE, which is similar to prefetch in reverse. + CLDEMOTE moves the cache line to the more remote cache, where it expects + sharing to be efficient. Moving the cache line to a level more distant from + the processor helps to accelerate core-to-core communication. Removed Items -------------
lib/librte_eal/arm/include/rte_prefetch_32.h +5 -0
@@ -33,6 +33,11 @@ static inline void rte_prefetch_non_temporal(const volatile void *p)rte_prefetch0 (p); } +static inline void rte_cldemote (const volatile void *p) +{ +RTE_SET_USED (p); +} + #ifdef __cplusplus }#endif
lib/librte_eal/arm/include/rte_prefetch_64.h +5 -0
@@ -32,6 +32,11 @@ static inline void rte_prefetch_non_temporal(const volatile void *p) asmvolatile ("PRFM PLDL1STRM, [%0]" : :"r" (p)); } +static inline void rte_cldemote (const volatile void *p) +{ +RTE_SET_USED (p); +} + #ifdef __cplusplus }#endif
lib/librte_eal/include/generic/rte_prefetch.h +13 -0
@@ -51,4 +51,17 @@*/ static inline void rte_prefetch_non_temporal (const volatile void *p); +/** +* Demote a cache line to a more distant level of cache from the processor. +* +* CLDEMOTE hints to hardware to move (demote) a cache line from the closest to +* the processor to a level more distant from the processor. It is a hint and +* not guarantee. rte_cldemote is intended to speed up things at the producer, +* in the producer-consumer case. +* +* @param p +* Address to demote +*/ +static inline void rte_cldemote (const volatile void *p); +#endif /* _RTE_PREFETCH_H_ */
lib/librte_eal/ppc/include/rte_prefetch.h +5 -0
@@ -34,6 +34,11 @@ static inline void rte_prefetch_non_temporal(const volatile void *p)rte_prefetch0 (p); } +static inline void rte_cldemote (const volatile void *p) +{ +RTE_SET_USED (p); +} + #ifdef __cplusplus }#endif
lib/librte_eal/x86/include/rte_prefetch.h +9 -0
@@ -32,6 +32,15 @@ static inline void rte_prefetch_non_temporal(const volatile void *p) asmvolatile ("prefetchnta %[p]" : : [p]"m" (*(const volatile char *)p)); } +/* +* we're using raw byte codes for now as only the newest compiler +* versions support this instruction natively. +*/ +static inline void rte_cldemote (const volatile void *p) +{ + asmvolatile (".byte 0x0f, 0x1c, 0x06" ::"S" (p)); +} + #ifdef __cplusplus }#endif
Signature · 1 line
1.8.3.1
Re: [dpdk-dev] [PATCH v4] eal: add cache-line demote support
Quoted 9 lines · Omkar Maslekar
rte_cldemoteis similar to a prefetch hint - in reverse. cldemote(addr) enables software to hint to hardware that line is likely to be shared. Useful in core-to-core communications where cache-line is likely to be shared. ARM and PPC implementation is provided with NOP and can be added if any equivalent instructions could be used for implementation on those architectures.Signed-off-by Omkar Maslekar <[email protected]>
Few minor suggestions below. With those fixed, feel free to add my ack to future versions of this patch.
Quoted 21 lines
---
v4: updated bold text for title and fixed margin in release notes *
v3: fixed warning regarding whitespace
*
v2: documentation updated
------ doc/guides/rel_notes/release_20_11.rst | 6 ++++++ lib/librte_eal/arm/include/rte_prefetch_32.h | 5 +++++ lib/librte_eal/arm/include/rte_prefetch_64.h | 5 +++++ lib/librte_eal/include/generic/rte_prefetch.h | 13 +++++++++++++ lib/librte_eal/ppc/include/rte_prefetch.h | 5 +++++ lib/librte_eal/x86/include/rte_prefetch.h | 9 +++++++++ 6 files changed, 43 insertions(+)doc/guides/rel_notes/release_20_11.rst +0
-0
doc/guides/rel_notes/release_20_11.rst New Features · line 64
Quoted 10 lines
doc/guides/rel_notes/release_20_11.rst +6
-0@@ -55,6 +55,12 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added new function rte_cldemote in rte_prefetch.h.** + + Added a hardware hint CLDEMOTE, which is similar to prefetch in reverse. + CLDEMOTE moves the cache line to the more remote cache, where it expects + sharing to be efficient. Moving the cache line to a level more distant from + the processor helps to accelerate core-to-core communication.
I think you need two blank lines between sections here, not just one.
Quoted 40 lines
doc/guides/rel_notes/release_20_11.rst +0
-0Removed Items -------------lib/librte_eal/arm/include/rte_prefetch_32.h +5
-0@@ -33,6 +33,11 @@ static inline void rte_prefetch_non_temporal(const volatile void *p)rte_prefetch0 (p); } +static inline void rte_cldemote (const volatile void *p) +{ +RTE_SET_USED (p); +} + #ifdef __cplusplus }#endif lib/librte_eal/arm/include/rte_prefetch_64.h +5
-0@@ -32,6 +32,11 @@ static inline void rte_prefetch_non_temporal(const volatile void *p) asmvolatile ("PRFM PLDL1STRM, [%0]" : :"r" (p)); } +static inline void rte_cldemote (const volatile void *p) +{ +RTE_SET_USED (p); +} + #ifdef __cplusplus }#endif lib/librte_eal/include/generic/rte_prefetch.h +0
-0@@ -51,4 +51,17 @@*/
lib/librte_eal/include/generic/rte_prefetch.h line 61
Quoted 10 lines
lib/librte_eal/include/generic/rte_prefetch.h +8
-0static inline void rte_prefetch_non_temporal (const volatile void *p); +/** +* Demote a cache line to a more distant level of cache from the processor. +* +* CLDEMOTE hints to hardware to move (demote) a cache line from the closest to +* the processor to a level more distant from the processor. It is a hint and +* not guarantee. rte_cldemote is intended to speed up things at the producer, +* in the producer-consumer case. +*
Two thoughts here:
1. Is it not more the consumer who benefits more since they are the ones receiving the demoted value, while the producer pays a higher cost since they have to demote the value on send?
2. Rather than talking about producer consumer case specifically, I think it would be good to replace the last sentence with what you have in the cover letter about it being for sharing, and to indicate that a line may be accessed by a different core in the future.
Quoted 45 lines
lib/librte_eal/include/generic/rte_prefetch.h +5
-0+* @param p +* Address to demote +*/ +static inline void rte_cldemote (const volatile void *p); +#endif /* _RTE_PREFETCH_H_ */ lib/librte_eal/ppc/include/rte_prefetch.h +5
-0@@ -34,6 +34,11 @@ static inline void rte_prefetch_non_temporal(const volatile void *p)rte_prefetch0 (p); } +static inline void rte_cldemote (const volatile void *p) +{ +RTE_SET_USED (p); +} + #ifdef __cplusplus }#endif lib/librte_eal/x86/include/rte_prefetch.h +9
-0@@ -32,6 +32,15 @@ static inline void rte_prefetch_non_temporal(const volatile void *p) asmvolatile ("prefetchnta %[p]" : : [p]"m" (*(const volatile char *)p)); } +/* +* we're using raw byte codes for now as only the newest compiler +* versions support this instruction natively. +*/ +static inline void rte_cldemote (const volatile void *p) +{ + asmvolatile (".byte 0x0f, 0x1c, 0x06" ::"S" (p)); +} + #ifdef __cplusplus }#endif Signature · 1 line
1.8.3.1
Re: [dpdk-dev] [PATCH v4] eal: add cache-line demote support
Hi Bruce,
My comments are inline
Quoted 52 lines
-----Original Message-----
From: Bruce Richardson <[email protected]>
Sent: Tuesday, September 22, 2020 1:28 AM
To: Maslekar, Omkar <[email protected]>
Cc: [email protected]; Loftus, Ciara <[email protected]>
Subject: Re: [PATCH v4] eal: add cache-line demote supportQuoted 2 lines · Omkar Maslekar
rte_cldemoteis similar to a prefetch hint - in reverse. cldemote(addr) enables software to hint to hardware that line is likely to beshared.
Quoted 7 lines
Useful in core-to-core communications where cache-line is likely to be shared. ARM and PPC implementation is provided with NOP and can be added if any equivalent instructions could be used for implementation on those architectures.
Signed-off-by Omkar Maslekar <[email protected]>Few minor suggestions below. With those fixed, feel free to add my ack to future versions of this patch.
Acked-by Bruce Richardson <[email protected]>Quoted 22 lines
---
v4: updated bold text for title and fixed margin in release notes *
v3: fixed warning regarding whitespace
*
v2: documentation updated
------ doc/guides/rel_notes/release_20_11.rst | 6 ++++++ lib/librte_eal/arm/include/rte_prefetch_32.h | 5 +++++ lib/librte_eal/arm/include/rte_prefetch_64.h | 5 +++++ lib/librte_eal/include/generic/rte_prefetch.h | 13 +++++++++++++ lib/librte_eal/ppc/include/rte_prefetch.h | 5 +++++ lib/librte_eal/x86/include/rte_prefetch.h | 9 +++++++++ 6 files changed, 43 insertions(+)doc/guides/rel_notes/release_20_11.rst +0
-0doc/guides/rel_notes/release_20_11.rst New Features · line 60
Quoted 6 lines
doc/guides/rel_notes/release_20_11.rst +3
-0@@ -55,6 +55,12 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added new function rte_cldemote in rte_prefetch.h.** + + Added a hardware hint CLDEMOTE, which is similar to prefetch inreverse.
Quoted 7 lines
doc/guides/rel_notes/release_20_11.rst New Features · line 63
Quoted 3 lines
doc/guides/rel_notes/release_20_11.rst +3
-0+ CLDEMOTE moves the cache line to the more remote cache, where it + expects sharing to be efficient. Moving the cache line to a level + more distant from the processor helps to accelerate core-to-corecommunication.
Quoted 1 line
I think you need two blank lines between sections here, not just one.
[om] you are right, I will fix in v5.
Quoted 48 lines
lib/librte_eal/arm/include/rte_prefetch_32.h static inline void rte_prefetch_non_temporal(const
Quoted 9 lines
Removed Items
-------------lib/librte_eal/arm/include/rte_prefetch_32.h +0
-0@@ -33,6 +33,11 @@ static inline void rte_prefetch_non_temporal(constvolatile void *p)
lib/librte_eal/arm/include/rte_prefetch_64.h static inline void rte_prefetch_non_temporal(const
Quoted 16 lines
lib/librte_eal/arm/include/rte_prefetch_32.h +4
-0rte_prefetch0 (p); } +static inline void rte_cldemote (const volatile void *p) { +RTE_SET_USED (p); +} + #ifdef __cplusplus }#endif lib/librte_eal/arm/include/rte_prefetch_64.h +0
-0@@ -32,6 +32,11 @@ static inline void rte_prefetch_non_temporal(constvolatile void *p)
Quoted 15 lines
lib/librte_eal/arm/include/rte_prefetch_64.h +4
-0asmvolatile ("PRFM PLDL1STRM, [%0]" : :"r" (p)); } +static inline void rte_cldemote (const volatile void *p) { +RTE_SET_USED (p); +} + #ifdef __cplusplus }#endif lib/librte_eal/include/generic/rte_prefetch.h +0
-0lib/librte_eal/include/generic/rte_prefetch.h line 55
Quoted 5 lines
lib/librte_eal/include/generic/rte_prefetch.h +2
-0@@ -51,4 +51,17 @@*/ static inline void rte_prefetch_non_temporal (const volatile void *p); +/** +* Demote a cache line to a more distant level of cache from the processor.
Quoted 14 lines
lib/librte_eal/include/generic/rte_prefetch.h line 64
Quoted 9 lines
lib/librte_eal/include/generic/rte_prefetch.h +9
-0+* +* CLDEMOTE hints to hardware to move (demote) a cache line from the +closest to +* the processor to a level more distant from the processor. It is a +hint and +* not guarantee. rte_cldemote is intended to speed up things at the +producer, +* in the producer-consumer case. +* Two thoughts here:
1. Is it not more the consumer who benefits more since they are the ones receiving the demoted value, while the producer pays a higher cost since they have to demote the value on send?
[OM] CLDEMOTE benefits the consumer. My statement "speed up things at the producer" indicate proximity where the distance is reduced. But I will make it simple and more readable.
Quoted 4 lines
2. Rather than talking about producer consumer case specifically, I think it would be good to replace the last sentence with what you have in the cover letter about it being for sharing, and to indicate that a line may be accessed by a different core in the future.
[OM] Good point, there could be many other cores that can benefit instead of just a single consumer. I will update this.
Quoted 47 lines
lib/librte_eal/ppc/include/rte_prefetch.h static inline void rte_prefetch_non_temporal(const
Quoted 13 lines
lib/librte_eal/include/generic/rte_prefetch.h +5
-0+* @param p +* Address to demote +*/ +static inline void rte_cldemote (const volatile void *p); +#endif /* _RTE_PREFETCH_H_ */ lib/librte_eal/ppc/include/rte_prefetch.h +0
-0@@ -34,6 +34,11 @@ static inline void rte_prefetch_non_temporal(constvolatile void *p)
lib/librte_eal/x86/include/rte_prefetch.h static inline void rte_prefetch_non_temporal(const
Quoted 16 lines
lib/librte_eal/ppc/include/rte_prefetch.h +4
-0rte_prefetch0 (p); } +static inline void rte_cldemote (const volatile void *p) { +RTE_SET_USED (p); +} + #ifdef __cplusplus }#endif lib/librte_eal/x86/include/rte_prefetch.h +0
-0@@ -32,6 +32,15 @@ static inline void rte_prefetch_non_temporal(constvolatile void *p)
Quoted 16 lines
lib/librte_eal/x86/include/rte_prefetch.h +7
-1asmvolatile ("prefetchnta %[p]" : : [p]"m" (*(const volatile char *)p)); } +/* +* we're using raw byte codes for now as only the newest compiler +* versions support this instruction natively. +*/ +static inline void rte_cldemote (const volatile void *p) { + asmvolatile (".byte 0x0f, 0x1c, 0x06" ::"S" (p)); } + #ifdef __cplusplus }#endif --1.8.3.1
PATCH v5 1/1 eal: add cache-line demote support
In reply to Omkar MaslekarWe are including this in rte_prefetch.h since it is the most closely related code location.rte_cldemte is similar to a prefetch hint -in reverse
Omkar Maslekar (1):
eal: add cache-line demote support
doc/guides/rel_notes/release_20_11.rst | 7 +++++++ lib/librte_eal/arm/include/rte_prefetch_32.h | 5 +++++ lib/librte_eal/arm/include/rte_prefetch_64.h | 5 +++++ lib/librte_eal/include/generic/rte_prefetch.h | 14 ++++++++++++++ lib/librte_eal/ppc/include/rte_prefetch.h | 5 +++++ lib/librte_eal/x86/include/rte_prefetch.h | 9 +++++++++ 6 files changed, 45 insertions(+)
Signature · 1 line
1.8.3.1
PATCH v5 1/1 eal: add cache-line demote support
rte_cldemote is similar to a prefetch hint - in reverse. cldemote(addr) enables software to hint to hardware that line is likely to be shared. Useful in core-to-core communications where cache-line is likely to be shared. ARM and PPC implementation is provided with NOP and can be added if any equivalent instructions could be used for implementation on those architectures.
---
v5: documentation updated
fixed formatting issue in release notes
added Acked-by: Bruce Richardson <[email protected]>
*
v4: updated bold text for title and fixed margin in release notes *
v3: fixed warning regarding whitespace
*
v2: documentation updated
---
--- doc/guides/rel_notes/release_20_11.rst | 7 +++++++ lib/librte_eal/arm/include/rte_prefetch_32.h | 5 +++++ lib/librte_eal/arm/include/rte_prefetch_64.h | 5 +++++ lib/librte_eal/include/generic/rte_prefetch.h | 14 ++++++++++++++ lib/librte_eal/ppc/include/rte_prefetch.h | 5 +++++ lib/librte_eal/x86/include/rte_prefetch.h | 9 +++++++++ 6 files changed, 45 insertions(+)
doc/guides/rel_notes/release_20_11.rst +7 -0
@@ -55,6 +55,13 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added new function rte_cldemote in rte_prefetch.h.** + + Added a hardware hint CLDEMOTE, which is similar to prefetch in reverse. + CLDEMOTE moves the cache line to the more remote cache, where it expects + sharing to be efficient. Moving the cache line to a level more distant from + the processor helps to accelerate core-to-core communication. + Removed Items -------------
lib/librte_eal/arm/include/rte_prefetch_32.h +5 -0
@@ -33,6 +33,11 @@ static inline void rte_prefetch_non_temporal(const volatile void *p)rte_prefetch0 (p); } +static inline void rte_cldemote (const volatile void *p) +{ +RTE_SET_USED (p); +} + #ifdef __cplusplus }#endif
lib/librte_eal/arm/include/rte_prefetch_64.h +5 -0
@@ -32,6 +32,11 @@ static inline void rte_prefetch_non_temporal(const volatile void *p) asmvolatile ("PRFM PLDL1STRM, [%0]" : :"r" (p)); } +static inline void rte_cldemote (const volatile void *p) +{ +RTE_SET_USED (p); +} + #ifdef __cplusplus }#endif
lib/librte_eal/include/generic/rte_prefetch.h +14 -0
@@ -51,4 +51,18 @@*/ static inline void rte_prefetch_non_temporal (const volatile void *p); +/** +* Demote a cache line to a more distant level of cache from the processor. +* +* CLDEMOTE hints to hardware to move (demote) a cache line from the closest to +* the processor to a level more distant from the processor. It is a hint and +* not guarantee. rte_cldemote is intended to move the cache line to the more +* remote cache, where it expects sharing to be efficient and to indicate that a +* line may be accessed by a different core in the future. +* +* @param p +* Address to demote +*/ +static inline void rte_cldemote (const volatile void *p); +#endif /* _RTE_PREFETCH_H_ */
lib/librte_eal/ppc/include/rte_prefetch.h +5 -0
@@ -34,6 +34,11 @@ static inline void rte_prefetch_non_temporal(const volatile void *p)rte_prefetch0 (p); } +static inline void rte_cldemote (const volatile void *p) +{ +RTE_SET_USED (p); +} + #ifdef __cplusplus }#endif
lib/librte_eal/x86/include/rte_prefetch.h +9 -0
@@ -32,6 +32,15 @@ static inline void rte_prefetch_non_temporal(const volatile void *p) asmvolatile ("prefetchnta %[p]" : : [p]"m" (*(const volatile char *)p)); } +/* +* we're using raw byte codes for now as only the newest compiler +* versions support this instruction natively. +*/ +static inline void rte_cldemote (const volatile void *p) +{ + asmvolatile (".byte 0x0f, 0x1c, 0x06" ::"S" (p)); +} + #ifdef __cplusplus }#endif
Signature · 1 line
1.8.3.1
Re: [dpdk-dev] [PATCH v5] eal: add cache-line demote support
Quoted 10 lines · Omkar Maslekar
rte_cldemoteis similar to a prefetch hint - in reverse. cldemote(addr) enables software to hint to hardware that line is likely to be shared. Useful in core-to-core communications where cache-line is likely to be shared. ARM and PPC implementation is provided with NOP and can be added if any equivalent instructions could be used for implementation on those architectures.Signed-off-by Omkar Maslekar <[email protected]>Acked-by Bruce Richardson <[email protected]>
I find this "rte_cldemote" name too close to the Intel instruction, but I can see no complaint from other arch maintainers, so I guess everyone is happy with it.
In any case, this is a new API, so it should be marked experimental.
As for unit tests, not sure there is much to do, maybe rename test_prefetch.c and call this new API too, wdyt?
Signature · 1 line
David Marchand
Re: [dpdk-dev] [PATCH v5] eal: add cache-line demote support
Quoted 9 lines · David Marchand
Quoted 8 lines · Omkar Maslekar
rte_cldemoteis similar to a prefetch hint - in reverse. cldemote(addr) enables software to hint to hardware that line is likely to be shared. Useful in core-to-core communications where cache-line is likely to be shared. ARM and PPC implementation is provided with NOP and can be added if any equivalent instructions could be used for implementation on those architectures.
Quoted 6 lines
Quoted 2 lines
Signed-off-by Omkar Maslekar <[email protected]>Acked-by Bruce Richardson <[email protected]>I find this "
rte_cldemote" name too close to the Intel instruction, but I can see no complaint from other arch maintainers, so I guess everyone is happy with it.
It is very close, alright - though the name too does fairly well convey the likely actual done by the instruction.. Is there a suggestion for a better, more generic name.
Quoted 2 lines
In any case, this is a new API, so it should be marked experimental.
Agreed.
Quoted 3 lines
As for unit tests, not sure there is much to do, maybe rename
test_prefetch.cand call this new API too, wdyt?
I'm not sure how much value this would provide, but it can be done.
Re: [dpdk-dev] [PATCH v5] eal: add cache-line demote support
Quoted 14 lines · Bruce Richardson
Quoted 12 lines · David Marchand
Quoted 10 lines · Omkar Maslekar
rte_cldemoteis similar to a prefetch hint - in reverse. cldemote(addr) enables software to hint to hardware that line is likely to be shared. Useful in core-to-core communications where cache-line is likely to be shared. ARM and PPC implementation is provided with NOP and can be added if any equivalent instructions could be used for implementation on those architectures.Signed-off-by Omkar Maslekar <[email protected]>Acked-by Bruce Richardson <[email protected]>
Quoted 7 lines
Quoted 3 lines
I find this "
rte_cldemote" name too close to the Intel instruction, but I can see no complaint from other arch maintainers, so I guess everyone is happy with it.It is very close, alright - though the name too does fairly well convey the likely actual done by the instruction.. Is there a suggestion for a better, more generic name.
I don't have a better suggestion.
The prefetch API has some hints on the level of cache to put data in. For this new API, we have no indication, would it make sense?
Is this available on all Intel CPUs supported with DPDK? No cpuflag check needed?
Quoted 9 lines
Quoted 3 lines
In any case, this is a new API, so it should be marked experimental.
Agreed.
Quoted 3 lines
As for unit tests, not sure there is much to do, maybe rename
test_prefetch.cand call this new API too, wdyt?I'm not sure how much value this would provide, but it can be done.
As much as the existing test, checking we can call this API. If you think it is not worth it, we can drop the prefetch ut code.
Signature · 1 line
David Marchand
Re: [dpdk-dev] [PATCH v5] eal: add cache-line demote support
In reply to Omkar MaslekarQuoted 70 lines · Omkar Maslekar
rte_cldemoteis similar to a prefetch hint - in reverse. cldemote(addr) enables software to hint to hardware that line is likely to be shared. Useful in core-to-core communications where cache-line is likely to be shared. ARM and PPC implementation is provided with NOP and can be added if any equivalent instructions could be used for implementation on those architectures.Signed-off-by Omkar Maslekar <[email protected]>Acked-by Bruce Richardson <[email protected]>---
v5: documentation updated
fixed formatting issue in release notes
added Acked-by: Bruce Richardson <[email protected]>
*
v4: updated bold text for title and fixed margin in release notes *
v3: fixed warning regarding whitespace
*
v2: documentation updated
------ doc/guides/rel_notes/release_20_11.rst | 7 +++++++ lib/librte_eal/arm/include/rte_prefetch_32.h | 5 +++++ lib/librte_eal/arm/include/rte_prefetch_64.h | 5 +++++ lib/librte_eal/include/generic/rte_prefetch.h | 14 ++++++++++++++ lib/librte_eal/ppc/include/rte_prefetch.h | 5 +++++ lib/librte_eal/x86/include/rte_prefetch.h | 9 +++++++++ 6 files changed, 45 insertions(+)doc/guides/rel_notes/release_20_11.rst +7
-0@@ -55,6 +55,13 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added new function rte_cldemote in rte_prefetch.h.** + + Added a hardware hint CLDEMOTE, which is similar to prefetch in reverse. + CLDEMOTE moves the cache line to the more remote cache, where it expects + sharing to be efficient. Moving the cache line to a level more distant from + the processor helps to accelerate core-to-core communication. + Removed Items -------------lib/librte_eal/arm/include/rte_prefetch_32.h +5
-0@@ -33,6 +33,11 @@ static inline void rte_prefetch_non_temporal(const volatile void *p)rte_prefetch0 (p); } +static inline void rte_cldemote (const volatile void *p) +{ +RTE_SET_USED (p); +} + #ifdef __cplusplus }#endif lib/librte_eal/arm/include/rte_prefetch_64.h +0
-0
lib/librte_eal/arm/include/rte_prefetch_64.h static inline void rte_prefetch_non_temporal(const volatile void *p) · line 38
Quoted 7 lines
lib/librte_eal/arm/include/rte_prefetch_64.h +4
-0@@ -32,6 +32,11 @@ static inline void rte_prefetch_non_temporal(const volatile void *p) asmvolatile ("PRFM PLDL1STRM, [%0]" : :"r" (p)); } +static inline void rte_cldemote (const volatile void *p) +{ +RTE_SET_USED (p); +}
ARM64 does not have this support so NOP is fine for this.
Quoted 66 lines
lib/librte_eal/arm/include/rte_prefetch_64.h +1
-0+ #ifdef __cplusplus }#endif lib/librte_eal/include/generic/rte_prefetch.h +14
-0@@ -51,4 +51,18 @@*/ static inline void rte_prefetch_non_temporal (const volatile void *p); +/** +* Demote a cache line to a more distant level of cache from the processor. +* +* CLDEMOTE hints to hardware to move (demote) a cache line from the closest to +* the processor to a level more distant from the processor. It is a hint and +* not guarantee. rte_cldemote is intended to move the cache line to the more +* remote cache, where it expects sharing to be efficient and to indicate that a +* line may be accessed by a different core in the future. +* +* @param p +* Address to demote +*/ +static inline void rte_cldemote (const volatile void *p); +#endif /* _RTE_PREFETCH_H_ */ lib/librte_eal/ppc/include/rte_prefetch.h +5
-0@@ -34,6 +34,11 @@ static inline void rte_prefetch_non_temporal(const volatile void *p)rte_prefetch0 (p); } +static inline void rte_cldemote (const volatile void *p) +{ +RTE_SET_USED (p); +} + #ifdef __cplusplus }#endif lib/librte_eal/x86/include/rte_prefetch.h +9
-1@@ -32,6 +32,15 @@ static inline void rte_prefetch_non_temporal(const volatile void *p) asmvolatile ("prefetchnta %[p]" : : [p]"m" (*(const volatile char *)p)); } +/* +* we're using raw byte codes for now as only the newest compiler +* versions support this instruction natively. +*/ +static inline void rte_cldemote (const volatile void *p) +{ + asmvolatile (".byte 0x0f, 0x1c, 0x06" ::"S" (p)); +} + #ifdef __cplusplus }#endif --1.8.3.1
PATCH v6 1/1 eal: add cache-line demote support
In reply to Omkar MaslekarWe are including this in rte_prefetch.h since it is the most closely related code location.rte_cldemte is similar to a prefetch hint -in reverse
Omkar Maslekar (1):
eal: add cache-line demote support
app/test/test_prefetch.c | 4 ++++ doc/guides/rel_notes/release_20_11.rst | 7 +++++++ lib/librte_eal/arm/include/rte_prefetch_32.h | 8 ++++++++ lib/librte_eal/arm/include/rte_prefetch_64.h | 8 ++++++++ lib/librte_eal/include/generic/rte_prefetch.h | 16 ++++++++++++++++ lib/librte_eal/ppc/include/rte_prefetch.h | 8 ++++++++ lib/librte_eal/x86/include/rte_prefetch.h | 12 ++++++++++++ 7 files changed, 63 insertions(+)
Signature · 1 line
1.8.3.1
PATCH v6 1/1 eal: add cache-line demote support
rte_cldemote is similar to a prefetch hint - in reverse. cldemote(addr) enables software to hint to hardware that line is likely to be shared. Useful in core-to-core communications where cache-line is likely to be shared. ARM and PPC implementation is provided with NOP and can be added if any equivalent instructions could be used for implementation on those architectures.
---
v6: marked rte_cldemote as experimental
added rte_cldemote call in existing app/test_prefetch.c
v5: documentation updated
fixed formatting issue in release notes
added Acked-by: Bruce Richardson <[email protected]>
*
v4: updated bold text for title and fixed margin in release notes *
v3: fixed warning regarding whitespace
*
v2: documentation updated
---
--- app/test/test_prefetch.c | 4 ++++ doc/guides/rel_notes/release_20_11.rst | 7 +++++++ lib/librte_eal/arm/include/rte_prefetch_32.h | 8 ++++++++ lib/librte_eal/arm/include/rte_prefetch_64.h | 8 ++++++++ lib/librte_eal/include/generic/rte_prefetch.h | 16 ++++++++++++++++ lib/librte_eal/ppc/include/rte_prefetch.h | 8 ++++++++ lib/librte_eal/x86/include/rte_prefetch.h | 12 ++++++++++++ 7 files changed, 63 insertions(+)
app/test/test_prefetch.c +4 -0
@@ -26,7 +26,11 @@rte_prefetch1 (&a);rte_prefetch2 (&a); +/* test for marking a line as shared to test cldemote functionality */ +rte_cldemote (&a); +return 0 ; } +REGISTER_TEST_COMMAND (prefetch_autotest, test_prefetch);
doc/guides/rel_notes/release_20_11.rst +7 -0
@@ -55,6 +55,13 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added new function rte_cldemote in rte_prefetch.h.** + + Added a hardware hint CLDEMOTE, which is similar to prefetch in reverse. + CLDEMOTE moves the cache line to the more remote cache, where it expects + sharing to be efficient. Moving the cache line to a level more distant from + the processor helps to accelerate core-to-core communication. + Removed Items -------------
lib/librte_eal/arm/include/rte_prefetch_32.h +8 -0
@@ -10,6 +10,7 @@#endif #include <rte_common.h> +#include <rte_compat.h> #include "generic/rte_prefetch.h" static inline void rte_prefetch0 (const volatile void *p)
@@ -33,6 +34,13 @@ static inline void rte_prefetch_non_temporal(const volatile void *p)rte_prefetch0 (p); } +static inline void +__rte_experimental +rte_cldemote (const volatile void *p) +{ +RTE_SET_USED (p); +} + #ifdef __cplusplus }#endif
lib/librte_eal/arm/include/rte_prefetch_64.h +8 -0
@@ -10,6 +10,7 @@#endif #include <rte_common.h> +#include <rte_compat.h> #include "generic/rte_prefetch.h" static inline void rte_prefetch0 (const volatile void *p)
@@ -32,6 +33,13 @@ static inline void rte_prefetch_non_temporal(const volatile void *p) asmvolatile ("PRFM PLDL1STRM, [%0]" : :"r" (p)); } +static inline void +__rte_experimental +rte_cldemote (const volatile void *p) +{ +RTE_SET_USED (p); +} + #ifdef __cplusplus }#endif
lib/librte_eal/include/generic/rte_prefetch.h +16 -0
@@ -51,4 +51,20 @@*/ static inline void rte_prefetch_non_temporal (const volatile void *p); +/** +* Demote a cache line to a more distant level of cache from the processor. +* +* CLDEMOTE hints to hardware to move (demote) a cache line from the closest to +* the processor to a level more distant from the processor. It is a hint and +* not guarantee. rte_cldemote is intended to move the cache line to the more +* remote cache, where it expects sharing to be efficient and to indicate that a +* line may be accessed by a different core in the future. +* +* @param p +* Address to demote +*/ +static inline void +__rte_experimental +rte_cldemote (const volatile void *p); +#endif /* _RTE_PREFETCH_H_ */
lib/librte_eal/ppc/include/rte_prefetch.h +8 -0
@@ -11,6 +11,7 @@#endif #include <rte_common.h> +#include <rte_compat.h> #include "generic/rte_prefetch.h" static inline void rte_prefetch0 (const volatile void *p)
@@ -34,6 +35,13 @@ static inline void rte_prefetch_non_temporal(const volatile void *p)rte_prefetch0 (p); } +static inline void +__rte_experimental +rte_cldemote (const volatile void *p) +{ +RTE_SET_USED (p); +} + #ifdef __cplusplus }#endif
lib/librte_eal/x86/include/rte_prefetch.h +12 -0
@@ -10,6 +10,7 @@#endif #include <rte_common.h> +#include <rte_compat.h> #include "generic/rte_prefetch.h" static inline void rte_prefetch0 (const volatile void *p)
@@ -32,6 +33,17 @@ static inline void rte_prefetch_non_temporal(const volatile void *p) asmvolatile ("prefetchnta %[p]" : : [p]"m" (*(const volatile char *)p)); } +/* +* we're using raw byte codes for now as only the newest compiler +* versions support this instruction natively. +*/ +static inline void +__rte_experimental +rte_cldemote (const volatile void *p) +{ + asmvolatile (".byte 0x0f, 0x1c, 0x06" ::"S" (p)); +} + #ifdef __cplusplus }#endif
Signature · 1 line
1.8.3.1
Re: [dpdk-dev] [PATCH v6] eal: add cache-line demote support
Quoted 33 lines · Omkar Maslekar
rte_cldemoteis similar to a prefetch hint - in reverse. cldemote(addr) enables software to hint to hardware that line is likely to be shared. Useful in core-to-core communications where cache-line is likely to be shared. ARM and PPC implementation is provided with NOP and can be added if any equivalent instructions could be used for implementation on those architectures.Signed-off-by Omkar Maslekar <[email protected]>Acked-by Bruce Richardson <[email protected]>---
v6: markedrte_cldemoteas experimental
addedrte_cldemotecall in existingapp/test_prefetch.cv5: documentation updated
fixed formatting issue in release notes
added Acked-by: Bruce Richardson <[email protected]>
*
v4: updated bold text for title and fixed margin in release notes *
v3: fixed warning regarding whitespace
*
v2: documentation updated
------ app/test/test_prefetch.c | 4 ++++ doc/guides/rel_notes/release_20_11.rst | 7 +++++++ lib/librte_eal/arm/include/rte_prefetch_32.h | 8 ++++++++ lib/librte_eal/arm/include/rte_prefetch_64.h | 8 ++++++++ lib/librte_eal/include/generic/rte_prefetch.h | 16 ++++++++++++++++ lib/librte_eal/ppc/include/rte_prefetch.h | 8 ++++++++ lib/librte_eal/x86/include/rte_prefetch.h | 12 ++++++++++++ 7 files changed, 63 insertions(+)
...snip...
Quoted 16 lines
lib/librte_eal/ppc/include/rte_prefetch.h +1
-0@@ -11,6 +11,7 @@#endif #include <rte_common.h> +#include <rte_compat.h> #include "generic/rte_prefetch.h" static inline void rte_prefetch0 (const volatile void *p)@@ -34,6 +35,13 @@ static inline void rte_prefetch_non_temporal(const volatile void *p)rte_prefetch0 (p); }
lib/librte_eal/ppc/include/rte_prefetch.h static inline void rte_prefetch_non_temporal(const volatile void *p) · line 47
Quoted 10 lines
lib/librte_eal/ppc/include/rte_prefetch.h +7
-0+static inline void +__rte_experimental +rte_cldemote (const volatile void *p) +{ +RTE_SET_USED (p); +} + #ifdef __cplusplus }#endif
Don't see an equivalent operation in the 3.1 ISA for POWER processors, so NOP is the right implementation.
Re: [dpdk-dev] [PATCH v6] eal: add cache-line demote support
In reply to Omkar MaslekarQuoted 76 lines
-----Original Message-----
From: Omkar Maslekar <[email protected]>
Sent: Monday, October 12, 2020 6:20 PM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Ruifeng Wang <[email protected]>; Honnappa Nagarahalli <[email protected]>
Subject: [PATCH v6] eal: add cache-line demote support
rte_cldemoteis similar to a prefetch hint - in reverse. cldemote(addr) enables software to hint to hardware that line is likely to be shared. Useful in core-to-core communications where cache-line is likely to be shared. ARM and PPC implementation is provided with NOP and can be added if any equivalent instructions could be used for implementation on those architectures.Signed-off-by Omkar Maslekar <[email protected]>Acked-by Bruce Richardson <[email protected]>---
v6: markedrte_cldemoteas experimental
addedrte_cldemotecall in existingapp/test_prefetch.cv5: documentation updated
fixed formatting issue in release notes
added Acked-by: Bruce Richardson <[email protected]>
*
v4: updated bold text for title and fixed margin in release notes *
v3: fixed warning regarding whitespace
*
v2: documentation updated
------ app/test/test_prefetch.c | 4 ++++ doc/guides/rel_notes/release_20_11.rst | 7 +++++++ lib/librte_eal/arm/include/rte_prefetch_32.h | 8 ++++++++ lib/librte_eal/arm/include/rte_prefetch_64.h | 8 ++++++++ lib/librte_eal/include/generic/rte_prefetch.h | 16 ++++++++++++++++ lib/librte_eal/ppc/include/rte_prefetch.h | 8 ++++++++ lib/librte_eal/x86/include/rte_prefetch.h | 12 ++++++++++++ 7 files changed, 63 insertions(+)app/test/test_prefetch.c index renamed from app/test/test_prefetch.c +0
-041f219a..5c58d0c 100644
app/test/test_prefetch.c +4
-0@@ -26,7 +26,11 @@rte_prefetch1 (&a);rte_prefetch2 (&a); +/* test for marking a line as shared to test cldemote functionality */ +rte_cldemote (&a); +return 0 ; } + REGISTER_TEST_COMMAND(prefetch_autotest, test_prefetch); diff --git
a/doc/guides/rel_notes/release_20_11.rstb/doc/guides/rel_notes/release_20_11.rst
index df227a1..dc402ab 100644doc/guides/rel_notes/release_20_11.rst +6
-0@@ -55,6 +55,13 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added new function rte_cldemote in rte_prefetch.h.** + + Added a hardware hint CLDEMOTE, which is similar to prefetch in reverse. + CLDEMOTE moves the cache line to the more remote cache, where it + expects sharing to be efficient. Moving the cache line to a level + more distant from the processor helps to accelerate core-to-core
Quoted 2 lines
communication.
+
Patch cannot apply. Maybe rebase is needed.
Quoted 17 lines
Removed Items
-------------lib/librte_eal/arm/include/rte_prefetch_32.h +1
-0@@ -10,6 +10,7 @@#endif #include <rte_common.h> +#include <rte_compat.h> #include "generic/rte_prefetch.h" static inline void rte_prefetch0(const volatile void *p) @@ -33,6 +34,13 @@static inline void
rte_prefetch_non_temporal(const volatile void *p)
lib/librte_eal/arm/include/rte_prefetch_32.h static inline void rte_prefetch_non_temporal(const volatile void *p) · line 38
Quoted 5 lines
lib/librte_eal/arm/include/rte_prefetch_32.h +2
-0rte_prefetch0 (p); } +static inline void +__rte_experimental
See below.
Quoted 51 lines
lib/librte_eal/arm/include/rte_prefetch_32.h +5
-0+rte_cldemote(const volatile void *p) +{ +RTE_SET_USED (p); +} +#ifdef __cplusplus }#endif lib/librte_eal/arm/include/rte_prefetch_64.h +1
-0@@ -10,6 +10,7 @@#endif #include <rte_common.h> +#include <rte_compat.h> #include "generic/rte_prefetch.h" static inline void rte_prefetch0(const volatile void *p) @@ -32,6 +33,13 @@static inline void
rte_prefetch_non_temporal(const volatile void *p)lib/librte_eal/arm/include/rte_prefetch_64.h +7
-0asmvolatile ("PRFM PLDL1STRM, [%0]" : :"r" (p)); } +static inline void +__rte_experimental +rte_cldemote (const volatile void *p) +{ +RTE_SET_USED (p); +} + #ifdef __cplusplus }#endif lib/librte_eal/include/generic/rte_prefetch.h +8
-0@@ -51,4 +51,20 @@*/ static inline void rte_prefetch_non_temporal (const volatile void *p); +/** +* Demote a cache line to a more distant level of cache from the processor. +* +* CLDEMOTE hints to hardware to move (demote) a cache line from the +closest to +* the processor to a level more distant from the processor. It is a +hint and +* not guarantee. rte_cldemote is intended to move the cache line to
lib/librte_eal/include/generic/rte_prefetch.h line 67
Quoted 10 lines
lib/librte_eal/include/generic/rte_prefetch.h +10
-0+the more +* remote cache, where it expects sharing to be efficient and to +indicate that a +* line may be accessed by a different core in the future. +* +* @param p +* Address to demote +*/ +static inline void +__rte_experimental
1. Experimental tag is only needed in this file. Tags at other places can be removed.
2. To align with other codes, experimental tag can be put above 'static inline void' line.
Quoted 62 lines
lib/librte_eal/include/generic/rte_prefetch.h +2
-0+rte_cldemote(const volatile void *p); +#endif /* _RTE_PREFETCH_H_ */ lib/librte_eal/ppc/include/rte_prefetch.h +1
-0@@ -11,6 +11,7 @@#endif #include <rte_common.h> +#include <rte_compat.h> #include "generic/rte_prefetch.h" static inline void rte_prefetch0(const volatile void *p) @@ -34,6 +35,13 @@static inline void
rte_prefetch_non_temporal(const volatile void *p)lib/librte_eal/ppc/include/rte_prefetch.h +7
-0rte_prefetch0 (p); } +static inline void +__rte_experimental +rte_cldemote (const volatile void *p) +{ +RTE_SET_USED (p); +} + #ifdef __cplusplus }#endif lib/librte_eal/x86/include/rte_prefetch.h +1
-0@@ -10,6 +10,7 @@#endif #include <rte_common.h> +#include <rte_compat.h> #include "generic/rte_prefetch.h" static inline void rte_prefetch0(const volatile void *p) @@ -32,6 +33,17 @@static inline void
rte_prefetch_non_temporal(const volatile void *p)
asm volatile ("prefetchnta %[p]" : : [p] "m" (*(const volatile char
*)p)); }lib/librte_eal/x86/include/rte_prefetch.h +10
-1+/* +* we're using raw byte codes for now as only the newest compiler +* versions support this instruction natively. +*/ +static inline void +__rte_experimental +rte_cldemote (const volatile void *p) +{ + asmvolatile (".byte 0x0f, 0x1c, 0x06" ::"S" (p)); } + #ifdef __cplusplus }#endif --1.8.3.1
Re: [dpdk-dev] [PATCH v6] eal: add cache-line demote support
Quoted 36 lines · Ruifeng Wang
Quoted 36 lines
-----Original Message-----
From: Omkar Maslekar <[email protected]>
Sent: Monday, October 12, 2020 6:20 PM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Ruifeng Wang <[email protected]>; Honnappa Nagarahalli <[email protected]>
Subject: [PATCH v6] eal: add cache-line demote support
rte_cldemoteis similar to a prefetch hint - in reverse. cldemote(addr) enables software to hint to hardware that line is likely to be shared. Useful in core-to-core communications where cache-line is likely to be shared. ARM and PPC implementation is provided with NOP and can be added if any equivalent instructions could be used for implementation on those architectures.Signed-off-by Omkar Maslekar <[email protected]>Acked-by Bruce Richardson <[email protected]>---
v6: markedrte_cldemoteas experimental
addedrte_cldemotecall in existingapp/test_prefetch.cv5: documentation updated
fixed formatting issue in release notes
added Acked-by: Bruce Richardson <[email protected]>
*
v4: updated bold text for title and fixed margin in release notes *
v3: fixed warning regarding whitespace
*
v2: documentation updated
---
---
<snip>
Quoted 13 lines
Quoted 13 lines
(quoted diff) +12
-0+/** + * Demote a cache line to a more distant level of cache from the processor. + * + * CLDEMOTE hints to hardware to move (demote) a cache line from the +closest to + * the processor to a level more distant from the processor. It is a +hint and + * not guarantee. rte_cldemote is intended to move the cache line to +the more + * remote cache, where it expects sharing to be efficient and to +indicate that a + * line may be accessed by a different core in the future.
Quoted 8 lines
Review
Quoted 6 lines
+ *
+ * @param p
+ * Address to demote
+ */(quoted diff) +2
-0+static inline void +__rte_experimental1. Experimental tag is only needed in this file. Tags at other places can be removed.
I'm not sure that is the case. The generic file is used when preparing the docs, so the experimental tag needs to go there for the docs, but when actually using the function in compiled code the "generic" version is unused. Therefore we need the experimental tag there to trigger a build warning about using the function if the appropriate ALLOW_EXPERIMENTAL_APIS flag is not set.
/Bruce
Re: [dpdk-dev] [PATCH v6] eal: add cache-line demote support
Quoted 72 lines
-----Original Message-----
From: Bruce Richardson <[email protected]>
Sent: Wednesday, October 14, 2020 12:20 AM
To: Ruifeng Wang <[email protected]>
Cc: Omkar Maslekar <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Honnappa Nagarahalli <[email protected]>; nd <[email protected]>
Subject: Re: [PATCH v6] eal: add cache-line demote supportQuoted 8 lines · Ruifeng Wang
Quoted 8 lines
-----Original Message-----
From: Omkar Maslekar <[email protected]>
Sent: Monday, October 12, 2020 6:20 PM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Ruifeng Wang <[email protected]>;Honnappa
Quoted 5 lines
Quoted 5 lines
Nagarahalli <[email protected]>
Subject: [PATCH v6] eal: add cache-line demote support
rte_cldemoteis similar to a prefetch hint - in reverse. cldemote(addr) enables software to hint to hardware that line is likely tobe shared.
Quoted 23 lines
Quoted 23 lines
Useful in core-to-core communications where cache-line is likely to be shared. ARM and PPC implementation is provided with NOP and can be added if any equivalent instructions could be used for implementation on those architectures.
Signed-off-by Omkar Maslekar <[email protected]>Acked-by Bruce Richardson <[email protected]>---
v6: markedrte_cldemoteas experimental
addedrte_cldemotecall in existingapp/test_prefetch.cv5: documentation updated
fixed formatting issue in release notes
added Acked-by: Bruce Richardson <[email protected]>
*
v4: updated bold text for title and fixed margin in release notes *
v3: fixed warning regarding whitespace
*
v2: documentation updated
---
---<snip>
Quoted 3 lines
Quoted 3 lines
+/**
+ * Demote a cache line to a more distant level of cache from theprocessor.
Quoted 10 lines
Quoted 10 lines
+ *
+ * CLDEMOTE hints to hardware to move (demote) a cache line from(quoted diff) +8
-0+the closest to + * the processor to a level more distant from the processor. It is +a hint and + * not guarantee. rte_cldemote is intended to move the cache line +to the more + * remote cache, where it expects sharing to be efficient and to +indicate that a + * line may be accessed by a different core in the future.Quoted 8 lines
Review
Quoted 6 lines
+ *
+ * @param p
+ * Address to demote
+ */(quoted diff) +2
-0+static inline void +__rte_experimental1. Experimental tag is only needed in this file. Tags at other places can be
Quoted 9 lines
removed.
I'm not sure that is the case. The generic file is used when preparing the docs, so the experimental tag needs to go there for the docs, but when actually using the function in compiled code the "generic" version is unused. Therefore we need the experimental tag there to trigger a build warning about using the function if the appropriate
ALLOW_EXPERIMENTAL_APISflag is not set.
+David in cc.
I learnt this from David's comment in thread:
http://patches.dpdk.org/patch/61573/
"We only need it in the function prototype"
Hi David,
Can you comment if my understanding of experimental tag usage is correct?
/Ruifeng
Quoted 1 line
/Bruce
Re: [dpdk-dev] [PATCH v6] eal: add cache-line demote support
In reply to Bruce RichardsonQuoted 8 lines · Bruce Richardson
Quoted 1 line
1. Experimental tag is only needed in this file. Tags at other places can be removed.
I'm not sure that is the case. The generic file is used when preparing the docs, so the experimental tag needs to go there for the docs, but when actually using the function in compiled code the "generic" version is unused. Therefore we need the experimental tag there to trigger a build warning about using the function if the appropriate
ALLOW_EXPERIMENTAL_APISflag is not set.
It is enough to put an experimental tag when declaring a symbol. Here, the generic/ header only contains the doxygen part and there is no common declaration: the tag is needed in the arch specific header.
Signature · 1 line
David Marchand
Re: [dpdk-dev] [PATCH v6] eal: add cache-line demote support
Quoted 23 lines
-----Original Message-----
From: David Marchand <[email protected]>
Sent: Wednesday, October 14, 2020 3:14 PM
To: Bruce Richardson <[email protected]>; Ruifeng Wang <[email protected]>
Cc: Omkar Maslekar <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Honnappa Nagarahalli <[email protected]>; nd <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v6] eal: add cache-line demote supportQuoted 1 line · Bruce Richardson
Quoted 1 line
1. Experimental tag is only needed in this file. Tags at other places can be
removed.
Quoted 7 lines
I'm not sure that is the case. The generic file is used when preparing the docs, so the experimental tag needs to go there for the docs, but when actually using the function in compiled code the "generic" version is unused. Therefore we need the experimental tag there to trigger a build warning about using the function if the appropriate
ALLOW_EXPERIMENTAL_APISflag is not set.
Quoted 4 lines
It is enough to put an experimental tag when declaring a symbol. Here, the generic/ header only contains the doxygen part and there is no common declaration: the tag is needed in the arch specific header.
Thank you David for the clarification.
I added my reviewed-by tag to v7.
Quoted 3 lines
--
David Marchand
PATCH v7 1/1 eal: add cache-line demote support
In reply to Omkar MaslekarWe are including this in rte_prefetch.h since it is the most closely related code location.rte_cldemte is similar to a prefetch hint -in reverse
Omkar Maslekar (1):
eal: add cache-line demote support
app/test/test_prefetch.c | 4 ++++ doc/guides/rel_notes/release_20_11.rst | 7 +++++++ lib/librte_eal/arm/include/rte_prefetch_32.h | 7 +++++++ lib/librte_eal/arm/include/rte_prefetch_64.h | 7 +++++++ lib/librte_eal/include/generic/rte_prefetch.h | 15 +++++++++++++++ lib/librte_eal/ppc/include/rte_prefetch.h | 7 +++++++ lib/librte_eal/x86/include/rte_prefetch.h | 11 +++++++++++ 7 files changed, 58 insertions(+)
Signature · 1 line
1.8.3.1
PATCH v7 1/1 eal: add cache-line demote support
rte_cldemote is similar to a prefetch hint - in reverse. cldemote(addr) enables software to hint to hardware that line is likely to be shared. Useful in core-to-core communications where cache-line is likely to be shared. ARM and PPC implementation is provided with NOP and can be added if any equivalent instructions could be used for implementation on those architectures.
---
v7: fixed experimental tag
v6: marked rte_cldemote as experimental
added rte_cldemote call in existing app/test_prefetch.c
v5: documentation updated
fixed formatting issue in release notes
added Acked-by: Bruce Richardson <[email protected]>
*
v4: updated bold text for title and fixed margin in release notes *
v3: fixed warning regarding whitespace
*
v2: documentation updated
---
--- app/test/test_prefetch.c | 4 ++++ doc/guides/rel_notes/release_20_11.rst | 7 +++++++ lib/librte_eal/arm/include/rte_prefetch_32.h | 7 +++++++ lib/librte_eal/arm/include/rte_prefetch_64.h | 7 +++++++ lib/librte_eal/include/generic/rte_prefetch.h | 15 +++++++++++++++ lib/librte_eal/ppc/include/rte_prefetch.h | 7 +++++++ lib/librte_eal/x86/include/rte_prefetch.h | 11 +++++++++++ 7 files changed, 58 insertions(+)
app/test/test_prefetch.c +4 -0
@@ -26,7 +26,11 @@rte_prefetch1 (&a);rte_prefetch2 (&a); +/* test for marking a line as shared to test cldemote functionality */ +rte_cldemote (&a); +return 0 ; } +REGISTER_TEST_COMMAND (prefetch_autotest, test_prefetch);
doc/guides/rel_notes/release_20_11.rst +7 -0
@@ -171,6 +171,13 @@ New Features * Extern objects and functions can be plugged into the pipeline. * Transaction-oriented table updates. +* **Added new function rte_cldemote in rte_prefetch.h.** + + Added a hardware hint CLDEMOTE, which is similar to prefetch in reverse. + CLDEMOTE moves the cache line to the more remote cache, where it expects + sharing to be efficient. Moving the cache line to a level more distant from + the processor helps to accelerate core-to-core communication. + Removed Items -------------
lib/librte_eal/arm/include/rte_prefetch_32.h +7 -0
@@ -10,6 +10,7 @@#endif #include <rte_common.h> +#include <rte_compat.h> #include "generic/rte_prefetch.h" static inline void rte_prefetch0 (const volatile void *p)
@@ -33,6 +34,12 @@ static inline void rte_prefetch_non_temporal(const volatile void *p)rte_prefetch0 (p); } +__rte_experimental +static inline void rte_cldemote(const volatile void *p) +{ +RTE_SET_USED (p); +} + #ifdef __cplusplus }#endif
lib/librte_eal/arm/include/rte_prefetch_64.h +7 -0
@@ -10,6 +10,7 @@#endif #include <rte_common.h> +#include <rte_compat.h> #include "generic/rte_prefetch.h" static inline void rte_prefetch0 (const volatile void *p)
@@ -32,6 +33,12 @@ static inline void rte_prefetch_non_temporal(const volatile void *p) asmvolatile ("PRFM PLDL1STRM, [%0]" : :"r" (p)); } +__rte_experimental +static inline void rte_cldemote(const volatile void *p) +{ +RTE_SET_USED (p); +} + #ifdef __cplusplus }#endif
lib/librte_eal/include/generic/rte_prefetch.h +15 -0
@@ -51,4 +51,19 @@*/ static inline void rte_prefetch_non_temporal (const volatile void *p); +/** +* Demote a cache line to a more distant level of cache from the processor. +* +* CLDEMOTE hints to hardware to move (demote) a cache line from the closest to +* the processor to a level more distant from the processor. It is a hint and +* not guarantee. rte_cldemote is intended to move the cache line to the more +* remote cache, where it expects sharing to be efficient and to indicate that a +* line may be accessed by a different core in the future. +* +* @param p +* Address to demote +*/ +__rte_experimental +static inline void rte_cldemote(const volatile void *p); +#endif /* _RTE_PREFETCH_H_ */
lib/librte_eal/ppc/include/rte_prefetch.h +7 -0
@@ -11,6 +11,7 @@#endif #include <rte_common.h> +#include <rte_compat.h> #include "generic/rte_prefetch.h" static inline void rte_prefetch0 (const volatile void *p)
@@ -34,6 +35,12 @@ static inline void rte_prefetch_non_temporal(const volatile void *p)rte_prefetch0 (p); } +__rte_experimental +static inline void rte_cldemote(const volatile void *p) +{ +RTE_SET_USED (p); +} + #ifdef __cplusplus }#endif
lib/librte_eal/x86/include/rte_prefetch.h +11 -0
@@ -10,6 +10,7 @@#endif #include <rte_common.h> +#include <rte_compat.h> #include "generic/rte_prefetch.h" static inline void rte_prefetch0 (const volatile void *p)
@@ -32,6 +33,16 @@ static inline void rte_prefetch_non_temporal(const volatile void *p) asmvolatile ("prefetchnta %[p]" : : [p]"m" (*(const volatile char *)p)); } +/* +* we're using raw byte codes for now as only the newest compiler +* versions support this instruction natively. +*/ +__rte_experimental +static inline void rte_cldemote(const volatile void *p) +{ + asmvolatile (".byte 0x0f, 0x1c, 0x06" ::"S" (p)); +} + #ifdef __cplusplus }#endif
Signature · 1 line
1.8.3.1
Re: [dpdk-dev] [PATCH v7] eal: add cache-line demote support
Quoted 217 lines
-----Original Message-----
From: Omkar Maslekar <[email protected]>
Sent: Tuesday, October 13, 2020 5:43 PM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Ruifeng Wang <[email protected]>; Honnappa Nagarahalli <[email protected]>
Subject: [PATCH v7] eal: add cache-line demote support
rte_cldemoteis similar to a prefetch hint - in reverse. cldemote(addr) enables software to hint to hardware that line is likely to be shared. Useful in core-to-core communications where cache-line is likely to be shared. ARM and PPC implementation is provided with NOP and can be added if any equivalent instructions could be used for implementation on those architectures.Signed-off-by Omkar Maslekar <[email protected]>Acked-by Bruce Richardson <[email protected]>Acked-by Jerin Jacob <[email protected]>---
v7: fixed experimental tagv6: marked
rte_cldemoteas experimental
addedrte_cldemotecall in existingapp/test_prefetch.cv5: documentation updated
fixed formatting issue in release notes
added Acked-by: Bruce Richardson <[email protected]>
*
v4: updated bold text for title and fixed margin in release notes *
v3: fixed warning regarding whitespace
*
v2: documentation updated
------ app/test/test_prefetch.c | 4 ++++ doc/guides/rel_notes/release_20_11.rst | 7 +++++++ lib/librte_eal/arm/include/rte_prefetch_32.h | 7 +++++++ lib/librte_eal/arm/include/rte_prefetch_64.h | 7 +++++++ lib/librte_eal/include/generic/rte_prefetch.h | 15 +++++++++++++++ lib/librte_eal/ppc/include/rte_prefetch.h | 7 +++++++ lib/librte_eal/x86/include/rte_prefetch.h | 11 +++++++++++ 7 files changed, 58 insertions(+)app/test/test_prefetch.c index renamed from app/test/test_prefetch.c +0
-041f219a..5c58d0c 100644
app/test/test_prefetch.c +4
-0@@ -26,7 +26,11 @@rte_prefetch1 (&a);rte_prefetch2 (&a); +/* test for marking a line as shared to test cldemote functionality */ +rte_cldemote (&a); +return 0 ; } + REGISTER_TEST_COMMAND(prefetch_autotest, test_prefetch); diff --git
a/doc/guides/rel_notes/release_20_11.rstb/doc/guides/rel_notes/release_20_11.rst
index b7881f2..8a1ed01 100644doc/guides/rel_notes/release_20_11.rst +6
-0@@ -171,6 +171,13 @@ New Features * Extern objects and functions can be plugged into the pipeline. * Transaction-oriented table updates. +* **Added new function rte_cldemote in rte_prefetch.h.** + + Added a hardware hint CLDEMOTE, which is similar to prefetch in reverse. + CLDEMOTE moves the cache line to the more remote cache, where it + expects sharing to be efficient. Moving the cache line to a level + more distant from the processor helps to accelerate core-to-corecommunication.
doc/guides/rel_notes/release_20_11.rst +1
-0+ Removed Items -------------lib/librte_eal/arm/include/rte_prefetch_32.h +1
-0@@ -10,6 +10,7 @@#endif #include <rte_common.h> +#include <rte_compat.h> #include "generic/rte_prefetch.h" static inline void rte_prefetch0(const volatile void *p) @@ -33,6 +34,12 @@static inline void
rte_prefetch_non_temporal(const volatile void *p)lib/librte_eal/arm/include/rte_prefetch_32.h +5
-0rte_prefetch0 (p); } +__rte_experimental +static inline void rte_cldemote(const volatile void *p) { +RTE_SET_USED (p); +} + #ifdef __cplusplus }#endif lib/librte_eal/arm/include/rte_prefetch_64.h +1
-0@@ -10,6 +10,7 @@#endif #include <rte_common.h> +#include <rte_compat.h> #include "generic/rte_prefetch.h" static inline void rte_prefetch0(const volatile void *p) @@ -32,6 +33,12 @@static inline void
rte_prefetch_non_temporal(const volatile void *p)lib/librte_eal/arm/include/rte_prefetch_64.h +5
-0asmvolatile ("PRFM PLDL1STRM, [%0]" : :"r" (p)); } +__rte_experimental +static inline void rte_cldemote(const volatile void *p) { +RTE_SET_USED (p); +} + #ifdef __cplusplus }#endif lib/librte_eal/include/generic/rte_prefetch.h +19
-0@@ -51,4 +51,19 @@*/ static inline void rte_prefetch_non_temporal (const volatile void *p); +/** +* Demote a cache line to a more distant level of cache from the processor. +* +* CLDEMOTE hints to hardware to move (demote) a cache line from the +closest to +* the processor to a level more distant from the processor. It is a +hint and +* not guarantee. rte_cldemote is intended to move the cache line to +the more +* remote cache, where it expects sharing to be efficient and to +indicate that a +* line may be accessed by a different core in the future. +* +* @param p +* Address to demote +*/ +__rte_experimental +static inline void rte_cldemote(const volatile void *p); +#endif /* _RTE_PREFETCH_H_ */ lib/librte_eal/ppc/include/rte_prefetch.h +1
-0@@ -11,6 +11,7 @@#endif #include <rte_common.h> +#include <rte_compat.h> #include "generic/rte_prefetch.h" static inline void rte_prefetch0(const volatile void *p) @@ -34,6 +35,12 @@static inline void
rte_prefetch_non_temporal(const volatile void *p)lib/librte_eal/ppc/include/rte_prefetch.h +5
-0rte_prefetch0 (p); } +__rte_experimental +static inline void rte_cldemote(const volatile void *p) { +RTE_SET_USED (p); +} + #ifdef __cplusplus }#endif lib/librte_eal/x86/include/rte_prefetch.h +1
-0@@ -10,6 +10,7 @@#endif #include <rte_common.h> +#include <rte_compat.h> #include "generic/rte_prefetch.h" static inline void rte_prefetch0(const volatile void *p) @@ -32,6 +33,16 @@static inline void
rte_prefetch_non_temporal(const volatile void *p)
asm volatile ("prefetchnta %[p]" : : [p] "m" (*(const volatile char
*)p)); }lib/librte_eal/x86/include/rte_prefetch.h +8
-1+/* +* we're using raw byte codes for now as only the newest compiler +* versions support this instruction natively. +*/ +__rte_experimental +static inline void rte_cldemote(const volatile void *p) { + asmvolatile (".byte 0x0f, 0x1c, 0x06" ::"S" (p)); } + #ifdef __cplusplus }#endif --
Quoted 1 line
1.8.3.1
Re: [dpdk-dev] [PATCH v7] eal: add cache-line demote support
In reply to Omkar MaslekarRepeating my questions:
- would there be a point in hinting at where the "demoted" line goes?
- is this instruction available on all x86 CPUs?
See comments:
app/test/test_prefetch.c line 29
Quoted 9 lines · Omkar Maslekar
app/test/test_prefetch.c +1
-0@@ -26,7 +26,11 @@rte_prefetch1 (&a);rte_prefetch2 (&a); +/* test for marking a line as shared to test cldemote functionality */
Non indented comment that gives no more info than the call itself. Please remove.
app/test/test_prefetch.c line 35
Quoted 6 lines
app/test/test_prefetch.c +3
-0+rte_cldemote (&a); +return 0 ; } +
Please remove this empty line.
doc/guides/rel_notes/release_20_11.rst New Features · line 176
Quoted 12 lines
app/test/test_prefetch.c +0
-0REGISTER_TEST_COMMAND (prefetch_autotest, test_prefetch);doc/guides/rel_notes/release_20_11.rst +3
-0@@ -171,6 +171,13 @@ New Features * Extern objects and functions can be plugged into the pipeline. * Transaction-oriented table updates. +* **Added new function rte_cldemote in rte_prefetch.h.** + + Added a hardware hint CLDEMOTE, which is similar to prefetch in reverse.
This should come at the top of the features list (but after "write combining store" entry that got in first).
Please add a mention that it only concerns x86.
Quoted 12 lines
doc/guides/rel_notes/release_20_11.rst +4
-0+ CLDEMOTE moves the cache line to the more remote cache, where it expects + sharing to be efficient. Moving the cache line to a level more distant from + the processor helps to accelerate core-to-core communication. + Removed Items -------------lib/librte_eal/arm/include/rte_prefetch_32.h +0
-0
lib/librte_eal/arm/include/rte_prefetch_32.h line 13
Quoted 4 lines
lib/librte_eal/arm/include/rte_prefetch_32.h +1
-0@@ -10,6 +10,7 @@#endif #include <rte_common.h> +#include <rte_compat.h>
Move rte_compat.h inclusion from the arch headers to the generic/rte_prefetch.h header only.
Quoted 46 lines
lib/librte_eal/arm/include/rte_prefetch_32.h +6
-0#include "generic/rte_prefetch.h" static inline void rte_prefetch0 (const volatile void *p)@@ -33,6 +34,12 @@ static inline void rte_prefetch_non_temporal(const volatile void *p)rte_prefetch0 (p); } +__rte_experimental +static inline void rte_cldemote(const volatile void *p) +{ +RTE_SET_USED (p); +} + #ifdef __cplusplus }#endif lib/librte_eal/arm/include/rte_prefetch_64.h +7
-0@@ -10,6 +10,7 @@#endif #include <rte_common.h> +#include <rte_compat.h> #include "generic/rte_prefetch.h" static inline void rte_prefetch0 (const volatile void *p)@@ -32,6 +33,12 @@ static inline void rte_prefetch_non_temporal(const volatile void *p) asmvolatile ("PRFM PLDL1STRM, [%0]" : :"r" (p)); } +__rte_experimental +static inline void rte_cldemote(const volatile void *p) +{ +RTE_SET_USED (p); +} + #ifdef __cplusplus }#endif lib/librte_eal/include/generic/rte_prefetch.h +0
-0
lib/librte_eal/include/generic/rte_prefetch.h line 59
Quoted 9 lines
lib/librte_eal/include/generic/rte_prefetch.h +6
-0@@ -51,4 +51,19 @@*/ static inline void rte_prefetch_non_temporal (const volatile void *p); +/** +* Demote a cache line to a more distant level of cache from the processor. +* +* CLDEMOTE hints to hardware to move (demote) a cache line from the closest to +* the processor to a level more distant from the processor. It is a hint and +* not guarantee. rte_cldemote is intended to move the cache line to the more
guaranteed*
Quoted 48 lines
lib/librte_eal/include/generic/rte_prefetch.h +9
-0+* remote cache, where it expects sharing to be efficient and to indicate that a +* line may be accessed by a different core in the future. +* +* @param p +* Address to demote +*/ +__rte_experimental +static inline void rte_cldemote(const volatile void *p); +#endif /* _RTE_PREFETCH_H_ */ lib/librte_eal/ppc/include/rte_prefetch.h +7
-0@@ -11,6 +11,7 @@#endif #include <rte_common.h> +#include <rte_compat.h> #include "generic/rte_prefetch.h" static inline void rte_prefetch0 (const volatile void *p)@@ -34,6 +35,12 @@ static inline void rte_prefetch_non_temporal(const volatile void *p)rte_prefetch0 (p); } +__rte_experimental +static inline void rte_cldemote(const volatile void *p) +{ +RTE_SET_USED (p); +} + #ifdef __cplusplus }#endif lib/librte_eal/x86/include/rte_prefetch.h +1
-0@@ -10,6 +10,7 @@#endif #include <rte_common.h> +#include <rte_compat.h> #include "generic/rte_prefetch.h" static inline void rte_prefetch0 (const volatile void *p)
lib/librte_eal/x86/include/rte_prefetch.h static inline void rte_prefetch_non_temporal(const volatile void *p) · line 37
Quoted 5 lines
lib/librte_eal/x86/include/rte_prefetch.h +2
-0@@ -32,6 +33,16 @@ static inline void rte_prefetch_non_temporal(const volatile void *p) asmvolatile ("prefetchnta %[p]" : : [p]"m" (*(const volatile char *)p)); } +/* +* we're using raw byte codes for now as only the newest compiler
We use
Quoted 14 lines
lib/librte_eal/x86/include/rte_prefetch.h +8
-1+* versions support this instruction natively. +*/ +__rte_experimental +static inline void rte_cldemote(const volatile void *p) +{ + asmvolatile (".byte 0x0f, 0x1c, 0x06" ::"S" (p)); +} + #ifdef __cplusplus }#endif --1.8.3.1
Signature · 1 line
David Marchand
Re: [dpdk-dev] [PATCH v7] eal: add cache-line demote support
Hi David,
Quoted 11 lines
-----Original Message-----
From: David Marchand <[email protected]>
Sent: Thursday, October 15, 2020 1:01 AM
To: Maslekar, Omkar <[email protected]>
Cc: dev <[email protected]>; Richardson, Bruce <[email protected]>; Loftus, Ciara <[email protected]>; David Christensen <[email protected]>; Jerin Jacob Kollanukkaran <[email protected]>; Ruifeng Wang (Arm Technology China) <[email protected]>; Honnappa Nagarahalli <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v7] eal: add cache-line demote support
Quoted 2 lines
Repeating my questions:
- would there be a point in hinting at where the "demoted" line goes?
Yes, it is worth mentioning a point that demoted line goes to last shared level of cache hierarchy. Demotion to desired cache level is not possible.
Quoted 1 line
- is this instruction available on all x86 CPUs?
Yes, this instruction is available on all x86 CPUs, it works on latest cpus and substitute NOP in the older generations
Quoted 14 lines
See comments:
Quoted 8 lines · Omkar Maslekar
app/test/test_prefetch.c index renamed from app/test/test_prefetch.c +0
-041f219a..5c58d0c 100644
app/test/test_prefetch.c +0
-0@@ -26,7 +26,11 @@rte_prefetch1 (&a);rte_prefetch2 (&a);
Quoted 5 lines
app/test/test_prefetch.c line 30
Quoted 2 lines
app/test/test_prefetch.c +2
-0+/* test for marking a line as shared to test cldemote functionality +*/ Non indented comment that gives no more info than the call itself. Please remove.
I will fix it
Quoted 9 lines
app/test/test_prefetch.c line 35
Quoted 7 lines
app/test/test_prefetch.c +3
-0+rte_cldemote (&a); +return 0 ; } +Please remove this empty line.
I will fix it
Quoted 16 lines
Quoted 8 lines
REGISTER_TEST_COMMAND(prefetch_autotest, test_prefetch); diff --gita/doc/guides/rel_notes/release_20_11.rstb/doc/guides/rel_notes/release_20_11.rst
index b7881f2..8a1ed01 100644doc/guides/rel_notes/release_20_11.rst New Features · line 176
Quoted 6 lines
doc/guides/rel_notes/release_20_11.rst +3
-0@@ -171,6 +171,13 @@ New Features * Extern objects and functions can be plugged into the pipeline. * Transaction-oriented table updates. +* **Added new function rte_cldemote in rte_prefetch.h.** + + Added a hardware hint CLDEMOTE, which is similar to prefetch inreverse.
Quoted 4 lines
This should come at the top of the features list (but after "write combining store" entry that got in first).
Please add a mention that it only concerns x86.
I will modify the sequence in the release notes
Quoted 18 lines
doc/guides/rel_notes/release_20_11.rst New Features · line 179
Quoted 5 lines
doc/guides/rel_notes/release_20_11.rst +3
-0+ CLDEMOTE moves the cache line to the more remote cache, where it + expects sharing to be efficient. Moving the cache line to a level + more distant from the processor helps to accelerate core-to-corecommunication.
Quoted 12 lines
doc/guides/rel_notes/release_20_11.rst +1
-0+ Removed Items -------------lib/librte_eal/arm/include/rte_prefetch_32.h +0
-0@@ -10,6 +10,7 @@#endif
Quoted 5 lines
lib/librte_eal/arm/include/rte_prefetch_32.h line 13
Quoted 2 lines
lib/librte_eal/arm/include/rte_prefetch_32.h +1
-0#include <rte_common.h> +#include <rte_compat.h> Move
rte_compat.hinclusion from the arch headers to thegeneric/rte_prefetch.hheader only.
I got below build error if I move rte_compat.h inclusion from the arch headers to the generic/rte_prefetch.h header only. I will remove it and send out a new patch v8. In file included from ../lib/librte_eal/x86/include/rte_prefetch.h:14:0,
from ../lib/librte_table/rte_swx_table_em.c:10:
../lib/librte_eal/include/generic/rte_prefetch.h:67:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘static’
static inline void rte_cldemote(const volatile void *p);
Quoted 55 lines
lib/librte_eal/arm/include/rte_prefetch_32.h
Quoted 6 lines
lib/librte_eal/arm/include/rte_prefetch_32.h +1
-0#include "generic/rte_prefetch.h" static inline void rte_prefetch0(const volatile void *p) @@ -33,6 +34,12 @@ static inline void rte_prefetch_non_temporal(const volatilevoid *p)
Quoted 17 lines
rte_prefetch0(p);}
lib/librte_eal/arm/include/rte_prefetch_32.h +5
-0+__rte_experimental +static inline void rte_cldemote(const volatile void *p) { +RTE_SET_USED (p); +} + #ifdef __cplusplus }#endif lib/librte_eal/arm/include/rte_prefetch_64.h +0
-0lib/librte_eal/arm/include/rte_prefetch_64.h
Quoted 8 lines
lib/librte_eal/arm/include/rte_prefetch_64.h +2
-0@@ -10,6 +10,7 @@#endif #include <rte_common.h> +#include <rte_compat.h> #include "generic/rte_prefetch.h" static inline void rte_prefetch0(const volatile void *p) @@ -32,6 +33,12 @@ static inline void rte_prefetch_non_temporal(const volatilevoid *p)
Quoted 16 lines
asm volatile ("PRFM PLDL1STRM, [%0]" : : "r" (p)); }lib/librte_eal/arm/include/rte_prefetch_64.h +5
-0+__rte_experimental +static inline void rte_cldemote(const volatile void *p) { +RTE_SET_USED (p); +} + #ifdef __cplusplus }#endif lib/librte_eal/include/generic/rte_prefetch.h +0
-0lib/librte_eal/include/generic/rte_prefetch.h line 55
Quoted 5 lines
lib/librte_eal/include/generic/rte_prefetch.h +2
-0@@ -51,4 +51,19 @@*/ static inline void rte_prefetch_non_temporal (const volatile void *p); +/** +* Demote a cache line to a more distant level of cache from the processor.
Quoted 9 lines
lib/librte_eal/include/generic/rte_prefetch.h line 62
Quoted 7 lines
lib/librte_eal/include/generic/rte_prefetch.h +7
-0+* +* CLDEMOTE hints to hardware to move (demote) a cache line from the +closest to +* the processor to a level more distant from the processor. It is a +hint and +* not guarantee. rte_cldemote is intended to move the cache line to +the more guaranteed*
I will fix this
Quoted 54 lines
Quoted 19 lines
lib/librte_eal/include/generic/rte_prefetch.h +10
-0+* remote cache, where it expects sharing to be efficient and to +indicate that a +* line may be accessed by a different core in the future. +* +* @param p +* Address to demote +*/ +__rte_experimental +static inline void rte_cldemote(const volatile void *p); +#endif /* _RTE_PREFETCH_H_ */ lib/librte_eal/ppc/include/rte_prefetch.h +0
-0lib/librte_eal/ppc/include/rte_prefetch.h
Quoted 8 lines
lib/librte_eal/ppc/include/rte_prefetch.h +2
-0@@ -11,6 +11,7 @@#endif #include <rte_common.h> +#include <rte_compat.h> #include "generic/rte_prefetch.h" static inline void rte_prefetch0(const volatile void *p) @@ -34,6 +35,12 @@ static inline void rte_prefetch_non_temporal(const volatilevoid *p)
Quoted 17 lines
rte_prefetch0(p);}
lib/librte_eal/ppc/include/rte_prefetch.h +5
-0+__rte_experimental +static inline void rte_cldemote(const volatile void *p) { +RTE_SET_USED (p); +} + #ifdef __cplusplus }#endif lib/librte_eal/x86/include/rte_prefetch.h +0
-0lib/librte_eal/x86/include/rte_prefetch.h
Quoted 8 lines
lib/librte_eal/x86/include/rte_prefetch.h +2
-0@@ -10,6 +10,7 @@#endif #include <rte_common.h> +#include <rte_compat.h> #include "generic/rte_prefetch.h" static inline void rte_prefetch0(const volatile void *p) @@ -32,6 +33,16 @@ static inline void rte_prefetch_non_temporal(const volatilevoid *p)
Quoted 7 lines
Quoted 5 lines
asm volatile ("prefetchnta %[p]" : : [p] "m" (*(const volatile
char *)p)); }+/*
+ * we're using raw byte codes for now as only the newest compilerWe use
I will fix this
Quoted 17 lines
Quoted 11 lines
+ * versions support this instruction natively.
+ */lib/librte_eal/x86/include/rte_prefetch.h +4
-1+__rte_experimental +static inline void rte_cldemote(const volatile void *p) { + asmvolatile (".byte 0x0f, 0x1c, 0x06" ::"S" (p)); } + #ifdef __cplusplus }#endif --Quoted 2 lines
1.8.3.1
--
David Marchand
Re: [dpdk-dev] [PATCH v7] eal: add cache-line demote support
Quoted 13 lines · Omkar
Quoted 8 lines
Quoted 8 lines
lib/librte_eal/arm/include/rte_prefetch_32.h +0
-0@@ -10,6 +10,7 @@#endif Quoted 5 lines
lib/librte_eal/arm/include/rte_prefetch_32.h line 13
Quoted 2 lines
lib/librte_eal/arm/include/rte_prefetch_32.h +1
-0#include <rte_common.h> +#include <rte_compat.h> Move
rte_compat.hinclusion from the arch headers to thegeneric/rte_prefetch.hheader only.
Quoted 4 lines
I got below build error if I move
rte_compat.hinclusion from the arch headers to thegeneric/rte_prefetch.hheader only. I will remove it and send out a new patch v8. In file included from../lib/librte_eal/x86/include/rte_prefetch.h:14:0,from ../lib/librte_table/rte_swx_table_em.c:10:
../lib/librte_eal/include/generic/rte_prefetch.h:67:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘static’
Please rebase on main as I took Harry patch which was ready. Thanks.
Signature · 1 line
David Marchand
PATCH v8 1/1 eal: add cache-line demote support
In reply to Omkar MaslekarWe are including this in rte_prefetch.h since it is the most closely related code location.rte_cldemte is similar to a prefetch hint -in reverse
Omkar Maslekar (1):
eal: add cache-line demote support
app/test/test_prefetch.c | 2 ++ doc/guides/rel_notes/release_20_11.rst | 8 ++++++++ lib/librte_eal/arm/include/rte_prefetch_32.h | 5 +++++ lib/librte_eal/arm/include/rte_prefetch_64.h | 5 +++++ lib/librte_eal/include/generic/rte_prefetch.h | 18 ++++++++++++++++++ lib/librte_eal/ppc/include/rte_prefetch.h | 5 +++++ lib/librte_eal/x86/include/rte_prefetch.h | 9 +++++++++ 7 files changed, 52 insertions(+)
Signature · 1 line
1.8.3.1
PATCH v8 1/1 eal: add cache-line demote support
rte_cldemote is similar to a prefetch hint - in reverse. cldemote(addr) enables software to hint to hardware that line is likely to be shared. Useful in core-to-core communications where cache-line is likely to be shared. ARM and PPC implementation is provided with NOP and can be added if any equivalent instructions could be used for implementation on those architectures.
---
v8: removed unnecessary comment in test_prefetch.h
removed header file rte_compat.h from specific arch rearranged sequence in the release notes
fixed coding style in test_prefetch.h and grammar issue in documentation added tag Reviewed-by: Ruifeng Wang <[email protected]>
v7: fixed experimental tag
v6: marked rte_cldemote as experimental
added rte_cldemote call in existing app/test_prefetch.c
v5: documentation updated
fixed formatting issue in release notes
added Acked-by: Bruce Richardson <[email protected]>
*
v4: updated bold text for title and fixed margin in release notes *
v3: fixed warning regarding whitespace
*
v2: documentation updated
---
--- app/test/test_prefetch.c | 2 ++ doc/guides/rel_notes/release_20_11.rst | 8 ++++++++ lib/librte_eal/arm/include/rte_prefetch_32.h | 5 +++++ lib/librte_eal/arm/include/rte_prefetch_64.h | 5 +++++ lib/librte_eal/include/generic/rte_prefetch.h | 18 ++++++++++++++++++ lib/librte_eal/ppc/include/rte_prefetch.h | 5 +++++ lib/librte_eal/x86/include/rte_prefetch.h | 9 +++++++++ 7 files changed, 52 insertions(+)
app/test/test_prefetch.c +2 -0
@@ -30,6 +30,8 @@rte_prefetch1_write (&a);rte_prefetch2_write (&a); +rte_cldemote (&a); +return 0 ; }
doc/guides/rel_notes/release_20_11.rst +8 -0
@@ -68,6 +68,14 @@ New Features which allow the programmer to prefetch a cache line and also indicate the intention to write. +* **Added new function rte_cldemote in rte_prefetch.h.** + + Added a hardware hint CLDEMOTE, which is similar to prefetch in reverse. + CLDEMOTE moves the cache line to the more remote cache, where it expects + sharing to be efficient. Moving the cache line to a level more distant from + the processor helps to accelerate core-to-core communication.This is X86 + specific implementation. + * **Updated CRC modules of the net library.** * Added runtime selection of the optimal architecture-specific CRC path.
lib/librte_eal/arm/include/rte_prefetch_32.h +5 -0
@@ -33,6 +33,11 @@ static inline void rte_prefetch_non_temporal(const volatile void *p)rte_prefetch0 (p); } +static inline void rte_cldemote (const volatile void *p) +{ +RTE_SET_USED (p); +} + #ifdef __cplusplus }#endif
lib/librte_eal/arm/include/rte_prefetch_64.h +5 -0
@@ -32,6 +32,11 @@ static inline void rte_prefetch_non_temporal(const volatile void *p) asmvolatile ("PRFM PLDL1STRM, [%0]" : :"r" (p)); } +static inline void rte_cldemote (const volatile void *p) +{ +RTE_SET_USED (p); +} + #ifdef __cplusplus }#endif
lib/librte_eal/include/generic/rte_prefetch.h +18 -0
@@ -116,4 +116,22 @@ __builtin_prefetch(p, 1, 1); } +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice +* +* Demote a cache line to a more distant level of cache from the processor. +* CLDEMOTE hints to hardware to move (demote) a cache line from the closest to +* the processor to a level more distant from the processor. It is a hint and +* not guaranteed. rte_cldemote is intended to move the cache line to the more +* remote cache, where it expects sharing to be efficient and to indicate that +* a line may be accessed by a different core in the future. +* +* @param p +* Address to demote +*/ +__rte_experimental +static inline void +rte_cldemote (const volatile void *p); +#endif /* _RTE_PREFETCH_H_ */
lib/librte_eal/ppc/include/rte_prefetch.h +5 -0
@@ -34,6 +34,11 @@ static inline void rte_prefetch_non_temporal(const volatile void *p)rte_prefetch0 (p); } +static inline void rte_cldemote (const volatile void *p) +{ +RTE_SET_USED (p); +} + #ifdef __cplusplus }#endif
lib/librte_eal/x86/include/rte_prefetch.h +9 -0
@@ -32,6 +32,15 @@ static inline void rte_prefetch_non_temporal(const volatile void *p) asmvolatile ("prefetchnta %[p]" : : [p]"m" (*(const volatile char *)p)); } +/* +* we use raw byte codes for now as only the newest compiler +* versions support this instruction natively. +*/ +static inline void rte_cldemote (const volatile void *p) +{ + asmvolatile (".byte 0x0f, 0x1c, 0x06" ::"S" (p)); +} + #ifdef __cplusplus }#endif
Signature · 1 line
1.8.3.1
PATCH v9 1/1 eal: add cache-line demote support
In reply to Omkar MaslekarWe are including this in rte_prefetch.h since it is the most closely related code location.rte_cldemte is similar to a prefetch hint -in reverse
Omkar Maslekar (1):
eal: add cache-line demote support
app/test/test_prefetch.c | 2 ++ doc/guides/rel_notes/release_20_11.rst | 8 ++++++++ lib/librte_eal/arm/include/rte_prefetch_32.h | 7 +++++++ lib/librte_eal/arm/include/rte_prefetch_64.h | 7 +++++++ lib/librte_eal/include/generic/rte_prefetch.h | 18 ++++++++++++++++++ lib/librte_eal/ppc/include/rte_prefetch.h | 7 +++++++ lib/librte_eal/x86/include/rte_prefetch.h | 11 +++++++++++ 7 files changed, 60 insertions(+)
Signature · 1 line
1.8.3.1
PATCH v9 1/1 eal: add cache-line demote support
rte_cldemote is similar to a prefetch hint - in reverse. cldemote(addr) enables software to hint to hardware that line is likely to be shared. Useful in core-to-core communications where cache-line is likely to be shared. ARM and PPC implementation is provided with NOP and can be added if any equivalent instructions could be used for implementation on those architectures.
---
v9: added experimental tag in arch specific files
v8: removed unnecessary comment in test_prefetch.h
removed header file rte_compat.h from specific arch rearranged sequence in the release notes
fixed coding style in test_prefetch.h and grammar issue in documentation added tag Reviewed-by: Ruifeng Wang <[email protected]>
v7: fixed experimental tag
v6: marked rte_cldemote as experimental
added rte_cldemote call in existing app/test_prefetch.c
v5: documentation updated
fixed formatting issue in release notes
added Acked-by: Bruce Richardson <[email protected]>
*
v4: updated bold text for title and fixed margin in release notes *
v3: fixed warning regarding whitespace
*
v2: documentation updated
---
--- app/test/test_prefetch.c | 2 ++ doc/guides/rel_notes/release_20_11.rst | 8 ++++++++ lib/librte_eal/arm/include/rte_prefetch_32.h | 7 +++++++ lib/librte_eal/arm/include/rte_prefetch_64.h | 7 +++++++ lib/librte_eal/include/generic/rte_prefetch.h | 18 ++++++++++++++++++ lib/librte_eal/ppc/include/rte_prefetch.h | 7 +++++++ lib/librte_eal/x86/include/rte_prefetch.h | 11 +++++++++++ 7 files changed, 60 insertions(+)
app/test/test_prefetch.c +2 -0
@@ -30,6 +30,8 @@rte_prefetch1_write (&a);rte_prefetch2_write (&a); +rte_cldemote (&a); +return 0 ; }
doc/guides/rel_notes/release_20_11.rst +8 -0
@@ -68,6 +68,14 @@ New Features which allow the programmer to prefetch a cache line and also indicate the intention to write. +* **Added new function rte_cldemote in rte_prefetch.h.** + + Added a hardware hint CLDEMOTE, which is similar to prefetch in reverse. + CLDEMOTE moves the cache line to the more remote cache, where it expects + sharing to be efficient. Moving the cache line to a level more distant from + the processor helps to accelerate core-to-core communication.This is X86 + specific implementation. + * **Updated CRC modules of the net library.** * Added runtime selection of the optimal architecture-specific CRC path.
lib/librte_eal/arm/include/rte_prefetch_32.h +7 -0
@@ -33,6 +33,13 @@ static inline void rte_prefetch_non_temporal(const volatile void *p)rte_prefetch0 (p); } +__rte_experimental +static inline void +rte_cldemote (const volatile void *p) +{ +RTE_SET_USED (p); +} + #ifdef __cplusplus }#endif
lib/librte_eal/arm/include/rte_prefetch_64.h +7 -0
@@ -32,6 +32,13 @@ static inline void rte_prefetch_non_temporal(const volatile void *p) asmvolatile ("PRFM PLDL1STRM, [%0]" : :"r" (p)); } +__rte_experimental +static inline void +rte_cldemote (const volatile void *p) +{ +RTE_SET_USED (p); +} + #ifdef __cplusplus }#endif
lib/librte_eal/include/generic/rte_prefetch.h +18 -0
@@ -116,4 +116,22 @@ __builtin_prefetch(p, 1, 1); } +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice +* +* Demote a cache line to a more distant level of cache from the processor. +* CLDEMOTE hints to hardware to move (demote) a cache line from the closest to +* the processor to a level more distant from the processor. It is a hint and +* not guaranteed. rte_cldemote is intended to move the cache line to the more +* remote cache, where it expects sharing to be efficient and to indicate that +* a line may be accessed by a different core in the future. +* +* @param p +* Address to demote +*/ +__rte_experimental +static inline void +rte_cldemote (const volatile void *p); +#endif /* _RTE_PREFETCH_H_ */
lib/librte_eal/ppc/include/rte_prefetch.h +7 -0
@@ -34,6 +34,13 @@ static inline void rte_prefetch_non_temporal(const volatile void *p)rte_prefetch0 (p); } +__rte_experimental +static inline void +rte_cldemote (const volatile void *p) +{ +RTE_SET_USED (p); +} + #ifdef __cplusplus }#endif
lib/librte_eal/x86/include/rte_prefetch.h +11 -0
@@ -32,6 +32,17 @@ static inline void rte_prefetch_non_temporal(const volatile void *p) asmvolatile ("prefetchnta %[p]" : : [p]"m" (*(const volatile char *)p)); } +/* +* we use raw byte codes for now as only the newest compiler +* versions support this instruction natively. +*/ +__rte_experimental +static inline void +rte_cldemote (const volatile void *p) +{ + asmvolatile (".byte 0x0f, 0x1c, 0x06" ::"S" (p)); +} + #ifdef __cplusplus }#endif
Signature · 1 line
1.8.3.1
David Marchand
AppliedRe: [dpdk-dev] [PATCH v9] eal: add cache-line demote support
Quoted 8 lines · Omkar Maslekar
rte_cldemoteis similar to a prefetch hint - in reverse. cldemote(addr) enables software to hint to hardware that line is likely to be shared. Useful in core-to-core communications where cache-line is likely to be shared. ARM and PPC implementation is provided with NOP and can be added if any equivalent instructions could be used for implementation on those architectures.
Quoted 5 lines
Signed-off-by Omkar Maslekar <[email protected]>Acked-by Bruce Richardson <[email protected]>Acked-by Jerin Jacob <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>
Applied, thanks Omkar.
Signature · 1 line
David Marchand