Patchwork [v2] Enable tunables by default

login
register
mail settings
Submitter Adhemerval Zanella Netto
Date June 16, 2017, 7:12 p.m.
Message ID <755ad681-dc4f-2505-d103-11f3795cbf3e@linaro.org>
Download mbox | patch
Permalink /patch/21055/
State New
Headers show

Comments

Adhemerval Zanella Netto - June 16, 2017, 7:12 p.m.
On 16/06/2017 13:12, Szabolcs Nagy wrote:
> On 14/06/17 19:08, Siddhesh Poyarekar wrote:
>> All of the major architectures are adopting tunables as a way to add
>> tuning to the library, from hwcap_mask for aarch64 to HLE for s390 and
>> ifunc and cache geometry for x86.  Given this adoption and the fact
>> that we don't want additional tuning knobs to be added outside of
>> tunables, it makes sense to enable tunables by default using this
>> trivial patch.
>>
>> Smoke tested on x86 to ensure that tunables code was built without
>> specifying it as a configure flag.  I have kept it as --enabled and
>> not changed it to --disable since we want to still keep the option of
>> different kinds of front-ends for tunables.
>>
>> 	* configure.ac(--enable-tunables): Enable by default.
>> 	* configure: Regenerate.
>> 	* NEWS: Mention change.
>> 	* manual/install.texi (enable-tunables): Adjust documentation.
>> 	* INSTALL: Regenerate.
> 
> note that gen-tunables.awk does not work with gawk 3.1.8
> because it uses multi-dimensional arrays
> 
> so this broke the build for me on x86.
> 

This patch below seems to work on gawk 3.1.8.  It changes the order or the
elements in tunable_id_t and tunable_list, but as long both order match
I think it should work.
Siddhesh Poyarekar - June 19, 2017, 4:17 a.m.
On Saturday 17 June 2017 12:42 AM, Adhemerval Zanella wrote:
> This patch below seems to work on gawk 3.1.8.  It changes the order or the
> elements in tunable_id_t and tunable_list, but as long both order match
> I think it should work.

Thanks for fixing this.  I verified on gawk 4.1.x as well, so looks good
to me.

Siddhesh
Siddhesh Poyarekar - June 19, 2017, 9:43 a.m.
On Saturday 17 June 2017 12:42 AM, Adhemerval Zanella wrote:
> This patch below seems to work on gawk 3.1.8.  It changes the order or the
> elements in tunable_id_t and tunable_list, but as long both order match
> I think it should work.

I've pushed this for you to fix builds for ARM.

Siddhesh

Patch

