1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-12-24 17:51:17 +03:00

S390: Use new __libc_tbegin_retry macro in elision-lock.c.

This patch implements __libc_tbegin_retry macro which is equivalent to
gcc builtin __builtin_tbegin_retry, except the changes which were applied
to __libc_tbegin in the previous patch.

If tbegin aborts with _HTM_TBEGIN_TRANSIENT.  Then this macros restores
the fpc, fprs and automatically retries up to retry_cnt tbegins.
Further saving of the state is omitted as it is already saved in the
first round.  Before retrying a further transaction, the
transaction-abort-assist instruction is used to support the cpu.

This macro is now used in function __lll_lock_elision.

ChangeLog:

	* sysdeps/unix/sysv/linux/s390/htm.h(__libc_tbegin_retry): New macro.
	* sysdeps/unix/sysv/linux/s390/elision-lock.c (__lll_lock_elision):
	Use __libc_tbegin_retry macro.
This commit is contained in:
Stefan Liebler
2016-12-20 15:12:48 +01:00
parent 8bfc4a2ab4
commit 53c5c3d5ac
3 changed files with 64 additions and 28 deletions

View File

@@ -69,7 +69,36 @@
started. Thus the user of the tbegin macros in this header file has to
compile the file / function with -msoft-float. It prevents gcc from using
fprs / vrs. */
#define __libc_tbegin(tdb) \
#define __libc_tbegin(tdb) __libc_tbegin_base(tdb,,,)
#define __libc_tbegin_retry_output_regs , [R_TX_CNT] "+&d" (__tx_cnt)
#define __libc_tbegin_retry_input_regs(retry_cnt) , [R_RETRY] "d" (retry_cnt)
#define __libc_tbegin_retry_abort_path_insn \
/* If tbegin returned _HTM_TBEGIN_TRANSIENT, retry immediately so \
that max tbegin_cnt transactions are tried. Otherwise return and \
let the caller of this macro do the fallback path. */ \
" jnh 1f\n\t" /* cc 1/3: jump to fallback path. */ \
/* tbegin returned _HTM_TBEGIN_TRANSIENT: retry with transaction. */ \
" crje %[R_TX_CNT], %[R_RETRY], 1f\n\t" /* Reached max retries? */ \
" ahi %[R_TX_CNT], 1\n\t" \
" ppa %[R_TX_CNT], 0, 1\n\t" /* Transaction-Abort Assist. */ \
" j 2b\n\t" /* Loop to tbegin. */
/* Same as __libc_tbegin except if tbegin aborts with _HTM_TBEGIN_TRANSIENT.
Then this macros restores the fpc, fprs and automatically retries up to
retry_cnt tbegins. Further saving of the state is omitted as it is already
saved. This macro calls tbegin at most as retry_cnt + 1 times. */
#define __libc_tbegin_retry(tdb, retry_cnt) \
({ int __ret; \
int __tx_cnt = 0; \
__ret = __libc_tbegin_base(tdb, \
__libc_tbegin_retry_abort_path_insn, \
__libc_tbegin_retry_output_regs, \
__libc_tbegin_retry_input_regs(retry_cnt)); \
__ret; \
})
#define __libc_tbegin_base(tdb, abort_path_insn, output_regs, input_regs) \
({ int __ret; \
int __fpc; \
char __fprs[TX_FPRS_BYTES]; \
@@ -95,7 +124,7 @@
again and result in a core dump wich does \
now show at tbegin but the real executed \
instruction. */ \
" tbegin 0, 0xFF0E\n\t" \
"2: tbegin 0, 0xFF0E\n\t" \
/* Branch away in abort case (this is the \
prefered sequence. See PoP in chapter 5 \
Transactional-Execution Facility \
@@ -111,11 +140,14 @@
" srl %[R_RET], 28\n\t" \
" sfpc %[R_FPC]\n\t" \
TX_RESTORE_FPRS \
abort_path_insn \
"1:\n\t" \
".machine pop\n" \
: [R_RET] "=&d" (__ret), \
[R_FPC] "=&d" (__fpc) \
output_regs \
: [R_FPRS] "a" (__fprs) \
input_regs \
: "cc", "memory"); \
__ret; \
})