From owner-freebsd-current@FreeBSD.ORG Wed Apr 28 12:41:30 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 4664316A4CE for ; Wed, 28 Apr 2004 12:41:30 -0700 (PDT) Received: from mail3.speakeasy.net (mail3.speakeasy.net [216.254.0.203]) by mx1.FreeBSD.org (Postfix) with ESMTP id 21B5943D46 for ; Wed, 28 Apr 2004 12:41:30 -0700 (PDT) (envelope-from jhb@FreeBSD.org) Received: (qmail 30892 invoked from network); 28 Apr 2004 19:41:29 -0000 Received: from dsl027-160-063.atl1.dsl.speakeasy.net (HELO server.baldwin.cx) ([216.27.160.63]) (envelope-sender ) encrypted SMTP for ; 28 Apr 2004 19:41:29 -0000 Received: from 10.50.40.205 (gw1.twc.weather.com [216.133.140.1]) by server.baldwin.cx (8.12.11/8.12.11) with ESMTP id i3SJfQfj016300; Wed, 28 Apr 2004 15:41:26 -0400 (EDT) (envelope-from jhb@FreeBSD.org) From: John Baldwin To: Julian Elischer Date: Wed, 28 Apr 2004 15:41:08 -0400 User-Agent: KMail/1.6 References: In-Reply-To: MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200404281541.08851.jhb@FreeBSD.org> X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on server.baldwin.cx cc: "freebsd-current@freebsd.org" cc: Alex Lyashkov Subject: Re: code cleanup 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, 28 Apr 2004 19:41:30 -0000 On Wednesday 28 April 2004 02:26 pm, Julian Elischer wrote: > On Wed, 28 Apr 2004, John Baldwin wrote: > > On Wednesday 28 April 2004 02:26 am, Alex Lyashkov wrote: > > > Hi All > > > > > > how i see many points at kernel work with allproc list direct, but > > > proc.h introduce macros FOREACH_PROC_IN_SYSTEM. > > > This patch clean this places. > > > > I'd actually rather see the FOREACH_PROC macro removed, I don't think > > hiding the fact that it's a TAILQ is all that useful. > > it makes it possible (well, easier) to do: > > FOREACH_PROC_IN_SYSTEM(p) { > FOREACH_KSEGROUP_IN_PROC(p, kg) { > FOREACH_THREAD_IN_GROUP(kg.td) { > something(td, kg); > } > } > } > > Which is a lot easier to read and understand > than the expanded version. You don't kave to remember the linkage > pointer's names and you can add debugging to it > and check that the correct loks are held etc. > (the latter being a major reason I did it). Note that the allproc_lock protects the allproc list. W/o the FOREACH_PROC macro, I can grep for 'allproc' in the source tree to find all users to verify locking, etc. With the extra macro, I now have to do multiple greps. When you multiple the effect with several wrapper macros, it now becomes much more work to work on locking the lists of structures since you have to do multiple greps to find the places to look at. I think remembering the linkages for lists is actually quite important to avoid using the same linkage for multiple lists incorrectly. -- John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve" = http://www.FreeBSD.org