Commit 8424c4f3 authored by David Goulet's avatar David Goulet 🤘
Browse files

sched: Detect KIST support at compile time



Add a detection for the KIST scheduler in our build system and set
HAVE_KIST_SUPPORT if available.

Adapt the should use kist function with this new compile option.
Signed-off-by: David Goulet's avatarDavid Goulet <dgoulet@torproject.org>
parent dde35866
......@@ -792,6 +792,34 @@ AC_CHECK_MEMBERS([SSL.state], , ,
[#include <openssl/ssl.h>
])
dnl Define the set of checks for KIST scheduler support.
AC_DEFUN([CHECK_KIST_SUPPORT],[
dnl KIST needs struct tcp_info and for certain members to exist.
AC_CHECK_MEMBERS(
[struct tcp_info.tcpi_unacked, struct tcp_info.tcpi_snd_mss],
, ,[[#include <netinet/tcp.h>]])
dnl KIST needs SIOCOUTQNSD to exist for an ioctl call.
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
#include <linux/sockios.h>
#ifndef SIOCOUTQNSD
#error
#endif
])], have_siocoutqnsd=yes, have_siocoutqnsd=no)
if test "x$have_siocoutqnsd" = "xyes"; then
if test "x$ac_cv_member_struct_tcp_info_tcpi_unacked" = "xyes"; then
if test "x$ac_cv_member_struct_tcp_info_tcpi_snd_mss" = "xyes"; then
have_kist_support=yes
fi
fi
fi
])
dnl Now, trigger the check.
CHECK_KIST_SUPPORT
AS_IF([test "x$have_kist_support" = "xyes"],
[AC_DEFINE(HAVE_KIST_SUPPORT, 1, [Defined if KIST scheduler is supported
on this system])],
[AC_MSG_NOTICE([KIST scheduler can't be used. Missing support.])])
LIBS="$save_LIBS"
LDFLAGS="$save_LDFLAGS"
CPPFLAGS="$save_CPPFLAGS"
......
......@@ -215,17 +215,6 @@ get_run_sched_ev(void)
return run_sched_ev;
}
/* Return true iff the scheduler subsystem should use KIST. */
int
scheduler_should_use_kist(void)
{
int64_t run_freq = kist_scheduler_run_interval();
log_info(LD_SCHED, "Determined sched_run_interval should be %" PRId64 ". "
"Will%s use KIST.",
run_freq, (run_freq > 0 ? "" : " not"));
return run_freq > 0;
}
/* Comparison function to use when sorting pending channels */
MOCK_IMPL(int,
scheduler_compare_channels, (const void *c1_v, const void *c2_v))
......
......@@ -116,7 +116,6 @@ MOCK_DECL(void, scheduler_channel_has_waiting_cells, (channel_t *chan));
/*********************************
* Defined in scheduler.c
*********************************/
int scheduler_should_use_kist(void);
smartlist_t *get_channels_pending(void);
struct event *get_run_sched_ev(void);
MOCK_DECL(int, scheduler_compare_channels,
......@@ -156,6 +155,7 @@ MOCK_DECL(int, channel_should_write_to_kernel,
MOCK_DECL(void, channel_write_to_kernel, (channel_t *chan));
MOCK_DECL(void, update_socket_info_impl, (socket_table_ent_t *ent));
int scheduler_should_use_kist(void);
scheduler_t *get_kist_scheduler(void);
int32_t kist_scheduler_run_interval(const networkstatus_t *ns);
......
......@@ -588,3 +588,26 @@ kist_scheduler_run_interval(const networkstatus_t *ns)
return run_interval;
}
#ifdef HAVE_KIST_SUPPORT
/* Return true iff the scheduler subsystem should use KIST. */
int
scheduler_should_use_kist(void)
{
int64_t run_interval = kist_scheduler_run_interval(NULL);
log_info(LD_SCHED, "Determined sched_run_interval should be %" PRId64 ". "
"Will%s use KIST.",
run_interval, (run_interval > 0 ? "" : " not"));
return run_interval > 0;
}
#else /* HAVE_KIST_SUPPORT */
int
scheduler_should_use_kist(void)
{
return 0;
}
#endif /* HAVE_KIST_SUPPORT */
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment