From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 2/3] perf_event_open02: make do_work() run for specified time
Date: Wed, 20 Nov 2019 13:33:39 +0100 [thread overview]
Message-ID: <20191120123339.GE14963@rei.lan> (raw)
In-Reply-To: <5b0f2a837117f3af1351d8b3da357cacecaa1463.1574087532.git.jstancek@redhat.com>
> -static void do_work(void)
> +void alarm_handler(int sig LTP_ATTRIBUTE_UNUSED)
static void ?
> +{
> + work_done = 1;
> +}
> +
> +static void do_work(int time_ms)
> {
> int i;
> + struct sigaction sa;
> + struct itimerval val;
>
> - for (i = 0; i < LOOPS; ++i)
> - asm volatile (""::"g" (i));
> -}
> + work_done = 0;
> + memset(&val, 0, sizeof(val));
> + val.it_value.tv_sec = time_ms / 1000;
> + val.it_value.tv_usec = (time_ms % 1000) * 1000;
>
> + sa.sa_handler = alarm_handler;
> + sa.sa_flags = SA_RESETHAND;
> + SAFE_SIGACTION(SIGALRM, &sa, NULL);
I would have set up the signal handler just once in the test setup.
> + if (setitimer(ITIMER_REAL, &val, NULL))
> + tst_brk(TBROK | TERRNO, "setitimer");
> +
> + while (!work_done) {
> + for (i = 0; i < 100000; ++i)
> + asm volatile (""::"g" (i));
> + }
> +}
Otherwise it looks great, acked.
--
Cyril Hrubis
chrubis@suse.cz
next prev parent reply other threads:[~2019-11-20 12:33 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-18 14:59 [LTP] [PATCH 0/3] perf_event_open02 tweaks Jan Stancek
2019-11-18 14:59 ` [LTP] [PATCH 1/3] perf_event_open02: migrate to newlib Jan Stancek
2019-11-20 12:29 ` Cyril Hrubis
2019-11-21 8:45 ` Jan Stancek
2019-11-18 14:59 ` [LTP] [PATCH 2/3] perf_event_open02: make do_work() run for specified time Jan Stancek
2019-11-20 12:33 ` Cyril Hrubis [this message]
2019-11-21 8:48 ` Jan Stancek
2019-11-21 19:21 ` [LTP] [PATCH v2 " Jan Stancek
2019-11-22 13:33 ` Cyril Hrubis
2019-11-25 14:54 ` Jan Stancek
2019-11-18 14:59 ` [LTP] [PATCH 3/3] perf_event_open02: workaround for Pentium4 Jan Stancek
2019-11-20 13:44 ` Cyril Hrubis
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=20191120123339.GE14963@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox