[PATCH][aarch64] Fix glibc.tune.cpu tunable handling

Steve Ellcey sellcey@cavium.com
Fri Sep 1 19:41:00 GMT 2017


While working on a gcc patch I realized that the glibc tunable
'glibc.tune.cpu' was not working on aarch64.  I tracked it down to
get_midr_from_mcpu and at first I thought I should remove the '== 0'
from the if statement because tunable_is_name returns true/false, not
-1/0/1 like strcmp.  But then I realized we shouldn't be using
tunable_is_name at all because we are comparing two null terminated
strings and tunable_is_name is trying to compare a null terminated
string with a '=' terminated string which is not what we have.

I tested this by running a program that calls memcpy and checking what
memcpy gets run after setting glibc.tune.cpu to generic, thunderx,
and falkor.

OK to checkin?

Steve Ellcey
sellcey@cavium.com


2017-09-01  Steve Ellcey  <sellcey@cavium.com>

	* sysdeps/unix/sysv/linux/aarch64/cpu-features.c (get_midr_from_mcpu):
	Use strcmp instead of tunable_is_name.


diff --git a/sysdeps/unix/sysv/linux/aarch64/cpu-features.c b/sysdeps/unix/sysv/
linux/aarch64/cpu-features.c
index 18f5e60..0c7e13f 100644
--- a/sysdeps/unix/sysv/linux/aarch64/cpu-features.c
+++ b/sysdeps/unix/sysv/linux/aarch64/cpu-features.c
@@ -37,7 +37,7 @@ static uint64_t
 get_midr_from_mcpu (const char *mcpu)
 {
   for (int i = 0; i < sizeof (cpu_list) / sizeof (struct cpu_list); i++)
-    if (tunable_is_name (mcpu, cpu_list[i].name) == 0)
+    if (strcmp (mcpu, cpu_list[i].name) == 0)
       return cpu_list[i].midr;
 
   return UINT64_MAX;



More information about the Libc-alpha mailing list