From: EXT Bill Fischofer [mailto:[email protected]]
Sent: Tuesday, January 05, 2016 8:01 PM
To: Savolainen, Petri (Nokia - FI/Espoo)
Cc: LNG ODP Mailman List
Subject: Re: [lng-odp] [API-NEXT PATCH 5/5] linux-generic: removed spin_internal
diff --git a/platform/linux-generic/odp_barrier.c
b/platform/linux-generic/odp_barrier.c
index 53d83c0..0bfc0f0 100644
--- a/platform/linux-generic/odp_barrier.c
+++ b/platform/linux-generic/odp_barrier.c
@@ -6,7 +6,7 @@
#include <odp/barrier.h>
#include <odp/sync.h>
-#include <odp_spin_internal.h>
+#include <odp/cpu.h>
#include <odp_atomic_internal.h>
void odp_barrier_init(odp_barrier_t *barrier, int count)
@@ -43,7 +43,7 @@ void odp_barrier_wait(odp_barrier_t *barrier)
} else {
while ((odp_atomic_load_u32(&barrier->bar) < barrier->count)
== wasless)
- odp_spin();
+ odp_cpu_pause();
Why wouldn't you just want to change the implementation of odp_spin() to use
the pause instruction here? These are spin lock waits but nowhere does ODP
specify that spins must be implemented inefficiently.
Since odp_cpu_pause() is intended for exactly this use case, it’s better to use
the call also internally to highlight the correct usage (and eat our own dog
food).
The implementation is arch specific (“pause” vs. “nop” vs. empty). For example,
on multi-core x86 “pause” improves lock performance since CPUs are not
stressing the interconnect at 100% speed. Pause instruction was designed for
this use case.
-Petri
}
_ODP_FULL_BARRIER();
_______________________________________________
lng-odp mailing list
[email protected]
https://lists.linaro.org/mailman/listinfo/lng-odp