https://bugzilla.novell.com/show_bug.cgi?id=214840 Summary: Kernel latency seems to be much higher than 10.1 or other Linux releases Product: openSUSE 10.2 Version: Alpha 5 Platform: i586 OS/Version: SuSE Other Status: NEW Severity: Normal Priority: P5 - None Component: Kernel AssignedTo: kernel-maintainers@forge.provo.novell.com ReportedBy: jbeck@navcomtech.com QAContact: qa@suse.de Hi. I am trying out the 2.6.18 SUSE 10.2 alpha 5 (in order to get the 2.6.18 enhancement of priority inheritence mutexes) and I noticed that the context-switching latency for a real-time, FIFO, high-priority thread seems to be a lot higher than it used to be, at least when using a posix timer. Try this program out in both 10.1 and the 10.2 alpha 5 and you'll see what I mean. It basically starts a timer and checks the real-time clock. It differences the times in between timer timeouts and keeps running average and squared average. At the end it prints out the mean and standard deviation for the clock deltas. The standard veviation is orders of magnitude lower on the old release than in the alpha. Please feel free to call me or email me to discuss this (jbeck@navcomtech.com, or 310-381-2610). Thank you and good luck! #include <iostream> using namespace std; #include <math.h> #include <unistd.h> #include <signal.h> #include <time.h> #include <sched.h> #include <pthread.h> #include <semaphore.h> static unsigned long testLengthSeconds(30); static unsigned long samplePeriodMilliseconds(900); static unsigned long maxSamples(testLengthSeconds*1000/samplePeriodMilliseconds); timer_t theTimer; struct timespec lastTime; unsigned long numTimes(0); double sum0(0.0); double sum1(0.0); double sum2(0.0); double minDt(std::numeric_limits<double>::infinity()); double maxDt(-std::numeric_limits<double>::infinity()); double diffTime(struct timespec &t0, struct timespec &t1) { double td1 = t1.tv_sec + t1.tv_nsec/1e9; double td0 = t0.tv_sec + t0.tv_nsec/1e9; return td1 - td0; } void Tick( int signo, siginfo_t * sig_info, void * extra ) { struct timespec currentTime; clock_gettime(CLOCK_REALTIME,¤tTime); //cout << currentTime.tv_sec << ":" << currentTime.tv_nsec << endl; if ( numTimes > 0 ) { double dt(diffTime(lastTime,currentTime)); lastTime = currentTime; if ( numTimes > 1 ) // throw out the first measurement { if ( dt > maxDt ) maxDt = dt; if ( dt < minDt ) minDt = dt; sum0 += 1; sum1 += dt; sum2 += dt*dt; } } ++numTimes; if ( numTimes > maxSamples ) { // normalize sum1 /= sum0; sum2 /= sum0; cout << "That's it" << endl; cout << sum0 << " samples" << endl; cout << sum1 << " mean" << endl; cout << minDt << " min" << endl; cout << maxDt << " max" << endl; cout << sqrt(sum2-sum1*sum1) << " dev" << endl; timer_delete(theTimer); exit(0); } } int main(int argc, char *argv[]) { cout << "Length: " << testLengthSeconds << endl; cout << "Period ms: " << samplePeriodMilliseconds << endl; cout << "Max samples: " << maxSamples << endl; int policy = SCHED_FIFO; int priority = 50; sched_param sched; if ( sched_getparam(0,&sched) ) { perror( "sched_getparam" ); } else { sched.sched_priority = priority; if ( sched_setscheduler(0,policy,&sched) ) { perror( "sched_setscheduler" ); } } cout << "Setting up signal handler" << endl; // Set up and register a signal handler for MY_RT_SIGNAL struct sigaction action; if ( sigemptyset(&action.sa_mask) ) { cout << "error sigemptyset" << endl; return false; } action.sa_flags = SA_SIGINFO; action.sa_sigaction = Tick; if ( sigaction(SIGRTMIN, &action, NULL) ) { cout << "error sigaction" << endl; perror("hey"); return false; } // Set up and register the event handler struct sigevent event; event.sigev_signo = SIGRTMIN; event.sigev_notify = SIGEV_SIGNAL;//SIGEV_THREAD; event.sigev_value.sival_int = 0; //event.sigev_notify_function = TickedOff; //pthread_attr_t attr; //SetupHandlerAttributes(attr); //event.sigev_notify_attributes = &attr; // DONT FORGET TO DELETE ATTR or whatever that call is to free stuff up // Set up the timer rate struct itimerspec timer_spec; timer_spec.it_interval.tv_sec = 0; timer_spec.it_interval.tv_nsec = samplePeriodMilliseconds*1000*1000; timer_spec.it_value = timer_spec.it_interval; // Create the timer //cout << "going to create..." << endl; //sleep(5); cout << "Setting up timer" << endl; if ( timer_create(CLOCK_REALTIME, &event, &theTimer) ) { return false; //err_quit("timer_create"); } // Start the timer if ( timer_settime(theTimer, 0, &timer_spec, NULL) ) { return false; //err_quit("timer_settime"); } // Wait forever for something sem_t PSemaphore; sem_init(&PSemaphore,0,0); while ( 1 ) { if ( sem_wait(&PSemaphore) ) { // cout << "error" << endl; // perror("jhey"); } else { // cout << "worked" << endl; } } cout << "Done" << endl; return 0; } -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is.