All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
To: Zhoupeng <zhoupeng1982@qq.com>
Subject: Re: [Xenomai] I find a way to reduce latency, but I don't know why.
Date: Wed, 18 Mar 2015 14:39:21 +0100	[thread overview]
Message-ID: <20150318133921.GC24525@hermes.click-hack.org> (raw)
In-Reply-To: <tencent_1DF1E8A94FD8F46B59E71CC9@qq.com>

On Wed, Mar 18, 2015 at 09:31:33PM +0800, Zhoupeng wrote:
> > On Tue, Mar 17, 2015 at 09:41:05PM +0800, 书呆子 wrote:
> > > The x86 machine have two CPUs, and I need periodic task on CPU1.
> > > In order to reduce latency, a busy task will run on CPU2.
> > > 
> > > cpu1_task
> > > {
> > >   rt_task_wait_period;
> > >   real_work;
> > >   rt_sem_v(&busySEM);
> > > }
> > > 
> > > cpu2_task
> > > {
> > >   rt_sem_p(&busySEM);
> > >   rt_timer_spin(spin_ns);
> > > }
> > > 
> > > And spin_ns will be long enough: spin_ns + real_work_ns > periodic cycle.
> > > Yes, it means rt_code is always running on CPU1 or CPU2.
> > > 
> > > In doing this, the cpu1_task will get low latency and drift, but why ?
> 
> > Two possibilities:
> > - task2 is cache friendly, so if the cache is shared between the two
> > cpus, it prevents Linux from evicting xenomai and I-pipe code from
> > the cache, we know that cache has a big influence on latency;
> 
> I agree this is the best guess, the I5 CPUs do share L3 cache between them. 
> 
> I also use rt_timer_read() wrap real_work() to measure time consumption: 
> without task2 real_work() expend 20 to 36us, with task2 real_work() 
> expend 20 to 22us to compelte. 
> real_work() only contain float-point arithmetic, the time stability is
> improved obviously.
> 
> If this is cache problem, is task2 the right way to keep code in cache ?
> 
> > - task2 prevents the cpu from entering idle mode, and so potentially
> > prevents any low power optimization from happening, low power modes
> > are generally not latency friendly.
> 
> CONFIG_CPU_FREQ and CONFIG_CPU_IDLE is already disabled, smi workaround
> also enabled.
> I have notice C1E mode is disabled in Xenomai 3, but not in Xenomai 2,
> but C1E is triggered by mwait, I don't think this is the problem.

Linux idle task uses mwait, and nothing prevents the chip maker to
do any optimization he wants when hlt is called. On geode
processors, with some configuration, hlt causes the tsc to be
stopped for instance.

-- 
					    Gilles.


  parent reply	other threads:[~2015-03-18 13:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-17 13:41 [Xenomai] I find a way to reduce latency, but I don't know why =?gb18030?B?yum09NfT?=
2015-03-18  7:51 ` Gilles Chanteperdrix
     [not found]   ` <tencent_1DF1E8A94FD8F46B59E71CC9@qq.com>
2015-03-18 13:39     ` Gilles Chanteperdrix [this message]
2015-03-23  2:44       ` Zhoupeng
  -- strict thread matches above, loose matches on Subject: below --
2015-03-18 13:36 =?gb18030?B?WmhvdXBlbmc=?=

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=20150318133921.GC24525@hermes.click-hack.org \
    --to=gilles.chanteperdrix@xenomai.org \
    --cc=zhoupeng1982@qq.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.