]>
Commit | Line | Data |
---|---|---|
1cdbe579 AK |
1 | /* elision-conf.c: Lock elision tunable parameters. |
2 | Copyright (C) 2013 Free Software Foundation, Inc. | |
3 | This file is part of the GNU C Library. | |
4 | ||
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. | |
9 | ||
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. | |
14 | ||
15 | You should have received a copy of the GNU Lesser General Public | |
16 | License along with the GNU C Library; if not, see | |
075b9322 | 17 | <http://www.gnu.org/licenses/>. */ |
1cdbe579 | 18 | |
1717da59 | 19 | #include "config.h" |
1cdbe579 AK |
20 | #include <pthreadP.h> |
21 | #include <init-arch.h> | |
22 | #include <elision-conf.h> | |
23 | #include <unistd.h> | |
24 | ||
25 | /* Reasonable initial tuning values, may be revised in the future. | |
26 | This is a conservative initial value. */ | |
27 | ||
28 | struct elision_config __elision_aconf = | |
29 | { | |
30 | /* How often to not attempt to use elision if a transaction aborted | |
31 | because the lock is already acquired. Expressed in number of lock | |
32 | acquisition attempts. */ | |
33 | .skip_lock_busy = 3, | |
34 | /* How often to not attempt to use elision if a transaction aborted due | |
075b9322 | 35 | to reasons other than other threads' memory accesses. Expressed in |
1cdbe579 AK |
36 | number of lock acquisition attempts. */ |
37 | .skip_lock_internal_abort = 3, | |
38 | /* How often we retry using elision if there is chance for the transaction | |
39 | to finish execution (e.g., it wasn't aborted due to the lock being | |
40 | already acquired. */ | |
41 | .retry_try_xbegin = 3, | |
42 | /* Same as SKIP_LOCK_INTERNAL_ABORT but for trylock. */ | |
43 | .skip_trylock_internal_abort = 3, | |
44 | }; | |
45 | ||
075b9322 DV |
46 | /* Set when the CPU supports elision. When false elision is never attempted. |
47 | */ | |
1cdbe579 AK |
48 | |
49 | int __elision_available attribute_hidden; | |
50 | ||
075b9322 | 51 | /* Force elision for all new locks. This is used to decide whether existing |
1cdbe579 | 52 | DEFAULT locks should be automatically upgraded to elision in |
075b9322 | 53 | pthread_mutex_lock(). Disabled for suid programs. Only used when elision |
1cdbe579 AK |
54 | is available. */ |
55 | ||
56 | int __pthread_force_elision attribute_hidden; | |
57 | ||
58 | /* Initialize elison. */ | |
59 | ||
60 | static void | |
61 | elision_init (int argc __attribute__ ((unused)), | |
62 | char **argv __attribute__ ((unused)), | |
63 | char **environ) | |
64 | { | |
65 | __elision_available = HAS_RTM; | |
1717da59 | 66 | #ifdef ENABLE_LOCK_ELISION |
1cdbe579 | 67 | __pthread_force_elision = __libc_enable_secure ? 0 : __elision_available; |
1717da59 | 68 | #endif |
1cdbe579 AK |
69 | } |
70 | ||
71 | #ifdef SHARED | |
72 | # define INIT_SECTION ".init_array" | |
73 | #else | |
74 | # define INIT_SECTION ".preinit_array" | |
75 | #endif | |
76 | ||
77 | void (*const __pthread_init_array []) (int, char **, char **) | |
78 | __attribute__ ((section (INIT_SECTION), aligned (sizeof (void *)))) = | |
79 | { | |
80 | &elision_init | |
81 | }; |