On Thu, Sep 8, 2016 at 2:19 PM, Uwe Kleine-König <u.kleine-koenig@xxxxxxxxxxxxxx> wrote: > Hello, > > On Thu, Sep 08, 2016 at 09:49:14AM +0800, Hardik A Gohil (WMSC-HW) wrote: >> I am working on Linux 3.2.0. > > Wow, you're still developing on a kernel that is 4.5 years old and > you're not even taking the stable updates. since we did development with phyCORE-AM335x-PD13.1.2 which is using 3.2 kernel. we have already completed production and it wont be a easy task to shift to 4. series > >> We had a requirement to make Linux Real Time so using RT-PREEMPT >> (patch-3.2-rt10.patch.bz2) > > Even if you stick to 3.2.x, there is 3.2.82-rt118. > >> We are facing a network hang issue while running the periodic task of 5 ms. >> >> cannot ping any more when task is running is ran for some time. >> >> I am using Timer fd protocol to achieve this. >> >> I would like to know if there is such know issue in this patch. >> >> Any help will be appreciated. > > I bet you won't find help here until you reproduce the issue with a > recent kernel (currently there is v4.6.7-rt11) and show the code of your > periodic task. I am using iperf to transfer the data over network same problem of network hang happens cannot ping any more. Attached code for rt task > > Best regards > Uwe > > -- > Pengutronix e.K. | Uwe Kleine-König | > Industrial Linux Solutions | http://www.pengutronix.de/ | -- -- Regards, Hardik A Gohil WILLOWGLEN MSC BERHAD (462648-V) NO 17 JALAN 2/149B, TAMAN SRI ENDAH, BANDAR BARU SRI PETALING, 57000 KUALA LUMPUR, MALAYSIA TEL +603 90571228 FAX +603 90571218 WILLOWGLEN.COM.MY
#include <stdio.h> #include <stdlib.h> #include <time.h> #include <sched.h> #include <sys/mman.h> #include <string.h> #include <signal.h> #define MY_PRIORITY (99) struct periodic_info { int timer_fd; unsigned long long wakeups_missed; }; static int make_periodic (unsigned int period, struct periodic_info *info) { int ret; unsigned int ns; unsigned int sec; int fd; struct itimerspec itval; /* Create the timer */ fd = timerfd_create (CLOCK_MONOTONIC, 0); info->wakeups_missed = 0; info->timer_fd = fd; if (fd == -1) return fd; /* Make the timer periodic */ sec = period/1000000; ns = (period - (sec * 1000000)) * 1000; itval.it_interval.tv_sec = sec; itval.it_interval.tv_nsec = ns; itval.it_value.tv_sec = sec; itval.it_value.tv_nsec = ns; ret = timerfd_settime (fd, 0, &itval, NULL); return ret; } static void wait_period (struct periodic_info *info) { unsigned long long missed; int ret; /* Wait for the next timer event. If we have missed any the number is written to "missed" */ ret = read (info->timer_fd, &missed, sizeof (missed)); if (ret == -1) { perror ("read timer"); return; } /* "missed" should always be >= 1, but just to be sure, check it is not 0 anyway */ if (missed > 0) info->wakeups_missed += (missed - 1); } int main(void) { struct periodic_info info; struct sched_param param; struct timeval stop, start; param.sched_priority = MY_PRIORITY; if(sched_setscheduler(0, SCHED_FIFO, ¶m) == -1) { perror("sched_setscheduler failed"); exit(-1); } make_periodic(5000, &info); //1 sec while (1) { /* Do useful work */ printf("This is real time task"); gettimeofday(&start, NULL); wait_period (&info); gettimeofday(&stop, NULL); printf("took %lu\n", stop.tv_usec - start.tv_usec); } return 0; }