Date: Mon, 17 Mar 2014 17:59:47 GMT From: Vasily Postnicov <shamaz.mazum@gmail.com> To: freebsd-gnats-submit@FreeBSD.org Subject: misc/187668: Profiling timer does not work when setting low interval Message-ID: <201403171759.s2HHxlhK008917@cgiserv.freebsd.org> Resent-Message-ID: <201403171800.s2HI00Wv041526@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 187668 >Category: misc >Synopsis: Profiling timer does not work when setting low interval >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Mar 17 18:00:00 UTC 2014 >Closed-Date: >Last-Modified: >Originator: Vasily Postnicov >Release: Freebsd 10.0 >Organization: >Environment: FreeBSD vonbraun 10.0-RELEASE FreeBSD 10.0-RELEASE #1 513d8e6(clocktst): Sun Mar 16 23:02:04 MSK 2014 vasily@vonbraun:/usr/obj/usr/src/sys/MYKERNEL10 am d64 >Description: After this commit: https://github.com/freebsd/freebsd/commit/5dfd8a110a3e6121977586541b839200faef91da a statistical profiler in SBCL (Steel Bank Common Lisp) does not work when sampling interval is set very low. I attach a test which gives unexpected results which confuse SBCL when profiling interval is set to 0.1 ms (just as in sb-sprof test from SBCL): Start 1 0 100 -15 676200 And with that commit reverted it gives following: Start 14344 0 1000 0 1000 It means that lowest possible profiling interval is set (1 ms). All as expected. >How-To-Repeat: Just compile and run my test and wait 15 sec. >Fix: Patch attached with submission follows: #include <sys/time.h> #include <signal.h> #include <stdio.h> int counter = 0; void handler (int sig) { counter++; } int main () { printf ("Start\n"); struct sigaction sa; sa.sa_handler = handler; sa.sa_flags = 0; sigemptyset (&sa.sa_mask); sigaction (SIGPROF, &sa, NULL); struct itimerval val; struct itimerval val_old; val.it_interval.tv_sec = 0; val.it_interval.tv_usec = 100; val.it_value.tv_sec = 0; val.it_value.tv_usec = 100; struct timeval time; gettimeofday(&time, 0); time_t start = time.tv_sec; time_t cur = start; setitimer (2, &val, NULL); do { gettimeofday(&time, 0); cur = time.tv_sec; } while (cur < start+15); val.it_value.tv_sec = 0; val.it_value.tv_usec = 0; setitimer (2, &val, &val_old); printf ("%i\n", counter); printf ("%li %li %li %li\n", val_old.it_interval.tv_sec, val_old.it_interval.tv_usec, val_old.it_value.tv_sec, val_old.it_value.tv_usec); return 0; } >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201403171759.s2HHxlhK008917>