All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wolfgang Mauerer <wolfgang.mauerer@siemens.com>
To: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
Cc: "Kiszka, Jan" <jan.kiszka@siemens.com>,
	"xenomai@xenomai.org" <xenomai@xenomai.org>
Subject: Re: [Xenomai] [GIT PULL] core-5 for x86
Date: Tue, 25 Sep 2012 16:45:40 +0200	[thread overview]
Message-ID: <5061C394.1050005@siemens.com> (raw)
In-Reply-To: <505B4044.7030103@xenomai.org>

On 20/09/12 18:11, Gilles Chanteperdrix wrote:
> On 09/19/2012 02:15 PM, Wolfgang Mauerer wrote:
>> On 18/09/12 21:36, Gilles Chanteperdrix wrote:
>>> On 09/18/2012 05:27 PM, Wolfgang Mauerer wrote:

>>> Ok. We have a currently pending issue on x86 which you should be
>>> informed about before discovering it during your tests: using
>>> rthal_supported_cpus is broken in I-pipe core patches when using the
>>> LAPIC timer: since there is only one irq handler for all the LAPIC
>>> timers, the handler is registered on all cpus, but on non started cpus,
>>> the handler will do nothing at best, and not foward the LAPIC ticks to
>>> Linux (which is still in control of the LAPIC timer on these cpus).
>>>
>>> This problem is due to the fact that we keep the same vector as Linux,
>>> and so the same irq. There are two ways out of this:
>>>
>>> - change the LAPIC vector when xenomai takes the control of the LAPIC
>>> timer, like we use to do, this is racy with current code because the
>>> timer is taken by Xenomai but still used a bit by Linux, before it is
>>> programmed by Xenomai, and Xenomai assumes that the host tick irq is the
>>> same as the timer irq. All this can be fixed, but the last drawback of
>>> this approach is that it does not fix the issue on architectures where
>>> the local timer irq is the same on all cpus, but can not be changed,
>>> hence the second approach;
>>> - the second approach is to add a test at the beginning of
>>> xnintr_clock_handler and forward the irq to the root domain if the
>>> current cpu does not belong to xnarch_supported_cpus. This means some
>>> patching of I-pipe timers so that ipipe_percpu.hrtimer_irq also gets
>>> defined for non supported cpus when they use the timer shared with other
>>> cpus, essentially what this patch tries (but fails) to achieve:
>>>
>>> http://www.xenomai.org/pipermail/xenomai/2012-September/026066.html
>>
>> thanks for the info! Unfortunately, I was not able to reproduce this
>> issue quickly using two latency instances bound to different CPUs on a
>> machine booted with isolcpus=1, though.
> 
> The issue is not with isolcpus, but with rthal_supported_cpus, that is
> xenomai "supported_cpus" parameter. And maybe Linux is running fine with
> the bug, but if you do a cat /proc/interrupts, you should see the local
> timer interrupt no longer incrementing on cpus not intercepted by xenomai.
 
the attached patch (against core-4), which is a slight modification of 
yours, resolves the issue for me when applied together with the xnintr 
patch (I've also rebased to core-5, see https://github.com/siemens/ipipe core-3.5_for-upstream)

Cheers, Wolfgang

########################################################################

Use ipipe_percpu.hrtimer_irq for non-RT CPUs when required

We need to be able to forward the timer interrupt to the
root domain on CPUs that are not used for real-time loads,
but use a timer shared with other CPUs. Based on a patch
by Gilles Chanteperdrix.

Signed-off-by: Wolfgang Mauerer <wolfgang.mauerer@siemens.com>
---
 kernel/ipipe/timer.c |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/kernel/ipipe/timer.c b/kernel/ipipe/timer.c
index 7dcd725..67ae4a7 100644
--- a/kernel/ipipe/timer.c
+++ b/kernel/ipipe/timer.c
@@ -172,11 +172,23 @@ int ipipe_select_timers(const struct cpumask *mask)
 	hrclock_khz = tmp;
 
 	spin_lock_irqsave(&lock, flags);
-	for_each_cpu(cpu, mask) {
+	for_each_cpu(cpu, cpu_online_mask) {
 		list_for_each_entry(t, &timers, link) {
 			if (!cpumask_test_cpu(cpu, t->cpumask))
 				continue;
 
+			/*
+			 * When the CPU is not used for real-time
+			 * loads, we need to be able to forward the
+			 * IRQ for this CPU to the root domain in case
+			 * it is shared with other CPUs.
+			 */
+			if (!cpumask_test_cpu(cpu, mask)
+			    && t->irq == per_cpu(ipipe_percpu.hrtimer_irq, 0)) {
+				per_cpu(ipipe_percpu.hrtimer_irq, cpu) = t->irq;
+				goto found;
+			}
+
 			evtdev = t->host_timer;
 #ifdef CONFIG_GENERIC_CLOCKEVENTS
 			if (!evtdev
@@ -184,6 +196,9 @@ int ipipe_select_timers(const struct cpumask *mask)
 #endif /* CONFIG_GENERIC_CLOCKEVENTS */
 				goto found;
 		}
+		if (!cpumask_test_cpu(cpu, mask))
+			continue;
+
 		printk("I-pipe: could not find timer for cpu #%d\n", cpu);
 		goto err_remove_all;
 
-- 
1.7.1




  reply	other threads:[~2012-09-25 14:45 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-18 14:11 [Xenomai] [GIT PULL] core-5 for x86 Wolfgang Mauerer
2012-09-18 14:25 ` Gilles Chanteperdrix
2012-09-18 15:27   ` Wolfgang Mauerer
2012-09-18 19:36     ` Gilles Chanteperdrix
2012-09-19 12:15       ` Wolfgang Mauerer
2012-09-19 12:36         ` Gilles Chanteperdrix
2012-09-20 16:11         ` Gilles Chanteperdrix
2012-09-25 14:45           ` Wolfgang Mauerer [this message]
2012-09-25 14:57             ` Gilles Chanteperdrix
2012-09-25 14:58               ` Wolfgang Mauerer
2012-09-26 14:41               ` Wolfgang Mauerer
2012-09-26 13:16                 ` [Xenomai] [PATCH 1/2] Refactor ipipe_select_timers Wolfgang Mauerer
2012-09-26 21:28                   ` Gilles Chanteperdrix
2012-09-27  8:28                     ` Wolfgang Mauerer
2012-09-27 12:04                       ` Gilles Chanteperdrix
2012-09-27 12:47                         ` Wolfgang Mauerer
2012-09-27 12:54                           ` Gilles Chanteperdrix
2012-09-27 12:56                             ` Wolfgang Mauerer
2012-09-27 18:33                           ` Gilles Chanteperdrix
2012-09-28  8:32                             ` Wolfgang Mauerer
2012-09-30 20:50                               ` Gilles Chanteperdrix
2012-09-26 13:16                 ` [Xenomai] [PATCH 2/2] Register high-res timer irq for non-ipipe timers if necessary Wolfgang Mauerer
2012-09-27 18:39                   ` Gilles Chanteperdrix

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=5061C394.1050005@siemens.com \
    --to=wolfgang.mauerer@siemens.com \
    --cc=gilles.chanteperdrix@xenomai.org \
    --cc=jan.kiszka@siemens.com \
    --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.