]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Enhance --enable-tunables to select tunables frontend at build time
authorSiddhesh Poyarekar <siddhesh@sourceware.org>
Sat, 31 Dec 2016 18:04:04 +0000 (23:34 +0530)
committerSiddhesh Poyarekar <siddhesh@sourceware.org>
Sat, 31 Dec 2016 18:19:24 +0000 (23:49 +0530)
At the GNU Tools Cauldron 2016, the state of the current tunables
patchset was considered OK with the addition of a way to select the
frontend to be used for the tunables.  That is, to avoid being locked
in to one type of frontend initially, it should be possible to build
tunables with a different frontend with something as simple as a
configure switch.

To that effect, this patch enhances the --enable-tunables option to
accept more values than just 'yes' or 'no'.  The current frontend (and
default when enable-tunables is 'yes') is called 'valstring', to
select the frontend where a single environment variable is set to a
colon-separated value string.  More such frontends can be added in
future.

* Makeconfig (have-tunables): Check for non-negative instead
of positive.
* configure.ac: Add 'valstring' as a valid value for
--enable-tunables.
* configure: Regenerate.
* elf/Makefile (have-tunables): Check for non-negative instead
of positive.
(CPPFLAGS-dl-tunables.c): Define TUNABLES_FRONTEND for
dl-tunables.c.
* elf/dl-tunables.c (GLIBC_TUNABLES): Define only when
TUNABLES_FRONTEND == TUNABLES_FRONTEND_valstring.
(tunables_strdup): Likewise.
(disable_tunables): Likewise.
(parse_tunables): Likewise.
(__tunables_init): Process GLIBC_TUNABLES envvar only when.
TUNABLES_FRONTEND == TUNABLES_FRONTEND_valstring.
* elf/dl-tunables.h (TUNABLES_FRONTEND_valstring): New macro.
(TUNABLES_FRONTEND_yes): New macro, define as
TUNABLES_FRONTEND_valstring by default.
* manual/install.texi: Document new acceptable values for
--enable-tunables.
* INSTALL: Regenerate.

ChangeLog
INSTALL
Makeconfig
configure
configure.ac
elf/Makefile
elf/dl-tunables.c
elf/dl-tunables.h
manual/install.texi

index 69e527c3eaa1eee7858ffca0007d0f6f7297b77d..eded27fbe3621bc6b5b948100746aef431fe42bd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,28 @@
 2016-12-31  Siddhesh Poyarekar  <siddhesh@sourceware.org>
 
+       * Makeconfig (have-tunables): Check for non-negative instead
+       of positive.
+       * configure.ac: Add 'valstring' as a valid value for
+       --enable-tunables.
+       * configure: Regenerate.
+       * elf/Makefile (have-tunables): Check for non-negative instead
+       of positive.
+       (CPPFLAGS-dl-tunables.c): Define TUNABLES_FRONTEND for
+       dl-tunables.c.
+       * elf/dl-tunables.c (GLIBC_TUNABLES): Define only when
+       TUNABLES_FRONTEND == TUNABLES_FRONTEND_valstring.
+       (tunables_strdup): Likewise.
+       (disable_tunables): Likewise.
+       (parse_tunables): Likewise.
+       (__tunables_init): Process GLIBC_TUNABLES envvar only when.
+       TUNABLES_FRONTEND == TUNABLES_FRONTEND_valstring.
+       * elf/dl-tunables.h (TUNABLES_FRONTEND_valstring): New macro.
+       (TUNABLES_FRONTEND_yes): New macro, define as
+       TUNABLES_FRONTEND_valstring by default.
+       * manual/install.texi: Document new acceptable values for
+       --enable-tunables.
+       * INSTALL: Regenerate.
+
        * config.make.in (have-loop-to-function): Define.
        * elf/Makefile (CFLAGS-dl-tunables.c): Add
        -fno-tree-loop-distribute-patterns.
diff --git a/INSTALL b/INSTALL
index 25619fc5208c07c29ca0823ae97c1d27933503be..55d52c5f1544c3f67aebf793036cc89825000599 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -172,7 +172,23 @@ will be used, and CFLAGS sets optimization options for the compiler.
 '--enable-tunables'
      Tunables support allows additional library parameters to be
      customized at runtime.  This is an experimental feature and affects
