-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
linux-gen: ticketlock: enable WFE on aarch64
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
1 parent
53388ca
commit f20bf61
Showing
5 changed files
with
89 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
platform/linux-generic/arch/aarch64/odp/api/abi/ticketlock_inlines.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* Copyright (c) 2016-2018, Linaro Limited | ||
* Copyright (c) 2021, Nokia | ||
* All rights reserved. | ||
* | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*/ | ||
|
||
/** | ||
* @file | ||
* | ||
* ODP Ticketlock inline functions | ||
*/ | ||
#ifndef ODP_API_ABI_TICKETLOCK_INLINES_H_ | ||
#define ODP_API_ABI_TICKETLOCK_INLINES_H_ | ||
|
||
static inline uint32_t monitorll32(uint32_t *var, int mm) | ||
{ | ||
uint32_t old; | ||
|
||
if (mm == __ATOMIC_ACQUIRE) | ||
__asm__ volatile("ldaxr %w0, [%1]" | ||
: "=&r" (old) | ||
: "r" (var) | ||
: "memory"); | ||
else if (mm == __ATOMIC_RELAXED) | ||
__asm__ volatile("ldxr %w0, [%1]" | ||
: "=&r" (old) | ||
: "r" (var) | ||
: ); | ||
return old; | ||
} | ||
|
||
static inline void | ||
_odp_wait_until_equal_32(uint32_t expected, uint32_t *addr, int memorder) | ||
{ | ||
uint32_t value; | ||
|
||
__asm__ volatile("sevl" : : : ); | ||
do { | ||
__asm__ volatile("wfe" : : : ); | ||
value = monitorll32(addr, memorder); | ||
} while (expected != value); | ||
} | ||
|
||
#endif |
19 changes: 19 additions & 0 deletions
19
platform/linux-generic/arch/default/odp/api/abi/ticketlock_generic.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* Copyright (c) 2021, ARM Limited | ||
* Copyright (c) 2021-2022, Nokia | ||
* All rights reserved. | ||
* | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*/ | ||
|
||
#ifndef ODP_API_ABI_TICKETLOCK_GENERIC_H_ | ||
#define ODP_API_ABI_TICKETLOCK_GENERIC_H_ | ||
#include <odp/api/ticketlock.h> | ||
|
||
static inline void | ||
_odp_wait_until_equal_32(uint32_t expected, uint32_t *addr, int memorder) | ||
{ | ||
while (expected != __atomic_load_n(addr, memorder)) | ||
odp_cpu_pause(); | ||
} | ||
|
||
#endif |
7 changes: 7 additions & 0 deletions
7
platform/linux-generic/arch/default/odp/api/abi/ticketlock_inlines.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* Copyright (c) 2021, Nokia | ||
* All rights reserved. | ||
* | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*/ | ||
|
||
#include <odp/api/abi/ticketlock_generic.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters