-
Notifications
You must be signed in to change notification settings - Fork 140
[PATCH v2] linux-gen: cpu_pause: added wfet instruction along with isb #2257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -199,6 +199,17 @@ if test "x$enable_host_optimization" = "xno" ; then | |
| ARCH_ABI=default-linux | ||
| fi | ||
|
|
||
| AC_ARG_ENABLE([wfxt-cpu-pause], | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ODP pull requests are not supposed to contain merge commits as ODP development in this repository is based on rebases and linear commit history. So could you please rebase your branch on top of the latest master instead of merging it. |
||
| [AS_HELP_STRING([--enable-wfxt-cpu-pause], | ||
| [Enable WFXT support in cpu_pause code])], | ||
| [enable_wfxt_cpu_pause=$enableval], | ||
| [enable_wfxt_cpu_pause=no]) | ||
| AM_CONDITIONAL([ENABLE_WFXT_CPU_PAUSE], [test "x$enable_wfxt_cpu_pause" = "xyes"]) | ||
|
|
||
| if test "x$enable_wfxt_cpu_pause" = "xyes"; then | ||
| AC_DEFINE([ENABLE_WFXT_CPU_PAUSE], [1], [Enable WFXT in cpu_pause]) | ||
| fi | ||
|
|
||
| ########################################################################## | ||
| # Warn on the defaults if arch is undefined | ||
| ########################################################################## | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ | |
| #define ODP_ARCH_CPU_INLINES_H_ | ||
|
|
||
| #include <odp/api/abi/time_cpu.h> | ||
| #include <odp/autoheader_build.h> | ||
|
|
||
| #include <stdint.h> | ||
|
|
||
|
|
@@ -28,12 +29,17 @@ extern _odp_cpu_cycles_global_t _odp_cpu_cycles_glob; | |
|
|
||
| static inline void _odp_cpu_pause(void) | ||
| { | ||
| #if defined(ENABLE_WFXT_CPU_PAUSE) && defined(__ARM_FEATURE_WFXT) | ||
| __asm__ volatile("sevl" : : : "memory"); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is the SEVL done here? Doesn't is basically defeat the purpose of the following WFET as the WFET would wake immediately and not wait for the timeout? If the SEVL is intentional and serves a purpose, then maybe that could be explained in a comment, unless it is just me who cannot see it. But if the SEVL stays, then why WFET instead of just WFE which would be available in much earlier arch levels? |
||
| __asm__ volatile("wfet %x0" : : "r"(100) : "memory"); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why the delay is 100? I presume the unit is clock cycles. The constant could be defined as a macro outside the inline asm and have some comment about why the particular value is selected. I wonder if the timeout of 100 cycles adds too much unwanted latency in some uses of odp_cpu_pause(). odp_cpu_pause() is being used in quite many places in the linux-gen ODP implementation. It appears that many of the call sites could use WFE through _odp_wait_until_equal_acq_u32() so that they would not spin unnecessarily and would resume with lower latency when ready. Maybe many of the call sites should first be changed before making them use WFET through the odp_cpu_pause() call? |
||
| #else | ||
| /* YIELD hints the CPU to switch to another thread if possible | ||
| * and executes as a NOP otherwise. | ||
| * ISB flushes the pipeline, then restarts. This is guaranteed to | ||
| * stall the CPU a number of cycles. | ||
| */ | ||
| __asm volatile("isb" ::: "memory"); | ||
| #endif | ||
| } | ||
|
|
||
| static inline uint64_t _odp_cpu_cycles(void) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The commit message could be improved: