This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

how to reduce the latency of the kernel

I am using a spi uart bridge ,

It have 64 byte fifo.i use a kernel thread to read the spi data,it will sleep when there is no data,when there is data come ,the irq with wake up the kernel thread,

Because I think I can not use spi_read to read data directly in the interrupt context.

I want to support the 115200bps with 8N1,then it will spend 86us to receive one byte ,and Then the fifo of the uart bridge will full in  5.6ms seconds,

Then problem come out ,the linux kernel of my am335x shedule  with 10ms  ,the data will lost .

Can anyone give me some advice?

 

wangl

 

  • Hi Liang,

    I suggest you two ways to solving your issue:
    The simplest way is to increase the size of fifo buffer.
    The other way is to decrease the Linux default scheduler timeslice. You need to modify the default value of RR_TIMESLICE macro in ../linux/include/linux/sched/rt.h file:
    #define RR_TIMESLICE (100 * HZ / 1000)
    I only would like to note that for Sitara devices CONFIG_HZ=100 which means the timeslice is 10 ms bus not 100 ms as noted in rt.h file.

    BR
    Tsvetolin Shulev
  • Liang,

    One more clarification: You can modify Linux timeslice run-time for Linux kernel versions after 3.9 by the following command:


    # echo 1 > /proc/sys/kernel/sched_rr_timeslice_ms



    BR
    Tsvetolin Shulev

  • Hi Tsvetolin:

    the first way :

    To increase the size of fifo buffer

    the buffer is fixed by hardware ,it is 64bytes,I can not increase it,it is sc16is762 nxp spi uart bridge.

    the second way:

    I wonder whether it  have influence to other part of the whole system,it will increase the interrupt frequence of the system.

    I am using 3.2.0 kernel,because of some reason,it is not the latest sdk version.

    Though there is driver in the newest sdk kernel source ,it also have this problem.

    Best regards

    wangl

  • Wangl,

    For older Linux kernels (like version 3.2) check ../linux/kernel/sched.c file where can modify timeslice:
    #define DEF_TIMESLICE (100 * HZ / 1000)

    BR
    Tsvetolin Shulev