From: Amitay Isaacs Date: Thu, 26 Sep 2013 08:47:27 +0000 (+1000) Subject: common/util: Use AIX specific code for setting high priority for CTDB daemon X-Git-Tag: ctdb-2.5~62 X-Git-Url: http://git.samba.org/?a=commitdiff_plain;h=7764cf67a61bbf1caad5aa8e2d75a262b9da654c;p=ctdb.git common/util: Use AIX specific code for setting high priority for CTDB daemon Signed-off-by: Amitay Isaacs --- diff --git a/common/ctdb_util.c b/common/ctdb_util.c index d4bfeeb5..d4f85416 100644 --- a/common/ctdb_util.c +++ b/common/ctdb_util.c @@ -322,17 +322,45 @@ struct ctdb_rec_data *ctdb_marshall_loop_next(struct ctdb_marshall_buffer *m, st #include #endif +#if HAVE_PROCINFO_H +#include +#endif + /* if possible, make this task real time */ void ctdb_set_scheduler(struct ctdb_context *ctdb) { -#if HAVE_SCHED_SETSCHEDULER +#ifdef _AIX_ +#if HAVE_THREAD_SETSCHED + struct thrdentry64 te; + tid64_t ti; + + ti = 0ULL; + if (getthrds64(getpid(), &te, sizeof(te), &ti, 1) != 1) { + DEBUG(DEBUG_ERR, ("Unable to get thread information\n")); + return; + } + + if (ctdb->saved_scheduler_param == NULL) { + ctdb->saved_scheduler_param = talloc_size(ctdb, sizeof(te)); + } + *(struct thrdentry64 *)ctdb->saved_scheduler_param = te; + + if (thread_setsched(te.ti_tid, 0, SCHED_RR) == -1) { + DEBUG(DEBUG_ERR, ("Unable to set scheduler to SCHED_RR (%s)\n", + strerror(errno))); + } else { + DEBUG(DEBUG_NOTICE, ("Set scheduler to SCHED_RR\n")); + } +#endif +#else /* no AIX */ +#if HAVE_SCHED_SETSCHEDULER struct sched_param p; if (ctdb->saved_scheduler_param == NULL) { ctdb->saved_scheduler_param = talloc_size(ctdb, sizeof(p)); } - + if (sched_getparam(0, (struct sched_param *)ctdb->saved_scheduler_param) == -1) { DEBUG(DEBUG_ERR,("Unable to get old scheduler params\n")); return; @@ -348,6 +376,7 @@ void ctdb_set_scheduler(struct ctdb_context *ctdb) DEBUG(DEBUG_NOTICE,("Set scheduler to SCHED_FIFO\n")); } #endif +#endif } /* @@ -355,7 +384,25 @@ void ctdb_set_scheduler(struct ctdb_context *ctdb) */ void ctdb_restore_scheduler(struct ctdb_context *ctdb) { -#if HAVE_SCHED_SETSCHEDULER +#ifdef _AIX_ +#if HAVE_THREAD_SETSCHED + struct thrdentry64 te, *saved; + tid64_t ti; + + ti = 0ULL; + if (getthrds64(getpid(), &te, sizeof(te), &ti, 1) != 1) { + ctdb_fatal(ctdb, "Unable to get thread information\n"); + } + if (ctdb->saved_scheduler_param == NULL) { + ctdb_fatal(ctdb, "No saved scheduler parameters\n"); + } + saved = (struct thrdentry64 *)ctdb->saved_scheduler_param; + if (thread_setsched(te.ti_tid, saved->ti_pri, saved->ti_policy) == -1) { + ctdb_fatal(ctdb, "Unable to restore old scheduler parameters\n"); + } +#endif +#else /* no AIX */ +#if HAVE_SCHED_SETSCHEDULER if (ctdb->saved_scheduler_param == NULL) { ctdb_fatal(ctdb, "No saved scheduler parameters\n"); } @@ -363,6 +410,7 @@ void ctdb_restore_scheduler(struct ctdb_context *ctdb) ctdb_fatal(ctdb, "Unable to restore old scheduler parameters\n"); } #endif +#endif } void set_nonblocking(int fd) diff --git a/configure.ac b/configure.ac index 37b5a640..f3d2033a 100644 --- a/configure.ac +++ b/configure.ac @@ -26,6 +26,7 @@ case `uname` in AIX*) CTDB_SYSTEM_OBJ=common/system_aix.o CTDB_SCSI_IO= + CPPFLAGS="$CPPFLAGS -D_AIX_=1" CTDB_PCAP_LDFLAGS=-lpcap ;; GNU/kFreeBSD) @@ -97,12 +98,14 @@ m4_include(lib/socket_wrapper/config.m4) m4_include(utils/pmda/config.m4) AC_CHECK_HEADERS(sched.h) +AC_CHECK_HEADERS(procinfo.h) AC_CHECK_DECL([ETIME], [],[AC_DEFINE([ETIME], ETIMEDOUT, [ETIME on non-supporting platforms])], [ #include ]) AC_CHECK_FUNCS(sched_setscheduler) +AC_CHECK_FUNCS(thread_setsched) AC_CHECK_FUNCS(mlockall) AC_CACHE_CHECK([for sin_len in sock],ctdb_cv_HAVE_SOCK_SIN_LEN,[