From owner-freebsd-arch@FreeBSD.ORG Tue May 29 22:28:13 2007 Return-Path: X-Original-To: arch@freebsd.org Delivered-To: freebsd-arch@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id C741816A421 for ; Tue, 29 May 2007 22:28:13 +0000 (UTC) (envelope-from jroberson@chesapeake.net) Received: from webaccess-cl.virtdom.com (webaccess-cl.virtdom.com [216.240.101.25]) by mx1.freebsd.org (Postfix) with ESMTP id 912C013C480 for ; Tue, 29 May 2007 22:28:13 +0000 (UTC) (envelope-from jroberson@chesapeake.net) Received: from [192.168.1.101] (c-71-231-138-78.hsd1.or.comcast.net [71.231.138.78]) (authenticated bits=0) by webaccess-cl.virtdom.com (8.13.6/8.13.6) with ESMTP id l4TMSBhi026110 (version=TLSv1/SSLv3 cipher=DHE-DSS-AES256-SHA bits=256 verify=NO) for ; Tue, 29 May 2007 18:28:12 -0400 (EDT) (envelope-from jroberson@chesapeake.net) Date: Tue, 29 May 2007 15:28:07 -0700 (PDT) From: Jeff Roberson X-X-Sender: jroberson@10.0.0.1 To: arch@freebsd.org Message-ID: <20070529152059.Y661@10.0.0.1> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: Subject: initial rusage patch. X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 May 2007 22:28:13 -0000 http://people.freebsd.org/~jeff/rusage3.diff I'm providing this patch for discussion only. I've just implemented enough that you can see the fallout from this change. I have not yet tested enough to say that this is perfect. I have also not yet fixed the RLIMIT_CPU check in mi_switch(). You can see, however, that with this change there is no access to struct proc in mi_switch() except for INVARIANTS and KTR. Aside, of course, for the rlimit that needs to move anyway. You can also see, that most access to rusage are done through fewer indirects and to local memory. The storage impact of struct proc doesn't change as pstat can be reclaimed as it could before. Furthermore, the only time we need locks is in rufetch() where we aggregate the threads counters and rusage structs into one allocated by the caller. Doing this aggregation less frequently means we're touching struct proc less frequently. In this patch the scheduler lock protects this aggregation. In my threadlock diff this will be protected by the per process spinlock and the thread lock. However, in most places that we aggregate with calcru() we're grabbing a spinlock anyway. So it is not so expensive to grab another. Thanks, Jeff