Skip to contentSkip to conversation

rt-tests: fix-policy-display-for-cyclictest.patch

PATCH In review Carsten Emde 2 participants 3 messages Mar 8, 2010

lore
Share & tools
lore
#0 lore raw

cover rt-tests: fix-policy-display-for-cyclictest.patch

Display all policies of cyclictest, if forced to something else than specified.

Evaluate the priority before it is decremented.

#1 lore raw

PATCH 1/1 fix-policy-display-for-cyclictest.patch

If the policy is forced to SCHED_OTHER, since the priority no longer fits into the SCHED_FIFO or SCHED_RR range, the policy display of cyclictest is somewhat incorrect.

Display all policies.

Also make the variable policystr static; the condition "if (!policystr)" is useless, otherwise.

In addition, place the priority logic before decrementing the priority; a priority of 1 is incorrectly made SCHED_OTHER, otherwise.

src/cyclictest/cyclictest.c +19 -6
Index: rt-tests/src/cyclictest/cyclictest.c
===================================================================
@@ -156,6 +156,7 @@ static int histogram = 0;
 static int duration = 0;
 static int use_nsecs = 0;
 static int refresh_on_max;
+static int force_sched_other;
 
 static pthread_cond_t refresh_on_max_cond = PTHREAD_COND_INITIALIZER;
 static pthread_mutex_t refresh_on_max_lock = PTHREAD_MUTEX_INITIALIZER;
@@ -1295,11 +1296,14 @@ int main(int argc, char **argv)
 		}
 
 		par->prio = priority;
+                if (priority && (policy == SCHED_FIFO || policy == SCHED_RR))
+			par->policy = policy;
+                else {
+			par->policy = SCHED_OTHER;
+			force_sched_other = 1;
+		}
 		if (priority && !histogram && !smp && !numa)
 			priority--;
-                if (priority && policy == SCHED_FIFO) par->policy = SCHED_FIFO;
-                else if (priority && policy == SCHED_RR) par->policy = SCHED_RR;
-                else  par->policy = SCHED_OTHER;
 		par->clock = clocksources[clocksel];
 		par->mode = mode;
 		par->timermode = timermode;
@@ -1330,18 +1334,27 @@ int main(int argc, char **argv)
 	while (!shutdown) {
 		char lavg[256];
 		int fd, len, allstopped = 0;
-		char *policystr = NULL;
+		static char *policystr = NULL;
+		static char *slash = NULL;
+		static char *policystr2;
 
 		if (!policystr)
 			policystr = policyname(policy);
 
+		if (!slash) {
+			if (force_sched_other) {
+				slash = "/";
+				policystr2 = policyname(SCHED_OTHER);
+			} else
+				slash = policystr2 = "";
+		}
 		if (!verbose && !quiet) {
 			fd = open("/proc/loadavg", O_RDONLY, 0666);
 			len = read(fd, &lavg, 255);
 			close(fd);
 			lavg[len-1] = 0x0;
-			printf("policy: %s: loadavg: %s          \n\n", 
-			       policystr, lavg);
+			printf("policy: %s%s%s: loadavg: %s          \n\n",
+			       policystr, slash, policystr2, lavg);
 		}
 
 		for (i = 0; i < num_threads; i++) {
Acked-by on v1 1/1
#2 lore raw

Re: [PATCH 1/1] fix-policy-display-for-cyclictest.patch

Quoted 67 lines · Carsten Emde

If the policy is forced to SCHED_OTHER, since the priority no longer fits into the SCHED_FIFO or SCHED_RR range, the policy display of cyclictest is somewhat incorrect.

Display all policies.

Also make the variable policystr static; the condition "if (!policystr)" is useless, otherwise.

In addition, place the priority logic before decrementing the priority; a priority of 1 is incorrectly made SCHED_OTHER, otherwise.

Index: rt-tests/src/cyclictest/cyclictest.c
===================================================================

src/cyclictest/cyclictest.c +17 -4
@@ -156,6 +156,7 @@ static int histogram = 0;
  static int duration = 0;
  static int use_nsecs = 0;
  static int refresh_on_max;
+static int force_sched_other;
 
  static pthread_cond_t refresh_on_max_cond = PTHREAD_COND_INITIALIZER;
  static pthread_mutex_t refresh_on_max_lock = PTHREAD_MUTEX_INITIALIZER;
@@ -1295,11 +1296,14 @@ int main(int argc, char **argv)
                }
 
                par->prio = priority;
+                if (priority && (policy == SCHED_FIFO || policy == SCHED_RR))
+                       par->policy = policy;
+                else {
+                       par->policy = SCHED_OTHER;
+                       force_sched_other = 1;
+               }
                if (priority && !histogram && !smp && !numa)
                        priority--;
-                if (priority && policy == SCHED_FIFO) par->policy = SCHED_FIFO;
-                else if (priority && policy == SCHED_RR) par->policy = SCHED_RR;
-                else  par->policy = SCHED_OTHER;
                par->clock = clocksources[clocksel];
                par->mode = mode;
                par->timermode = timermode;
@@ -1330,18 +1334,27 @@ int main(int argc, char **argv)
        while (!shutdown) {
                char lavg[256];
                int fd, len, allstopped = 0;
-               char *policystr = NULL;
+               static char *policystr = NULL;
+               static char *slash = NULL;
+               static char *policystr2;
 
                if (!policystr)
                        policystr = policyname(policy);
 
+               if (!slash) {
+                       if (force_sched_other) {
+                               slash = "/";
+                               policystr2 = policyname(SCHED_OTHER);
+                       } else
+                               slash = policystr2 = "";
+               }
                if (!verbose && !quiet) {
                        fd = open("/proc/loadavg", O_RDONLY, 0666);
                        len = read(fd, &lavg, 255);
                        close(fd);

src/cyclictest/cyclictest.c int main(int argc, char **argv)

Quoted 10 lines
src/cyclictest/cyclictest.c +2 -3
                        lavg[len-1] = 0x0;
-                       printf("policy: %s: loadavg: %s          \n\n",
-                              policystr, lavg);
+                       printf("policy: %s%s%s: loadavg: %s          \n\n",
+                              policystr, slash, policystr2, lavg);
                }
 
                for (i = 0; i < num_threads; i++) {
 
--

Thanks! I like the fifo / other display - that's more correct.

--
To unsubscribe from this list: send the line "unsubscribe linux-rt-users" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html