All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai] rt_task_set_affinity causes hang
@ 2017-10-04  3:05 Jackson Jones
  2017-10-04 17:49 ` Philippe Gerum
  0 siblings, 1 reply; 6+ messages in thread
From: Jackson Jones @ 2017-10-04  3:05 UTC (permalink / raw)
  To: xenomai

Below is an example program that runs fine under xenomai-3.0.3. Under 3.0.5
it hangs when rt_task_set_affinity() is called.

Any ideas?

Thanks,

Jackson

------------------------------------------------------------------------------------------

#include <stdio.h>
#include <signal.h>
#include <unistd.h>
#include <sys/mman.h>

#include <alchemy/task.h>
#include <alchemy/timer.h>

// periodically prints "hello world" and the task name
void demo(void *arg)
{
  RT_TASK *curtask;
  RT_TASK_INFO curtaskinfo;

  while (1)
  {
    // hello world
    rt_printf("Hello World! ");

    // inquire current task
    curtask=rt_task_self();
    rt_task_inquire(curtask,&curtaskinfo);

    // print task name
    rt_printf("Task name : %s \n", curtaskinfo.name);

    // put task to sleep
    rt_task_sleep(1000000000);
  }
}

int main(int argc, char* argv[])
{

    RT_TASK demo_task;
    cpu_set_t mask;

    // set CPU to affine to
    CPU_ZERO(&mask);    // clear all CPUs
    CPU_SET(3, &mask);    // select CPU 3


    // Lock memory : avoid memory swapping for this program
    //mlockall(MCL_CURRENT|MCL_FUTURE);

    rt_printf("start task\n");

    /*
    * Arguments: &task,
    *            name,
    *            stack size (0=default),
    *            priority,
    *            mode (FPU, start suspended, ...)
    */
    rt_task_create(&demo_task, "demo", 0, 50, 0);

    // set task cpu affinity
    rt_task_set_affinity(&demo_task, &mask);

    /*
    * Arguments: &task,
    *            task function,
    *            function argument
    */
    rt_task_start(&demo_task, &demo, 0);

    pause();

    return 0;
}

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Xenomai] rt_task_set_affinity causes hang
  2017-10-04  3:05 [Xenomai] rt_task_set_affinity causes hang Jackson Jones
@ 2017-10-04 17:49 ` Philippe Gerum
  2017-10-04 20:03   ` Piotr Piorkowski
  0 siblings, 1 reply; 6+ messages in thread
From: Philippe Gerum @ 2017-10-04 17:49 UTC (permalink / raw)
  To: Jackson Jones, xenomai

On 10/04/2017 05:05 AM, Jackson Jones wrote:
> Below is an example program that runs fine under xenomai-3.0.3. Under 3.0.5
> it hangs when rt_task_set_affinity() is called.
> 
> Any ideas?
>

- which CPU architecture is your app running on?

- what do you mean by "it hangs"? Sleeps with no action with the rest of
the system still ok, or hard lockup of the whole SoC?

- rt_task_sleep() returns a status code; if the application does not
care about it, it might enter a tight loop whenever the call fails, for
whatever reason. That status may help determining such reason.

CONFIG_XENO_OPT_WATCHDOG is usually helpful for detecting runaway
threads, preventing hard lockups. --
Philippe.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Xenomai] rt_task_set_affinity causes hang
  2017-10-04 17:49 ` Philippe Gerum
@ 2017-10-04 20:03   ` Piotr Piorkowski
  2017-10-04 20:57     ` Jackson Jones
  0 siblings, 1 reply; 6+ messages in thread
From: Piotr Piorkowski @ 2017-10-04 20:03 UTC (permalink / raw)
  To: Philippe Gerum; +Cc: xenomai

I have the same problem on Raspberry Pi 3.
Its look as freeze platform. Under xenomai 3.0.3 programs works fine.

Piotr

2017-10-04 19:49 GMT+02:00 Philippe Gerum <rpm@xenomai.org>:

