From patchwork Thu Dec 17 17:19:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tulio Magno Quites Machado Filho X-Patchwork-Id: 10055 Received: (qmail 30091 invoked by alias); 17 Dec 2015 17:19:50 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 30079 invoked by uid 89); 17 Dec 2015 17:19:50 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, T_RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=adapt, adaptive, 20151203, 2015-12-03 X-HELO: e24smtp02.br.ibm.com X-IBM-Helo: d24dlp01.br.ibm.com X-IBM-MailFrom: tuliom@linux.vnet.ibm.com X-IBM-RcptTo: libc-alpha@sourceware.org From: "Tulio Magno Quites Machado Filho" To: libc-alpha@sourceware.org Cc: Paul Murphy Subject: [COMMITTED 2.22] powerpc: Fix usage of elision transient failure adapt param Date: Thu, 17 Dec 2015 15:19:16 -0200 Message-Id: <1450372756-26189-1-git-send-email-tuliom@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15121717-0021-0000-0000-000004805948 From: Paul Murphy The skip_lock_out_of_tbegin_retries adaptive parameter was not being used correctly, nor as described. This prevents a fallback for all users of the lock if a transient abort occurs within the accepted number of retries. [BZ #19174] * sysdeps/powerpc/nptl/elide.h (__elide_lock): Fix usage of .skip_lock_out_of_tbegin_retries. * sysdeps/unix/sysv/linux/powerpc/elision-lock.c (__lll_lock_elision): Likewise, and respect a value of try_tbegin <= 0. (cherry picked from commit 72f1463df85a522bfd1568e47bd81371522ee358) Conflicts: NEWS --- ChangeLog | 9 +++++++++ NEWS | 2 +- sysdeps/powerpc/nptl/elide.h | 6 +++--- sysdeps/unix/sysv/linux/powerpc/elision-lock.c | 15 ++++++--------- 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5c92a3e..d96d6ef 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2015-12-17 Paul E. Murphy + + [BZ #19174] + * sysdeps/powerpc/nptl/elide.h (__elide_lock): Fix usage of + .skip_lock_out_of_tbegin_retries. + * sysdeps/unix/sysv/linux/powerpc/elision-lock.c + (__lll_lock_elision): Likewise, and respect a value of + try_tbegin <= 0. + 2015-12-03 Andrew Senkevich * math/Makefile ($(inst_libdir)/libm.so): Corrected path to diff --git a/NEWS b/NEWS index e100318..e1c1e58 100644 --- a/NEWS +++ b/NEWS @@ -10,7 +10,7 @@ Version 2.22.1 * The following bugs are resolved with this release: 18589, 18743, 18778, 18781, 18787, 18796, 18870, 18887, 18921, 18928, - 18969, 19018, 19058, 19178. + 18969, 19018, 19058, 19174, 19178. * The LD_POINTER_GUARD environment variable can no longer be used to disable the pointer guard feature. It is always enabled. diff --git a/sysdeps/powerpc/nptl/elide.h b/sysdeps/powerpc/nptl/elide.h index 12171f4..2e1e443 100644 --- a/sysdeps/powerpc/nptl/elide.h +++ b/sysdeps/powerpc/nptl/elide.h @@ -27,7 +27,7 @@ configurations. Returns true if the system should retry again or false otherwise. */ static inline bool -__get_new_count (uint8_t *adapt_count) +__get_new_count (uint8_t *adapt_count, int attempt) { /* A persistent failure indicates that a retry will probably result in another failure. Use normal locking now and @@ -40,7 +40,7 @@ __get_new_count (uint8_t *adapt_count) } /* Same logic as above, but for a number of temporary failures in a a row. */ - else if (__elision_aconf.skip_lock_out_of_tbegin_retries > 0 + else if (attempt <= 1 && __elision_aconf.skip_lock_out_of_tbegin_retries > 0 && __elision_aconf.try_tbegin > 0) *adapt_count = __elision_aconf.skip_lock_out_of_tbegin_retries; return true; @@ -78,7 +78,7 @@ __get_new_count (uint8_t *adapt_count) __builtin_tabort (_ABORT_LOCK_BUSY); \ } \ else \ - if (!__get_new_count(&adapt_count)) \ + if (!__get_new_count (&adapt_count,i)) \ break; \ } \ ret; \ diff --git a/sysdeps/unix/sysv/linux/powerpc/elision-lock.c b/sysdeps/unix/sysv/linux/powerpc/elision-lock.c index 7f9bcc2..c6731ca 100644 --- a/sysdeps/unix/sysv/linux/powerpc/elision-lock.c +++ b/sysdeps/unix/sysv/linux/powerpc/elision-lock.c @@ -72,8 +72,7 @@ __lll_lock_elision (int *lock, short *adapt_count, EXTRAARG int pshared) goto use_lock; } - int try_begin = aconf.try_tbegin; - while (1) + for (int i = aconf.try_tbegin; i > 0; i--) { if (__builtin_tbegin (0)) { @@ -87,21 +86,19 @@ __lll_lock_elision (int *lock, short *adapt_count, EXTRAARG int pshared) /* A persistent failure indicates that a retry will probably result in another failure. Use normal locking now and for the next couple of calls. */ - if (try_begin-- <= 0 - || _TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ())) + if (_TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ())) { if (aconf.skip_lock_internal_abort > 0) *adapt_count = aconf.skip_lock_internal_abort; goto use_lock; } - /* Same logic as above, but for for a number of temporary failures - in a row. */ - else if (aconf.skip_lock_out_of_tbegin_retries > 0 - && aconf.try_tbegin > 0) - *adapt_count = aconf.skip_lock_out_of_tbegin_retries; } } + /* Fall back to locks for a bit if retries have been exhausted */ + if (aconf.try_tbegin > 0 && aconf.skip_lock_out_of_tbegin_retries > 0) + *adapt_count = aconf.skip_lock_out_of_tbegin_retries; + use_lock: return LLL_LOCK ((*lock), pshared); }