From: Jan Kiszka <jan.kiszka@domain.hid>
To: rpm@xenomai.org
Cc: xenomai@xenomai.org
Subject: Re: Rép. : Re: [Xenomai-help] Switch mode with x86
Date: Wed, 06 Dec 2006 09:37:27 +0100 [thread overview]
Message-ID: <45768147.7050001@domain.hid> (raw)
In-Reply-To: <1165357040.7218.15.camel@domain.hid>
[-- Attachment #1.1: Type: text/plain, Size: 2204 bytes --]
Philippe Gerum wrote:
> On Mon, 2006-12-04 at 22:06 +0100, Jan Kiszka wrote:
>> Jan Kiszka wrote:
>>> ...
>>> This indicates that we face an I-pipe bug: the scheduled Linux call on
>>> relaxation of TASK2 and then later TASK1 somehow gets lost (there is no
>>> rthal_apc_handler in the remaining trace).
>> I think I got it. No I-pipe bug, but one in the HAL.
>>
>> What happened? A weird race caused by the unprotected optimisation to
>> only call rthal_schedule_irq() if there is no APC pending yet. This is
>> the constellation I finally worked out via instrumenting and tracing:
>>
>> PRIO 1:
>> rthal_apc_schedule()
>> test&set rthal_apc_pending
>> (but no rthal_schedule_irq() yet)
>>
>> -PREEMPTION-
>>
>> PRIO 99:
>> ...
>> rthal_apc_schedule()
>> test rthal_apc_pending
>> (already set => no
>> rthal_schedule_irq()!)
>>
>> So, no one reported the ACP to I-pipe, and no one ever will in Nicolas
>> scenario - soft lock-up!
>>
>> Nicolas, please give the attached patch a try. Your test is running fine
>> for me now.
>>
>>
>> At this chance: do we need rthal_apc_schedule() returning the previous
>> state at all? No current caller checks the return value. If it's OK to
>> clean this up, I will post a combined patch.
>
> It's pointless to return this info, the caller would not be able to
> exploit it in any way.
>
> Could you please try this other form of your fix? This would prevent the
> virq to be fired twice (or more) uselessly, with no request pending.
> Masking interrupts to enforce atomicity is ok here, since
> rthal_schedule_irq() will run this way in any case. Additionally, my
> comment about migration was suspicious, I do see a case where CPU
> migration would leave this code in limbos. But to get the cpuid
> properly, we need the local interrupts to be masked first. TIA,
Yes, works fine as well.
Then go for the attached fix+cleanup?
Jan
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: fix-rthal_apc_schedule-v2.patch --]
[-- Type: text/x-patch; name="fix-rthal_apc_schedule-v2.patch", Size: 1479 bytes --]
Index: ksrc/arch/generic/hal.c
===================================================================
--- ksrc/arch/generic/hal.c (Revision 1920)
+++ ksrc/arch/generic/hal.c (Arbeitskopie)
@@ -565,7 +565,7 @@ int rthal_apc_free(int apc)
/**
* @fn int rthal_apc_schedule (int apc)
- *
+ *
* @brief Schedule an APC invocation.
*
* This service marks the APC as pending for the Linux domain, so that
@@ -580,8 +580,7 @@ int rthal_apc_free(int apc)
*
* @param apc The APC id. to schedule.
*
- * @return 0 or 1 are returned upon success, the former meaning that
- * the APC was already pending. Otherwise:
+ * @return 0 is returned upon success. Otherwise:
*
* - -EINVAL is returned if @a apc is invalid.
*
@@ -596,18 +595,21 @@ int rthal_apc_free(int apc)
int rthal_apc_schedule(int apc)
{
rthal_declare_cpuid;
+ unsigned long flags;
if (apc < 0 || apc >= RTHAL_NR_APCS)
return -EINVAL;
- rthal_load_cpuid(); /* Migration would be harmless here. */
+ rthal_local_irq_save(flags);
+
+ rthal_load_cpuid();
- if (!test_and_set_bit(apc, &rthal_apc_pending[cpuid])) {
+ if (!__test_and_set_bit(apc, &rthal_apc_pending[cpuid]))
rthal_schedule_irq(rthal_apc_virq);
- return 1;
- }
- return 0; /* Already pending. */
+ rthal_local_irq_restore(flags);
+
+ return 0;
}
#ifdef CONFIG_PROC_FS
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 249 bytes --]
next prev parent reply other threads:[~2006-12-06 8:37 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-11-29 12:19 Rép. : Re: [Xenomai-help] Switch mode with x86 Nicolas BLANCHARD
2006-12-03 19:32 ` Jan Kiszka
2006-12-03 19:59 ` Philippe Gerum
2006-12-03 20:10 ` Jan Kiszka
2006-12-03 21:09 ` Jan Kiszka
2006-12-03 23:30 ` Philippe Gerum
2006-12-04 8:13 ` Jan Kiszka
2006-12-04 21:06 ` Jan Kiszka
2006-12-05 22:17 ` Philippe Gerum
2006-12-06 8:37 ` Jan Kiszka [this message]
2006-12-06 9:06 ` Philippe Gerum
2006-12-05 22:18 ` Philippe Gerum
2006-12-04 9:46 ` Gilles Chanteperdrix
2006-12-03 21:02 ` Philippe Gerum
[not found] <s575af89.064@domain.hid>
2006-12-05 17:15 ` Jan Kiszka
-- strict thread matches above, loose matches on Subject: below --
2006-12-05 12:33 Nicolas BLANCHARD
[not found] <s56d88c0.000@domain.hid>
2006-11-29 13:52 ` Jan Kiszka
2006-11-29 10:25 Nicolas BLANCHARD
[not found] <s56c97a4.096@domain.hid>
2006-11-28 20:27 ` Jan Kiszka
2006-11-28 19:09 Nicolas BLANCHARD
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=45768147.7050001@domain.hid \
--to=jan.kiszka@domain.hid \
--cc=rpm@xenomai.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.