Re: SMP driver core lock real-time driver

Doug Renton <[email protected]> Tue, 21 Nov 2017 08:26:23 -0500
Newsgroups gmane.linux.real-time.rtai
Message-ID <[email protected]>
Thanks for the feedback and ideas.

When rtai first started, I was happy to have one core, now we can have 
18 cores (easy 6-8). I'm just wondering if there is a simpler model 
possible if we assume a number of cores are available. Ie one core per 
real-time thread. Forget all the playing nice, having a micro kernel 
etc.., and just lock up the cores we want, communicate through shared 
memory. Has this been tried? How to do this? I know it is a bit 
wasteful, but if it can work, and be simpler to maintain, configure I 
think it is worth trying.

I'm asking about this here because I've used RTAI from day 1, RTAI is 
the best option for real-time, I want to see it continue, progress, and 
if a simpler solution is now possible which reduces the burden on the 
maintainers, and users, I think it is important to consider. Also I know 
the readers of this mail know much more than I do about the details of 
this, and they may be able to say this is not going to work because of 
some obvious reasons.


Apparently the NMI watch dog can be turned off by writing timeout values 
to:
  cat /proc/sys/kernel/watchdog_thresh
  cat /proc/sys/kernel/softlockup_thresh

I will try this. There is also a mask that can be set at boot to keep 
linux off of a set of cores, if I get to that point.
I will then want to disable interrupts in my task, and see..

Thanks
Doug


On 11/21/2017 6:24 AM, Paolo Mantegazza wrote:
> I beg you pardon but, since I do not see where RTAI has a place in all 
> of this, I'm a bit confused.
> 
> When I want to set aside cpus dedicated to RTAI, I'll do it by setting 
> the needed cpumask while insmoding rtai_hal.ko
> In such a case there still remains some linux stuff, e.g, dynamically 
> created workqs and timers interrupts, but it helps RTAI jitter and 
> latency anyhow.
> 
> Morevor if I want to keep my dedicated cpus awake, always, I simple bind 
> an idle (user space) "while(1)" task to my dedicated cpus.  Old style 
> idel task getting read of all the troublesome energy savings.
> 
> I experimented also with a more aggressive policy, i.e. try to move/kill 
> any task still remaining on the reserved cpus, but, even if RTAI hard 
> stuff kept running, it caused troubles to Linux.
> 
> Perhaps I'm likely missing something. Is it possible I missed a previous 
> email of yours?
> 
> Paolo.
> 
> On 11/21/2017 09:19 AM, Asier wrote:
>>
>> *Hi Doug,*
>>
>> **
>>
>> *maybe you could try to somehow tell Linux that the core is no longer 
>> available/online. Could you try one of the following alternatives?*
>>
>> **
>>
>> *1- while the task is on the busy wait execute something like this: 
>> (where * is the desired cpu core)*
>>
>> **
>>
>> *echo 0 > /sys/devices/system/cpu/cpu*/online*
>>
>> **
>>
>> *2- Another alternative could be to call this function *
>>
>> **
>>
>> *int cpu_down(unsigned int cpu);*
>>
>> **
>>
>> *cheers,*
>>
>> *Asier.*
>>
>>
>> On Tue, Nov 21, 2017 at 3:40 AM, Doug Renton <[email protected] 
>> <mailto:[email protected]>> wrote:
>>
>>
>>      I cut and pasted a kernel module, and made it do busy work, until
>>     the kernel decided it had found a bug. While the busy work was
>>     going on, everything seemed fine, could not tell one core was busy.
>>
>>     Everything seems to run fine with one core doing my made up task,
>>     until eventually the kernel decides it has found a bug.
>>     With the loops at something reasonable like 999, everything runs
>>     fine and my task ends. Once turned up to 999999, the kernel
>>     eventually gives my module the boot. Looks like this could be
>>     tricky. I still can't see why we cant just simplify everything and
>>     dedicate one/two core(s) to RTAI, and busy wait.
>>
>>
>>     [  189.566739] Timer module installing
>>     [  189.566743] Starting timer to fire in 200ms (4294939693)
>>     [  189.763714] my_timer_callback called (4294939743).
>>     [  216.060934] NMI watchdog: BUG: soft lockup - CPU#1 stuck for
>>     23s! [swapper/1:0]
>>     [  216.060945] Modules linked in: hello_2(O) Bla Bla Bla...
>>
>>
>>     /*
>>      *  hello-2.c - Demonstrating the module_init() and module_exit()
>>     macros.
>>      *  This is preferred over using init_module() and cleanup_module().
>>      */
>>     #include <linux/module.h>       /* Needed by all modules */
>>     #include <linux/kernel.h>       /* Needed for KERN_INFO */
>>     #include <linux/init.h>         /* Needed for the macros */
>>     #include <linux/timer.h>
>>
>>     MODULE_LICENSE("GPL");
>>
>>     static struct timer_list my_timer;
>>
>>     void my_timer_callback( unsigned long data )
>>     {
>>       int delay = 0;
>>       int delay2;
>>       int delay3;
>>       int delay4;
>>       volatile int glob_test;
>>
>>       glob_test = 1000000;
>>
>>
>>       printk( "my_timer_callback called (%ld).\n", jiffies );
>>       for ( delay4 = 0; delay4 < 99; delay4 += 1)
>>       {
>>       for ( delay3 = 0; delay3 < 99; delay3 += 1)
>>       {
>>          for ( delay2 = 0; delay2 < 99; delay2 += 1)
>>          {
>>             //printk( "my_timer_callback loop %d.\n",delay2);
>>             for( delay = 0; delay < 99; delay += 1)
>>             {
>>                if (delay > glob_test) { printk("What??\n");}
>>             }
>>          }
>>       }
>>       }
>>      printk( "my_timer_callback done.\n" );
>>     }
>>
>>
>>     static int __init hello_2_init(void)
>>     {
>>       int ret;
>>       printk("Timer module installing\n");
>>
>>       // my_timer.function, my_timer.data
>>       setup_timer( &my_timer, my_timer_callback, 0 );
>>
>>       printk( "Starting timer to fire in 200ms (%ld)\n", jiffies );
>>       ret = mod_timer( &my_timer, jiffies + msecs_to_jiffies(200) );
>>       if (ret) printk("Error in mod_timer\n");
>>             return 0;
>>     }
>>
>>     static void __exit hello_2_exit(void)
>>     {
>>     //      printk(KERN_INFO "Goodbye, world 2\n");
>>       int ret;
>>       ret = del_timer( &my_timer );
>>       if (ret) printk("The timer is still in use...\n");
>>
>>       printk("Timer module uninstalling\n");
>>
>>     }
>>
>>     module_init(hello_2_init);
>>     module_exit(hello_2_exit);
>>
>>
>>     _______________________________________________
>>     Rtai mailing list
>>     [email protected] <mailto:[email protected]>
>>     https://mail.rtai.org/cgi-bin/mailman/listinfo/rtai
>>     <https://mail.rtai.org/cgi-bin/mailman/listinfo/rtai>
>>
>>
>>
>>
>> _______________________________________________
>> Rtai mailing list
>> [email protected]
>> https://mail.rtai.org/cgi-bin/mailman/listinfo/rtai
> 
> 
_______________________________________________
Rtai mailing list
[email protected]
https://mail.rtai.org/cgi-bin/mailman/listinfo/rtai