Skip to content

Commit

Permalink
linux-gen: ticketlock: enable WFE on aarch64
Browse files Browse the repository at this point in the history
Use WFE instruction on aarch64 to replace ISB instrution, making
threads waiting for their turn into low-power state. Performance
test with "odp_lock_perf" shows that it could reduce IPC while
maintain similar performance.

Signed-off-by: Fan Hong <fan.hong@arm.com>
  • Loading branch information
FanHong674 committed Nov 6, 2023
1 parent d17da1d commit bb9398d
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions platform/linux-generic/include/odp/api/plat/ticketlock_inlines.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
#ifndef _ODP_PLAT_TICKETLOCK_INLINES_H_
#define _ODP_PLAT_TICKETLOCK_INLINES_H_

#if defined(__aarch64__)
#include <odp_cpu.h>
#endif

#include <odp/api/atomic.h>
#include <odp/api/cpu.h>

Expand Down Expand Up @@ -47,8 +51,15 @@ _ODP_INLINE void odp_ticketlock_lock(odp_ticketlock_t *ticketlock)

/* Spin waiting for our turn. Use load-acquire so that we acquire
* all stores from the previous lock owner */
while (ticket != odp_atomic_load_acq_u32(&ticketlock->cur_ticket))
odp_cpu_pause();
#ifdef CONFIG_WFE
sevl();
while (wfe() && ticket !=
monitor32((uint32_t *)&ticketlock->cur_ticket, __ATOMIC_ACQUIRE)) {
}
#else
while (ticket != odp_atomic_load_acq_u32(&ticketlock->cur_ticket))
odp_cpu_pause();
#endif
}

_ODP_INLINE int odp_ticketlock_trylock(odp_ticketlock_t *tklock)
Expand Down

0 comments on commit bb9398d

Please sign in to comment.