mcexec: --disable-sched-yield: avoid kernel/user switch
This commit is contained in:
13
configure
vendored
13
configure
vendored
@ -634,6 +634,7 @@ KERNDIR
|
||||
KMODDIR
|
||||
ETCDIR
|
||||
SBINDIR
|
||||
LIBDIR
|
||||
BINDIR
|
||||
TARGET
|
||||
UNAME_R
|
||||
@ -4039,6 +4040,9 @@ case $WITH_TARGET in
|
||||
if test "X$BINDIR" = X; then
|
||||
BINDIR="$prefix/bin"
|
||||
fi
|
||||
if test "X$LIBDIR" = X; then
|
||||
LIBDIR="$prefix/lib"
|
||||
fi
|
||||
if test "X$SBINDIR" = X; then
|
||||
SBINDIR="$prefix/sbin"
|
||||
fi
|
||||
@ -4506,6 +4510,15 @@ else
|
||||
$as_echo "$as_me: mcoverlayfs is disabled" >&6;}
|
||||
fi
|
||||
|
||||
if test "x$LIBDIR" != "x" ; then
|
||||
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
#define MCKERNEL_LIBDIR "$LIBDIR"
|
||||
_ACEOF
|
||||
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -162,6 +162,9 @@ case $WITH_TARGET in
|
||||
if test "X$BINDIR" = X; then
|
||||
BINDIR="$prefix/bin"
|
||||
fi
|
||||
if test "X$LIBDIR" = X; then
|
||||
LIBDIR="$prefix/lib"
|
||||
fi
|
||||
if test "X$SBINDIR" = X; then
|
||||
SBINDIR="$prefix/sbin"
|
||||
fi
|
||||
@ -295,6 +298,10 @@ else
|
||||
AC_MSG_NOTICE([mcoverlayfs is disabled])
|
||||
fi
|
||||
|
||||
if test "x$LIBDIR" != "x" ; then
|
||||
AC_DEFINE_UNQUOTED(MCKERNEL_LIBDIR,"$LIBDIR",[McKernel specific libraries])
|
||||
fi
|
||||
|
||||
AC_SUBST(CC)
|
||||
AC_SUBST(XCC)
|
||||
AC_SUBST(ARCH)
|
||||
@ -302,6 +309,7 @@ AC_SUBST(KDIR)
|
||||
AC_SUBST(UNAME_R)
|
||||
AC_SUBST(TARGET)
|
||||
AC_SUBST(BINDIR)
|
||||
AC_SUBST(LIBDIR)
|
||||
AC_SUBST(SBINDIR)
|
||||
AC_SUBST(ETCDIR)
|
||||
AC_SUBST(KMODDIR)
|
||||
|
||||
@ -72,6 +72,9 @@
|
||||
/* Define to address of kernel symbol zap_page_range, or 0 if exported */
|
||||
#undef MCCTRL_KSYM_zap_page_range
|
||||
|
||||
/* McKernel specific libraries */
|
||||
#undef MCKERNEL_LIBDIR
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#undef PACKAGE_BUGREPORT
|
||||
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
CC=@CC@
|
||||
BINDIR=@BINDIR@
|
||||
LIBDIR=@LIBDIR@
|
||||
KDIR ?= @KDIR@
|
||||
CFLAGS=-Wall -O -I.
|
||||
VPATH=@abs_srcdir@
|
||||
TARGET=mcexec
|
||||
TARGET=mcexec libsched_yield
|
||||
@uncomment_if_ENABLE_MEMDUMP@TARGET+=eclair
|
||||
LIBS=@LIBS@
|
||||
IHKDIR ?= $(VPATH)/../../../ihk/linux/include/
|
||||
@ -16,6 +17,9 @@ mcexec: mcexec.c
|
||||
eclair: eclair.c
|
||||
$(CC) $(CFLAGS) -I${IHKDIR} -o $@ $^ $(LIBS)
|
||||
|
||||
libsched_yield: libsched_yield.c
|
||||
$(CC) -shared -fPIC -Wl,-soname,sched_yield.so.1 -o libsched_yield.so.1.0.0 $^ -lc -ldl
|
||||
|
||||
clean:
|
||||
$(RM) $(TARGET) *.o
|
||||
|
||||
@ -24,5 +28,7 @@ clean:
|
||||
install:
|
||||
mkdir -p -m 755 $(BINDIR)
|
||||
install -m 755 mcexec $(BINDIR)
|
||||
mkdir -p -m 755 $(LIBDIR)
|
||||
install -m 755 libsched_yield.so.1.0.0 $(LIBDIR)
|
||||
@uncomment_if_ENABLE_MEMDUMP@install -m 755 eclair $(BINDIR)
|
||||
|
||||
|
||||
27
executer/user/libsched_yield.c
Normal file
27
executer/user/libsched_yield.c
Normal file
@ -0,0 +1,27 @@
|
||||
#define _GNU_SOURCE
|
||||
#include <dlfcn.h>
|
||||
#include <sys/time.h>
|
||||
#include <sched.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#undef sched_yield
|
||||
|
||||
typedef int (*int_void_fn)(void);
|
||||
|
||||
static int_void_fn orig_sched_yield = 0;
|
||||
|
||||
int sched_yield(void)
|
||||
{
|
||||
#if 0
|
||||
if (!orig_sched_yield) {
|
||||
orig_sched_yield = (int_void_fn)dlsym(RTLD_NEXT, "sched_yield");
|
||||
}
|
||||
|
||||
printf("sched_yield() called\n");
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -152,6 +152,7 @@ static int fd;
|
||||
static char *exec_path = NULL;
|
||||
static char *altroot;
|
||||
static const char rlimit_stack_envname[] = "MCKERNEL_RLIMIT_STACK";
|
||||
static const char ld_preload_envname[] = "MCKERNEL_LD_PRELOAD";
|
||||
static int ischild;
|
||||
static int enable_vdso = 1;
|
||||
static int mpol_no_heap = 0;
|
||||
@ -160,6 +161,7 @@ static int mpol_no_bss = 0;
|
||||
static int no_bind_ikc_map = 0;
|
||||
static unsigned long mpol_threshold = 0;
|
||||
static int profile = 0;
|
||||
static int disable_sched_yield = 0;
|
||||
|
||||
/* Partitioned execution (e.g., for MPI) */
|
||||
static int nr_processes = 0;
|
||||
@ -1321,6 +1323,12 @@ static struct option mcexec_options[] = {
|
||||
.flag = NULL,
|
||||
.val = 'm',
|
||||
},
|
||||
{
|
||||
.name = "disable-sched-yield",
|
||||
.has_arg = no_argument,
|
||||
.flag = &disable_sched_yield,
|
||||
.val = 1,
|
||||
},
|
||||
/* end */
|
||||
{ NULL, 0, NULL, 0, },
|
||||
};
|
||||
@ -1361,10 +1369,6 @@ int main(int argc, char **argv)
|
||||
altroot = "/usr/linux-k1om-4.7/linux-k1om";
|
||||
}
|
||||
|
||||
/* Collect environment variables */
|
||||
envs_len = flatten_strings(-1, NULL, environ, &envs);
|
||||
envs = envs;
|
||||
|
||||
rlim_stack.rlim_cur = MCEXEC_DEF_CUR_STACK_SIZE;
|
||||
rlim_stack.rlim_max = MCEXEC_DEF_MAX_STACK_SIZE;
|
||||
|
||||
@ -1436,6 +1440,29 @@ int main(int argc, char **argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (disable_sched_yield) {
|
||||
char sched_yield_lib_path[PATH_MAX];
|
||||
sprintf(sched_yield_lib_path, "%s/libsched_yield.so.1.0.0",
|
||||
MCKERNEL_LIBDIR);
|
||||
__dprintf("%s: %s\n", __FUNCTION__, sched_yield_lib_path);
|
||||
if (setenv("LD_PRELOAD", sched_yield_lib_path, 1) < 0) {
|
||||
printf("%s: warning: failed to set LD_PRELOAD for sched_yield\n",
|
||||
__FUNCTION__);
|
||||
}
|
||||
}
|
||||
/* Set LD_PRELOAD to McKernel specific value */
|
||||
else if (getenv(ld_preload_envname)) {
|
||||
if (setenv("LD_PRELOAD", getenv(ld_preload_envname), 1) < 0) {
|
||||
printf("%s: warning: failed to set LD_PRELOAD environment variable\n",
|
||||
__FUNCTION__);
|
||||
}
|
||||
unsetenv(ld_preload_envname);
|
||||
}
|
||||
|
||||
/* Collect environment variables */
|
||||
envs_len = flatten_strings(-1, NULL, environ, &envs);
|
||||
envs = envs;
|
||||
|
||||
#ifdef ENABLE_MCOVERLAYFS
|
||||
__dprintf("mcoverlay enable\n");
|
||||
char mcos_procdir[PATH_MAX];
|
||||
|
||||
Reference in New Issue
Block a user