From owner-freebsd-bugs@FreeBSD.ORG Mon Mar 17 18:00:00 2014 Return-Path: Delivered-To: freebsd-bugs@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 90580ED2 for ; Mon, 17 Mar 2014 18:00:00 +0000 (UTC) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 6D1F636F for ; Mon, 17 Mar 2014 18:00:00 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.8/8.14.8) with ESMTP id s2HI00OP041527 for ; Mon, 17 Mar 2014 18:00:00 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.8/8.14.8/Submit) id s2HI00Wv041526; Mon, 17 Mar 2014 18:00:00 GMT (envelope-from gnats) Resent-Date: Mon, 17 Mar 2014 18:00:00 GMT Resent-Message-Id: <201403171800.s2HI00Wv041526@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Vasily Postnicov Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 98ED6EBF for ; Mon, 17 Mar 2014 17:59:47 +0000 (UTC) Received: from cgiserv.freebsd.org (cgiserv.freebsd.org [IPv6:2001:1900:2254:206a::50:4]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 6D411365 for ; Mon, 17 Mar 2014 17:59:47 +0000 (UTC) Received: from cgiserv.freebsd.org ([127.0.1.6]) by cgiserv.freebsd.org (8.14.8/8.14.8) with ESMTP id s2HHxl9n008918 for ; Mon, 17 Mar 2014 17:59:47 GMT (envelope-from nobody@cgiserv.freebsd.org) Received: (from nobody@localhost) by cgiserv.freebsd.org (8.14.8/8.14.8/Submit) id s2HHxlhK008917; Mon, 17 Mar 2014 17:59:47 GMT (envelope-from nobody) Message-Id: <201403171759.s2HHxlhK008917@cgiserv.freebsd.org> Date: Mon, 17 Mar 2014 17:59:47 GMT From: Vasily Postnicov To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Subject: misc/187668: Profiling timer does not work when setting low interval X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 Mar 2014 18:00:00 -0000 >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 #include #include 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: