Skip to content

Commit

Permalink
ihkmond: Fix location of kmsg buffer file
Browse files Browse the repository at this point in the history
kmsg should be stored in a fast buffer before sent to /dev/log via
syslog(2) because syslog(2) drops messages when the message rate
exceeds the relatively low limit.
File is used as the buffer and its location is fixed so that it
resides in the node local file-system (i.e. /tmp/ihkmond).
  • Loading branch information
masamichitakagi committed Mar 27, 2018
1 parent b498486 commit cbca1a8
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 34 deletions.
3 changes: 0 additions & 3 deletions config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,6 @@
/* Define to address of kernel symbol x86_trampoline_base, or 0 if exported */
#undef IHK_KSYM_x86_trampoline_base

/* Temporary directory used by IHK */
#undef IHK_TMPDIR

/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT

Expand Down
13 changes: 0 additions & 13 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,6 @@ IHK_RELEASE_DATE
DCFA_VERSION
MCKERNEL_VERSION
IHK_VERSION
IHK_TMPDIR
MANDIR
KMODDIR
LIBDIR
Expand Down Expand Up @@ -3058,9 +3057,6 @@ case $WITH_TARGET in
if test "X$INCLUDEDIR" = X; then
INCLUDEDIR="$prefix/include"
fi
if test "X$IHK_TMPDIR" = X; then
IHK_TMPDIR="$prefix/tmp"
fi
;;
smp-arm64)
if test "X$BINDIR" = X; then
Expand Down Expand Up @@ -5051,14 +5047,6 @@ if test "x$libudev" = "xno" ; then
as_fn_error $? "Install libudev package, e.g. yum install libudev-devel" "$LINENO" 5
fi

if test "x$IHK_TMPDIR" != "x" ; then

cat >>confdefs.h <<_ACEOF
#define IHK_TMPDIR "$IHK_TMPDIR"
_ACEOF

fi

if test "x$ENABLE_PERF" = "xyes" ; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: perf is enabled" >&5
$as_echo "$as_me: perf is enabled" >&6;}
Expand Down Expand Up @@ -5103,7 +5091,6 @@ fi






case "$TARGET" in
Expand Down
8 changes: 0 additions & 8 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,6 @@ case $WITH_TARGET in
if test "X$INCLUDEDIR" = X; then
INCLUDEDIR="$prefix/include"
fi
if test "X$IHK_TMPDIR" = X; then
IHK_TMPDIR="$prefix/tmp"
fi
;;
smp-arm64)
if test "X$BINDIR" = X; then
Expand Down Expand Up @@ -401,10 +398,6 @@ if test "x$libudev" = "xno" ; then
AC_MSG_ERROR([Install libudev package, e.g. yum install libudev-devel])
fi

if test "x$IHK_TMPDIR" != "x" ; then
AC_DEFINE_UNQUOTED(IHK_TMPDIR,"$IHK_TMPDIR",[Temporary directory used by IHK])
fi

if test "x$ENABLE_PERF" = "xyes" ; then
AC_MSG_NOTICE([perf is enabled])
AC_DEFINE([ENABLE_PERF],[1],[whether perf is enabled])
Expand Down Expand Up @@ -432,7 +425,6 @@ AC_SUBST(INCLUDEDIR)
AC_SUBST(LIBDIR)
AC_SUBST(KMODDIR)
AC_SUBST(MANDIR)
AC_SUBST(IHK_TMPDIR)
AC_SUBST(CFLAGS)

AC_SUBST(IHK_VERSION)
Expand Down
2 changes: 0 additions & 2 deletions linux/user/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ SBINDIR=@SBINDIR@
LIBDIR=@LIBDIR@
INCLUDEDIR=@INCLUDEDIR@
MANDIR=@MANDIR@
IHK_TMPDIR=@IHK_TMPDIR@
VPATH=@abs_srcdir@
LIBS=@LIBS@
TARGET=libihk.so ihkconfig ihkosctl memdump pagetable maccess memdump-mic ihkmond
Expand Down Expand Up @@ -61,4 +60,3 @@ install:
install -m 644 ihkconfig.1 $(MANDIR)/man1/ihkconfig.1
install -m 644 ihkosctl.1 $(MANDIR)/man1/ihkosctl.1
install -m 755 ihkmond $(SBINDIR)/ihkmond
mkdir -p -m 757 $(IHK_TMPDIR)
17 changes: 14 additions & 3 deletions linux/user/ihkmond.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@

#define IHKMOND_SIZE_FILEBUF_SLOT (1 * (1ULL << 20))
#define IHKMOND_NUM_FILEBUF_SLOTS 64
#define IHKMOND_TMP "/tmp/ihkmond"