-     startup time and is thus disabled by default.
+     startup time and is thus disabled by default.  This option can take
+     the following values:
+
+     'no'
+          This is the default if the option is not passed to configure.
+          This disables tunables.
+
+     'yes'
+          This is the default if the option is passed to configure.
+          This enables tunables and selects the default frontend
+          (currently 'valstring').
+
+     'valstring'
+          This enables tunables and selects the 'valstring' frontend for
+          tunables.  This frontend allows users to specify tunables as a
+          colon-separated list in a single environment variable
+          'GLIBC_TUNABLES'.
 
 '--build=BUILD-SYSTEM'
 '--host=HOST-SYSTEM'
index b173e4cc08ecb61f20ad4cff2354836d305521b0..1a2db6da1d7996aae1f6e7ece6eb818d451a32e4 100644 (file)
@@ -935,7 +935,7 @@ CPPFLAGS = $(config-extra-cppflags) $(CPPUNDEFS) $(CPPFLAGS-config) \
                         $(libof-$(<F)) $(libof-$(@F)),$(CPPFLAGS-$(lib))) \
           $(CPPFLAGS-$(<F)) $(CPPFLAGS-$(@F)) $(CPPFLAGS-$(basename $(@F)))
 
-ifeq (yes,$(have-tunables))
+ifneq (no,$(have-tunables))
 CPPFLAGS += -DTOP_NAMESPACE=glibc
 endif
 
@@ -1115,7 +1115,7 @@ endif
 
 # Build the tunables list header early since it could be used by any module in
 # glibc.
-ifeq (yes,$(have-tunables))
+ifneq (no,$(have-tunables))
 before-compile += $(common-objpfx)dl-tunable-list.h
 
 $(common-objpfx)dl-tunable-list.h: $(..)scripts/gen-tunables.awk \
index d80d738fd10588e1e502ce9dc05ce5929e1d907a..eecd0ace740e8fafcb01c0019bc592fe1469b609 100755 (executable)
--- a/configure
+++ b/configure
@@ -1454,7 +1454,8 @@ Optional Features:
   --disable-build-nscd    disable building and installing the nscd daemon
   --disable-nscd          library functions will not contact the nscd daemon
   --enable-pt_chown       Enable building and installing pt_chown
-  --enable-tunables       Enable tunables support
+  --enable-tunables       Enable tunables support. Known values are 'yes',
+                          'no' and 'valstring'
   --enable-mathvec        Enable building and installing mathvec [default
                           depends on architecture]
 
index 22f5cab20099caf8b448b529882cad75ba719070..4a77411b71949771233cea4b525f95bf446f3dc1 100644 (file)
@@ -423,7 +423,7 @@ fi
 
 AC_ARG_ENABLE([tunables],
              [AS_HELP_STRING([--enable-tunables],
-              [Enable tunables support])],
+              [Enable tunables support. Known values are 'yes', 'no' and 'valstring'])],
              [have_tunables=$enableval],
              [have_tunables=no])
 AC_SUBST(have_tunables)
index 3cda2c9db85b7bf1a62f132a330428fed1aa27f7..c3636a64d25e3e9fd31cc51f3e88b974fdc030bb 100644 (file)
@@ -36,8 +36,10 @@ ifeq (yes,$(use-ldconfig))
 dl-routines += dl-cache
 endif
 
-ifeq (yes,$(have-tunables))
+ifneq (no,$(have-tunables))
 dl-routines += dl-tunables
+tunables-type = $(addprefix TUNABLES_FRONTEND_,$(have-tunables))
+CPPFLAGS-dl-tunables.c = -DTUNABLES_FRONTEND=$(tunables-type)
 
 # Make sure that the compiler does not insert any library calls in tunables
 # code paths.
index 8d6914020df5f64a0cae345c4eefda56f607c52a..39feecde165e1e1e3586780752a653f045900a4c 100644 (file)
@@ -30,7 +30,9 @@
 #define TUNABLES_INTERNAL 1
 #include "dl-tunables.h"
 
