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.

On AM3517 when receiving information from the CAN interface to generate a lot of Linux software interrupts

Other Parts Discussed in Thread: AM3517

Hello,

On AM3517 when receiving information from the CAN interface (transfer rate of 1 Mbit/s CAN bus load of about 80%) in the Linux operating system it is generated a lot of software interrupts (about 45% CPU load). Is it possible to reduce the number of software interrupts on the receiving?

  • Mem: 32336K used, 204116K free, 0K shrd, 1568K buff, 6260K cached
    CPU: 0% usr 21% sys 0% nic 35% idle 0% io 0% irq 42% sirq
    Load average: 0.03 0.04 0.05 1/58 1009
      PID    PPID        USER     STAT     VSZ     %MEM     %CPU     COMMAND
    1008     951        root         R      1472         1%        44%     ./a.out
      622         2        root       SW           0          0%          6%    [kworker/0:2]
      644         2        root       SW           0          0%          1%    [ksdioirqd/mmc1]
    1009     951        root         R      2844          1%          1%    top
        45         2        root       SW           0          0%          0%    [irq/74-serial i]
       951    949        root         S      2844          1%          0%    -sh
       924        1        root         S      2732          1%          0%    /sbin/syslogd -n -C64 -m 20
       926        1        root         S      2668          1%          0%    /sbin/klogd -n
       917        1        root         S      2668          1%          0%    /usr/sbin/telnetd
       912        1   messageb    S       2436          1%          0%    /usr/bin/dbus-daemon --system
       949        1        root         S      2400          1%          0%    login -- root
       692        1        root         S <   2188          1%          0%    /sbin/udevd -d
       726    692        root         S <   2184          1%          0%    /sbin/udevd -d
       727    692        root         S <   2184          1%          0%    /sbin/udevd -d
       933        1        root         S      2064           1%          0%    /usr/sbin/thttpd -d /srv/www -p 8080 -
           1        0        root         S      1628           1%          0%    init [5]
       588        2        root      SW            0           0%          0%    [w1_bus_master1]
           5        2        root      SW            0           0%          0%    [kworker/u:0]
       633        2        root      SW            0           0%          0%    [mmcqd/0]
           3        2        root      SW            0           0%          0%    [ksoftirqd/0]

  • root@am3517-evm:~# cat /proc/interrupts ; ifconfig
               CPU0
    11:               0 INTC prcm
    12:         1873 INTC DMA
    20:               0 INTC gpmc
    24: 12114477 INTC can0
    25:               2 INTC OMAP DSS
    37:     454780 INTC gp timer
    56:   1874385 INTC omap_i2c
    57:               0 INTC omap_i2c
    58:       84972 INTC omap_hdq
    61:               0 INTC omap_i2c
    71:               1 INTC musb-hdrc.0
    72:               0 INTC serial idle
    73:               0 INTC serial idle
    74:       22509 INTC serial idle, OMAP UART2
    77:               0 INTC ehci_hcd:usb2
    83:         2765 INTC mmc0
    86:     286560 INTC mmc1
    160:             0 GPIO tps6507x
    162:             1 GPIO mmc1
    184:             0 GPIO ds1374
    186:             0 GPIO tca8418-keypad
    224:             0 GPIO mmc0
    Err:              0

    can0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
    UP RUNNING NOARP MTU:16 Metric:1
    RX packets:12732263 errors:0 dropped:0 overruns:0 frame:0
    TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:10
    RX bytes:88788609 (84.6 MiB) TX bytes:0 (0.0 B)
    Interrupt:24

  • 1 #include <stdio.h>
    2 #include <sys/types.h>
    3 #include <sys/socket.h>
    4 #include <sys/ioctl.h>
    5 #include <net/if.h>
    6
    7 #include <linux/can.h>
    8 #include <linux/can/raw.h>
    9 #include <string.h>
    10
    11 /* At time of writing, these constants are not defined in the headers */
    12 #ifndef PF_CAN
    13 #define PF_CAN 29
    14 #endif
    15
    16 #ifndef AF_CAN
    17 #define AF_CAN PF_CAN
    18 #endif
    19
    20 int main(int argc, char *argv[])
    21 {
    22     /* create a frame */
    23     struct can_frame frame;
    24     /* interface */
    25     struct ifreq ifr;
    26     /* number of te */
    27     int bytes_read;
    28     /* create the socket */
    29     int skt = socket( PF_CAN, SOCK_RAW, CAN_RAW );
    30     /* socket address */
    31     struct sockaddr_can addr;
    32     /* counter SFF */
    33     unsigned long countSFF;
    34     /* counter EFF*/
    35     unsigned long countEFF;
    36
    37     countSFF = 0;
    38     countEFF = 0;
    39     /* locate the interface you wish to use */
    40     strcpy( ifr.ifr_name, "can0" );
    41     ioctl( skt, SIOCGIFINDEX, &ifr ); /* ifr.ifr_ifindex gets filled with that device's index */
    42     /* select that CAN interface, and bind the socket to it. */
    43     addr.can_family = AF_CAN;
    44     addr.can_ifindex = ifr.ifr_ifindex;
    45     bind( skt, ( struct sockaddr * ) &addr, sizeof( addr ) );
    46     while(1)
    47     {
    48         bytes_read = read( skt, &frame, sizeof( frame ) );
    49         if( bytes_read < 0 )
    50         {
    51             printf( "CAN\n" );
    52         }
    53         else if ( bytes_read > 0 )
    54         {
    55             if( !( frame.can_id & 0x80000000U ) )
    56             {
    57                 countSFF++;
    58             }
    59             else
    60             {
    61                 countEFF++;
    62             }
    63         }
    64     }
    65
    66     return 0;
    67 }

  • Thanks for a prompt reply. I found in what a problem.