[lttng-dev] [RFC PATCH 1/1] check if set_schedaffinity works in configure.ac

Pranith Kumar bobby.prani at gmail.com
Sun Jun 8 16:18:41 EDT 2014


On 06/08/2014 04:15 PM, Pranith Kumar wrote:
> On some systems set_schedaffinity exists but return "-1" when called. Tests fail in such cases ("test_urcu_hash")
>
> Check if we can call set_schedaffinity and 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.

>
> Signed-off-by: Pranith Kumar <bobby.prani at gmail.com>
> ---
>  configure.ac | 37 +++++++++++++++++++++++++++++++++++--
>  1 file changed, 35 insertions(+), 2 deletions(-)
>
> diff --git a/configure.ac b/configure.ac
> index 008336c..3074bbc 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -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




More information about the lttng-dev mailing list