-#define GLIBC_TUNABLES "GLIBC_TUNABLES"
+#if TUNABLES_FRONTEND == TUNABLES_FRONTEND_valstring
+# define GLIBC_TUNABLES "GLIBC_TUNABLES"
+#endif
 
 /* Compare environment or tunable names, bounded by the name hardcoded in
    glibc.  */
@@ -48,6 +50,7 @@ is_name (const char *orig, const char *envname)
     return false;
 }
 
+#if TUNABLES_FRONTEND == TUNABLES_FRONTEND_valstring
 static char *
 tunables_strdup (const char *in)
 {
@@ -70,6 +73,7 @@ tunables_strdup (const char *in)
 
   return out;
 }
+#endif
 
 static char **
 get_next_env (char **envp, char **name, size_t *namelen, char **val)
@@ -244,6 +248,7 @@ tunable_initialize (tunable_t *cur, const char *strval)
     }
 }
 
+#if TUNABLES_FRONTEND == TUNABLES_FRONTEND_valstring
 static void
 parse_tunables (char *tunestr)
 {
@@ -309,6 +314,7 @@ parse_tunables (char *tunestr)
        return;
     }
 }
+#endif
 
 static size_t
 min_strlen (const char *s)
@@ -329,6 +335,7 @@ disable_tunable (tunable_id_t id, char **envp)
   if (env_alias != NULL)
     tunables_unsetenv (envp, tunable_list[id].env_alias);
 
+#if TUNABLES_FRONTEND == TUNABLES_FRONTEND_valstring
   char *tunable = getenv (GLIBC_TUNABLES);
   const char *cmp = tunable_list[id].name;
   const size_t len = min_strlen (cmp);
@@ -345,6 +352,7 @@ disable_tunable (tunable_id_t id, char **envp)
        }
       tunable++;
     }
+#endif
 }
 
 /* Disable the glibc.malloc.check tunable in SETUID/SETGID programs unless
@@ -375,6 +383,7 @@ __tunables_init (char **envp)
 
   while ((envp = get_next_env (envp, &envname, &len, &envval)) != NULL)
     {
+#if TUNABLES_FRONTEND == TUNABLES_FRONTEND_valstring
       if (is_name (GLIBC_TUNABLES, envname))
        {
          char *val = tunables_strdup (envval);
@@ -382,6 +391,7 @@ __tunables_init (char **envp)
            parse_tunables (val);
          continue;
        }
+#endif
 
       for (int i = 0; i < sizeof (tunable_list) / sizeof (tunable_t); i++)
        {
index a3f5472b45796d201039e7fd63c0d15f47f8b242..033781856ac955a6ff20890a972fae74ac76b751 100644 (file)
@@ -84,5 +84,9 @@ extern void __tunable_set_val (tunable_id_t, void *, tunable_callback_t);
 /* Namespace sanity for callback functions.  Use this macro to keep the
    namespace of the modules clean.  */
 # define DL_TUNABLE_CALLBACK(__name) _dl_tunable_ ## __name
+
+# define TUNABLES_FRONTEND_valstring 1
+/* The default value for TUNABLES_FRONTEND.  */
+# define TUNABLES_FRONTEND_yes TUNABLES_FRONTEND_valstring
 #endif
 #endif
index d41296294e03a43f450612a54e4c56994077ed8a..2657da108b5fa14aabb0dd6f76f4ef8a5f11645a 100644 (file)
@@ -203,7 +203,22 @@ Use this option to disable the vector math library.
 @item --enable-tunables
 Tunables support allows additional library parameters to be customized at
 runtime.  This is an experimental feature and affects startup time and is thus
-disabled by default.
+disabled by default.  This option can take the following values:
+
+@table @code
+@item no
+This is the default if the option is not passed to configure. This disables
+tunables.
+
+@item yes
+This is the default if the option is passed to configure. This enables tunables
+and selects the default frontend (currently @samp{valstring}).
+
+@item valstring
+This enables tunables and selects the @samp{valstring} frontend for tunables.
+This frontend allows users to specify tunables as a colon-separated list in a
+single environment variable @env{GLIBC_TUNABLES}.
+@end table
 
 @item --build=@var{build-system}
 @itemx --host=@var{host-system}