From owner-freebsd-stable@FreeBSD.ORG Wed Aug 8 19:59:37 2007 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 47F9516A417 for ; Wed, 8 Aug 2007 19:59:37 +0000 (UTC) (envelope-from dan@dan.emsphone.com) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by mx1.freebsd.org (Postfix) with ESMTP id 068D713C45E for ; Wed, 8 Aug 2007 19:59:36 +0000 (UTC) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.14.1/8.14.1) id l78FaTau021959 for freebsd-stable@freebsd.org; Wed, 8 Aug 2007 10:36:29 -0500 (CDT) (envelope-from dan) Date: Wed, 8 Aug 2007 10:36:29 -0500 From: Dan Nelson To: freebsd-stable@freebsd.org Message-ID: <20070808153628.GL77822@dan.emsphone.com> References: <200708081335.l78DZxN7045656@lurza.secnetix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200708081335.l78DZxN7045656@lurza.secnetix.de> X-OS: FreeBSD 7.0-CURRENT User-Agent: Mutt/1.5.16 (2007-06-09) Subject: Re: moused(8) consuming cpu for nothing 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: Wed, 08 Aug 2007 19:59:37 -0000 In the last episode (Aug 08), Oliver Fromme said: > I noticed that the moused(8) process had accumulated about one minute > of CPU time, after only three days of uptime. That's really a lot, > given the fact that this server doesn't have a mouse connected at > all. :-) Well, it is connected to a KVM switch, but it was never > used since the last reboot. Accoding to "vmstat -i" psm0 received > zero interrupts. So I really wonder why it has consumed that much > CPU time. > > So I tried to strace the process, and got an endless series > of these: > > 15:22:31.122276 gettimeofday({...}, NULL) = 0 > 15:22:31.122388 select(1024, [?], NULL, NULL, {...}) = 0 (Timeout) > 15:22:31.143275 gettimeofday({...}, NULL) = 0 > 15:22:31.143386 select(1024, [?], NULL, NULL, {...}) = 0 (Timeout) > 15:22:31.164276 gettimeofday({...}, NULL) = 0 > 15:22:31.164388 select(1024, [?], NULL, NULL, {...}) = 0 (Timeout) > 15:22:31.185276 gettimeofday({...}, NULL) = 0 > 15:22:31.185387 select(1024, [?], NULL, NULL, {...}) = 0 (Timeout) > .. and so on. > > So it seems to call select(2) with a 0.02s timeout and > then gettimeofday(2) within a loop. 50 times per second. > Without doing anything useful (remember there's no mouse > device connected and zero interrupts occuring). Moused only selects with a timeout when you have 3-button emulation enabled, so try disabling that. One possible optimization to moused would be to only use the timeout if the current button state requires one (i.e. only if button1 or button3 is pressed, or the virtual button3 is pressed). BTW - running with /usr/bin/truss instead of strace would have let you see the timeout directly without having to subtract timestamps: select(1024,{3},0x0,0x0,{0.020000}) = 0 (0x0) gettimeofday({1186587244.432606},0x0) = 0 (0x0) select(1024,{3},0x0,0x0,{0.020000}) = 0 (0x0) gettimeofday({1186587244.457868},0x0) = 0 (0x0) -- Dan Nelson dnelson@allantgroup.com