From owner-freebsd-stable@FreeBSD.ORG Fri Jul 21 14:24:23 2006 Return-Path: X-Original-To: freebsd-stable@freebsd.org Delivered-To: freebsd-stable@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C848916A4E8; Fri, 21 Jul 2006 14:24:23 +0000 (UTC) (envelope-from GMcCaughan@synaptics-uk.com) Received: from mx2.synaptics-uk.com (mx2.synaptics-uk.com [194.203.111.209]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3945143D55; Fri, 21 Jul 2006 14:24:16 +0000 (GMT) (envelope-from GMcCaughan@synaptics-uk.com) Received: from firewall.synaptics-uk.com ([194.203.111.212] helo=ukexchange2k.synaptics-inc.local) by mx2.synaptics-uk.com with esmtp (Exim 4.62) (envelope-from ) id 1G3vvL-0007Cn-Ps; Fri, 21 Jul 2006 15:24:15 +0100 Received: from lists.synaptics-uk.com ([172.20.11.6]) by ukexchange2k.synaptics-inc.local with Microsoft SMTPSVC(5.0.2195.6713); Fri, 21 Jul 2006 15:24:10 +0100 Received: from [172.20.11.5] (unknown [172.20.11.5]) by lists.synaptics-uk.com (Postfix) with ESMTP id 92C4417011; Fri, 21 Jul 2006 15:04:35 +0100 (BST) From: Gareth McCaughan To: freebsd-questions@freebsd.org, freebsd-stable@freebsd.org Date: Fri, 21 Jul 2006 15:24:09 +0100 User-Agent: KMail/1.9.1 References: <200607132002.43637.gmccaughan@synaptics-uk.com> In-Reply-To: <200607132002.43637.gmccaughan@synaptics-uk.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200607211524.10033.gmccaughan@synaptics-uk.com> X-OriginalArrivalTime: 21 Jul 2006 14:24:10.0698 (UTC) FILETIME=[555DA2A0:01C6ACD1] Cc: Subject: Re: "swiN: clock sio" process taking 75% CPU X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Jul 2006 14:24:24 -0000 I wrote: > About 6 minutes after booting (on two occasions; I don't > guarantee that this doesn't vary), a process that appears > in the output of "ps" as "[swi4: clock sio]" begins to > use about 3/4 of the machine's CPU. I think it does so > more or less instantaneously. It continues to do so > indefinitely, so far as I can tell. So, here's the answer. Whether it's the same thing that's afflicted the other people who've reported similar problems, I don't know. (Thanks to John Baldwin on -hackers for pointing me in a useful direction.) Executive summary: If you see symptoms like the one above, are you running a syscons screen saver? (To check: run "kldstat | grep _saver".) If so, turn it off and the problem may go away. 1. The machine in question runs largely unattended. 2. I'd enabled the syscons screen saver and chosen one of the ones that puts the screen into a graphics mode. ("warp", as it happens; "fire" behaves similarly; the character-mode ones don't; I haven't looked at all of them.) 3. The screen saver kicks in 5 minutes after it gets turned on in /etc/rc.d/syscons, provided nothing's happening on the console. Which it isn't: see #1. 4. Now, how do those graphics-mode screen savers work? They write to the video card's frame buffer directly, but there's only a 64k block of RAM they can do this through. So, to cope with larger screens, there's a bank switching facility accessed by a BIOS call. 5. This BIOS call, on my machine, takes about 0.1ms; you need to do two of them for a bank switch, so the time actually taken is about 0.2ms. 6. The screen savers are written in a less than optimal way, and do that bank switching thing many times. For instance, the "fire" screen saver does it at least once for every screen line. Even when the entire screen actually fits into a single bank so that no switching at all should be needed. 7. So the screensaver eats up something on the order of half my CPU time; the exact figure depends on which screensaver and on more exact timings than I've given above, which is how it ends up actually being 75% for the "warp" screensaver. 8. The screensaver gets run in callouts from a kernel interrupt thread that happens to have a silly name like "swi4: clock sio". This is eminently fixable, in several different ways. I've offered to prepare a patch, or perhaps someone else will do so, so there's a reasonable prospect of later versions of FreeBSD not having this problem. For the time being, there's a simple workaround for anyone facing the same problem I did: *turn off the screensaver*, or replace it with one that doesn't use a graphics mode. For clarity: this is a problem with (some) FreeBSD syscons screen savers, the ones you might enable in /etc/rc.conf; not with the ones like xscreensaver that you might run in user mode under X. -- g