All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luiz Capitulino <lcapitulino@redhat.com>
To: John Kacur <jkacur@redhat.com>
Cc: linux-rt-users@vger.kernel.org, williams@redhat.com
Subject: Re: [PATCH 3/3] cyclictest: initialize 'stop' early
Date: Tue, 22 Mar 2016 10:59:53 -0400	[thread overview]
Message-ID: <20160322105953.1b50ca8f@redhat.com> (raw)
In-Reply-To: <alpine.LFD.2.20.1603221553550.10687@riemann>

On Tue, 22 Mar 2016 15:55:10 +0100 (CET)
John Kacur <jkacur@redhat.com> wrote:

> 
> 
> On Thu, 17 Mar 2016, Luiz Capitulino wrote:
> 
> > For some modes like MODE_CLOCK_NANOSLEEP, the clock
> > is already ticking when 'stop' is initialized. This
> > shouldn't matter, as this memset() should very fast
> > (I'd guess a few dozens or hundrends nanoseconds at
> > most?), but I also think there's no reason to do it
> > this late. So, initialize it along with everything
> > else.
> > 
> > Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
> > ---
> >  src/cyclictest/cyclictest.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
> > index f5a67dc..202939f 100644
> > --- a/src/cyclictest/cyclictest.c
> > +++ b/src/cyclictest/cyclictest.c
> > @@ -829,6 +829,8 @@ static void *timerthread(void *param)
> >  		tspec.it_interval = interval;
> >  	}
> >  
> > +	memset(&stop, 0, sizeof(stop));
> > +
> >  	memset(&schedp, 0, sizeof(schedp));
> >  	schedp.sched_priority = par->prio;
> >  	if (setscheduler(0, par->policy, &schedp))
> > @@ -868,10 +870,10 @@ static void *timerthread(void *param)
> >  	tsnorm(&next);
> >  
> >  	if (duration) {
> > -		memset(&stop, 0, sizeof(stop)); /* grrr */
> >  		stop = now;
> >  		stop.tv_sec += duration;
> >  	}
> > +
> >  	if (par->mode == MODE_CYCLIC) {
> >  		if (par->timermode == TIMER_ABSTIME)
> >  			tspec.it_value = next;
> > -- 
> > 2.1.0
> > 
> > --
> 
> Not sure about this one. It might be okay, but it certainly
> makes the code messier. Is this just a theorectical possibility
> or do you have some evidence that this is a problem?
> 
> I think I'll skip it for now unless you can show that it's a
> real problem.

It's not a problem. Personally, I think it's a good practice
to do all the initialization before the clock starts ticking,
but that doesn't mean that we have a problem with that memset.

      reply	other threads:[~2016-03-22 14:59 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-17 18:29 [PATCH v2 0/3] rt-tests: minor fixes Luiz Capitulino
2016-03-17 18:29 ` [PATCH 1/3] rt-migrate-test: fix return code Luiz Capitulino
2016-03-22 14:22   ` John Kacur
2016-03-22 14:47     ` Luiz Capitulino
2016-03-22 14:59       ` John Kacur
2016-03-22 15:30         ` Luiz Capitulino
2016-03-22 16:24           ` John Kacur
2016-03-22 16:43             ` Luiz Capitulino
2016-03-22 15:05       ` John Kacur
2016-03-17 18:29 ` [PATCH 2/3] don't use exit(-1) for failures Luiz Capitulino
2016-03-22 14:21   ` John Kacur
2016-03-22 14:30     ` Luiz Capitulino
2016-04-14  6:53   ` Uwe Kleine-König
2016-03-17 18:29 ` [PATCH 3/3] cyclictest: initialize 'stop' early Luiz Capitulino
2016-03-22 14:55   ` John Kacur
2016-03-22 14:59     ` Luiz Capitulino [this message]

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=20160322105953.1b50ca8f@redhat.com \
    --to=lcapitulino@redhat.com \
    --cc=jkacur@redhat.com \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=williams@redhat.com \
    /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.