All of lore.kernel.org
 help / color / mirror / Atom feed
From: Philippe Gerum <rpm@xenomai.org>
To: Lowell Gilbert <kludge@be-well.ilk.org>, xenomai@xenomai.org
Subject: Re: [Xenomai] interrupt service
Date: Thu, 26 Feb 2015 21:24:53 +0100	[thread overview]
Message-ID: <54EF8115.6030200@xenomai.org> (raw)
In-Reply-To: <44a900eaqu.fsf@lowell-desk.lan>

On 02/26/2015 08:25 PM, Lowell Gilbert wrote:
> Philippe Gerum <rpm@xenomai.org> writes:
> 
>> On 02/26/2015 05:38 PM, Lowell Gilbert wrote:
>> The new task will be pinned to the CPU running rtdm_task_init() by
>> default, which is likely CPU0 as well.
>>
>> To check this, I would set the global Xenomai affinity to CPU1 before
>> starting the test, so that your driver task ends up there.
>>
>> # echo 2 > /proc/xenomai/affinity
> 
> Yes, I initialize that already. And give "isolcpus=1" to the kernel so
> that Linux will not schedule anything else on CPU1.
> 
>> At least you would have the timing IRQ and the task on a different CPU,
>> leaving some cycles to the latter. This said, 10 us between timer shots
>> is really too fast.
> 
> Having enough cycles for this isn't my fundamental problem. Running
> everything in the ISR has no trouble keeping up with the 100kHz data
> flow. The problem comes in a *non* real-time task, which is pulling data
> in from an IP socket and pushing it into a queue for the real-time code
> to use synchronously.

Could you determine whether the bottleneck is due to the IP stack being
starved from incoming packets? Or, is the contention observed between
the non rt task and the real-time code consuming it?

Since ethernet IRQs are of the SPI kind, the IP stack is likely
executing over CPU0, assuming that the driver (FEC?) is NAPI-enabled,
the packet processing takes place on behalf of a softirq context, on the
same CPU.

Btw, you mentioned a queue as the IPC between both threads. Which kind
of queue/IPC is it?

> 
> If I could run bare-metal on the second CPU, I would have done so.
> The real-time behaviour is easily characterized, and the periodic work
> can safely be done in 10 us even if all of the data has to be fetched
> from external memory.
>

This is what bothers me. The CPU running the ISR code is likely unable
to handle any regular linux activity in this case.

>>> I had used a counting semaphore (to account for possibly missed
>>> interrupts) in an earlier version of this code before changing it to an
>>> event when I found that the semaphore didn't work. I also tried a direct
>>> call to rtdm_task_unblock(), and that failed also.
> 
>> If you look at ksrc/drivers/testing/timerbench.c, you will see a typical
>> use of rtdm events with ISRs, this driver is used when running
>> latency -t2 for instance. I'm convinced the RTDM event API is not the issue.
> 
> I think you meant irqbench.c. And yes, I also am quite sure that the
> event API is behaving fine.
>

I really meant timerbench.c. The only difference is the use of the pulse
instead of signal interface, which makes no difference internally.

> I think I have two options to investigate. One is to do all of my work
> in the ISR, but to somehow re-enable enough interrupts to keep CPU0
> doing useful work while the ISR is running on CPU1.

If I understand this correctly, interrupt masking may not be the issue
on CPU0, I'd rather think that CPU1 is spending too much time in
real-time activity, preventing the regular kernel to properly
synchronize SMP-wise between CPUs.

e.g. IPIs won't flow to CPU1, if some regular linux activity gets
preempted by the ISR while holding a spinlock, CPU0 could contend on
that lock for as long as the ISR work keeps running on CPU1 and so on.

I'm likely missing important points about your application, but
generally speaking, the regular kernel is not going to be that happy if
one of the CPUs involved in the SMP architecture is not responsive enough.

 The other is to poll
> the hardware state rather than using the interrupt.  Do you see anything
> else I could do?
> 

Nothing that would use the general-purpose CPUs shared with the regular
kernel. I guess that option #2 might be the one with the most chance of
success.

-- 
Philippe.


  parent reply	other threads:[~2015-02-26 20:24 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-18 22:03 [Xenomai] interrupt service Lowell Gilbert
2015-02-18 22:08 ` Gilles Chanteperdrix
2015-02-19  4:44   ` Lowell Gilbert
2015-02-19 21:06     ` Lowell Gilbert
2015-02-20 19:38     ` Lowell Gilbert
2015-02-20 22:57       ` Gilles Chanteperdrix
2015-02-24 23:01         ` Lowell Gilbert
2015-02-24 23:34           ` Gilles Chanteperdrix
2015-02-25 16:22             ` Lowell Gilbert
2015-02-25 17:34               ` Philippe Gerum
2015-02-25 18:35                 ` Philippe Gerum
2015-02-25 20:41                 ` Lowell Gilbert
2015-02-25 21:02                   ` Lowell Gilbert
2015-02-26 11:19                     ` Philippe Gerum
2015-02-26 16:38                       ` Lowell Gilbert
2015-02-26 17:26                         ` Gilles Chanteperdrix
2015-02-26 17:56                         ` Philippe Gerum
2015-02-26 19:25                           ` Lowell Gilbert
2015-02-26 20:11                             ` Gilles Chanteperdrix
2015-02-26 21:58                               ` Lowell Gilbert
2015-02-26 22:37                                 ` Gilles Chanteperdrix
2015-02-26 23:12                                   ` Lowell Gilbert
2015-02-26 23:09                               ` Philippe Gerum
2015-03-06 22:57                               ` Lowell Gilbert
2015-03-06 22:58                               ` Lowell Gilbert
2015-03-08 15:52                                 ` Gilles Chanteperdrix
2015-03-09 13:28                                   ` Lowell Gilbert
2015-02-26 20:24                             ` Philippe Gerum [this message]
2015-02-26 22:55                               ` Lowell Gilbert
2015-02-26 23:17                                 ` Daniele Nicolodi
2015-02-26 23:21                                 ` Philippe Gerum
2015-02-27  7:15                                 ` Tom Evans
2015-02-25  8:30           ` Philippe Gerum
2015-02-25  9:36             ` Philippe Gerum

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=54EF8115.6030200@xenomai.org \
    --to=rpm@xenomai.org \
    --cc=kludge@be-well.ilk.org \
    --cc=xenomai@xenomai.org \
    /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.