Date: Sat, 02 Sep 2006 08:20:45 +0200 From: Suleiman Souhlal <ssouhlal@FreeBSD.org> To: Maxim Sobolev <sobomax@sippysoft.com> Cc: hackers@freebsd.org, "current@freebsd.org" <current@freebsd.org> Subject: Re: Proper (no) accounting for the disabled HTT cores Message-ID: <44F922BD.5060108@FreeBSD.org> In-Reply-To: <44F8EC7F.5090605@sippysoft.com> References: <44F8EC7F.5090605@sippysoft.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Maxim Sobolev wrote: > 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)++; You probably also want this for amd64. Also, wouldn't it be better to completely disable the LAPIC timer on the hyperthreaded cpus? -- Suleiman
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?44F922BD.5060108>