@@ -7,6 +7,7 @@
#include <stdlib.h>
#include <rte_memcpy.h>
+#include <rte_stdatomic.h>
#include <rte_string_fns.h>
#include "power_acpi_cpufreq.h"
@@ -41,13 +42,13 @@ enum power_state {
* Power info per lcore.
*/
struct acpi_power_info {
- unsigned int lcore_id; /**< Logical core id */
+ unsigned int lcore_id; /**< Logical core id */
uint32_t freqs[RTE_MAX_LCORE_FREQS]; /**< Frequency array */
uint32_t nb_freqs; /**< number of available freqs */
FILE *f; /**< FD of scaling_setspeed */
char governor_ori[32]; /**< Original governor name */
uint32_t curr_idx; /**< Freq index in freqs array */
- uint32_t state; /**< Power in use state */
+ RTE_ATOMIC(uint32_t) state; /**< Power in use state */
uint16_t turbo_available; /**< Turbo Boost available */
uint16_t turbo_enable; /**< Turbo Boost enable/disable */
} __rte_cache_aligned;
@@ -249,9 +250,9 @@ struct acpi_power_info {
* ordering below as lock to make sure the frequency operations
* in the critical section are done under the correct state.
*/
- if (!__atomic_compare_exchange_n(&(pi->state), &exp_state,
- POWER_ONGOING, 0,
- __ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) {
+ if (!rte_atomic_compare_exchange_strong_explicit(&(pi->state), &exp_state,
+ POWER_ONGOING,
+ rte_memory_order_acquire, rte_memory_order_relaxed)) {
RTE_LOG(INFO, POWER, "Power management of lcore %u is "
"in use\n", lcore_id);
return -1;
@@ -289,15 +290,15 @@ struct acpi_power_info {
RTE_LOG(INFO, POWER, "Initialized successfully for lcore %u "
"power management\n", lcore_id);
exp_state = POWER_ONGOING;
- __atomic_compare_exchange_n(&(pi->state), &exp_state, POWER_USED,
- 0, __ATOMIC_RELEASE, __ATOMIC_RELAXED);
+ rte_atomic_compare_exchange_strong_explicit(&(pi->state), &exp_state, POWER_USED,
+ rte_memory_order_release, rte_memory_order_relaxed);
return 0;
fail:
exp_state = POWER_ONGOING;
- __atomic_compare_exchange_n(&(pi->state), &exp_state, POWER_UNKNOWN,
- 0, __ATOMIC_RELEASE, __ATOMIC_RELAXED);
+ rte_atomic_compare_exchange_strong_explicit(&(pi->state), &exp_state, POWER_UNKNOWN,
+ rte_memory_order_release, rte_memory_order_relaxed);
return -1;
}
@@ -321,9 +322,9 @@ struct acpi_power_info {
* ordering below as lock to make sure the frequency operations
* in the critical section are done under the correct state.
*/
- if (!__atomic_compare_exchange_n(&(pi->state), &exp_state,
- POWER_ONGOING, 0,
- __ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) {
+ if (!rte_atomic_compare_exchange_strong_explicit(&(pi->state), &exp_state,
+ POWER_ONGOING,
+ rte_memory_order_acquire, rte_memory_order_relaxed)) {
RTE_LOG(INFO, POWER, "Power management of lcore %u is "
"not used\n", lcore_id);
return -1;
@@ -344,15 +345,15 @@ struct acpi_power_info {
"'userspace' mode and been set back to the "
"original\n", lcore_id);
exp_state = POWER_ONGOING;
- __atomic_compare_exchange_n(&(pi->state), &exp_state, POWER_IDLE,
- 0, __ATOMIC_RELEASE, __ATOMIC_RELAXED);
+ rte_atomic_compare_exchange_strong_explicit(&(pi->state), &exp_state, POWER_IDLE,
+ rte_memory_order_release, rte_memory_order_relaxed);
return 0;
fail:
exp_state = POWER_ONGOING;
- __atomic_compare_exchange_n(&(pi->state), &exp_state, POWER_UNKNOWN,
- 0, __ATOMIC_RELEASE, __ATOMIC_RELAXED);
+ rte_atomic_compare_exchange_strong_explicit(&(pi->state), &exp_state, POWER_UNKNOWN,
+ rte_memory_order_release, rte_memory_order_relaxed);
return -1;
}
@@ -6,6 +6,7 @@
#include <stdlib.h>
#include <rte_memcpy.h>
+#include <rte_stdatomic.h>
#include "power_cppc_cpufreq.h"
#include "power_common.h"
@@ -49,8 +50,8 @@ enum power_state {
* Power info per lcore.
*/
struct cppc_power_info {
- unsigned int lcore_id; /**< Logical core id */
- uint32_t state; /**< Power in use state */
+ unsigned int lcore_id; /**< Logical core id */
+ RTE_ATOMIC(uint32_t) state; /**< Power in use state */
FILE *f; /**< FD of scaling_setspeed */
char governor_ori[32]; /**< Original governor name */
uint32_t curr_idx; /**< Freq index in freqs array */
@@ -353,9 +354,9 @@ struct cppc_power_info {
* ordering below as lock to make sure the frequency operations
* in the critical section are done under the correct state.
*/
- if (!__atomic_compare_exchange_n(&(pi->state), &exp_state,
- POWER_ONGOING, 0,
- __ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) {
+ if (!rte_atomic_compare_exchange_strong_explicit(&(pi->state), &exp_state,
+ POWER_ONGOING,
+ rte_memory_order_acquire, rte_memory_order_relaxed)) {
RTE_LOG(INFO, POWER, "Power management of lcore %u is "
"in use\n", lcore_id);
return -1;
@@ -393,12 +394,12 @@ struct cppc_power_info {
RTE_LOG(INFO, POWER, "Initialized successfully for lcore %u "
"power management\n", lcore_id);
- __atomic_store_n(&(pi->state), POWER_USED, __ATOMIC_RELEASE);
+ rte_atomic_store_explicit(&(pi->state), POWER_USED, rte_memory_order_release);
return 0;
fail:
- __atomic_store_n(&(pi->state), POWER_UNKNOWN, __ATOMIC_RELEASE);
+ rte_atomic_store_explicit(&(pi->state), POWER_UNKNOWN, rte_memory_order_release);
return -1;
}
@@ -431,9 +432,9 @@ struct cppc_power_info {
* ordering below as lock to make sure the frequency operations
* in the critical section are done under the correct state.
*/
- if (!__atomic_compare_exchange_n(&(pi->state), &exp_state,
- POWER_ONGOING, 0,
- __ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) {
+ if (!rte_atomic_compare_exchange_strong_explicit(&(pi->state), &exp_state,
+ POWER_ONGOING,
+ rte_memory_order_acquire, rte_memory_order_relaxed)) {
RTE_LOG(INFO, POWER, "Power management of lcore %u is "
"not used\n", lcore_id);
return -1;
@@ -453,12 +454,12 @@ struct cppc_power_info {
RTE_LOG(INFO, POWER, "Power management of lcore %u has exited from "
"'userspace' mode and been set back to the "
"original\n", lcore_id);
- __atomic_store_n(&(pi->state), POWER_IDLE, __ATOMIC_RELEASE);
+ rte_atomic_store_explicit(&(pi->state), POWER_IDLE, rte_memory_order_release);
return 0;
fail:
- __atomic_store_n(&(pi->state), POWER_UNKNOWN, __ATOMIC_RELEASE);
+ rte_atomic_store_explicit(&(pi->state), POWER_UNKNOWN, rte_memory_order_release);
return -1;
}
@@ -12,6 +12,7 @@
#include <inttypes.h>
#include <rte_memcpy.h>
+#include <rte_stdatomic.h>
#include "rte_power_pmd_mgmt.h"
#include "power_pstate_cpufreq.h"
@@ -59,7 +60,7 @@ struct pstate_power_info {
uint32_t non_turbo_max_ratio; /**< Non Turbo Max ratio */
uint32_t sys_max_freq; /**< system wide max freq */
uint32_t core_base_freq; /**< core base freq */
- uint32_t state; /**< Power in use state */
+ RTE_ATOMIC(uint32_t) state; /**< Power in use state */
uint16_t turbo_available; /**< Turbo Boost available */
uint16_t turbo_enable; /**< Turbo Boost enable/disable */
uint16_t priority_core; /**< High Performance core */
@@ -555,9 +556,9 @@ struct pstate_power_info {
* ordering below as lock to make sure the frequency operations
* in the critical section are done under the correct state.
*/
- if (!__atomic_compare_exchange_n(&(pi->state), &exp_state,
- POWER_ONGOING, 0,
- __ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) {
+ if (!rte_atomic_compare_exchange_strong_explicit(&(pi->state), &exp_state,
+ POWER_ONGOING,
+ rte_memory_order_acquire, rte_memory_order_relaxed)) {
RTE_LOG(INFO, POWER, "Power management of lcore %u is "
"in use\n", lcore_id);
return -1;
@@ -600,15 +601,15 @@ struct pstate_power_info {
RTE_LOG(INFO, POWER, "Initialized successfully for lcore %u "
"power management\n", lcore_id);
exp_state = POWER_ONGOING;
- __atomic_compare_exchange_n(&(pi->state), &exp_state, POWER_USED,
- 0, __ATOMIC_RELEASE, __ATOMIC_RELAXED);
+ rte_atomic_compare_exchange_strong_explicit(&(pi->state), &exp_state, POWER_USED,
+ rte_memory_order_release, rte_memory_order_relaxed);
return 0;
fail:
exp_state = POWER_ONGOING;
- __atomic_compare_exchange_n(&(pi->state), &exp_state, POWER_UNKNOWN,
- 0, __ATOMIC_RELEASE, __ATOMIC_RELAXED);
+ rte_atomic_compare_exchange_strong_explicit(&(pi->state), &exp_state, POWER_UNKNOWN,
+ rte_memory_order_release, rte_memory_order_relaxed);
return -1;
}
@@ -633,9 +634,9 @@ struct pstate_power_info {
* ordering below as lock to make sure the frequency operations
* in the critical section are under done the correct state.
*/
- if (!__atomic_compare_exchange_n(&(pi->state), &exp_state,
- POWER_ONGOING, 0,
- __ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) {
+ if (!rte_atomic_compare_exchange_strong_explicit(&(pi->state), &exp_state,
+ POWER_ONGOING,
+ rte_memory_order_acquire, rte_memory_order_relaxed)) {
RTE_LOG(INFO, POWER, "Power management of lcore %u is "
"not used\n", lcore_id);
return -1;
@@ -658,15 +659,15 @@ struct pstate_power_info {
"'performance' mode and been set back to the "
"original\n", lcore_id);
exp_state = POWER_ONGOING;
- __atomic_compare_exchange_n(&(pi->state), &exp_state, POWER_IDLE,
- 0, __ATOMIC_RELEASE, __ATOMIC_RELAXED);
+ rte_atomic_compare_exchange_strong_explicit(&(pi->state), &exp_state, POWER_IDLE,
+ rte_memory_order_release, rte_memory_order_relaxed);
return 0;
fail:
exp_state = POWER_ONGOING;
- __atomic_compare_exchange_n(&(pi->state), &exp_state, POWER_UNKNOWN,
- 0, __ATOMIC_RELEASE, __ATOMIC_RELAXED);
+ rte_atomic_compare_exchange_strong_explicit(&(pi->state), &exp_state, POWER_UNKNOWN,
+ rte_memory_order_release, rte_memory_order_relaxed);
return -1;
}