struct thr_args {
pthread_t thread;
Expand Down Expand Up @@ -232,15 +233,19 @@ static int fwrite_kmsg(int dev_index, void* handle, int os_index, FILE **fps, in

if (next_slot || fps[*prod] == NULL) {
if (fps[*prod] == NULL) {
sprintf(fn, IHK_TMPDIR "/mcos%d", os_index);
sprintf(fn, IHKMOND_TMP);
ret_lib = mkdir(fn, 0755);
CHKANDJUMP(ret_lib != 0 && errno != EEXIST, -errno, "mkdir failed\n");

sprintf(fn, IHKMOND_TMP "/mcos%d", os_index);
ret_lib = mkdir(fn, 0755);
CHKANDJUMP(ret_lib != 0 && errno != EEXIST, -errno, "mkdir failed\n");
} else {
fclose(fps[*prod]);
fps[*prod] = NULL;
}

sprintf(fn, IHK_TMPDIR "/mcos%d/kmsg%d", os_index, *prod);
sprintf(fn, IHKMOND_TMP "/mcos%d/kmsg%d", os_index, *prod);
fps[*prod] = fopen(fn, "w+");
CHKANDJUMP(fps[*prod] == NULL, -EINVAL, "fopen failed\n");
sizes[*prod] = 0;
Expand Down Expand Up @@ -442,9 +447,15 @@ static void* redirect_kmsg(void* _arg) {
fps[i] = NULL;
#if 0
char fn[256];
sprintf(fn, IHK_TMPDIR "/mcos%d/kmsg%d", arg->os_index, i);
sprintf(fn, IHKMOND_TMP "/mcos%d/kmsg%d", arg->os_index, i);
ret_lib = unlink(fn);
CHKANDJUMP(ret_lib != 0, -EINVAL, "unlink failed\n");
sprintf(fn, IHKMOND_TMP "/mcos%d", arg->os_index);
ret_lib = rmdir(fn);
CHKANDJUMP(ret_lib != 0, -EINVAL, "rmdir failed\n");
sprintf(fn, IHKMOND_TMP);
ret_lib = rmdir(fn);
CHKANDJUMP(ret_lib != 0, -EINVAL, "rmdir failed\n");
#endif
}
}
Expand Down
10 changes: 5 additions & 5 deletions test/ihklib/ihklib006_lin.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ int main(int argc, char** argv) {
status = system(cmd);
CHKANDJUMP(WEXITSTATUS(status) != 0, -1, "system insmod");

sprintf(cmd, "insmod %s/kmod/ihk-smp-x86.ko ihk_start_irq=240 ihk_ikc_irq_core=0", PREFIX);
sprintf(cmd, "insmod %s/kmod/ihk-smp-x86_64.ko ihk_start_irq=240 ihk_ikc_irq_core=0", PREFIX);
status = system(cmd);
CHKANDJUMP(WEXITSTATUS(status) != 0, -1, "system insmod");

Expand Down Expand Up @@ -145,7 +145,7 @@ int main(int argc, char** argv) {

// create 0
ret_ihklib = ihk_create_os(0);
OKNG(ret_ihklib == 0, "ihk_create_os (2)\n");
OKNG(ret_ihklib == 0, "ihk_create_os\n");

sprintf(cmd, "chown takagi:takagi /dev/mcos*\n");
status = system(cmd);
Expand Down Expand Up @@ -196,7 +196,7 @@ int main(int argc, char** argv) {
nread = fread(buf, 1, sizeof(buf), fp);
buf[nread] = 0;
OKNG(strstr(buf, "ihklib006_mck exit OK") != NULL, "mcexec\n");

// check /var/log/local5. Note that kmsg is flushed on destroying /dev/mcos0
fp = popen("cat /var/log/local5", "r");
nread = fread(buf, 1, sizeof(buf), fp);
Expand All @@ -209,6 +209,7 @@ int main(int argc, char** argv) {
ret_ihklib = ihk_destroy_os(0, 0);
if (ret_ihklib == 0) {
OKNG(1, "ihk_destroy_os (4), trial #%d succeeded\n", i + 1);
break;
}
}
CHKANDJUMP(i == 4, 255, "ihk_destroy_os failed four times\n");
Expand Down Expand Up @@ -245,7 +246,7 @@ int main(int argc, char** argv) {
strstr(buf, "/tmp/mcos/mcos0_sys") == NULL, "ihk_os_destroy_pseudofs (3)\n");

// rmmod ihk-smp-x86
sprintf(cmd, "rmmod %s/kmod/ihk-smp-x86.ko", PREFIX);
sprintf(cmd, "rmmod %s/kmod/ihk-smp-x86_64.ko", PREFIX);
status = system(cmd);
CHKANDJUMP(WEXITSTATUS(status) != 0, -1, "system rmmod");

Expand All @@ -261,6 +262,5 @@ int main(int argc, char** argv) {
fn_fail:
// kill ihkmond
status = system("pid=`pidof ihkmond`&&if [ \"${pid}\" != \"\" ]; then kill -9 ${pid}; fi");
CHKANDJUMP(WEXITSTATUS(status) != 0, -1, "system");
goto fn_exit;
}

0 comments on commit cbca1a8

Please sign in to comment.