Commit a816faa0 authored by Tom Barbette's avatar Tom Barbette

Merge branch numa into queuedevice - Support for numa to automatically assign...

Merge branch numa into queuedevice - Support for numa to automatically assign threads to input device
parent aa0611cb
......@@ -662,6 +662,7 @@ XML2CLICK
PROPER_LIBS
PROPER_INCLUDES
NETMAP_INCLUDES
NUMA_INCLUDES
PCAP_LIBS
PCAP_INCLUDES
TOOL_TARGETS
......@@ -847,6 +848,7 @@ enable_dmalloc
enable_valgrind
enable_schedule_debugging
enable_intel_cpu
with_numa
with_netmap
with_proper
with_expat
......@@ -1549,6 +1551,7 @@ Optional Packages:
--with-linux-map[=FILE] filename for Linux System.map [LINUXDIR/System.map]
--with-freebsd[=SRC,INC] FreeBSD source code is in SRC [/usr/src/sys],
include directory is INC [/usr/include]
--with-numa enable numa [no]
--with-netmap enable netmap [no]
--with-proper[=PREFIX] use PlanetLab Proper library (optional)
--with-expat[=PREFIX] locate expat XML library (optional)
......@@ -10637,6 +10640,71 @@ done
# Check whether --with-numa was given.
if test "${with_numa+set}" = set; then :
withval=$with_numa; use_numa=$withval
else
use_numa=no
fi
if test "$use_numa" != "yes" -a "$use_numa" != "no"; then
if test "${NUMA_INCLUDES-NO}" != NO; then
:
elif test -f "$use_numa/numa.h"; then
NUMA_INCLUDES="-I$use_numa"
fi
fi
saveflags="$CPPFLAGS"
CPPFLAGS="$saveflags $NUMA_INCLUDES"
HAVE_NUMA=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for numa.h" >&5
$as_echo_n "checking for numa.h... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <numa.h>
_ACEOF
if ac_fn_c_try_cpp "$LINENO"; then :
ac_cv_numa_header_path="found"
else
ac_cv_numa_header_path="not found"
fi
rm -f conftest.err conftest.i conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_numa_header_path" >&5
$as_echo "$ac_cv_numa_header_path" >&6; }
if test "$ac_cv_net_numa_header_path" = "found"; then
HAVE_NUMA=yes
fi
if test "$HAVE_NUMA" = yes; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether numa.h works" >&5
$as_echo_n "checking whether numa.h works... " >&6; }
if ${ac_cv_working_numa_h+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <numa.h>
_ACEOF
if ac_fn_c_try_cpp "$LINENO"; then :
ac_cv_working_numa_h=yes
else
ac_cv_working_numa_h=no
fi
rm -f conftest.err conftest.i conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_working_numa_h" >&5
$as_echo "$ac_cv_working_numa_h" >&6; }
test "$ac_cv_working_numa_h" != yes && HAVE_NUMA=
fi
# Check whether --with-netmap was given.
if test "${with_netmap+set}" = set; then :
withval=$with_netmap; use_netmap=$withval
......@@ -13402,6 +13470,10 @@ if test "x$HAVE_NETMAP" = xyes; then
provisions="$provisions netmap"
fi
if test "x$HAVE_NUMA" = xyes; then
provisions="$provisions numa"
fi
if test "x$HAVE_PCAP" = xyes; then
provisions="$provisions pcap"
fi
......
......@@ -1218,6 +1218,7 @@ dnl note: no longer need pcap under Linux
if test "$enable_userlevel" = yes; then
CLICK_CHECK_LIBPCAP
CLICK_CHECK_NUMA
CLICK_CHECK_NETMAP
if test "$HAVE_PCAP" != yes -a "$HAVE_NETMAP" != yes -a "$ac_cv_under_linux" != yes; then
AC_MSG_WARN([
......@@ -2038,6 +2039,11 @@ if test "x$HAVE_NETMAP" = xyes; then
provisions="$provisions netmap"
fi
dnl add 'numa' if numa support is available
if test "x$HAVE_NUMA" = xyes; then
provisions="$provisions numa"
fi
dnl add 'pcap' if libpcap is available
if test "x$HAVE_PCAP" = xyes; then
provisions="$provisions pcap"
......
......@@ -29,7 +29,7 @@ Vector<int> QueueDevice::shared_offset = Vector<int>();
void QueueDevice::static_initialize() {
int num_nodes = 1;
int num_nodes = Numa::get_max_numas();
shared_offset.resize(num_nodes);
inputs_count.resize(num_nodes);
inputs_count.fill(0);
......@@ -42,7 +42,14 @@ int QueueDevice::configure_rx(int numa_node,unsigned int maxthreads, unsigned in
_maxqueues = maxqueues;
_threadoffset = threadoffset;
usable_threads.assign(master()->nthreads(),false);
usable_threads.assign(min(Numa::get_max_cpus(), master()->nthreads()),false);
#if !HAVE_NUMA
_this_node = 0;
#else
if (numa_node < 0) numa_node = 0;
_this_node = numa_node;
#endif
if (numa_node >= 0)
_this_node = numa_node;
......@@ -94,8 +101,16 @@ int QueueDevice::initialize_tx(ErrorHandler * errh) {
return 0;
}
int QueueDevice::initialize_rx(ErrorHandler *errh) {
usable_threads.negate();
NumaCpuBitmask b = NumaCpuBitmask::allocate();
if (numa && (numa_available()==0)) {
if (_this_node >= 0) {
b = Numa::node_to_cpus(_this_node);
} else
b = Numa::all_cpu();
b.toBitvector( usable_threads);
} else {
usable_threads.negate();
}
for (int i = nthreads; i < usable_threads.size(); i++)
usable_threads[i] = 0;
......
......@@ -9,6 +9,7 @@
#include <click/master.hh>
#include <click/multithread.hh>
#include <click/standard/scheduleinfo.hh>
#include <click/numa.hh>
class QueueDevice : public Element {
......
......@@ -460,6 +460,48 @@ AC_DEFUN([CLICK_CHECK_NETMAP], [
AC_SUBST(NETMAP_INCLUDES)
])
dnl
dnl CLICK_CHECK_NUMA
dnl Finds header files for numa.
dnl
AC_DEFUN([CLICK_CHECK_NUMA], [
AC_ARG_WITH([numa],
[AS_HELP_STRING([--with-numa], [enable numa [no]])],
[use_numa=$withval], [use_numa=no])
if test "$use_numa" != "yes" -a "$use_numa" != "no"; then
if test "${NUMA_INCLUDES-NO}" != NO; then
:
elif test -f "$use_numa/numa.h"; then
NUMA_INCLUDES="-I$use_numa"
fi
fi
saveflags="$CPPFLAGS"
CPPFLAGS="$saveflags $NUMA_INCLUDES"
HAVE_NUMA=no
AC_MSG_CHECKING([for numa.h])
AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <numa.h>]])],
[ac_cv_numa_header_path="found"],
[ac_cv_numa_header_path="not found"])
AC_MSG_RESULT($ac_cv_numa_header_path)
if test "$ac_cv_net_numa_header_path" = "found"; then
HAVE_NUMA=yes
fi
if test "$HAVE_NUMA" = yes; then
AC_CACHE_CHECK([whether numa.h works],
[ac_cv_working_numa_h], [
AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <numa.h>]])],
[ac_cv_working_numa_h=yes],
[ac_cv_working_numa_h=no])])
test "$ac_cv_working_numa_h" != yes && HAVE_NUMA=
fi
AC_SUBST(NUMA_INCLUDES)
])
dnl
dnl CLICK_PROG_INSTALL
......
Markdown is supported
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