All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH V2 1/2] ltp: Add the ability to specify the latency constraint
Date: Fri, 11 Aug 2017 16:09:05 +0200	[thread overview]
Message-ID: <20170811140905.GB3341@rei.lan> (raw)
In-Reply-To: <1502456086-14696-1-git-send-email-daniel.lezcano@linaro.org>

Hi!
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> ---
>  include/tst_test.h |  4 ++++
>  lib/tst_test.c     | 28 ++++++++++++++++++++++++++++
>  2 files changed, 32 insertions(+)
> 
> diff --git a/include/tst_test.h b/include/tst_test.h
> index e90312a..519fd4c 100644
> --- a/include/tst_test.h
> +++ b/include/tst_test.h
> @@ -124,6 +124,7 @@ struct tst_test {
>  	int needs_checkpoints:1;
>  	int format_device:1;
>  	int mount_device:1;
> +	int needs_latency:1;
>  
>  	/* Minimal device size in megabytes */
>  	unsigned int dev_min_size;
> @@ -154,6 +155,9 @@ struct tst_test {
>  
>  	/* NULL terminated array of resource file names */
>  	const char *const *resource_files;
> +
> +	/* Latency constraint to be set for the test */
> +	int latency;
>  };

This seems to be a bit too specific to me, I would be more happy if we
named it "measures_sleep_time" or something that describes what the
testcase does rather than calling it after specific workaround.

Also shouldn't this be set automatically for all timer related testcases
(these that make use of the sampling function) rather than just for the
pselect one? If so we should set the flag in the tst_timer_test.c
library instead. Or we can also stick the latency setup/cleanup
into the tst_timer_test.c as well and don't bother with adding more
flags into the tst_test structure (see timer_setup() and timer_cleanup()
in the tst_timer_test.c).

>  /*
> diff --git a/lib/tst_test.c b/lib/tst_test.c
> index 4c30eda..717a782 100644
> --- a/lib/tst_test.c
> +++ b/lib/tst_test.c
> @@ -619,6 +619,31 @@ static void copy_resources(void)
>  		TST_RESOURCE_COPY(NULL, tst_test->resource_files[i], NULL);
>  }
>  
> +static int set_latency(void)
> +{
> +	int fd, ret;
> +
> +	fd = open("/dev/cpu_dma_latency", O_WRONLY);
> +	if (fd < 0) {
> +		/*
> +		 * In case we are running on old kernel where the cpu_dma latency does
> +		 * not exist, do not fail, just inform and bail out.
> +		 */
> +		if (errno == ENOENT) {
> +			tst_res(TINFO, "/dev/cpu_dma_latency does not exists\n");
> +			return 0;
> +		}
> +
> +		return fd;
> +	}
> +
> +	ret = write(fd, &tst_test->latency, sizeof(tst_test->latency));
> +	if (ret < 0)
> +		return ret;
> +
> +	return 0;
> +}
> +
>  static const char *get_tid(char *argv[])
>  {
>  	char *p;
> @@ -736,6 +761,9 @@ static void do_setup(int argc, char *argv[])
>  
>  	if (tst_test->resource_files)
>  		copy_resources();
> +
> +	if (tst_test->needs_latency && set_latency())
> +		tst_brk(TBROK, "Failed to set cpu latency");
>  }
>  
>  static void do_test_setup(void)
> -- 
> 2.1.4
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp

-- 
Cyril Hrubis
chrubis@suse.cz

  parent reply	other threads:[~2017-08-11 14:09 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     ` Cyril Hrubis [this message]
2017-08-11 14:52       ` [LTP] [PATCH V2 1/2] ltp: Add the ability to specify the " 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                           ` [LTP] [PATCH V3] ltp: Add a zero latency constraint for the timer tests library Daniel Lezcano
2017-08-18 12:25                             ` 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=20170811140905.GB3341@rei.lan \
    --to=chrubis@suse.cz \
    --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.