summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmitay Isaacs <amitay@gmail.com>2014-06-06 12:21:25 +1000
committerMartin Schwenke <martins@samba.org>2014-06-12 05:40:10 +0200
commit19fcf6ff5206b14c481f078371f5b407d43900b7 (patch)
treeeaaa6a5ae9a96025d0d6f0632124e3bf6a8ff134
parent1dda098401a208d792bccc4a3f9e1b56571e6309 (diff)
downloadsamba-19fcf6ff5206b14c481f078371f5b407d43900b7.tar.gz
samba-19fcf6ff5206b14c481f078371f5b407d43900b7.tar.xz
samba-19fcf6ff5206b14c481f078371f5b407d43900b7.zip
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 <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
-rw-r--r--ctdb/common/ctdb_util.c34
-rw-r--r--ctdb/include/ctdb_private.h1
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;