> On 10/04/2017 05:05 AM, Jackson Jones wrote:
> > Below is an example program that runs fine under xenomai-3.0.3. Under
> 3.0.5
> > it hangs when rt_task_set_affinity() is called.
> >
> > Any ideas?
> >
>
> - which CPU architecture is your app running on?
>
> - what do you mean by "it hangs"? Sleeps with no action with the rest of
> the system still ok, or hard lockup of the whole SoC?
>
> - rt_task_sleep() returns a status code; if the application does not
> care about it, it might enter a tight loop whenever the call fails, for
> whatever reason. That status may help determining such reason.
>
> CONFIG_XENO_OPT_WATCHDOG is usually helpful for detecting runaway
> threads, preventing hard lockups. --
> Philippe.
>
> _______________________________________________
> Xenomai mailing list
> Xenomai@xenomai.org
> https://xenomai.org/mailman/listinfo/xenomai
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Xenomai] rt_task_set_affinity causes hang
  2017-10-04 20:03   ` Piotr Piorkowski
@ 2017-10-04 20:57     ` Jackson Jones
  2017-10-05  9:57       ` Philippe Gerum
  0 siblings, 1 reply; 6+ messages in thread
From: Jackson Jones @ 2017-10-04 20:57 UTC (permalink / raw)
  To: Xenomai

I am running on an i.MX6 quad core. It is running Debian Jessie with an
NXP/Varscite kernel 4.1.15. So it is a 32bit ARM platform like the Pi.

What I meant by freeze is it hangs the entire OS/SoC, a hard reset is the
only way out. I will check the status of all the return codes (I did not
write this example but I should have cleaned it up when the problem was
tossed to me).

On Wed, Oct 4, 2017 at 1:03 PM, Piotr Piorkowski <qba100@gmail.com> wrote:

> I have the same problem on Raspberry Pi 3.
> Its look as freeze platform. Under xenomai 3.0.3 programs works fine.
>
> Piotr
>
> 2017-10-04 19:49 GMT+02:00 Philippe Gerum <rpm@xenomai.org>:
>
>> On 10/04/2017 05:05 AM, Jackson Jones wrote:
>> > Below is an example program that runs fine under xenomai-3.0.3. Under
>> 3.0.5
>> > it hangs when rt_task_set_affinity() is called.
>> >
>> > Any ideas?
>> >
>>
>> - which CPU architecture is your app running on?
>>
>> - what do you mean by "it hangs"? Sleeps with no action with the rest of
>> the system still ok, or hard lockup of the whole SoC?
>>
>> - rt_task_sleep() returns a status code; if the application does not
>> care about it, it might enter a tight loop whenever the call fails, for
>> whatever reason. That status may help determining such reason.
>>
>> CONFIG_XENO_OPT_WATCHDOG is usually helpful for detecting runaway
>> threads, preventing hard lockups. --
>> Philippe.
>>
>> _______________________________________________
>> Xenomai mailing list
>> Xenomai@xenomai.org
>> https://xenomai.org/mailman/listinfo/xenomai
>>
>
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Xenomai] rt_task_set_affinity causes hang
  2017-10-04 20:57     ` Jackson Jones
@ 2017-10-05  9:57       ` Philippe Gerum
  2017-10-29 17:20         ` Philippe Gerum
  0 siblings, 1 reply; 6+ messages in thread
From: Philippe Gerum @ 2017-10-05  9:57 UTC (permalink / raw)
  To: Jackson Jones, Xenomai

On 10/04/2017 10:57 PM, Jackson Jones wrote:
> I am running on an i.MX6 quad core. It is running Debian Jessie with an
> NXP/Varscite kernel 4.1.15. So it is a 32bit ARM platform like the Pi.
> 
> What I meant by freeze is it hangs the entire OS/SoC, a hard reset is the
> only way out. I will check the status of all the return codes (I did not
> write this example but I should have cleaned it up when the problem was
> tossed to me).
> 
Confirmed, I can badly break a couple of SoCs here using this test
program, provided I run it twice. The first run passes, second time is
always lethal. The Cobalt core seems to be doing silly things in this case.

An additional bug also affects the interrupt pipeline for any release
starting with kernel 4.4 onward actually hides the issue in Cobalt,
making the affinity setting a nop, sort of.

Ok, I'll follow up on this.

-- 
Philippe.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Xenomai] rt_task_set_affinity causes hang
  2017-10-05  9:57       ` Philippe Gerum
@ 2017-10-29 17:20         ` Philippe Gerum
  0 siblings, 0 replies; 6+ messages in thread
From: Philippe Gerum @ 2017-10-29 17:20 UTC (permalink / raw)
  To: Jackson Jones, Xenomai, Piotr Piorkowski

On 10/05/2017 11:57 AM, Philippe Gerum wrote:
> On 10/04/2017 10:57 PM, Jackson Jones wrote:
>> I am running on an i.MX6 quad core. It is running Debian Jessie with an
>> NXP/Varscite kernel 4.1.15. So it is a 32bit ARM platform like the Pi.
>>
>> What I meant by freeze is it hangs the entire OS/SoC, a hard reset is the
>> only way out. I will check the status of all the return codes (I did not
>> write this example but I should have cleaned it up when the problem was
>> tossed to me).
>>
> Confirmed, I can badly break a couple of SoCs here using this test
> program, provided I run it twice. The first run passes, second time is
> always lethal. The Cobalt core seems to be doing silly things in this case.
> 
> An additional bug also affects the interrupt pipeline for any release
> starting with kernel 4.4 onward actually hides the issue in Cobalt,
> making the affinity setting a nop, sort of.
> 
> Ok, I'll follow up on this.
> 

That one was pretty ugly, and affects all Xenomai releases, 2.x, 3.x,
all of them. Fixed in 3.x by this commit:

http://git.xenomai.org/xenomai-3.git/commit/?id=59344943b0c58d5f0c8b58d2ad97f2d894d33354

Thanks for the test code, that helped a lot.

-- 
Philippe.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-10-29 17:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-04  3:05 [Xenomai] rt_task_set_affinity causes hang Jackson Jones
2017-10-04 17:49 ` Philippe Gerum
2017-10-04 20:03   ` Piotr Piorkowski
2017-10-04 20:57     ` Jackson Jones
2017-10-05  9:57       ` Philippe Gerum
2017-10-29 17:20         ` Philippe Gerum

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.