This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH v2 1/3] Tunables: Add tunables of spin count for pthread adaptive spin mutex
- From: Florian Weimer <fweimer at redhat dot com>
- To: Kemi Wang <kemi dot wang at intel dot com>, Adhemerval Zanella <adhemerval dot zanella at linaro dot org>, Glibc alpha <libc-alpha at sourceware dot org>
- Cc: Dave Hansen <dave dot hansen at linux dot intel dot com>, Tim Chen <tim dot c dot chen at intel dot com>, Andi Kleen <andi dot kleen at intel dot com>, Ying Huang <ying dot huang at intel dot com>, Aaron Lu <aaron dot lu at intel dot com>, Lu Aubrey <aubrey dot li at intel dot com>
- Date: Wed, 2 May 2018 10:04:13 +0200
- Subject: Re: [PATCH v2 1/3] Tunables: Add tunables of spin count for pthread adaptive spin mutex
- References: <1524624988-29141-1-git-send-email-kemi.wang@intel.com>
On 04/25/2018 04:56 AM, Kemi Wang wrote:
+ mutex {
+ spin_count {
+ type: INT_32
+ minval: 0
+ maxval: 30000
+ default: 1000
+ }
How did you come up with the default and maximum values? Larger maximum
values might be useful for testing boundary conditions.
+# define TUNABLE_CALLBACK_FNDECL(__name, __type) \
+static inline void \
+__always_inline \
+do_set_mutex_ ## __name (__type value) \
+{ \
+ __mutex_aconf.__name = value; \
+} \
+void \
+TUNABLE_CALLBACK (set_mutex_ ## __name) (tunable_val_t *valp) \
+{ \
+ __type value = (__type) (valp)->numval; \
+ do_set_mutex_ ## __name (value); \
+}
+
+TUNABLE_CALLBACK_FNDECL (spin_count, int32_t);
I'm not sure if the macro is helpful in this context.
+static void
+mutex_tunables_init (int argc __attribute__ ((unused)),
+ char **argv __attribute__ ((unused)),
+ char **environ)
+{
+#if HAVE_TUNABLES
+
+ TUNABLE_GET (spin_count, int32_t,
+ TUNABLE_CALLBACK (set_mutex_spin_count));
+#endif
+}
+
+#ifdef SHARED
+# define INIT_SECTION ".init_array"
+#else
+# define INIT_SECTION ".preinit_array"
+#endif
+
+void (*const __pthread_mutex_tunables_init_array []) (int, char **, char **)
+ __attribute__ ((section (INIT_SECTION), aligned (sizeof (void *)))) =
+{
+ &mutex_tunables_init
+};
Can't you perform the initialization as part of overall pthread
initialization? This would avoid the extra relocation.
Thanks,
Florian