All of lore.kernel.org
 help / color / mirror / Atom feed
* rtdm_task_init does not work with Xenomai 3
       [not found] <BCA29F40-0C3A-4DF7-9FE9-EF5D55C66C27.ref@yahoo.fr>
@ 2020-06-02 18:34 ` ayaida marwane
  2020-06-07 20:33   ` ayaida marwane
  2020-06-12 16:17   ` Jan Kiszka
  0 siblings, 2 replies; 7+ messages in thread
From: ayaida marwane @ 2020-06-02 18:34 UTC (permalink / raw)
  To: xenomai

Dear all,

I tried to have an example using rtdm_task_init with Xenomai 3.0.7. The example is tis one:

————————— 

#include <rtdm/driver.h>
static int periode_us = 1000;
static int a, ret;
module_param(periode_us, int, 0644);

rtdm_task_t task;

void task_ultrason(void *arg){
   a=1;
   rtdm_printk(KERN_INFO "%s.%s() : hello = %d\n", THIS_MODULE->name, __FUNCTION__,a);
}

int __init ultrason_init(void) {
   a=0;
   rtdm_printk(KERN_INFO "%s.%s() : hello = %d\n", THIS_MODULE->name, __FUNCTION__,a);
   ret = rtdm_task_init(&task, "ultrason", task_ultrason, NULL, 99, periode_us*1000);
   if (ret) {
        rtdm_printk(KERN_INFO "%s.%s() : error rtdm_task_init, hello = %d\n", THIS_MODULE->name, __FUNCTION__,a);
   }
   else  rtdm_printk(KERN_INFO "%s.%s() : success rtdm_task_init, hello = %d\n", THIS_MODULE->name, __FUNCTION__,a);
   return 0;
}
void __exit ultrason_exit(void) {
   a=2;
   rtdm_task_destroy(&task);
   rtdm_printk(KERN_INFO "%s.%s() : hello = %d\n", THIS_MODULE->name, __FUNCTION__,a);
   }

module_init(ultrason_init);
module_exit(ultrason_exit);
MODULE_LICENSE("GPL »);

————————— 

When I insert the module and remove it, I found in dmesg:

————————— 

[ 5045.187448] test.ultrason_init() : hello = 0
[ 5045.189495] test.ultrason_init() : success rtdm_task_init, hello = 0
[ 5049.631665] test.ultrason_exit() : hello = 2

————————— 

The task_ultrason is never called.

I read from https://gitlab.denx.de/Xenomai/xenomai/-/wikis/Migrating_From_Xenomai_2_To_3 <https://gitlab.denx.de/Xenomai/xenomai/-/wikis/Migrating_From_Xenomai_2_To_3>, that rtdm_task_init() shall be called from secondary mode.

Since Xenomai 3, rtdm_task_init() involves creating a regular kernel thread, which will be given real-time capabilities, such as running under the control of the Cobalt kernel. In order to invoke standard kernel services, rtdm_task_init() must be called from a regular Linux kernel context.

So, how to adapt my example to call rtdm_task_init() from  from a regular Linux kernel context to make this example working?

Thank you for your help.

BR,
Marwane.








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

* Re: rtdm_task_init does not work with Xenomai 3
  2020-06-02 18:34 ` rtdm_task_init does not work with Xenomai 3 ayaida marwane
@ 2020-06-07 20:33   ` ayaida marwane
  2020-06-08  7:36     ` Philippe Gerum
  2020-06-12 16:17   ` Jan Kiszka
  1 sibling, 1 reply; 7+ messages in thread
From: ayaida marwane @ 2020-06-07 20:33 UTC (permalink / raw)
  To: Marwane Ayaida; +Cc: xenomai

Hi,

Any suggestion about the request below?

Thanks!

BR,
Marwane.

> Le 2 juin 2020 à 20:34, ayaida marwane via Xenomai <xenomai@xenomai.org> a écrit :
> 
> Dear all,
> 
> I tried to have an example using rtdm_task_init with Xenomai 3.0.7. The example is tis one:
> 
> ————————— 
> 
> #include <rtdm/driver.h>
> static int periode_us = 1000;
> static int a, ret;
> module_param(periode_us, int, 0644);
> 
> rtdm_task_t task;
> 
> void task_ultrason(void *arg){
>   a=1;
>   rtdm_printk(KERN_INFO "%s.%s() : hello = %d\n", THIS_MODULE->name, __FUNCTION__,a);
> }
> 
> int __init ultrason_init(void) {
>   a=0;
>   rtdm_printk(KERN_INFO "%s.%s() : hello = %d\n", THIS_MODULE->name, __FUNCTION__,a);
>   ret = rtdm_task_init(&task, "ultrason", task_ultrason, NULL, 99, periode_us*1000);
>   if (ret) {
>        rtdm_printk(KERN_INFO "%s.%s() : error rtdm_task_init, hello = %d\n", THIS_MODULE->name, __FUNCTION__,a);
>   }
>   else  rtdm_printk(KERN_INFO "%s.%s() : success rtdm_task_init, hello = %d\n", THIS_MODULE->name, __FUNCTION__,a);
>   return 0;
> }
> void __exit ultrason_exit(void) {
>   a=2;
>   rtdm_task_destroy(&task);
>   rtdm_printk(KERN_INFO "%s.%s() : hello = %d\n", THIS_MODULE->name, __FUNCTION__,a);
>   }
> 
> module_init(ultrason_init);
> module_exit(ultrason_exit);
> MODULE_LICENSE("GPL »);
> 
> ————————— 
> 
> When I insert the module and remove it, I found in dmesg:
> 
> ————————— 
> 
> [ 5045.187448] test.ultrason_init() : hello = 0
> [ 5045.189495] test.ultrason_init() : success rtdm_task_init, hello = 0
> [ 5049.631665] test.ultrason_exit() : hello = 2
> 
> ————————— 
> 
> The task_ultrason is never called.
> 
> I read from https://gitlab.denx.de/Xenomai/xenomai/-/wikis/Migrating_From_Xenomai_2_To_3 <https://gitlab.denx.de/Xenomai/xenomai/-/wikis/Migrating_From_Xenomai_2_To_3>, that rtdm_task_init() shall be called from secondary mode.
> 
> Since Xenomai 3, rtdm_task_init() involves creating a regular kernel thread, which will be given real-time capabilities, such as running under the control of the Cobalt kernel. In order to invoke standard kernel services, rtdm_task_init() must be called from a regular Linux kernel context.
> 
> So, how to adapt my example to call rtdm_task_init() from  from a regular Linux kernel context to make this example working?
> 
> Thank you for your help.
> 
> BR,
> Marwane.
> 
> 
> 
> 
> 
> 
> 



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

* Re: rtdm_task_init does not work with Xenomai 3
  2020-06-07 20:33   ` ayaida marwane
