From 19fcf6ff5206b14c481f078371f5b407d43900b7 Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Fri, 6 Jun 2014 12:21:25 +1000 Subject: ctdb-common: No need to save previous scheduler priority When calling sched_setscheduler() with SCHED_OTHER, the only valid priority is 0. Nice value is "restored" anyway. Signed-off-by: Amitay Isaacs Reviewed-by: Martin Schwenke --- ctdb/common/ctdb_util.c | 34 ++++++++-------------------------- ctdb/include/ctdb_private.h | 1 - 2 files changed, 8 insertions(+), 27 deletions(-) diff --git a/ctdb/common/ctdb_util.c b/ctdb/common/ctdb_util.c index fd0d7da1d8f..82c4764ef8d 100644 --- a/ctdb/common/ctdb_util.c +++ b/ctdb/common/ctdb_util.c @@ -342,11 +342,6 @@ void ctdb_set_scheduler(struct ctdb_context *ctdb) 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))); @@ -357,16 +352,7 @@ void ctdb_set_scheduler(struct ctdb_context *ctdb) #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; - } - p = *(struct sched_param *)ctdb->saved_scheduler_param; p.sched_priority = 1; if (sched_setscheduler(0, SCHED_FIFO, &p) == -1) { @@ -386,28 +372,24 @@ void ctdb_restore_scheduler(struct ctdb_context *ctdb) { #ifdef _AIX_ #if HAVE_THREAD_SETSCHED - struct thrdentry64 te, *saved; + struct thrdentry64 te; 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"); + if (thread_setsched(te.ti_tid, 0, SCHED_OTHER) == -1) { + ctdb_fatal(ctdb, "Unable to set scheduler to SCHED_OTHER\n"); } #endif #else /* no AIX */ #if HAVE_SCHED_SETSCHEDULER - if (ctdb->saved_scheduler_param == NULL) { - ctdb_fatal(ctdb, "No saved scheduler parameters\n"); - } - if (sched_setscheduler(0, SCHED_OTHER, (struct sched_param *)ctdb->saved_scheduler_param) == -1) { - ctdb_fatal(ctdb, "Unable to restore old scheduler parameters\n"); + struct sched_param p; + + p.sched_priority = 0; + if (sched_setscheduler(0, SCHED_OTHER, &p) == -1) { + ctdb_fatal(ctdb, "Unable to set scheduler to SCHED_OTHER\n"); } #endif #endif diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h index 81759786dd1..8ebd1c55d9a 100644 --- a/ctdb/include/ctdb_private.h +++ b/ctdb/include/ctdb_private.h @@ -512,7 +512,6 @@ struct ctdb_context { bool do_checkpublicip; struct trbt_tree *server_ids; bool do_setsched; - void *saved_scheduler_param; const char *event_script_dir; const char *notification_script; const char *default_public_interface; -- cgit