spike in latency when calling popen() in the same process that runs a high priority RT thread

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We are seeing a fairly big spike in latency for an RT thread when another 
regular thread in the same process calls popen().
I have modified cyclictest (see the patch below) to spawn another thread 
that just does popen() in a loop and run cyclictest with the following 
options:

./cyclictest -m -S --policy=fifo -p 98

Normally the max latency on our system is ~50uS. This is a dual core ARM 
Cortex-A9 running a 3.2.35-rt52 kernel. With this change it spikes over 
500uS.
This doesn't happen if the popen() test is run in a separate process 

We are looking for ideas on the root cause for this.

Thanks,
        Gratian

>From c673b5be21686c92a4c94a60f465fe889d0978e3 Mon Sep 17 00:00:00 2001
From: Gratian Crisan <gratian.crisan@xxxxxx>
Date: Thu, 23 May 2013 17:22:05 -0500
Subject: [PATCH] Test for tracing popen() latency

This test adds a regular priority thread to cyclic test in order
to track down a latency exibited when using popen() in the same
process that runs a high priority RT thread (cyclic test in this
case)

Signed-off-by: Gratian Crisan <gratian.crisan@xxxxxx>
---
 src/cyclictest/cyclictest.c |   29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
index abf3e8b..423b0d5 100644
--- a/src/cyclictest/cyclictest.c
+++ b/src/cyclictest/cyclictest.c
@@ -930,6 +930,25 @@ out:
        return NULL;
 }
 
+void *popen_test(void *param)
+{
+       struct sched_param schedp;
+       FILE *fp = NULL;
+
+       schedp.sched_priority = 0;
+       sched_setscheduler(0, SCHED_OTHER, &schedp);
+
+       while (!shutdown) {
+               fp = popen("echo hello > /tmp/test", "r");
+               if (!fp) {
+                       perror("popen failed");
+                       break;
+               }
+               pclose(fp);
+       }
+       printf("# popen() test thread: %ld\n", gettid());
+       return NULL;
+}
 
 /* Print usage information */
 static void display_help(int error)
@@ -1511,6 +1530,8 @@ int main(int argc, char **argv)
        int max_cpus = sysconf(_SC_NPROCESSORS_CONF);
        int i, ret = -1;
        int status;
+       pthread_t popen_thread;
+       pthread_attr_t popen_attr;
 
        process_options(argc, argv);
 
@@ -1759,6 +1780,14 @@ int main(int argc, char **argv)
 
        }
 
+       status = pthread_attr_init(&popen_attr);
+       if (status != 0)
+               fatal("error from pthread_attr_init for popen test thread 
%s\n", strerror(status));
+
+       status = pthread_create(&popen_thread, &popen_attr, popen_test, 
NULL);
+       if (status)
+               fatal("failed to create popen test thread %s\n", 
strerror(status));
+
        while (!shutdown) {
                char lavg[256];
                int fd, len, allstopped = 0;
-- 
1.7.10.4

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




[Index of Archives]     [RT Stable]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux