All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Lezcano <daniel.lezcano@linaro.org>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH V3] ltp: Add a zero latency constraint for the timer tests library
Date: Thu, 17 Aug 2017 15:00:25 +0000	[thread overview]
Message-ID: <1502982026-4113-1-git-send-email-daniel.lezcano@linaro.org> (raw)
In-Reply-To: <20170817135029.GA31322@rei>

The ltp test suites provides a set of tests. Some of them are checking the test
happens in a specified amount of time.

Unfortunately, some platforms have slow power management routines adding more
than 1.5ms to wakeup from a deep idle state. This duration is far too long to
be acceptable when we are trying the measure a speficied routine with a timeout
reasonably delayed.

All the timers test measure the deviation between the measured and the expected
timeouts and check the gap is reasonable. A slow platform with the slow idle
states will introduce a latency breaking the tests randomly (eg. when the cpu
freq is low).

More precisely, the following tests fail randomly on a hikey 96board:

-------------------------------------------------
| latency constraint    infinite         0      |
-------------------------------------------------
| nanosleep01           failed          pass    |
-------------------------------------------------
| nanosleep02           pass            pass    |
-------------------------------------------------
| fcntl33               pass            pass    |
-------------------------------------------------
| clock_nanosleep02     failed          pass    |
-------------------------------------------------
| epoll_wait02          failed          pass    |
-------------------------------------------------
| futex_wait0           failed          pass    |
-------------------------------------------------

In order to reduce the impact of the energy framework on the tests, let's
specify a temporary latency constraint by setting the cpu_dma_latency to zero.

The constraint ends when the file descriptor to /dev/cpu_dma_latency is closed,
we let that happen when the process exits.

Note the access to /dev/cpu_dma_latency requires the root privileges. Without
them, the test will run without the latency constraint which is fine for most
of the platforms ltp runs on.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 lib/tst_timer_test.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/lib/tst_timer_test.c b/lib/tst_timer_test.c
index 7539c62..cd4ebca 100644
--- a/lib/tst_timer_test.c
+++ b/lib/tst_timer_test.c
@@ -335,6 +335,17 @@ void do_timer_test(long long usec, unsigned int nsamples)
 
 static void parse_timer_opts(void);
 
+static int set_latency(void)
+{
+        int fd, latency = 0;
+
+        fd = open("/dev/cpu_dma_latency", O_WRONLY);
+        if (fd < 0)
+                return fd;
+
+        return write(fd, &latency, sizeof(latency));
+}
+
 static void timer_setup(void)
 {
 	struct timespec t;
@@ -365,6 +376,9 @@ static void timer_setup(void)
 
 	samples = SAFE_MALLOC(sizeof(long long) * MAX(MAX_SAMPLES, sample_cnt));
 
+	if (set_latency() < 0)
+		tst_res(TINFO, "Failed to set zero latency constraint: %m");
+
 	if (setup)
 		setup();
 }
-- 
2.1.4


  parent reply	other threads:[~2017-08-17 15:00 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-10  8:01 [LTP] [PATCH 1/2] ltp: Add the ability to specify the latency constraint Daniel Lezcano
2017-08-10  8:01 ` [LTP] [PATCH 2/2] syscalls/pselect: Add a zero " Daniel Lezcano
2017-08-10 11:50   ` Jiri Jaburek
2017-08-10 12:00     ` Daniel Lezcano
2017-08-11 11:26       ` Jan Stancek
2017-08-11 11:25 ` [LTP] [PATCH 1/2] ltp: Add the ability to specify the " Jan Stancek
2017-08-11 12:54   ` [LTP] [PATCH V2 " Daniel Lezcano
2017-08-11 12:54     ` [LTP] [PATCH V2 2/2] syscalls/pselect: Add a zero " Daniel Lezcano
2017-08-11 14:09     ` [LTP] [PATCH V2 1/2] ltp: Add the ability to specify the " Cyril Hrubis
2017-08-11 14:52       ` Daniel Lezcano
2017-08-11 15:28         ` Cyril Hrubis
2017-08-14 12:56           ` Daniel Lezcano
2017-08-14 13:33             ` Cyril Hrubis
2017-08-14 14:19               ` Daniel Lezcano
2017-08-14 14:36                 ` Cyril Hrubis
2017-08-14 15:43                   ` Daniel Lezcano
2017-08-15 11:06                     ` Cyril Hrubis
2017-08-15 20:15                       ` Daniel Lezcano
2017-08-17 13:50                         ` Cyril Hrubis
2017-08-17 14:02                           ` Daniel Lezcano
2017-08-17 15:00                           ` Daniel Lezcano [this message]
2017-08-18 12:25                             ` [LTP] [PATCH V3] ltp: Add a zero latency constraint for the timer tests library Cyril Hrubis
2017-12-12 14:48                               ` Jan Stancek
2017-12-12 14:56                                 ` Daniel Lezcano
2017-12-12 15:04                                   ` Jan Stancek
2017-12-12 15:21                                     ` Daniel Lezcano
2017-12-13 17:00                                       ` Daniel Lezcano
2017-12-13 20:42                                         ` Jan Stancek
2018-02-01 22:52                                       ` Jan Stancek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1502982026-4113-1-git-send-email-daniel.lezcano@linaro.org \
    --to=daniel.lezcano@linaro.org \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.