From owner-freebsd-current@FreeBSD.ORG Wed Jan 14 11:09:56 2004 Return-Path: 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 5602116A4CE for ; Wed, 14 Jan 2004 11:09:56 -0800 (PST) Received: from fledge.watson.org (fledge.watson.org [204.156.12.50]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8646B43D66 for ; Wed, 14 Jan 2004 11:09:54 -0800 (PST) (envelope-from robert@fledge.watson.org) Received: from fledge.watson.org (localhost [127.0.0.1]) by fledge.watson.org (8.12.10/8.12.10) with ESMTP id i0EJ8CUd050627; Wed, 14 Jan 2004 14:08:12 -0500 (EST) (envelope-from robert@fledge.watson.org) Received: from localhost (robert@localhost)i0EJ8CZO050624; Wed, 14 Jan 2004 14:08:12 -0500 (EST) (envelope-from robert@fledge.watson.org) Date: Wed, 14 Jan 2004 14:08:11 -0500 (EST) From: Robert Watson X-Sender: robert@fledge.watson.org To: "Andrew Edwards (Olympic Shaver Centre)" In-Reply-To: <003c01c3da8f$c022a3e0$0b00a8c0@laptop> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: freebsd-current@freebsd.org Subject: Re: Hyperthreading with SMP in 5.2 X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 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: Wed, 14 Jan 2004 19:09:56 -0000 On Wed, 14 Jan 2004, Andrew Edwards (Olympic Shaver Centre) wrote: > Could anyone clarify the level of support for Pentium 4 hyperthreading > in 5.2? I understand that the kernel is now smp aware by default but > does it handle the logical cpu's of hyperthreading in the same manner as > it would a physical cpu? > > I ask as for the best part my machine rarely goes above 50% cpu > utilisation. However using -j2 when building the kernel or world for > example will give me nearer full use, which I can appreciate as it > generates concurrent processes that likely get divided over the two > logical cpu. > > Not being fully aware of the technical bits to hyperthreading is the > above scenario as good as it can be and is making good use of the cpu, > i.e if I run a single cpu heavy process, whereas without hyperthreading > I would see 100% usage now I only see around 50%. Part of the problem here is actually in the measurement -- when one hyperthreaded virtual CPU is idle, the other virtual CPU has more computational resources, and so will actually run faster. The FreeBSD kernel can only measure the utilization in terms of wall clock time, not underlying computational units, so it reports you have two CPU's, one idle, and one at 100% (i.e., 50%). In practice, you could easily be using 75% or more of the resources of the total silicon with your program. You might well not be able to utilize the full resources of the CPU without paralellism in your program, which would require writing the program to use parallelism (threading or multiple processes). Depending on the task, this may or may not be more efficient, since you may blow out shared cache resources with a larger working set, as well as paying the costs of synchronization. The real question is: do you get your work done faster from a wall clock perspective, and that depends on the workload and the efficiency of the FreeBSD kernel. We're working on making the FreeBSD kernel more efficient with SMP (one of the big goals for the 5.x branch), but it's definitely still a work in progress. If you just want to see 100%, you can disable hyperthreading so that the virtual CPU is simply kept idle the same as it might be now, but FreeBSD won't count it towards accounting. :-) Robert N M Watson FreeBSD Core Team, TrustedBSD Projects robert@fledge.watson.org Senior Research Scientist, McAfee Research