Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp697618pxp; Fri, 11 Mar 2022 12:40:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJydW16vLImYMqIOl6XWhcdNvrhekZWAMxdxfj4Y/CZdHF0drKrlLsk5/T7QpaPNM4yt536c X-Received: by 2002:a17:902:a40f:b0:14b:61:b19e with SMTP id p15-20020a170902a40f00b0014b0061b19emr12098958plq.20.1647031252049; Fri, 11 Mar 2022 12:40:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1647031252; cv=none; d=google.com; s=arc-20160816; b=kKI4bPL0Qs4EmK9f64KqxFHIzdbEFVOXacQd3RLj3fDI2LtlCGnnGONk760iSEcogi EWBYrS5MUkkG7YmHJIIgAmt28aJ/XdL7cKkUTmHkvEeNumTSNYKaCOAYkLl+68hQVsXT tAktbmhz+bz2QhEpgCZVIrxUnDbXEa5miq2firD2L4M3aEvwbr/yFMP1wZPZJ8ukp11t Sj+/KyMd0d0hWiwm1uk9eJTTtxmhher28AY3cFW0h0VPHQ9gfr3L7t+oja0bS9zbzPnw a7W8P89M59rxs9d964KHi9PFU+3bxPi49INJD41ipx9f+vOEnsK/Vs1axdnV+8qq2Le1 hqQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:reply-to:cc:from:to :dkim-signature:date; bh=75n7D8GkYY40Smy0jggoA4SN2YbNoOfxMs7WJaVH1BQ=; b=F0rQ1/gtbzdejFY20S4OJNTkHLhOE1Hz/1oGhc6UGh0sKd15Sc3BLcs0Q+tSfCtGzp 9q1NwCepf6n35kmSOayoH413vzgbdWEuUlGQmePB+ySj2LcKfjre3iHpzyoqlZwUa7Lr roq77+OYFYANwyMxX26r6PIC9wCjjGzHkyG7FF8tt4OJRhqkHTFVj3p94fmP38cSk120 01AsfkZa5PinzfwsoEsi7QNSdTVH4NzokW7zQ2joSD+VRCuUDZxJ6NbZpxLbGIsAaTy6 w1YLIcKFyz4kAXdENcmAUnR7rTHcgJ85nwvmN7E2dM3bwWbyl2JxsEw3YtqHPpYyIjtI cb2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@protonmail.com header.s=protonmail3 header.b=smcqxfpP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=protonmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id z88-20020a17090a6d6100b001bd14e01fb2si8755717pjj.160.2022.03.11.12.40.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Mar 2022 12:40:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@protonmail.com header.s=protonmail3 header.b=smcqxfpP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=protonmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 827DD1D4515; Fri, 11 Mar 2022 12:38:01 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345743AbiCKCqS (ORCPT + 99 others); Thu, 10 Mar 2022 21:46:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345695AbiCKCqR (ORCPT ); Thu, 10 Mar 2022 21:46:17 -0500 Received: from mail-4322.protonmail.ch (mail-4322.protonmail.ch [185.70.43.22]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 835821A616E for ; Thu, 10 Mar 2022 18:45:15 -0800 (PST) Date: Fri, 11 Mar 2022 02:45:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1646966713; bh=75n7D8GkYY40Smy0jggoA4SN2YbNoOfxMs7WJaVH1BQ=; h=Date:To:From:Cc:Reply-To:Subject:Message-ID:In-Reply-To: References:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID; b=smcqxfpP0eydrrymPUTUQKgUeY4UV3ULEfkQvq3VNj3sGW8i0CVEovFvDjUHAu+aD Bh2zEDb8F2EBGyMXGPEd2DHSWG2tzLj3w5w08uHBCzNZBR1dAibNILjDcqUILci+Qe GNDYMx2iem/kBGXyRuFAHhw8nYt1I/N3q8rtuJ3jW6KEyphkntPgt7GbV8tTM2/ZwQ iEHBdEoXhKPe1qthkJMnp4hcq0GgQ3VlLGbSo1CD+biVwOlF/K2/Yd7MC90+/RMClZ bfIq5TtmlZqiBx61UileYOxq0xQ3fAAmjEjR2+GI/+LiKvq75HzYGuwpE4S59Fl5EH gdMCSzBzuRc/Q== To: Linus Torvalds From: =?utf-8?Q?Barnab=C3=A1s_P=C5=91cze?= Cc: Linux Kernel Mailing List , Greg Kroah-Hartman , Andrew Morton , Xiaomeng Tong , Kees Cook , Jakob Koschel , Arnd Bergmann Reply-To: =?utf-8?Q?Barnab=C3=A1s_P=C5=91cze?= Subject: Re: [RFC PATCH v1 1/2] list: add type-safer list_head wrapper Message-ID: In-Reply-To: References: <20220311013238.3387227-1-pobrn@protonmail.com> <20220311013238.3387227-2-pobrn@protonmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi 2022. m=C3=A1rcius 11., p=C3=A9ntek 2:42 keltez=C3=A9ssel, Linus Torvalds = =C3=ADrta: > On Thu, Mar 10, 2022 at 5:33 PM Barnab=C3=A1s P=C5=91cze wrote: > > > > The underlying idea is to define each list head using an anonymous stru= ct: > > Why struct? Union is much better, and doesn't pointlessly waste memory > for members that are only used for their type. As far as I can tell, zero-sized arrays won't take up any space. It's true that if the type has excessive alignment requirements, then it may indeed waste space. Changing it to a pointer+union is a simple change, nonetheless= . > > Anyway, as far as I can tell, your model is unworkable as-is, since it > only works for a list that is external to the types in question. > > Which is not even remotely the interesting case. All serious list uses > are inside other types, and refer to each other. > > So this seems to be fundamentally broken, in that it only works for > trivial things, and is not even as good as > > https://lore.kernel.org/all/CAHk-=3DwiacQM76xec=3DHr7cLchVZ8Mo9VDHmXRJ= zJ_EX4sOsApEA@mail.gmail.com/ > > that actually converted a real case. > > That one didn't do the automatic offset thing, but see > > https://lore.kernel.org/all/CAADWXX-Pr-D3wSr5wsqTEOBSJzB9k7bSH+7hnCAj0= AeL0=3DU4mg@mail.gmail.com/ > > on the problems that has. > > Again, you avoided those problems by making the use-case a narrow and > uninteresting one. Yes, I have mentioned at the end that there are limitations of this approac= h (to keep it easy to use and sane) and that it won't work everywhere, namely where the value type is incomplete. E.g. * you cannot have a list of T inside a T; * you cannot have a list of B inside A plus a list of A inside B. Nonetheless, I still think there are legitimate use cases for this, where the simple, limited interface works fine. And I am by no means suggesting not going forward with the other ideas that came up. I mostly imagined this tlist as an "addition" for the simple, trivial cases. For example, there are currently more than 1000 occurrences of static LIST_HEAD( in the source tree. I did not check, but I think it's very likely that most= of them would satisfy the constraints of the proposed interface. And while I c= annot provide any numbers, I would not be surprised if most list uses in the kern= el were "boring" and "trivial", where this interface would work. But I understand if you don't want something that doesn't work for every ca= se. Best regards, Barnab=C3=A1s P=C5=91cze