@ 2020-06-08  7:36     ` Philippe Gerum
  2020-06-09  9:25       ` ayaida marwane
  0 siblings, 1 reply; 7+ messages in thread
From: Philippe Gerum @ 2020-06-08  7:36 UTC (permalink / raw)
  To: ayaida marwane; +Cc: xenomai

On 6/7/20 10:33 PM, ayaida marwane via Xenomai wrote:
> Hi,
> 
> Any suggestion about the request below?
> 
> Thanks!
> 
> BR,
> Marwane.
> 
>> Le 2 juin 2020 à 20:34, ayaida marwane via Xenomai <xenomai@xenomai.org> a écrit :
>>
>> Dear all,
>>
>> I tried to have an example using rtdm_task_init with Xenomai 3.0.7. The example is tis one:
>>
>> ————————— 
>>
>> #include <rtdm/driver.h>
>> static int periode_us = 1000;
>> static int a, ret;
>> module_param(periode_us, int, 0644);
>>
>> rtdm_task_t task;
>>
>> void task_ultrason(void *arg){
>>   a=1;
>>   rtdm_printk(KERN_INFO "%s.%s() : hello = %d\n", THIS_MODULE->name, __FUNCTION__,a);
>> }
>>
>> int __init ultrason_init(void) {
>>   a=0;
>>   rtdm_printk(KERN_INFO "%s.%s() : hello = %d\n", THIS_MODULE->name, __FUNCTION__,a);
>>   ret = rtdm_task_init(&task, "ultrason", task_ultrason, NULL, 99, periode_us*1000);
>>   if (ret) {
>>        rtdm_printk(KERN_INFO "%s.%s() : error rtdm_task_init, hello = %d\n", THIS_MODULE->name, __FUNCTION__,a);
>>   }
>>   else  rtdm_printk(KERN_INFO "%s.%s() : success rtdm_task_init, hello = %d\n", THIS_MODULE->name, __FUNCTION__,a);
>>   return 0;
>> }
>> void __exit ultrason_exit(void) {
>>   a=2;
>>   rtdm_task_destroy(&task);
>>   rtdm_printk(KERN_INFO "%s.%s() : hello = %d\n", THIS_MODULE->name, __FUNCTION__,a);
>>   }
>>
>> module_init(ultrason_init);
>> module_exit(ultrason_exit);
>> MODULE_LICENSE("GPL »);
>>
>> ————————— 
>>
>> When I insert the module and remove it, I found in dmesg:
>>
>> ————————— 
>>
>> [ 5045.187448] test.ultrason_init() : hello = 0
>> [ 5045.189495] test.ultrason_init() : success rtdm_task_init, hello = 0
>> [ 5049.631665] test.ultrason_exit() : hello = 2

This looks like a I bug fixed many moons ago in the printk support code for
the pipeline. This issue caused printk() output sent from the head stage not
to appear in the kernel log, a regression due to upstream changes which went
unnoticed.

You may want to update your I-pipe patch to the latest available in your
kernel series to make sure the fix is there. If not, your rt task would indeed
run shortly as requested by rtdm_task_init(), but the feedback would be
spuriously elided.

A trivial way to check this without ftracing: have task_ultrason() call
rtdm_task_sleep(10000000000ULL) before exiting, then you would have 10 secs to
manually check it was actually spawned by reading /proc/xenomai/sched/threads.

-- 
Philippe.


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

* Re: rtdm_task_init does not work with Xenomai 3
  2020-06-08  7:36     ` Philippe Gerum
@ 2020-06-09  9:25       ` ayaida marwane
  2020-06-09 10:53         ` Philippe Gerum
  0 siblings, 1 reply; 7+ messages in thread
From: ayaida marwane @ 2020-06-09  9:25 UTC (permalink / raw)
  To: Philippe Gerum; +Cc: xenomai

Hi Philippe,

> Le 8 juin 2020 à 09:36, Philippe Gerum <rpm@xenomai.org> a écrit :
> 
> On 6/7/20 10:33 PM, ayaida marwane via Xenomai wrote:
>> Hi,
>> 
>> Any suggestion about the request below?
>> 
>> Thanks!
>> 
>> BR,
>> Marwane.
>> 
>>> Le 2 juin 2020 à 20:34, ayaida marwane via Xenomai <xenomai@xenomai.org> a écrit :
>>> 
>>> Dear all,
>>> 
>>> I tried to have an example using rtdm_task_init with Xenomai 3.0.7. The example is tis one:
>>> 
>>> ————————— 
>>> 
>>> #include <rtdm/driver.h>
>>> static int periode_us = 1000;
>>> static int a, ret;
>>> module_param(periode_us, int, 0644);
>>> 
>>> rtdm_task_t task;
>>> 
>>> void task_ultrason(void *arg){
>>>  a=1;
>>>  rtdm_printk(KERN_INFO "%s.%s() : hello = %d\n", THIS_MODULE->name, __FUNCTION__,a);
>>> }
>>> 
>>> int __init ultrason_init(void) {
>>>  a=0;
>>>  rtdm_printk(KERN_INFO "%s.%s() : hello = %d\n", THIS_MODULE->name, __FUNCTION__,a);
>>>  ret = rtdm_task_init(&task, "ultrason", task_ultrason, NULL, 99, periode_us*1000);
>>>  if (ret) {
>>>       rtdm_printk(KERN_INFO "%s.%s() : error rtdm_task_init, hello = %d\n", THIS_MODULE->name, __FUNCTION__,a);
>>>  }
>>>  else  rtdm_printk(KERN_INFO "%s.%s() : success rtdm_task_init, hello = %d\n", THIS_MODULE->name, __FUNCTION__,a);
>>>  return 0;
>>> }
>>> void __exit ultrason_exit(void) {
>>>  a=2;
>>>  rtdm_task_destroy(&task);
>>>  rtdm_printk(KERN_INFO "%s.%s() : hello = %d\n", THIS_MODULE->name, __FUNCTION__,a);
>>>  }
>>> 
>>> module_init(ultrason_init);
>>> module_exit(ultrason_exit);
>>> MODULE_LICENSE("GPL »);
>>> 
>>> ————————— 
>>> 
>>> When I insert the module and remove it, I found in dmesg:
>>> 
>>> ————————— 
>>> 
>>> [ 5045.187448] test.ultrason_init() : hello = 0
>>> [ 5045.189495] test.ultrason_init() : success rtdm_task_init, hello = 0
>>> [ 5049.631665] test.ultrason_exit() : hello = 2
> 
> This looks like a I bug fixed many moons ago in the printk support code for
> the pipeline. This issue caused printk() output sent from the head stage not
> to appear in the kernel log, a regression due to upstream changes which went
> unnoticed.
> 
> You may want to update your I-pipe patch to the latest available in your
> kernel series to make sure the fix is there. If not, your rt task would indeed
> run shortly as requested by rtdm_task_init(), but the feedback would be
> spuriously elided.
> 
> A trivial way to check this without ftracing: have task_ultrason() call
> rtdm_task_sleep(10000000000ULL) before exiting, then you would have 10 secs to
> manually check it was actually spawned by reading /proc/xenomai/sched/threads.
> 
> -- 
> Philippe.

T tried your suggestion. I added rtdm_task_sleep(10000000000ULL) in task_ultrason():

#include <rtdm/driver.h>
static int periode_us = 1000;
static int a, ret;
module_param(periode_us, int, 0644);

rtdm_task_t task;

void task_ultrason(void *arg){
   a=1;
   rtdm_printk(KERN_INFO "%s.%s() : hello = %d\n", THIS_MODULE->name, __FUNCTION__,a);
   rtdm_task_sleep(10000000000ULL);
   }

int __init ultrason_init(void) {
   a=0;
   rtdm_printk(KERN_INFO "%s.%s() : hello = %d\n", THIS_MODULE->name, __FUNCTION__,a);
   ret = rtdm_task_init(&task, "ultrason", task_ultrason, NULL, 30, periode_us*1000);
   if (ret) {
        rtdm_printk(KERN_INFO "%s.%s() : error rtdm_task_init, hello = %d\n", THIS_MODULE->name, __FUNCTION__,a);
   }
   else  rtdm_printk(KERN_INFO "%s.%s() : success rtdm_task_init, hello = %d\n", THIS_MODULE->name, __FUNCTION__,a);
  rtdm_task_set_period(&task, 0, periode_us*1000);
   return 0;
}
void __exit ultrason_exit(void) {
   a=2;
   rtdm_task_destroy(&task);
   rtdm_printk(KERN_INFO "%s.%s() : hello = %d\n", THIS_MODULE->name, __FUNCTION__,a);
   }

module_init(ultrason_init);
module_exit(ultrason_exit);
MODULE_LICENSE("GPL");

When, I load the module after its compilation, I obtained:

root@raspberrypi:/home/pi/tests# cat /proc/xenomai/sched/threads
CPU  PID    CLASS  TYPE      PRI   TIMEOUT       STAT       NAME
  0  0      idle   core       -1   -             R          [ROOT/0]
  1  0      idle   core       -1   -             R          [ROOT/1]
  2  0      idle   core       -1   -             R          [ROOT/2]
  3  0      idle   core       -1   -             R          [ROOT/3]
root@raspberrypi:/home/pi/tests# insmod test.ko
root@raspberrypi:/home/pi/tests# cat /proc/xenomai/sched/threads
CPU  PID    CLASS  TYPE      PRI   TIMEOUT       STAT       NAME
  0  0      idle   core       -1   -             R          [ROOT/0]
  1  0      idle   core       -1   -             R          [ROOT/1]
  2  0      idle   core       -1   -             R          [ROOT/2]
  3  0      idle   core       -1   -             R          [ROOT/3]
root@raspberrypi:/home/pi/tests# cat /proc/xenomai/sched/threads
CPU  PID    CLASS  TYPE      PRI   TIMEOUT       STAT       NAME
  0  0      idle   core       -1   -             R          [ROOT/0]
  1  0      idle   core       -1   -             R          [ROOT/1]
  2  0      idle   core       -1   -             R          [ROOT/2]
  3  0      idle   core       -1   -             R          [ROOT/3]
root@raspberrypi:/home/pi/tests# cat /proc/xenomai/sched/threads
CPU  PID    CLASS  TYPE      PRI   TIMEOUT       STAT       NAME
  0  0      idle   core       -1   -             R          [ROOT/0]
  1  0      idle   core       -1   -             R          [ROOT/1]
  2  0      idle   core       -1   -             R          [ROOT/2]
  3  0      idle   core       -1   -             R          [ROOT/3]
root@raspberrypi:/home/pi/tests# cat /proc/xenomai/sched/threads
CPU  PID    CLASS  TYPE      PRI   TIMEOUT       STAT       NAME
  0  0      idle   core       -1   -             R          [ROOT/0]
  1  0      idle   core       -1   -             R          [ROOT/1]
  2  0      idle   core       -1   -             R          [ROOT/2]
  3  0      idle   core       -1   -             R          [ROOT/3]
root@raspberrypi:/home/pi/tests# rmmod test


So, the task_ultrason() is never scheduled. It seems very strange…

Do I something wrong?

I will try also to update my patch, but it will take some time. I prefer to make it working with this version of Xenomai (3.0.7).

BR,
Marwane. 






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

* Re: rtdm_task_init does not work with Xenomai 3
  2020-06-09  9:25       ` ayaida marwane
@ 2020-06-09 10:53         ` Philippe Gerum
  2020-06-09 15:32           ` ayaida marwane
  0 siblings, 1 reply; 7+ messages in thread
From: Philippe Gerum @ 2020-06-09 10:53 UTC (permalink / raw)
  To: ayaida marwane; +Cc: xenomai

On 6/9/20 11:25 AM, ayaida marwane wrote:
> Hi Philippe,
> 
>> Le 8 juin 2020 à 09:36, Philippe Gerum <rpm@xenomai.org
>> <mailto:rpm@xenomai.org>> a écrit :
>>
>> On 6/7/20 10:33 PM, ayaida marwane via Xenomai wrote:
>>> Hi,
>>>
>>> Any suggestion about the request below?
>>>
>>> Thanks!
>>>
>>> BR,
>>> Marwane.
>>>
>>>> Le 2 juin 2020 à 20:34, ayaida marwane via Xenomai <xenomai@xenomai.org
>>>> <mailto:xenomai@xenomai.org>> a écrit :
>>>>
>>>> Dear all,
>>>>
>>>> I tried to have an example using rtdm_task_init with Xenomai 3.0.7. The
>>>> example is tis one:
>>>>
>>>> —————————
>>>>
>>>> #include <rtdm/driver.h>
>>>> static int periode_us = 1000;
>>>> static int a, ret;
>>>> module_param(periode_us, int, 0644);
>>>>
>>>> rtdm_task_t task;
>>>>
>>>> void task_ultrason(void *arg){
>>>>  a=1;
>>>>  rtdm_printk(KERN_INFO "%s.%s() : hello = %d\n", THIS_MODULE->name,
>>>> __FUNCTION__,a);
>>>> }
>>>>
>>>> int __init ultrason_init(void) {
>>>>  a=0;
>>>>  rtdm_printk(KERN_INFO "%s.%s() : hello = %d\n", THIS_MODULE->name,
>>>> __FUNCTION__,a);
>>>>  ret = rtdm_task_init(&task, "ultrason", task_ultrason, NULL, 99,
>>>> periode_us*1000);
>>>>  if (ret) {
>>>>       rtdm_printk(KERN_INFO "%s.%s() : error rtdm_task_init, hello =
>>>> %d\n", THIS_MODULE->name, __FUNCTION__,a);
>>>>  }
>>>>  else  rtdm_printk(KERN_INFO "%s.%s() : success rtdm_task_init, hello =
>>>> %d\n", THIS_MODULE->name, __FUNCTION__,a);
>>>>  return 0;
>>>> }
>>>> void __exit ultrason_exit(void) {
>>>>  a=2;
>>>>  rtdm_task_destroy(&task);
>>>>  rtdm_printk(KERN_INFO "%s.%s() : hello = %d\n", THIS_MODULE->name,
>>>> __FUNCTION__,a);
>>>>  }
>>>>
>>>> module_init(ultrason_init);
>>>> module_exit(ultrason_exit);
>>>> MODULE_LICENSE("GPL »);
>>>>
>>>> —————————
>>>>
>>>> When I insert the module and remove it, I found in dmesg:
>>>>
>>>> —————————
>>>>
>>>> [ 5045.187448] test.ultrason_init() : hello = 0
>>>> [ 5045.189495] test.ultrason_init() : success rtdm_task_init, hello = 0
>>>> [ 5049.631665] test.ultrason_exit() : hello = 2
>>
>> This looks like a I bug fixed many moons ago in the printk support code for
>> the pipeline. This issue caused printk() output sent from the head stage not
>> to appear in the kernel log, a regression due to upstream changes which went
>> unnoticed.
>>
>> You may want to update your I-pipe patch to the latest available in your
>> kernel series to make sure the fix is there. If not, your rt task would indeed
>> run shortly as requested by rtdm_task_init(), but the feedback would be
>> spuriously elided.
>>
>> A trivial way to check this without ftracing: have task_ultrason() call
>> rtdm_task_sleep(10000000000ULL) before exiting, then you would have 10 secs to
>> manually check it was actually spawned by reading /proc/xenomai/sched/threads.
>>
>> -- 
>> Philippe.
> 
> T tried your suggestion. I added rtdm_task_sleep(10000000000ULL)
> in task_ultrason():
> 
> *#include**<rtdm/driver.h>*
> staticintperiode_us = 1000;
> staticinta, ret;
> module_param(periode_us, int, 0644);
> 
> rtdm_task_t task;
> 
> voidtask_ultrason(void*arg){
>    a=1;
>    rtdm_printk(*KERN_INFO**"%s.%s() : hello = %d\n"*, *THIS_MODULE*->name,
> *__FUNCTION__*,a);
>    rtdm_task_sleep(10000000000ULL);
>    }
> 
> int__init ultrason_init(void) {
>    a=0;
>    rtdm_printk(*KERN_INFO**"%s.%s() : hello = %d\n"*, *THIS_MODULE*->name,
> *__FUNCTION__*,a);
>    ret = rtdm_task_init(&task, *"ultrason"*, task_ultrason, *NULL*, 30,
> periode_us*1000);
>    *if*(ret) {
>         rtdm_printk(*KERN_INFO**"%s.%s() : error rtdm_task_init, hello =
> %d\n"*, *THIS_MODULE*->name, *__FUNCTION__*,a);
>    }
>    *else*  rtdm_printk(*KERN_INFO**"%s.%s() : success rtdm_task_init, hello =
> %d\n"*, *THIS_MODULE*->name, *__FUNCTION__*,a);
>   rtdm_task_set_period(&task, 0, periode_us*1000);
>    return0;
> }
> void__exit ultrason_exit(void) {
>    a=2;
>    rtdm_task_destroy(&task);
>    rtdm_printk(*KERN_INFO**"%s.%s() : hello = %d\n"*, *THIS_MODULE*->name,
> *__FUNCTION__*,a);
>    }
> 
> module_init(ultrason_init);
> module_exit(ultrason_exit);
> *MODULE_LICENSE*(*"GPL"*);
> 
> When, I load the module after its compilation, I obtained:
> 
> root@raspberrypi:/home/pi/tests# cat /proc/xenomai/sched/threads
> CPU  PID    CLASS  TYPE      PRI   TIMEOUT       STAT       NAME
>   0  0      idle   core       -1   -             R          [ROOT/0]
>   1  0      idle   core       -1   -             R          [ROOT/1]
>   2  0      idle   core       -1   -             R          [ROOT/2]
>   3  0      idle   core       -1   -             R          [ROOT/3]
> root@raspberrypi:/home/pi/tests# insmod test.ko
> root@raspberrypi:/home/pi/tests# cat /proc/xenomai/sched/threads
> CPU  PID    CLASS  TYPE      PRI   TIMEOUT       STAT       NAME
>   0  0      idle   core       -1   -             R          [ROOT/0]
>   1  0      idle   core       -1   -             R          [ROOT/1]
>   2  0      idle   core       -1   -             R          [ROOT/2]
>   3  0      idle   core       -1   -             R          [ROOT/3]
> root@raspberrypi:/home/pi/tests# cat /proc/xenomai/sched/threads
> CPU  PID    CLASS  TYPE      PRI   TIMEOUT       STAT       NAME
>   0  0      idle   core       -1   -             R          [ROOT/0]
>   1  0      idle   core       -1   -             R          [ROOT/1]
>   2  0      idle   core       -1   -             R          [ROOT/2]
>   3  0      idle   core       -1   -             R          [ROOT/3]
> root@raspberrypi:/home/pi/tests# cat /proc/xenomai/sched/threads
> CPU  PID    CLASS  TYPE      PRI   TIMEOUT       STAT       NAME
>   0  0      idle   core       -1   -             R          [ROOT/0]
>   1  0      idle   core       -1   -             R          [ROOT/1]
>   2  0      idle   core       -1   -             R          [ROOT/2]
>   3  0      idle   core       -1   -             R          [ROOT/3]
> root@raspberrypi:/home/pi/tests# cat /proc/xenomai/sched/threads
> CPU  PID    CLASS  TYPE      PRI   TIMEOUT       STAT       NAME
>   0  0      idle   core       -1   -             R          [ROOT/0]
>   1  0      idle   core       -1   -             R          [ROOT/1]
>   2  0      idle   core       -1   -             R          [ROOT/2]
>   3  0      idle   core       -1   -             R          [ROOT/3]
> root@raspberrypi:/home/pi/tests# rmmod test
> 
> 
> So, the task_ultrason() is never scheduled. It seems very strange…
> 
> Do I something wrong?
> 

Nope, my bad, your task is periodic, so it would be awaken by the first tick
from the sleep after 1 ms then exit. Just set the task period to zero in
rtdk_task_init() only for the purpose of testing.

PS: you do not need to call rtdm_task_set_period() for a task right after
having created that task, mentioning the same period value. This is redundant.

-- 
Philippe.


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

* Re: rtdm_task_init does not work with Xenomai 3
  2020-06-09 10:53         ` Philippe Gerum
@ 2020-06-09 15:32           ` ayaida marwane
  0 siblings, 0 replies; 7+ messages in thread
From: ayaida marwane @ 2020-06-09 15:32 UTC (permalink / raw)
  To: Philippe Gerum; +Cc: xenomai



> Le 9 juin 2020 à 12:53, Philippe Gerum <rpm@xenomai.org> a écrit :
> 
> On 6/9/20 11:25 AM, ayaida marwane wrote:
>> Hi Philippe,
>> 
>>> Le 8 juin 2020 à 09:36, Philippe Gerum <rpm@xenomai.org
>>> <mailto:rpm@xenomai.org>> a écrit :
>>> 
>>> On 6/7/20 10:33 PM, ayaida marwane via Xenomai wrote:
>>>> Hi,
>>>> 
>>>> Any suggestion about the request below?
>>>> 
>>>> Thanks!
>>>> 
>>>> BR,
>>>> Marwane.
>>>> 
>>>>> Le 2 juin 2020 à 20:34, ayaida marwane via Xenomai <xenomai@xenomai.org
>>>>> <mailto:xenomai@xenomai.org>> a écrit :
>>>>> 
>>>>> Dear all,
>>>>> 
>>>>> I tried to have an example using rtdm_task_init with Xenomai 3.0.7. The
>>>>> example is tis one:
>>>>> 
>>>>> —————————
>>>>> 
>>>>> #include <rtdm/driver.h>
>>>>> static int periode_us = 1000;
>>>>> static int a, ret;
>>>>> module_param(periode_us, int, 0644);
>>>>> 
>>>>> rtdm_task_t task;
>>>>> 
>>>>> void task_ultrason(void *arg){
>>>>>  a=1;
>>>>>  rtdm_printk(KERN_INFO "%s.%s() : hello = %d\n", THIS_MODULE->name,
>>>>> __FUNCTION__,a);
>>>>> }
>>>>> 
>>>>> int __init ultrason_init(void) {
>>>>>  a=0;
>>>>>  rtdm_printk(KERN_INFO "%s.%s() : hello = %d\n", THIS_MODULE->name,
>>>>> __FUNCTION__,a);
>>>>>  ret = rtdm_task_init(&task, "ultrason", task_ultrason, NULL, 99,
>>>>> periode_us*1000);
>>>>>  if (ret) {
>>>>>       rtdm_printk(KERN_INFO "%s.%s() : error rtdm_task_init, hello =
>>>>> %d\n", THIS_MODULE->name, __FUNCTION__,a);
>>>>>  }
>>>>>  else  rtdm_printk(KERN_INFO "%s.%s() : success rtdm_task_init, hello =
>>>>> %d\n", THIS_MODULE->name, __FUNCTION__,a);
>>>>>  return 0;
>>>>> }
>>>>> void __exit ultrason_exit(void) {
>>>>>  a=2;
>>>>>  rtdm_task_destroy(&task);
>>>>>  rtdm_printk(KERN_INFO "%s.%s() : hello = %d\n", THIS_MODULE->name,
>>>>> __FUNCTION__,a);
>>>>>  }
>>>>> 
>>>>> module_init(ultrason_init);
>>>>> module_exit(ultrason_exit);
>>>>> MODULE_LICENSE("GPL »);
>>>>> 
>>>>> —————————
>>>>> 
>>>>> When I insert the module and remove it, I found in dmesg:
>>>>> 
>>>>> —————————
>>>>> 
>>>>> [ 5045.187448] test.ultrason_init() : hello = 0
>>>>> [ 5045.189495] test.ultrason_init() : success rtdm_task_init, hello = 0
>>>>> [ 5049.631665] test.ultrason_exit() : hello = 2
>>> 
>>> This looks like a I bug fixed many moons ago in the printk support code for
>>> the pipeline. This issue caused printk() output sent from the head stage not
>>> to appear in the kernel log, a regression due to upstream changes which went
>>> unnoticed.
>>> 
>>> You may want to update your I-pipe patch to the latest available in your
>>> kernel series to make sure the fix is there. If not, your rt task would indeed
>>> run shortly as requested by rtdm_task_init(), but the feedback would be
>>> spuriously elided.
>>> 
>>> A trivial way to check this without ftracing: have task_ultrason() call
>>> rtdm_task_sleep(10000000000ULL) before exiting, then you would have 10 secs to
>>> manually check it was actually spawned by reading /proc/xenomai/sched/threads.
>>> 
>>> -- 
>>> Philippe.
>> 
>> T tried your suggestion. I added rtdm_task_sleep(10000000000ULL)
>> in task_ultrason():
>> 
>> *#include**<rtdm/driver.h>*
>> staticintperiode_us = 1000;
>> staticinta, ret;
>> module_param(periode_us, int, 0644);
>> 
>> rtdm_task_t task;
>> 
>> voidtask_ultrason(void*arg){
>>    a=1;
>>    rtdm_printk(*KERN_INFO**"%s.%s() : hello = %d\n"*, *THIS_MODULE*->name,
>> *__FUNCTION__*,a);
>>    rtdm_task_sleep(10000000000ULL);
>>    }
>> 
>> int__init ultrason_init(void) {
>>    a=0;
>>    rtdm_printk(*KERN_INFO**"%s.%s() : hello = %d\n"*, *THIS_MODULE*->name,
>> *__FUNCTION__*,a);
>>    ret = rtdm_task_init(&task, *"ultrason"*, task_ultrason, *NULL*, 30,
>> periode_us*1000);
>>    *if*(ret) {
>>         rtdm_printk(*KERN_INFO**"%s.%s() : error rtdm_task_init, hello =
>> %d\n"*, *THIS_MODULE*->name, *__FUNCTION__*,a);
>>    }
>>    *else*  rtdm_printk(*KERN_INFO**"%s.%s() : success rtdm_task_init, hello =
>> %d\n"*, *THIS_MODULE*->name, *__FUNCTION__*,a);
>>   rtdm_task_set_period(&task, 0, periode_us*1000);
>>    return0;
>> }
>> void__exit ultrason_exit(void) {
>>    a=2;
>>    rtdm_task_destroy(&task);
>>    rtdm_printk(*KERN_INFO**"%s.%s() : hello = %d\n"*, *THIS_MODULE*->name,
>> *__FUNCTION__*,a);
>>    }
>> 
>> module_init(ultrason_init);
>> module_exit(ultrason_exit);
>> *MODULE_LICENSE*(*"GPL"*);
>> 
>> When, I load the module after its compilation, I obtained:
>> 
>> root@raspberrypi:/home/pi/tests# cat /proc/xenomai/sched/threads
>> CPU  PID    CLASS  TYPE      PRI   TIMEOUT       STAT       NAME
>>   0  0      idle   core       -1   -             R          [ROOT/0]
>>   1  0      idle   core       -1   -             R          [ROOT/1]
>>   2  0      idle   core       -1   -             R          [ROOT/2]
>>   3  0      idle   core       -1   -             R          [ROOT/3]
>> root@raspberrypi:/home/pi/tests# insmod test.ko
>> root@raspberrypi:/home/pi/tests# cat /proc/xenomai/sched/threads
>> CPU  PID    CLASS  TYPE      PRI   TIMEOUT       STAT       NAME
>>   0  0      idle   core       -1   -             R          [ROOT/0]
>>   1  0      idle   core       -1   -             R          [ROOT/1]
>>   2  0      idle   core       -1   -             R          [ROOT/2]
>>   3  0      idle   core       -1   -             R          [ROOT/3]
>> root@raspberrypi:/home/pi/tests# cat /proc/xenomai/sched/threads
>> CPU  PID    CLASS  TYPE      PRI   TIMEOUT       STAT       NAME
>>   0  0      idle   core       -1   -             R          [ROOT/0]
>>   1  0      idle   core       -1   -             R          [ROOT/1]
>>   2  0      idle   core       -1   -             R          [ROOT/2]
>>   3  0      idle   core       -1   -             R          [ROOT/3]
>> root@raspberrypi:/home/pi/tests# cat /proc/xenomai/sched/threads
>> CPU  PID    CLASS  TYPE      PRI   TIMEOUT       STAT       NAME
>>   0  0      idle   core       -1   -             R          [ROOT/0]
>>   1  0      idle   core       -1   -             R          [ROOT/1]
>>   2  0      idle   core       -1   -             R          [ROOT/2]
>>   3  0      idle   core       -1   -             R          [ROOT/3]
>> root@raspberrypi:/home/pi/tests# cat /proc/xenomai/sched/threads
>> CPU  PID    CLASS  TYPE      PRI   TIMEOUT       STAT       NAME
>>   0  0      idle   core       -1   -             R          [ROOT/0]
>>   1  0      idle   core       -1   -             R          [ROOT/1]
>>   2  0      idle   core       -1   -             R          [ROOT/2]
>>   3  0      idle   core       -1   -             R          [ROOT/3]
>> root@raspberrypi:/home/pi/tests# rmmod test
>> 
>> 
>> So, the task_ultrason() is never scheduled. It seems very strange…
>> 
>> Do I something wrong?
>> 
> 
> Nope, my bad, your task is periodic, so it would be awaken by the first tick
> from the sleep after 1 ms then exit. Just set the task period to zero in
> rtdk_task_init() only for the purpose of testing.
> 
> PS: you do not need to call rtdm_task_set_period() for a task right after
> having created that task, mentioning the same period value. This is redundant.
> 
> -- 
> Philippe.


Thank you Philippe, it works well now, when I put the period to 0:

root@raspberrypi:/home/pi/tests# insmod test.ko
root@raspberrypi:/home/pi/tests# cat /proc/xenomai/sched/threads
CPU  PID    CLASS  TYPE      PRI   TIMEOUT       STAT       NAME
  0  0      idle   core       -1   -             R          [ROOT/0]
  1  0      idle   core       -1   -             R          [ROOT/1]
  2  0      idle   core       -1   -             R          [ROOT/2]
  3  0      idle   core       -1   -             R          [ROOT/3]
  3  1015   rt     core       30   5s964ms894us  D          [ultrason]
root@raspberrypi:/home/pi/tests# cat /proc/xenomai/sched/threads
CPU  PID    CLASS  TYPE      PRI   TIMEOUT       STAT       NAME
  0  0      idle   core       -1   -             R          [ROOT/0]
  1  0      idle   core       -1   -             R          [ROOT/1]
  2  0      idle   core       -1   -             R          [ROOT/2]
  3  0      idle   core       -1   -             R          [ROOT/3]
  3  1015   rt     core       30   890ms509us    D          [ultrason]
root@raspberrypi:/home/pi/tests# cat /proc/xenomai/sched/threads
CPU  PID    CLASS  TYPE      PRI   TIMEOUT       STAT       NAME
  0  0      idle   core       -1   -             R          [ROOT/0]
  1  0      idle   core       -1   -             R          [ROOT/1]
  2  0      idle   core       -1   -             R          [ROOT/2]
  3  0      idle   core       -1   -             R          [ROOT/3]

When I put it periodic, why I did not see it anymore in /proc/xenomai/sched/threads  even with a sleep?

PS : Ok rtdm_task_set_period(), I added it since it does not work to test.

BR,
Marwane.




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

* Re: rtdm_task_init does not work with Xenomai 3
  2020-06-02 18:34 ` rtdm_task_init does not work with Xenomai 3 ayaida marwane
  2020-06-07 20:33   ` ayaida marwane
@ 2020-06-12 16:17   ` Jan Kiszka
  1 sibling, 0 replies; 7+ messages in thread
From: Jan Kiszka @ 2020-06-12 16:17 UTC (permalink / raw)
  To: ayaida marwane, xenomai

On 02.06.20 20:34, ayaida marwane via Xenomai wrote:
> Dear all,
> 
> I tried to have an example using rtdm_task_init with Xenomai 3.0.7. The example is tis one:
> 
> ————————— 
> 
> #include <rtdm/driver.h>
> static int periode_us = 1000;
> static int a, ret;
> module_param(periode_us, int, 0644);
> 
> rtdm_task_t task;
> 
> void task_ultrason(void *arg){
>    a=1;
>    rtdm_printk(KERN_INFO "%s.%s() : hello = %d\n", THIS_MODULE->name, __FUNCTION__,a);

This will only be printed once, then the task terminates. You likely
want to put this in a loop and wait on the next cycle via
rtdm_task_wait_period().

Jan

> }
> 
> int __init ultrason_init(void) {
>    a=0;
>    rtdm_printk(KERN_INFO "%s.%s() : hello = %d\n", THIS_MODULE->name, __FUNCTION__,a);
>    ret = rtdm_task_init(&task, "ultrason", task_ultrason, NULL, 99, periode_us*1000);
>    if (ret) {
>         rtdm_printk(KERN_INFO "%s.%s() : error rtdm_task_init, hello = %d\n", THIS_MODULE->name, __FUNCTION__,a);
>    }
>    else  rtdm_printk(KERN_INFO "%s.%s() : success rtdm_task_init, hello = %d\n", THIS_MODULE->name, __FUNCTION__,a);
>    return 0;
> }
> void __exit ultrason_exit(void) {
>    a=2;
>    rtdm_task_destroy(&task);
>    rtdm_printk(KERN_INFO "%s.%s() : hello = %d\n", THIS_MODULE->name, __FUNCTION__,a);
>    }
> 
> module_init(ultrason_init);
> module_exit(ultrason_exit);
> MODULE_LICENSE("GPL »);
> 
> ————————— 
> 
> When I insert the module and remove it, I found in dmesg:
> 
> ————————— 
> 
> [ 5045.187448] test.ultrason_init() : hello = 0
> [ 5045.189495] test.ultrason_init() : success rtdm_task_init, hello = 0
> [ 5049.631665] test.ultrason_exit() : hello = 2
> 
> ————————— 
> 
> The task_ultrason is never called.
> 
> I read from https://gitlab.denx.de/Xenomai/xenomai/-/wikis/Migrating_From_Xenomai_2_To_3 <https://gitlab.denx.de/Xenomai/xenomai/-/wikis/Migrating_From_Xenomai_2_To_3>, that rtdm_task_init() shall be called from secondary mode.
> 
> Since Xenomai 3, rtdm_task_init() involves creating a regular kernel thread, which will be given real-time capabilities, such as running under the control of the Cobalt kernel. In order to invoke standard kernel services, rtdm_task_init() must be called from a regular Linux kernel context.
> 
> So, how to adapt my example to call rtdm_task_init() from  from a regular Linux kernel context to make this example working?
> 
> Thank you for your help.
> 
> BR,
> Marwane.
> 
> 
> 
> 
> 
> 
> 


-- 
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux


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

end of thread, other threads:[~2020-06-12 16:17 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <BCA29F40-0C3A-4DF7-9FE9-EF5D55C66C27.ref@yahoo.fr>
2020-06-02 18:34 ` rtdm_task_init does not work with Xenomai 3 ayaida marwane
2020-06-07 20:33   ` ayaida marwane
2020-06-08  7:36     ` Philippe Gerum
2020-06-09  9:25       ` ayaida marwane
2020-06-09 10:53         ` Philippe Gerum
2020-06-09 15:32           ` ayaida marwane
2020-06-12 16:17   ` Jan Kiszka

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.