This is the mail archive of the cluster-cvs@sourceware.org mailing list for the cluster.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RHEL5 - clogd: Set priority scheduling for the cluster log daemon


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=20451b5c73ba42447aee9f0917839258ee1dfc62
Commit:        20451b5c73ba42447aee9f0917839258ee1dfc62
Parent:        12d9370aba6ab5b987739e4016faeb26cdd906ae
Author:        Jonathan Brassow <jbrassow@redhat.com>
AuthorDate:    Tue Sep 23 15:29:53 2008 -0500
Committer:     Jonathan Brassow <jbrassow@redhat.com>
CommitterDate: Tue Sep 23 15:29:53 2008 -0500

clogd:  Set priority scheduling for the cluster log daemon

Prevents excessive waiting and allows the daemon to finish
AIS workload while under heavy I/O.
---
 cmirror/src/clogd.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/cmirror/src/clogd.c b/cmirror/src/clogd.c
index 114c711..0fa00ec 100644
--- a/cmirror/src/clogd.c
+++ b/cmirror/src/clogd.c
@@ -3,6 +3,7 @@
 #include <stdint.h>
 #include <string.h>
 #include <errno.h>
+#include <sched.h>
 #include <sys/types.h>
 #include <sys/wait.h>
 #include <sys/stat.h>
@@ -31,6 +32,7 @@ static void process_signals(void);
 static void daemonize(void);
 static void init_all(void);
 static void cleanup_all(void);
+static void set_priority(void);
 
 int main(int argc, char *argv[])
 {
@@ -41,6 +43,8 @@ int main(int argc, char *argv[])
 	/* Parent can now exit, we're ready to handle requests */
 	kill(getppid(), SIGTERM);
 
+	set_priority();
+
 	LOG_PRINT("Starting clogd:");
 	LOG_PRINT(" Built: "__DATE__" "__TIME__"\n");
 	LOG_DBG(" Compiled with debugging.");
@@ -269,3 +273,18 @@ static void cleanup_all(void)
 	cleanup_cluster();
 	cleanup_queues();
 }
+
+static void set_priority(void)
+{
+        struct sched_param sched_param;
+        int res;
+
+        res = sched_get_priority_max(SCHED_RR);
+        if (res != -1) {
+                sched_param.sched_priority = res;
+                res = sched_setscheduler(0, SCHED_RR, &sched_param);
+	}
+
+	if (res == -1)
+		LOG_ERROR("Unable to set SCHED_RR priority.");
+}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]