1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-29 11:41:21 +03:00

tunables, aarch64: New tunable to override cpu

Add a new tunable (glibc.tune.cpu) to override CPU identification on
aarch64.  This is useful in two cases: one where it is desirable to
pretend to be another CPU for purposes of testing or because routines
written for that CPU are beneficial for specific workloads and second
where the underlying kernel does not support emulation of MRS to get
the MIDR of the CPU.

	* elf/dl-tunables.h (tunable_is_name): Move from...
	* elf/dl-tunables.c (is_name): ... here.
	(parse_tunables, __tunables_init): Adjust.
	* manual/tunables.texi: Document glibc.tune.cpu.
	* sysdeps/aarch64/dl-tunables.list: New file.
	* sysdeps/unix/sysv/linux/aarch64/cpu-features.c (struct
	cpu_list): New type.
	(cpu_list): New list of CPU names and their MIDR.
	(get_midr_from_mcpu): New function.
	(init_cpu_features): Override MIDR if necessary.
This commit is contained in:
Siddhesh Poyarekar
2017-06-30 22:58:39 +05:30
parent ab85da1530
commit 28cfa3a48e
6 changed files with 106 additions and 26 deletions

View File

@ -33,22 +33,6 @@
# define GLIBC_TUNABLES "GLIBC_TUNABLES"
#endif
/* Compare environment or tunable names, bounded by the name hardcoded in
glibc. */
static bool
is_name (const char *orig, const char *envname)
{
for (;*orig != '\0' && *envname != '\0'; envname++, orig++)
if (*orig != *envname)
break;
/* The ENVNAME is immediately followed by a value. */
if (*orig == '\0' && *envname == '=')
return true;
else
return false;
}
#if TUNABLES_FRONTEND == TUNABLES_FRONTEND_valstring
static char *
tunables_strdup (const char *in)
@ -235,7 +219,7 @@ parse_tunables (char *tunestr, char *valstring)
{
tunable_t *cur = &tunable_list[i];
if (is_name (cur->name, name))
if (tunable_is_name (cur->name, name))
{
/* If we are in a secure context (AT_SECURE) then ignore the tunable
unless it is explicitly marked as secure. Tunable values take
@ -318,7 +302,7 @@ __tunables_init (char **envp)
&prev_envp)) != NULL)
{
#if TUNABLES_FRONTEND == TUNABLES_FRONTEND_valstring
if (is_name (GLIBC_TUNABLES, envname))
if (tunable_is_name (GLIBC_TUNABLES, envname))
{
char *new_env = tunables_strdup (envname);
if (new_env != NULL)
@ -341,7 +325,7 @@ __tunables_init (char **envp)
const char *name = cur->env_alias;
/* We have a match. Initialize and move on to the next line. */
if (is_name (name, envname))
if (tunable_is_name (name, envname))
{
/* For AT_SECURE binaries, we need to check the security settings of
the tunable and decide whether we read the value and also whether
@ -356,7 +340,7 @@ __tunables_init (char **envp)
while (*ep != NULL)
{
if (is_name (name, *ep))
if (tunable_is_name (name, *ep))
{
char **dp = ep;