diff --git a/scripts/gen-tunables.awk b/scripts/gen-tunables.awk
index 93e5aff..ccdd0c6 100644
--- a/scripts/gen-tunables.awk
+++ b/scripts/gen-tunables.awk
@@ -39,20 +39,20 @@  $2 == "{" {
 $1 == "}" {
   if (tunable != "") {
     # Tunables definition ended, now fill in default attributes.
-    if (!types[top_ns][ns][tunable]) {
-      types[top_ns][ns][tunable] = "STRING"
+    if (!types[top_ns,ns,tunable]) {
+      types[top_ns,ns,tunable] = "STRING"
     }
-    if (!minvals[top_ns][ns][tunable]) {
-      minvals[top_ns][ns][tunable] = "0"
+    if (!minvals[top_ns,ns,tunable]) {
+      minvals[top_ns,ns,tunable] = "0"
     }
-    if (!maxvals[top_ns][ns][tunable]) {
-      maxvals[top_ns][ns][tunable] = "0"
+    if (!maxvals[top_ns,ns,tunable]) {
+      maxvals[top_ns,ns,tunable] = "0"
     }
-    if (!env_alias[top_ns][ns][tunable]) {
-      env_alias[top_ns][ns][tunable] = "NULL"
+    if (!env_alias[top_ns,ns,tunable]) {
+      env_alias[top_ns,ns,tunable] = "NULL"
     }
-    if (!security_level[top_ns][ns][tunable]) {
-      security_level[top_ns][ns][tunable] = "SXID_ERASE"
+    if (!security_level[top_ns,ns,tunable]) {
+      security_level[top_ns,ns,tunable] = "SXID_ERASE"
     }
 
     tunable = ""
@@ -81,7 +81,7 @@  $1 == "}" {
   if (tunable == "") {
     # We encountered a tunable without any attributes, so note it with a
     # default.
-    types[top_ns][ns][$1] = "STRING"
+    types[top_ns,ns,$1] = "STRING"
     next
   }
 
@@ -91,20 +91,20 @@  $1 == "}" {
   val = gensub(/^[ \t]+|[ \t]+$/, "", "g", arr[2])
 
   if (attr == "type") {
-    types[top_ns][ns][tunable] = val
+    types[top_ns,ns,tunable] = val
   }
   else if (attr == "minval") {
-    minvals[top_ns][ns][tunable] = val
+    minvals[top_ns,ns,tunable] = val
   }
   else if (attr == "maxval") {
-    maxvals[top_ns][ns][tunable] = val
+    maxvals[top_ns,ns,tunable] = val
   }
   else if (attr == "env_alias") {
-    env_alias[top_ns][ns][tunable] = sprintf("\"%s\"", val)
+    env_alias[top_ns,ns,tunable] = sprintf("\"%s\"", val)
   }
   else if (attr == "security_level") {
     if (val == "SXID_ERASE" || val == "SXID_IGNORE" || val == "NONE") {
-      security_level[top_ns][ns][tunable] = val
+      security_level[top_ns,ns,tunable] = val
     }
     else {
       printf("Line %d: Invalid value (%s) for security_level: %s, ", NR, val,
@@ -114,11 +114,11 @@  $1 == "}" {
     }
   }
   else if (attr == "default") {
-    if (types[top_ns][ns][tunable] == "STRING") {
-      default_val[top_ns][ns][tunable] = sprintf(".strval = \"%s\"", val);
+    if (types[top_ns,ns,tunable] == "STRING") {
+      default_val[top_ns,ns,tunable] = sprintf(".strval = \"%s\"", val);
     }
     else {
-      default_val[top_ns][ns][tunable] = sprintf(".numval = %s", val)
+      default_val[top_ns,ns,tunable] = sprintf(".numval = %s", val)
     }
   }
 }
@@ -139,27 +139,27 @@  END {
   # Now, the enum names
   print "\ntypedef enum"
   print "{"
-  for (t in types) {
-    for (n in types[t]) {
-      for (m in types[t][n]) {
-        printf ("  TUNABLE_ENUM_NAME(%s, %s, %s),\n", t, n, m);
-      }
-    }
+  for (tnm in types) {
+    split (tnm, indices, SUBSEP);
+    t = indices[1];
+    n = indices[2];
+    m = indices[3];
+    printf ("  TUNABLE_ENUM_NAME(%s, %s, %s),\n", t, n, m);
   }
   print "} tunable_id_t;\n"
 
   # Finally, the tunable list.
   print "\n#ifdef TUNABLES_INTERNAL"
   print "static tunable_t tunable_list[] attribute_relro = {"
-  for (t in types) {
-    for (n in types[t]) {
-      for (m in types[t][n]) {
-        printf ("  {TUNABLE_NAME_S(%s, %s, %s)", t, n, m)
-        printf (", {TUNABLE_TYPE_%s, %s, %s}, {%s}, NULL, TUNABLE_SECLEVEL_%s, %s},\n",
-		types[t][n][m], minvals[t][n][m], maxvals[t][n][m],
-		default_val[t][n][m], security_level[t][n][m], env_alias[t][n][m]);
-      }
-    }
+  for (tnm in types) {
+    split (tnm, indices, SUBSEP);
+    t = indices[1];
+    n = indices[2];
+    m = indices[3];
+    printf ("  {TUNABLE_NAME_S(%s, %s, %s)", t, n, m)
+    printf (", {TUNABLE_TYPE_%s, %s, %s}, {%s}, NULL, TUNABLE_SECLEVEL_%s, %s},\n",
+	    types[t,n,m], minvals[t,n,m], maxvals[t,n,m],
+	    default_val[t,n,m], security_level[t,n,m], env_alias[t,n,m]);
   }
   print "};"
   print "#endif"