From owner-freebsd-current@FreeBSD.ORG Sat Sep 2 02:29:32 2006 Return-Path: X-Original-To: current@freebsd.org Delivered-To: freebsd-current@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5991616A4DE; Sat, 2 Sep 2006 02:29:32 +0000 (UTC) (envelope-from sobomax@sippysoft.com) Received: from sippysoft.com (gk.360sip.com [72.236.70.226]) by mx1.FreeBSD.org (Postfix) with ESMTP id D27F743D49; Sat, 2 Sep 2006 02:29:31 +0000 (GMT) (envelope-from sobomax@sippysoft.com) Received: from [192.168.0.49] ([204.244.149.125]) (authenticated bits=0) by sippysoft.com (8.13.6/8.13.6) with ESMTP id k822TSbx004957 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 1 Sep 2006 19:29:30 -0700 (PDT) (envelope-from sobomax@sippysoft.com) Message-ID: <44F8EC7F.5090605@sippysoft.com> Date: Fri, 01 Sep 2006 19:29:19 -0700 From: Maxim Sobolev Organization: Sippy Software User-Agent: Thunderbird 1.5.0.5 (Windows/20060719) MIME-Version: 1.0 To: hackers@freebsd.org Content-Type: text/plain; charset=KOI8-U; format=flowed Content-Transfer-Encoding: 7bit X-Mailman-Approved-At: Sat, 02 Sep 2006 03:46:25 +0000 Cc: "current@freebsd.org" Subject: Proper (no) accounting for the disabled HTT cores X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Sep 2006 02:29:32 -0000 Hi, Currently, FreeBSD by default disables hyper-threading "cores", by not scheduling any threads to it. However, it still counts those cores as "active but permanently idle" when calculating system-wide CPUs statistics. It is incorrect, since it skews statistics quite a bit and creates real problems for certain types of applications (monitoring applications for example), by making them believe that the system does have enough idle resources, while in fact it does not. I think the proper way to handle disabled cores is to not account for them in any way. Please find the patch attached, which fixes the problem. Any comments or suggestions are welcome. -Maxim Index: local_apic.c =================================================================== RCS file: /home/ncvs/src/sys/i386/i386/local_apic.c,v retrieving revision 1.28 diff -d -u -r1.28 local_apic.c --- local_apic.c 12 Jul 2006 21:22:43 -0000 1.28 +++ local_apic.c 2 Sep 2006 00:42:32 -0000 @@ -615,6 +615,16 @@ /* Send EOI first thing. */ lapic_eoi(); + /* + * Don't do any accounting for the disabled HTT cores, since it + * will provide misleading numbers for the userland. + * + * No locking is necessary here, since even if we loose the race + * when hlt_cpus_mask changes it is not a big deal, really. + */ + if ((hlt_cpus_mask & (1 << PCPU_GET(cpuid))) != 0) + return; + /* Look up our local APIC structure for the tick counters. */ la = &lapics[PCPU_GET(apic_id)]; (*la->la_timer_count)++;