Fix rusage
This commit is contained in:
49
configure
vendored
49
configure
vendored
@ -644,13 +644,14 @@ IHK_RELEASE_DATE
|
|||||||
DCFA_VERSION
|
DCFA_VERSION
|
||||||
MCKERNEL_VERSION
|
MCKERNEL_VERSION
|
||||||
IHK_VERSION
|
IHK_VERSION
|
||||||
|
ENABLE_RUSAGE
|
||||||
ENABLE_MCOVERLAYFS
|
ENABLE_MCOVERLAYFS
|
||||||
MANDIR
|
MANDIR
|
||||||
KERNDIR
|
KERNDIR
|
||||||
KMODDIR
|
KMODDIR
|
||||||
ETCDIR
|
ETCDIR
|
||||||
|
MCKERNEL_LIBDIR
|
||||||
SBINDIR
|
SBINDIR
|
||||||
LIBDIR
|
|
||||||
BINDIR
|
BINDIR
|
||||||
TARGET
|
TARGET
|
||||||
UNAME_R
|
UNAME_R
|
||||||
@ -713,6 +714,7 @@ with_system_map
|
|||||||
enable_dcfa
|
enable_dcfa
|
||||||
enable_memdump
|
enable_memdump
|
||||||
enable_mcoverlayfs
|
enable_mcoverlayfs
|
||||||
|
enable_rusage
|
||||||
with_uname_r
|
with_uname_r
|
||||||
'
|
'
|
||||||
ac_precious_vars='build_alias
|
ac_precious_vars='build_alias
|
||||||
@ -1348,6 +1350,7 @@ Optional Features:
|
|||||||
--enable-dcfa Enable DCFA modules
|
--enable-dcfa Enable DCFA modules
|
||||||
--enable-memdump enable dumping memory and analyzing a dump
|
--enable-memdump enable dumping memory and analyzing a dump
|
||||||
--enable-mcoverlayfs enable mcoverlayfs implementation
|
--enable-mcoverlayfs enable mcoverlayfs implementation
|
||||||
|
--enable-rusage enable rusage implementation
|
||||||
|
|
||||||
Optional Packages:
|
Optional Packages:
|
||||||
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
|
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
|
||||||
@ -3649,6 +3652,14 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Check whether --enable-rusage was given.
|
||||||
|
if test "${enable_rusage+set}" = set; then :
|
||||||
|
enableval=$enable_rusage; ENABLE_RUSAGE=$enableval
|
||||||
|
else
|
||||||
|
ENABLE_RUSAGE=yes
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Check whether --with-uname_r was given.
|
# Check whether --with-uname_r was given.
|
||||||
if test "${with_uname_r+set}" = set; then
|
if test "${with_uname_r+set}" = set; then
|
||||||
@ -4478,12 +4489,12 @@ case $WITH_TARGET in
|
|||||||
if test "X$BINDIR" = X; then
|
if test "X$BINDIR" = X; then
|
||||||
BINDIR="$prefix/bin"
|
BINDIR="$prefix/bin"
|
||||||
fi
|
fi
|
||||||
if test "X$LIBDIR" = X; then
|
|
||||||
LIBDIR="$prefix/lib"
|
|
||||||
fi
|
|
||||||
if test "X$SBINDIR" = X; then
|
if test "X$SBINDIR" = X; then
|
||||||
SBINDIR="$prefix/sbin"
|
SBINDIR="$prefix/sbin"
|
||||||
fi
|
fi
|
||||||
|
if test "X$MCKERNEL_LIBDIR" = X; then
|
||||||
|
MCKERNEL_LIBDIR="$prefix/lib"
|
||||||
|
fi
|
||||||
if test "X$ETCDIR" = X; then
|
if test "X$ETCDIR" = X; then
|
||||||
ETCDIR="$prefix/etc"
|
ETCDIR="$prefix/etc"
|
||||||
fi
|
fi
|
||||||
@ -5118,10 +5129,32 @@ else
|
|||||||
$as_echo "$as_me: mcoverlayfs is disabled" >&6;}
|
$as_echo "$as_me: mcoverlayfs is disabled" >&6;}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test "x$LIBDIR" != "x" ; then
|
case $ENABLE_RUSAGE in
|
||||||
|
yes|no)
|
||||||
|
;;
|
||||||
|
default)
|
||||||
|
ENABLE_RUSAGE=yes
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
as_fn_error $? "unknown rusage argument: $ENABLE_RUSAGE" "$LINENO" 5
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if test "x$ENABLE_RUSAGE" = "xyes" ; then
|
||||||
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: rusage is enabled" >&5
|
||||||
|
$as_echo "$as_me: rusage is enabled" >&6;}
|
||||||
|
|
||||||
|
$as_echo "#define ENABLE_RUSAGE 1" >>confdefs.h
|
||||||
|
|
||||||
|
else
|
||||||
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: rusage is disabled" >&5
|
||||||
|
$as_echo "$as_me: rusage is disabled" >&6;}
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test "x$MCKERNEL_LIBDIR" != "x" ; then
|
||||||
|
|
||||||
cat >>confdefs.h <<_ACEOF
|
cat >>confdefs.h <<_ACEOF
|
||||||
#define MCKERNEL_LIBDIR "$LIBDIR"
|
#define MCKERNEL_LIBDIR "$MCKERNEL_LIBDIR"
|
||||||
_ACEOF
|
_ACEOF
|
||||||
|
|
||||||
fi
|
fi
|
||||||
@ -5149,6 +5182,9 @@ fi
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ac_config_headers="$ac_config_headers kernel/include/config.h"
|
||||||
|
|
||||||
ac_config_headers="$ac_config_headers executer/config.h"
|
ac_config_headers="$ac_config_headers executer/config.h"
|
||||||
|
|
||||||
@ -5755,6 +5791,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
|
|||||||
for ac_config_target in $ac_config_targets
|
for ac_config_target in $ac_config_targets
|
||||||
do
|
do
|
||||||
case $ac_config_target in
|
case $ac_config_target in
|
||||||
|
"kernel/include/config.h") CONFIG_HEADERS="$CONFIG_HEADERS kernel/include/config.h" ;;
|
||||||
"executer/config.h") CONFIG_HEADERS="$CONFIG_HEADERS executer/config.h" ;;
|
"executer/config.h") CONFIG_HEADERS="$CONFIG_HEADERS executer/config.h" ;;
|
||||||
"Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
|
"Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
|
||||||
"executer/user/Makefile") CONFIG_FILES="$CONFIG_FILES executer/user/Makefile" ;;
|
"executer/user/Makefile") CONFIG_FILES="$CONFIG_FILES executer/user/Makefile" ;;
|
||||||
|
|||||||
38
configure.ac
38
configure.ac
@ -55,6 +55,12 @@ AC_ARG_ENABLE([mcoverlayfs],
|
|||||||
[ENABLE_MCOVERLAYFS=$enableval],
|
[ENABLE_MCOVERLAYFS=$enableval],
|
||||||
[ENABLE_MCOVERLAYFS=yes])
|
[ENABLE_MCOVERLAYFS=yes])
|
||||||
|
|
||||||
|
AC_ARG_ENABLE([rusage],
|
||||||
|
AC_HELP_STRING([--enable-rusage],
|
||||||
|
[enable rusage implementation]),
|
||||||
|
[ENABLE_RUSAGE=$enableval],
|
||||||
|
[ENABLE_RUSAGE=yes])
|
||||||
|
|
||||||
AC_ARG_WITH([uname_r],
|
AC_ARG_WITH([uname_r],
|
||||||
AC_HELP_STRING(
|
AC_HELP_STRING(
|
||||||
[--with-uname_r=uname_r],[Value of '`uname -r`' on the target platform, default is local value]),
|
[--with-uname_r=uname_r],[Value of '`uname -r`' on the target platform, default is local value]),
|
||||||
@ -162,12 +168,12 @@ case $WITH_TARGET in
|
|||||||
if test "X$BINDIR" = X; then
|
if test "X$BINDIR" = X; then
|
||||||
BINDIR="$prefix/bin"
|
BINDIR="$prefix/bin"
|
||||||
fi
|
fi
|
||||||
if test "X$LIBDIR" = X; then
|
|
||||||
LIBDIR="$prefix/lib"
|
|
||||||
fi
|
|
||||||
if test "X$SBINDIR" = X; then
|
if test "X$SBINDIR" = X; then
|
||||||
SBINDIR="$prefix/sbin"
|
SBINDIR="$prefix/sbin"
|
||||||
fi
|
fi
|
||||||
|
if test "X$MCKERNEL_LIBDIR" = X; then
|
||||||
|
MCKERNEL_LIBDIR="$prefix/lib"
|
||||||
|
fi
|
||||||
if test "X$ETCDIR" = X; then
|
if test "X$ETCDIR" = X; then
|
||||||
ETCDIR="$prefix/etc"
|
ETCDIR="$prefix/etc"
|
||||||
fi
|
fi
|
||||||
@ -298,8 +304,26 @@ else
|
|||||||
AC_MSG_NOTICE([mcoverlayfs is disabled])
|
AC_MSG_NOTICE([mcoverlayfs is disabled])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test "x$LIBDIR" != "x" ; then
|
case $ENABLE_RUSAGE in
|
||||||
AC_DEFINE_UNQUOTED(MCKERNEL_LIBDIR,"$LIBDIR",[McKernel specific libraries])
|
yes|no)
|
||||||
|
;;
|
||||||
|
default)
|
||||||
|
ENABLE_RUSAGE=yes
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
AC_MSG_ERROR([unknown rusage argument: $ENABLE_RUSAGE])
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if test "x$ENABLE_RUSAGE" = "xyes" ; then
|
||||||
|
AC_MSG_NOTICE([rusage is enabled])
|
||||||
|
AC_DEFINE([ENABLE_RUSAGE],[1],[whether rusage is enabled])
|
||||||
|
else
|
||||||
|
AC_MSG_NOTICE([rusage is disabled])
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test "x$MCKERNEL_LIBDIR" != "x" ; then
|
||||||
|
AC_DEFINE_UNQUOTED(MCKERNEL_LIBDIR,"$MCKERNEL_LIBDIR",[McKernel specific libraries])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
AC_SUBST(CC)
|
AC_SUBST(CC)
|
||||||
@ -309,14 +333,15 @@ AC_SUBST(KDIR)
|
|||||||
AC_SUBST(UNAME_R)
|
AC_SUBST(UNAME_R)
|
||||||
AC_SUBST(TARGET)
|
AC_SUBST(TARGET)
|
||||||
AC_SUBST(BINDIR)
|
AC_SUBST(BINDIR)
|
||||||
AC_SUBST(LIBDIR)
|
|
||||||
AC_SUBST(SBINDIR)
|
AC_SUBST(SBINDIR)
|
||||||
|
AC_SUBST(MCKERNEL_LIBDIR)
|
||||||
AC_SUBST(ETCDIR)
|
AC_SUBST(ETCDIR)
|
||||||
AC_SUBST(KMODDIR)
|
AC_SUBST(KMODDIR)
|
||||||
AC_SUBST(KERNDIR)
|
AC_SUBST(KERNDIR)
|
||||||
AC_SUBST(MANDIR)
|
AC_SUBST(MANDIR)
|
||||||
AC_SUBST(CFLAGS)
|
AC_SUBST(CFLAGS)
|
||||||
AC_SUBST(ENABLE_MCOVERLAYFS)
|
AC_SUBST(ENABLE_MCOVERLAYFS)
|
||||||
|
AC_SUBST(ENABLE_RUSAGE)
|
||||||
|
|
||||||
AC_SUBST(IHK_VERSION)
|
AC_SUBST(IHK_VERSION)
|
||||||
AC_SUBST(MCKERNEL_VERSION)
|
AC_SUBST(MCKERNEL_VERSION)
|
||||||
@ -326,6 +351,7 @@ AC_SUBST(MCKERNEL_RELEASE_DATE)
|
|||||||
AC_SUBST(DCFA_RESEASE_DATE)
|
AC_SUBST(DCFA_RESEASE_DATE)
|
||||||
AC_SUBST(uncomment_if_ENABLE_MEMDUMP)
|
AC_SUBST(uncomment_if_ENABLE_MEMDUMP)
|
||||||
|
|
||||||
|
AC_CONFIG_HEADERS([kernel/include/config.h])
|
||||||
AC_CONFIG_HEADERS([executer/config.h])
|
AC_CONFIG_HEADERS([executer/config.h])
|
||||||
AC_CONFIG_FILES([
|
AC_CONFIG_FILES([
|
||||||
Makefile
|
Makefile
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
CC=@CC@
|
CC=@CC@
|
||||||
BINDIR=@BINDIR@
|
BINDIR=@BINDIR@
|
||||||
LIBDIR=@LIBDIR@
|
MCKERNEL_LIBDIR=@MCKERNEL_LIBDIR@
|
||||||
KDIR ?= @KDIR@
|
KDIR ?= @KDIR@
|
||||||
CFLAGS=-Wall -O -I.
|
CFLAGS=-Wall -O -I.
|
||||||
VPATH=@abs_srcdir@
|
VPATH=@abs_srcdir@
|
||||||
@ -28,7 +28,7 @@ clean:
|
|||||||
install:
|
install:
|
||||||
mkdir -p -m 755 $(BINDIR)
|
mkdir -p -m 755 $(BINDIR)
|
||||||
install -m 755 mcexec $(BINDIR)
|
install -m 755 mcexec $(BINDIR)
|
||||||
mkdir -p -m 755 $(LIBDIR)
|
mkdir -p -m 755 $(MCKERNEL_LIBDIR)
|
||||||
install -m 755 libsched_yield.so.1.0.0 $(LIBDIR)
|
install -m 755 libsched_yield.so.1.0.0 $(MCKERNEL_LIBDIR)
|
||||||
@uncomment_if_ENABLE_MEMDUMP@install -m 755 eclair $(BINDIR)
|
@uncomment_if_ENABLE_MEMDUMP@install -m 755 eclair $(BINDIR)
|
||||||
|
|
||||||
|
|||||||
@ -1,17 +1,12 @@
|
|||||||
ENABLE_RUSAGE=@ENABLE_RUSAGE@
|
|
||||||
VPATH=@abs_srcdir@
|
VPATH=@abs_srcdir@
|
||||||
SRC=$(VPATH)
|
SRC=$(VPATH)
|
||||||
IHKDIR=$(IHKBASE)/$(TARGETDIR)
|
IHKDIR=$(IHKBASE)/$(TARGETDIR)
|
||||||
OBJS = init.o mem.o debug.o mikc.o listeners.o ap.o syscall.o cls.o host.o
|
OBJS = init.o mem.o debug.o mikc.o listeners.o ap.o syscall.o cls.o host.o
|
||||||
OBJS += process.o copy.o waitq.o futex.o timer.o plist.o fileobj.o shmobj.o
|
OBJS += process.o copy.o waitq.o futex.o timer.o plist.o fileobj.o shmobj.o
|
||||||
OBJS += zeroobj.o procfs.o devobj.o sysfs.o xpmem.o profile.o rusage.o freeze.o
|
OBJS += zeroobj.o procfs.o devobj.o sysfs.o xpmem.o rusage.o profile.c freeze.o
|
||||||
DEPSRCS=$(wildcard $(SRC)/*.c)
|
DEPSRCS=$(wildcard $(SRC)/*.c)
|
||||||
DOPT=
|
|
||||||
ifeq ($(ENABLE_RUSAGE),yes)
|
|
||||||
DOPT=-DENABLE_RUSAGE
|
|
||||||
endif
|
|
||||||
|
|
||||||
CFLAGS += -I$(SRC)/include -D__KERNEL__ $(DOPT) -g -fno-omit-frame-pointer -fno-inline -fno-inline-small-functions
|
CFLAGS += -I$(SRC)/include -I@abs_builddir@/include -D__KERNEL__ -g -fno-omit-frame-pointer -fno-inline -fno-inline-small-functions
|
||||||
LDFLAGS += -e arch_start
|
LDFLAGS += -e arch_start
|
||||||
IHKOBJ = ihk/ihk.o
|
IHKOBJ = ihk/ihk.o
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
#ifndef __RUSAGE_H
|
#ifndef __RUSAGE_H
|
||||||
#define __RUSAGE_H
|
#define __RUSAGE_H
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#define RUSAGE_DEFAULT_SIZE 10
|
#define RUSAGE_DEFAULT_SIZE 10
|
||||||
|
|
||||||
enum RUSAGE_MEMBER {
|
enum RUSAGE_MEMBER {
|
||||||
@ -64,7 +66,6 @@ enum sys_delegate_state_enum {
|
|||||||
};
|
};
|
||||||
enum sys_delegate_state_enum sys_delegate_state;
|
enum sys_delegate_state_enum sys_delegate_state;
|
||||||
|
|
||||||
unsigned long rusage_rss[sizeof(cpu_set_t)/8];
|
|
||||||
unsigned long rusage_rss_max;
|
unsigned long rusage_rss_max;
|
||||||
long rusage_rss_current;
|
long rusage_rss_current;
|
||||||
unsigned long rusage_kmem_usage;
|
unsigned long rusage_kmem_usage;
|
||||||
@ -76,4 +77,7 @@ unsigned long rusage_max_memory;
|
|||||||
|
|
||||||
#define RUSAGE_MEM_LIMIT 2000000
|
#define RUSAGE_MEM_LIMIT 2000000
|
||||||
|
|
||||||
|
void rusage_init();
|
||||||
|
void rusage_inc_num_threads(int count);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -334,23 +334,7 @@ struct thread *create_thread(unsigned long user_pc,
|
|||||||
ihk_mc_spinlock_init(&thread->spin_sleep_lock);
|
ihk_mc_spinlock_init(&thread->spin_sleep_lock);
|
||||||
thread->spin_sleep = 0;
|
thread->spin_sleep = 0;
|
||||||
#ifdef ENABLE_RUSAGE
|
#ifdef ENABLE_RUSAGE
|
||||||
{
|
rusage_inc_num_threads(1);
|
||||||
int processor_id;
|
|
||||||
unsigned long curr;
|
|
||||||
processor_id = ihk_mc_get_processor_id();
|
|
||||||
rusage_rss[processor_id] += KERNEL_STACK_NR_PAGES * PAGE_SIZE;
|
|
||||||
curr = ihk_atomic_add_long_return ( KERNEL_STACK_NR_PAGES * PAGE_SIZE, &rusage_rss_current);
|
|
||||||
if (rusage_rss_max < curr) {
|
|
||||||
atomic_cmpxchg8(&rusage_rss_max, rusage_rss_max, curr);
|
|
||||||
}
|
|
||||||
if (rusage_max_memory - curr < RUSAGE_MEM_LIMIT) {
|
|
||||||
event_signal();
|
|
||||||
}
|
|
||||||
ihk_atomic_add_ulong ( 1, &rusage_num_threads);
|
|
||||||
if (rusage_max_num_threads < rusage_num_threads) {
|
|
||||||
atomic_cmpxchg8(&rusage_max_num_threads, rusage_max_num_threads, rusage_num_threads);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
return thread;
|
return thread;
|
||||||
|
|
||||||
@ -503,25 +487,7 @@ clone_thread(struct thread *org, unsigned long pc, unsigned long sp,
|
|||||||
thread->spin_sleep = 0;
|
thread->spin_sleep = 0;
|
||||||
|
|
||||||
#ifdef ENABLE_RUSAGE
|
#ifdef ENABLE_RUSAGE
|
||||||
{
|
rusage_inc_num_threads(1);
|
||||||
int processor_id;
|
|
||||||
long curr;
|
|
||||||
processor_id = ihk_mc_get_processor_id();
|
|
||||||
rusage_rss[processor_id] += KERNEL_STACK_NR_PAGES * PAGE_SIZE;
|
|
||||||
curr = ihk_atomic_add_long_return (KERNEL_STACK_NR_PAGES * PAGE_SIZE, &rusage_rss_current);
|
|
||||||
if (rusage_rss_max < curr) {
|
|
||||||
atomic_cmpxchg8(&rusage_rss_max, rusage_rss_max, curr);
|
|
||||||
}
|
|
||||||
if (rusage_max_memory - curr < RUSAGE_MEM_LIMIT) {
|
|
||||||
event_signal();
|
|
||||||
}
|
|
||||||
|
|
||||||
ihk_atomic_add_ulong ( 1, &rusage_num_threads);
|
|
||||||
|
|
||||||
if (rusage_max_num_threads < rusage_num_threads) {
|
|
||||||
atomic_cmpxchg8(&rusage_max_num_threads, rusage_max_num_threads, rusage_num_threads);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PROFILE_ENABLE
|
#ifdef PROFILE_ENABLE
|
||||||
@ -2040,11 +2006,7 @@ int init_process_stack(struct thread *thread, struct program_load_desc *pn,
|
|||||||
|
|
||||||
#ifdef ENABLE_RUSAGE
|
#ifdef ENABLE_RUSAGE
|
||||||
{
|
{
|
||||||
int processor_id;
|
|
||||||
long curr;
|
long curr;
|
||||||
|
|
||||||
processor_id = ihk_mc_get_processor_id();
|
|
||||||
rusage_rss[processor_id] += (minsz >> PAGE_SHIFT) * PAGE_SIZE;
|
|
||||||
curr = ihk_atomic_add_long_return ((minsz >> PAGE_SHIFT) * PAGE_SIZE, &rusage_rss_current);
|
curr = ihk_atomic_add_long_return ((minsz >> PAGE_SHIFT) * PAGE_SIZE, &rusage_rss_current);
|
||||||
if (rusage_rss_max < curr) {
|
if (rusage_rss_max < curr) {
|
||||||
atomic_cmpxchg8(&rusage_rss_max, rusage_rss_max, curr);
|
atomic_cmpxchg8(&rusage_rss_max, rusage_rss_max, curr);
|
||||||
@ -2054,7 +2016,6 @@ int init_process_stack(struct thread *thread, struct program_load_desc *pn,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2102,10 +2063,7 @@ unsigned long extend_process_region(struct process_vm *vm,
|
|||||||
|
|
||||||
#ifdef ENABLE_RUSAGE
|
#ifdef ENABLE_RUSAGE
|
||||||
{
|
{
|
||||||
int processor_id;
|
|
||||||
long curr;
|
long curr;
|
||||||
processor_id = ihk_mc_get_processor_id();
|
|
||||||
rusage_rss[processor_id] += ((new_end_allocated - end_allocated) >> PAGE_SHIFT) * PAGE_SIZE;
|
|
||||||
curr = ihk_atomic_add_long_return (((new_end_allocated - end_allocated) >> PAGE_SHIFT) * PAGE_SIZE, &rusage_rss_current);
|
curr = ihk_atomic_add_long_return (((new_end_allocated - end_allocated) >> PAGE_SHIFT) * PAGE_SIZE, &rusage_rss_current);
|
||||||
if (rusage_rss_max < curr) {
|
if (rusage_rss_max < curr) {
|
||||||
atomic_cmpxchg8(&rusage_rss_max, rusage_rss_max, curr);
|
atomic_cmpxchg8(&rusage_rss_max, rusage_rss_max, curr);
|
||||||
@ -2419,10 +2377,6 @@ void destroy_thread(struct thread *thread)
|
|||||||
|
|
||||||
#ifdef ENABLE_RUSAGE
|
#ifdef ENABLE_RUSAGE
|
||||||
{
|
{
|
||||||
int processor_id;
|
|
||||||
processor_id = ihk_mc_get_processor_id();
|
|
||||||
rusage_rss[processor_id] -= KERNEL_STACK_NR_PAGES * PAGE_SIZE;
|
|
||||||
ihk_atomic_add_long_return(KERNEL_STACK_NR_PAGES * PAGE_SIZE * (-1) , &rusage_rss_current);
|
|
||||||
ihk_atomic_add_ulong ( -1, &rusage_num_threads);
|
ihk_atomic_add_ulong ( -1, &rusage_num_threads);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -34,14 +34,40 @@ extern struct ihk_os_monitor *monitor;
|
|||||||
|
|
||||||
|
|
||||||
#ifdef ENABLE_RUSAGE
|
#ifdef ENABLE_RUSAGE
|
||||||
|
/* initialize rusage */
|
||||||
|
void rusage_init() {
|
||||||
|
int i;
|
||||||
|
rusage_num_threads = 0;
|
||||||
|
rusage_max_num_threads = 0;
|
||||||
|
|
||||||
|
os_status = IHK_STATUS_INACTIVE;
|
||||||
|
rusage_hugetlb_usage = 0;
|
||||||
|
rusage_hugetlb_max_usage = 0;
|
||||||
|
for (i = 0; i < 1024; i++) {
|
||||||
|
rusage_numa_stat[i] = 0;
|
||||||
|
}
|
||||||
|
rusage_rss_current = 0;
|
||||||
|
rusage_rss_max = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void rusage_inc_num_threads(int count) {
|
||||||
|
volatile unsigned long max_obs1, max_obs2;
|
||||||
|
ihk_atomic_add_ulong(count, &rusage_num_threads);
|
||||||
|
max_obs1 = rusage_max_num_threads;
|
||||||
|
if (max_obs1 < rusage_num_threads) {
|
||||||
|
retry:
|
||||||
|
max_obs2 = atomic_cmpxchg8(&rusage_max_num_threads, max_obs1, rusage_num_threads);
|
||||||
|
if(max_obs2 != max_obs1 &&
|
||||||
|
max_obs2 < rusage_num_threads) {
|
||||||
|
max_obs1 = max_obs2;
|
||||||
|
goto retry;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* count total rss */
|
/* count total rss */
|
||||||
unsigned long count_rss () {
|
unsigned long count_rss () {
|
||||||
int i;
|
return rusage_rss_current;
|
||||||
unsigned long val = 0;
|
|
||||||
for(i = 0; i < sizeof(cpu_set_t)/8; i++){
|
|
||||||
val += rusage_rss[i];
|
|
||||||
}
|
|
||||||
return val;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* count total cache */
|
/* count total cache */
|
||||||
|
|||||||
Reference in New Issue
Block a user