public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Jan Stancek <jstancek@redhat.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 2/3] perf_event_open02: make do_work() run for specified time
Date: Thu, 21 Nov 2019 03:48:24 -0500 (EST)	[thread overview]
Message-ID: <820987732.13285590.1574326104465.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <20191120123339.GE14963@rei.lan>


----- Original Message -----
> > -static void do_work(void)
> > +void alarm_handler(int sig LTP_ATTRIBUTE_UNUSED)
> 
> static void ?

Yes

> 
> > +{
> > +	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.

I'll move it.


  reply	other threads:[~2019-11-21  8:48 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
2019-11-21  8:48     ` Jan Stancek [this message]
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=820987732.13285590.1574326104465.JavaMail.zimbra@redhat.com \
    --to=jstancek@redhat.com \
    --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