check if set_schedaffinity works in configure.ac
Quoted 3 lines · Pranith Kumar
On some systems
set_schedaffinityexists but return "-1" when called. Tests fail in such cases ("test_urcu_hash")Check if we can call
set_schedaffinityand define accordingly
I just realized that this is a common mailing list. This is for userspace-rcu library. I am trying to use it on an Nvidia Tegra K1 device.
Quoted 66 lines
Signed-off-by Pranith Kumar <[email protected]>--- configure.ac | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-)configure.ac +35
-2@@ -269,7 +269,7 @@ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ ]) # First check if the function is available at all. -AC_CHECK_FUNCS([sched_setaffinity],[ +AC_CHECK_FUNC([sched_setaffinity],[ # Okay, we have it. Check if also have cpu_set_t. If we don't, # then we have the first version using unsigned long, and no # CPU_ZERO, etc. macros. If we do have cpu_set_t, we may have the@@ -295,12 +295,45 @@ AC_CHECK_FUNCS([sched_setaffinity],[ [sched_set_affinity_args=2]) AC_DEFINE_UNQUOTED(SCHED_SETAFFINITY_ARGS, $sched_set_affinity_args, - [Defined to sched_setaffinity's number of arguments.]) + [Defined to number of arguments taken by sched_setaffinity.]) AC_MSG_RESULT([$sched_set_affinity_args]) ],[ # No cpu_set_t, always 3 args. AC_DEFINE(SCHED_SETAFFINITY_ARGS, 3) ]) + AS_IF([test "x$sched_set_affinity_args" = "x3"], [ + # test if sched_setaffinity works + AC_MSG_CHECKING([if sched_setaffinity works]) + AC_RUN_IFELSE([AC_LANG_SOURCE([[ + #include <sched.h> + int main() + { + cpu_set_t foo; + return sched_setaffinity(0, sizeof (foo), &foo); + } + ]]) + ], + [sched_set_affinity_works=1], + [sched_set_affinity_works=0]) + AC_DEFINE_UNQUOTED(HAVE_SCHED_SETAFFINITY, + $sched_set_affinity_works) + ],[ + # test if sched_setaffinity works + AC_MSG_CHECKING([if sched_setaffinity works]) + AC_RUN_IFELSE([AC_LANG_SOURCE([[ + #include <sched.h> + int main() + { + cpu_set_t foo; + return sched_setaffinity(0, &foo); + } + ]]) + ], + [sched_set_affinity_works=1], + [sched_set_affinity_works=0]) + AC_DEFINE_UNQUOTED(HAVE_SCHED_SETAFFINITY, + $sched_set_affinity_works) + ]) ]) CFLAGS=$saved_CFLAGS
Quoted 6 lines · Pranith Kumar
Quoted 3 lines · Pranith Kumar
On some systems
set_schedaffinityexists but return "-1" when called. Tests fail in such cases ("test_urcu_hash")Check if we can call
set_schedaffinityand define accordinglyI just realized that this is a common mailing list. This is for userspace-rcu library. I am trying to use it on an Nvidia Tegra K1 device.
Oops, the generated files do not work as there is a missing message. Fixed and updated the patch below:
--- configure.ac | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-)
configure.ac +37 -2
@@ -269,7 +269,7 @@ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ ]) # First check if the function is available at all. -AC_CHECK_FUNCS([sched_setaffinity],[ +AC_CHECK_FUNC([sched_setaffinity],[ # Okay, we have it. Check if also have cpu_set_t. If we don't, # then we have the first version using unsigned long, and no # CPU_ZERO, etc. macros. If we do have cpu_set_t, we may have the
@@ -295,12 +295,47 @@ AC_CHECK_FUNCS([sched_setaffinity],[ [sched_set_affinity_args=2]) AC_DEFINE_UNQUOTED(SCHED_SETAFFINITY_ARGS, $sched_set_affinity_args, - [Defined to sched_setaffinity's number of arguments.]) + [Defined to number of arguments taken by sched_setaffinity.]) AC_MSG_RESULT([$sched_set_affinity_args]) ],[ # No cpu_set_t, always 3 args. AC_DEFINE(SCHED_SETAFFINITY_ARGS, 3) ]) + AS_IF([test "x$sched_set_affinity_args" = "x3"], [ + # test if sched_setaffinity works + AC_MSG_CHECKING([if sched_setaffinity works]) + AC_RUN_IFELSE([AC_LANG_SOURCE([[ + #include <sched.h> + int main() + { + cpu_set_t foo; + return sched_setaffinity(0, sizeof (foo), &foo); + } + ]]) + ], + [sched_set_affinity_works=1], + [sched_set_affinity_works=0]) + AC_DEFINE_UNQUOTED(HAVE_SCHED_SETAFFINITY, + $sched_set_affinity_works, + [Defined if sched_setaffinity works]) + ],[ + # test if sched_setaffinity works + AC_MSG_CHECKING([if sched_setaffinity works]) + AC_RUN_IFELSE([AC_LANG_SOURCE([[ + #include <sched.h> + int main() + { + cpu_set_t foo; + return sched_setaffinity(0, &foo); + } + ]]) + ], + [sched_set_affinity_works=1], + [sched_set_affinity_works=0]) + AC_DEFINE_UNQUOTED(HAVE_SCHED_SETAFFINITY, + $sched_set_affinity_works, + [Defined if sched_setaffinity works]) + ]) ]) CFLAGS=$saved_CFLAGS
Signature · 1 line
1.9.1
Quoted 8 lines · Pranith Kumar
Quoted 4 lines · Pranith Kumar
On some systems
set_schedaffinityexists but return "-1" when called. Tests fail in such cases ("test_urcu_hash")Check if we can call
set_schedaffinityand define accordinglyI just realized that this is a common mailing list. This is for userspace-rcu library. I am trying to use it on an Nvidia Tegra K1 device.
It seems odd that sched_setaffinity would fail... what is the value of errno associated with the failed calls?
(Also, you have the name of the function right in your patch, but need to correct it in the patch subject and description -- "sched_setaffinity" not "set_schedaffinity".)
Review
Quoted 9 lines · Pranith Kumar
(quoted diff) +9
-0+ AS_IF([test "x$sched_set_affinity_args" = "x3"], [ + # test if sched_setaffinity works + AC_MSG_CHECKING([if sched_setaffinity works]) + AC_RUN_IFELSE([AC_LANG_SOURCE([[ + #include <sched.h> + int main() + { + cpu_set_t foo; + return sched_setaffinity(0, sizeof (foo), &foo);
This passes uninitialized stack memory to the system call; the return value is unpredictable.
If it turns out that such a test is necessary, it should probably call sched_getaffinity first and pass the result to sched_setaffinity.
----- Original Message -----
Quoted 17 lines
From: "Nathan Lynch" <[email protected]>
To: "Pranith Kumar" <[email protected]>
Cc: "mathieu desnoyers" <[email protected]>, [email protected]
Sent: Monday, June 9, 2014 2:59:56 PM
Subject: Re: [lttng-dev] [RFC PATCH 1/1] check ifset_schedaffinityworks in configure.acReview
Quoted 9 lines · Pranith Kumar
(quoted diff) +9
-0+ AS_IF([test "x$sched_set_affinity_args" = "x3"], [ + # test if sched_setaffinity works + AC_MSG_CHECKING([if sched_setaffinity works]) + AC_RUN_IFELSE([AC_LANG_SOURCE([[ + #include <sched.h> + int main() + { + cpu_set_t foo; + return sched_setaffinity(0, sizeof (foo), &foo);
Quoted 6 lines
This passes uninitialized stack memory to the system call; the return value is unpredictable.
If it turns out that such a test is necessary, it should probably call
sched_getaffinityfirst and pass the result tosched_setaffinity.
It looks like a respin of the patch taking care of Nathan's comments is needed here. It might be a good thing to open a bug report against Userspace RCU on http://bugs.lttng.org to keep track of this issue.
Thanks!
Mathieu
Signature · 3 lines
Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com