From owner-freebsd-hackers@FreeBSD.ORG Fri Mar 9 09:38:33 2012 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id BDB5F106564A; Fri, 9 Mar 2012 09:38:33 +0000 (UTC) (envelope-from mavbsd@gmail.com) Received: from mail-bk0-f54.google.com (mail-bk0-f54.google.com [209.85.214.54]) by mx1.freebsd.org (Postfix) with ESMTP id 1648E8FC14; Fri, 9 Mar 2012 09:38:32 +0000 (UTC) Received: by bkcjc3 with SMTP id jc3so1350522bkc.13 for ; Fri, 09 Mar 2012 01:38:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :content-type:content-transfer-encoding; bh=CjTpOWsE9xLaMWYRZOgRbYdPnsH5/9tLw4FI3mwUaxU=; b=fmujHUhqr4WJGhsAQXgprYT//sOoH9tgVzjuVbX9Do6EQC1MCjBPJoewsBRxbvGQ4a D2Sfb8pImEBsqoCzTsOFILHNVIix/F1GxV11LKuuwteJMY6d6yLjVij7K+LAirFkPTC2 5TfOtr18oLxzp93+DTzfGY9NPZy/XEnhBhanbrWRo+mDZT5PgdcMJ8IpsXblgHsOQVB1 cwtaUf9gUwWORJlCkO7VvwdbzyUuuyCFMamZ7PPHfw25jeXcgLHxXLq+HRvVXlt68aiR ymzZhOW6OjJHT9Z50xA99HOpAzzVz8RS3+yR6+FffGGJrDBKPkH6NWd1a6ogs8bfKpSV TOJw== Received: by 10.204.150.78 with SMTP id x14mr581084bkv.114.1331285911842; Fri, 09 Mar 2012 01:38:31 -0800 (PST) Received: from mavbook2.mavhome.dp.ua (pc.mavhome.dp.ua. [212.86.226.226]) by mx.google.com with ESMTPS id t17sm8085000bke.6.2012.03.09.01.38.30 (version=SSLv3 cipher=OTHER); Fri, 09 Mar 2012 01:38:30 -0800 (PST) Sender: Alexander Motin Message-ID: <4F59CF94.7070506@FreeBSD.org> Date: Fri, 09 Mar 2012 11:38:28 +0200 From: Alexander Motin User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:10.0.2) Gecko/20120226 Thunderbird/10.0.2 MIME-Version: 1.0 To: freebsd-hackers@freebsd.org Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: jeff@freebsd.org Subject: [RFC] Thread CPU load estimation for ULE, not sampled by hardclock() X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Mar 2012 09:38:33 -0000 Hi. At this time ULE scheduler uses hardclock() ticks via sched_tick() to estimate threads CPU load. That strictly limits it's best possible precision and that is one more reason to call hardclock() on every HZ tick, even when there is no callouts scheduled. I've made a patch to get CPU load estimation in ULE in event-based way. It won't immediately increase precision as I still use ticks counter as time source, but it should be trivial to use more precise one later (if some global, fast and reliable one is available). What it gives now, is that sched_tick() function is now empty for ULE, same as it always was for 4BSD. With some more changes in other areas it should allow to run hardclock() with full HZ rate only on one non-idle CPU, not on each one as it is now. One more small step toward tick-less kernel. Patch can be found here: http://people.freebsd.org/~mav/sched.notick4.patch Any comments? Important theoretical question: what exactly we want to see as CPU load? ps(1) defines %cpu as: "decaying average over up to a minute of previous (real) time", but I think that definition is not exactly true now. As I understand, 4BSD calculates pure decaying average without time limit -- if not precision limitation, CPU load value would include data for all the thread life time with exponentially decreasing weight for old values. ULE behaves partially alike, but has strict idle deadline after which load considered equal to zero and in some cases it decays more linearly, that seems also depends on if/how often CPU load is read. So which way should be considered right? Should it be clear decaying average as 4BSD does, or should it be something closer to "average load for last N seconds", following ideas I see in ULE now? -- Alexander Motin