Update copyright dates with scripts/update-copyrights.
[glibc.git] / sysdeps / unix / sysv / linux / powerpc / elision-conf.c
blobf631f0a035146640c36a9911eb30b9b1a53c00c9
1 /* elision-conf.c: Lock elision tunable parameters.
2 Copyright (C) 2015-2017 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
19 #include "config.h"
20 #include <pthreadP.h>
21 #include <elision-conf.h>
22 #include <unistd.h>
23 #include <dl-procinfo.h>
25 /* Reasonable initial tuning values, may be revised in the future.
26 This is a conservative initial value. */
28 struct elision_config __elision_aconf =
30 /* How many times to use a non-transactional lock after a transactional
31 failure has occurred because the lock is already acquired. Expressed
32 in number of lock acquisition attempts. */
33 .skip_lock_busy = 3,
34 /* How often to not attempt to use elision if a transaction aborted due
35 to reasons other than other threads' memory accesses. Expressed in
36 number of lock acquisition attempts. */
37 .skip_lock_internal_abort = 3,
38 /* How often to not attempt to use elision if a lock used up all retries
39 without success. Expressed in number of lock acquisition attempts. */
40 .skip_lock_out_of_tbegin_retries = 3,
41 /* How often we retry using elision if there is chance for the transaction
42 to finish execution (e.g., it wasn't aborted due to the lock being
43 already acquired. */
44 .try_tbegin = 3,
45 /* Same as SKIP_LOCK_INTERNAL_ABORT but for trylock. */
46 .skip_trylock_internal_abort = 3,
49 /* Force elision for all new locks. This is used to decide whether existing
50 DEFAULT locks should be automatically use elision in pthread_mutex_lock().
51 Disabled for suid programs. Only used when elision is available. */
53 int __pthread_force_elision attribute_hidden;
55 /* Initialize elision. */
57 static void
58 elision_init (int argc __attribute__ ((unused)),
59 char **argv __attribute__ ((unused)),
60 char **environ)
62 #ifdef ENABLE_LOCK_ELISION
63 int elision_available = (GLRO (dl_hwcap2) & PPC_FEATURE2_HAS_HTM) ? 1 : 0;
64 __pthread_force_elision = __libc_enable_secure ? 0 : elision_available;
65 #endif
66 if (!__pthread_force_elision)
67 /* Disable elision on rwlocks. */
68 __elision_aconf.try_tbegin = 0;
71 #ifdef SHARED
72 # define INIT_SECTION ".init_array"
73 # define MAYBE_CONST
74 #else
75 # define INIT_SECTION ".preinit_array"
76 # define MAYBE_CONST const
77 #endif
79 void (*MAYBE_CONST __pthread_init_array []) (int, char **, char **)
80 __attribute__ ((section (INIT_SECTION), aligned (sizeof (void *)))) =
82 &elision_init