From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from minnie.tuhs.org (minnie.tuhs.org [45.79.103.53]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 7542bf21 for ; Mon, 13 Jan 2020 00:51:36 +0000 (UTC) Received: by minnie.tuhs.org (Postfix, from userid 112) id 979AF9BDC5; Mon, 13 Jan 2020 10:51:35 +1000 (AEST) Received: from minnie.tuhs.org (localhost [127.0.0.1]) by minnie.tuhs.org (Postfix) with ESMTP id CCD499BD1C; Mon, 13 Jan 2020 10:51:26 +1000 (AEST) Received: by minnie.tuhs.org (Postfix, from userid 112) id 4AAB89BD1C; Mon, 13 Jan 2020 10:51:25 +1000 (AEST) X-Greylist: delayed 404 seconds by postgrey-1.36 at minnie.tuhs.org; Mon, 13 Jan 2020 10:51:24 AEST Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11]) by minnie.tuhs.org (Postfix) with ESMTPS id 67A2A9BD0F for ; Mon, 13 Jan 2020 10:51:24 +1000 (AEST) Received: from callcc.thunk.org (pool-72-93-95-157.bstnma.fios.verizon.net [72.93.95.157]) (authenticated bits=0) (User authenticated as tytso@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 00D0iX3P000558 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 12 Jan 2020 19:44:34 -0500 Received: by callcc.thunk.org (Postfix, from userid 15806) id 4A1D84207DF; Sun, 12 Jan 2020 19:44:33 -0500 (EST) Date: Sun, 12 Jan 2020 19:44:33 -0500 From: "Theodore Y. Ts'o" To: Jon Steinhart Message-ID: <20200113004433.GA440748@mit.edu> References: <202001122225.00CMPc9S085970@tahoe.cs.Dartmouth.EDU> <202001122340.00CNeef0604557@darkstar.fourwinds.com> <20200112235051.GG9174@mcvoy.com> <202001130001.00D012bC608441@darkstar.fourwinds.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202001130001.00D012bC608441@darkstar.fourwinds.com> Subject: Re: [TUHS] Tech Sq elevator [ really type-checking ] X-BeenThere: tuhs@minnie.tuhs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: The Unix Heritage Society mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: The Eunuchs Hysterical Society Errors-To: tuhs-bounces@minnie.tuhs.org Sender: "TUHS" (Not sure this is appropriate for TUHS) On Sun, Jan 12, 2020 at 04:01:02PM -0800, Jon Steinhart wrote: > Larry McVoy writes: > > On Sun, Jan 12, 2020 at 03:40:40PM -0800, Jon Steinhart wrote: > > > Linux contains several sets of list_for_each_entry() macros that are essentially > > > obfuscated for loops that generate inefficient code. > > > > Very common idiom in any real system. BitKeeper has them as well, they are > > used everywhere. They are too useful to not use. The BitKeeper ones give > > you most of Perl's list capabilities. > > I don't see it. In the cases that I've seen so far in linux the only uses are > inserting, deleting, and traversing lists. My opinion that anyone who can't > write > for (p = list; p != NULL; p = p->next) There are many places where there is a desire to (a) add an object to the end of the list (b) remove an object from a linked list where the object was not found via iterating over the linked list One or the other was true for all of the linked lists that you complained about earlier up-thread. For example, a struct super has a doubly linked list of struct mount where we might want to drop a struct mount without needing iterate over the whole linked list. So "just use an open-coded singly linked list" is really not that simple. In addition, it should be noted that there are read-copy-update variants of these functions (e.g., list_for_each_entry_rcu, list_del_rcu) that can be used with the same struct list_head structure. Sure, it would be simpler to just take a global kernel lock, and iterating over the entire singly linked list to remove an object from it, or adding an object to the end of a list. That would be *simpler*. But that would be much more, not less, inefficient. Cheers, - Ted