1245faae90
Quoting from https://github.com/jemalloc/jemalloc/issues/761 : [...] reading the Power ISA documentation[1], the assembly in [the CPU_SPINWAIT macro] isn't correct anyway (as @marxin points out): the setting of the program-priority register is "sticky", and we never undo the lowering. We could do something similar, but given that we don't have testing here in the first place, I'm inclined to simply not try. I'll put something up reverting the problematic commit tomorrow. [1] Book II, chapter 3 of the 2.07B or 3.0B ISA documents.
41 lines
613 B
C
41 lines
613 B
C
#ifndef JEMALLOC_INTERNAL_SPIN_H
|
|
#define JEMALLOC_INTERNAL_SPIN_H
|
|
|
|
#define SPIN_INITIALIZER {0U}
|
|
|
|
typedef struct {
|
|
unsigned iteration;
|
|
} spin_t;
|
|
|
|
static inline void
|
|
spin_cpu_spinwait() {
|
|
# if HAVE_CPU_SPINWAIT
|
|
CPU_SPINWAIT;
|
|
# else
|
|
volatile int x = 0;
|
|
x = x;
|
|
# endif
|
|
}
|
|
|
|
static inline void
|
|
spin_adaptive(spin_t *spin) {
|
|
volatile uint32_t i;
|
|
|
|
if (spin->iteration < 5) {
|
|
for (i = 0; i < (1U << spin->iteration); i++) {
|
|
spin_cpu_spinwait();
|
|
}
|
|
spin->iteration++;
|
|
} else {
|
|
#ifdef _WIN32
|
|
SwitchToThread();
|
|
#else
|
|
sched_yield();
|
|
#endif
|
|
}
|
|
}
|
|
|
|
#undef SPIN_INLINE
|
|
|
|
#endif /* JEMALLOC_INTERNAL_SPIN_H */
|