From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796291736; b=1clyXIHdVjkqTXlHjEBfMToAO69nZPrCAsirK4W4fvEQfwr1Gx0fc0f3rzwqv5soIBAx 2yKNEyV/I+NqbkaiZGWiPuA79XGNYRhMpOD3UYNlhX5Cp7gpLauY81L6MpI4/4qWPL0qF 5SJ9XpBg3rueIH/l+bLEEJFxYrQvCdDLroUr6IQfvLKs+WY4+8LzGqCliZadYU2H+tUpk S7Pt/YjCoD7HotzKr85sAYs3RiqNoe98I0XGUq3FG2NU6GhkvFMCvQXeMufkjs/iHhG99 x1mHby1C1V/90iCflpzXYAVGW28bRMwA4myPKaAUNKeQS8IYp0VUzueAitZPx74jaxg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796291736; h=Received:DKIM-Signature:Received:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition: Content-Transfer-Encoding:In-Reply-To; bh=+2OS/zmq/phT08xeIno6p+ydcbdlph6hTREhq6U3+XU=; b=X91HhgYPxnyERlOsWhAD1b3xf40J/1DdhseYC0RKcemzdJah1escnPRBppUK8S6SeD3c VOGsrVJEcNTAYp7Z+AdBazyeBfqPFV0X1gvRbL/zH2thf3Pzs0oyeeT6ypBkCEEmO/3Mj LAmu5sILmaDPafKnPcyDNCIAJDOoxGaMxAMSzBtHYudPgBslgmoLwr564jewKjPlGTxId sKSctYkLbLmjneANKiQJ3iO2K0OhLGSVFJ6DF/5csNHDLArC8XLJ7ArpOZmLy+g7p8mQf mojbpv3qJDvtSQHVjg7XCuzitqFrymaMHU+4LZnjaH4CJG3JaOwJ4PMkuW2o89f+q1w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=TPZXOAtJ; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B8FB0606A322; Thu, 3 Dec 2026 09:55:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=TPZXOAtJ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 50D111F000C1; Thu, 3 Dec 2026 09:55:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796291736; bh=+2OS/zmq/phT08xeIno6p+ydcbdlph6hTREhq6U3+XU=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=TPZXOAtJoS5m2RXZ8CcgKaeUXexTibYqqmOxIa/IN9BaI13jvbmxy7ge5kKftQ3lz OgLnK3qKrVdSkt/68OA+gFx2XX6mAUQ1y8QzuJ1vqvSgaxVy0umGQf1q/h1F+7CJAN Bs1nq40UV/asE9qDsaDW/lOFdVD3jy9/SWlZ3JYHj6gmze876i0WyoYci3mhZuQ3C2 1CHKn1MUhthz2hC2ImX+hSt3WkILX5RKGrnTao7fiAk4iuclagr7zay8sPK2Q36lCa BGvrTqyyR0wRuOK7r2KopZFJW+t9csSvRsW2Y4iAUwWc7HjFl6BZtLg5XtJEfESS2E d9eFdfK0HtIXw== Received: from johan by xi.lan with local (Exim 4.100.2) (envelope-from ) id 1xZ3XJ-0000000511E-3Wm2; Thu, 03 Dec 2026 10:55:33 +0100 Date: Thu, 3 Dec 2026 10:55:33 +0100 From: Johan Hovold To: Ian Rogers Cc: Greg Kroah-Hartman , "Rafael J . Wysocki" , Danilo Krummrich , Luis Chamberlain , Dave Ertman , Ira Weiny , Leon Romanovsky , Kees Cook , Miguel Ojeda , Nathan Chancellor , driver-core@lists.linux.dev, llvm@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/3] driver core: Require explicit initialization of class and bus_type name Message-ID: References: <20261130225340.96859-1-irogers@google.com> <20261130225340.96859-2-irogers@google.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Tue, Dec 01, 2026 at 08:36:26AM -0800, Ian Rogers wrote: > On Tue, Dec 1, 2026 at 12:26 AM Johan Hovold wrote: > > > > On Mon, Nov 30, 2026 at 02:53:38PM -0800, Ian Rogers wrote: > > > class_register() and bus_register() pass .name to kobject_set_name() to > > > register the subsystem kset in sysfs, which fails with -ENOMEM if .name > > > is NULL. > > > > > > Annotate .name on struct class and struct bus_type with __must_init so > > > missing names are caught at compile time. > > > > I don't see the point in doing this as any superficial testing > > (i.e. registering the bus or class) will catch this. > You are right. The hope is to push a run time problem into a compile > time failure. If we have good run time test coverage a compile time > attribute won't catch anything new. > > For context, I gave this presentation at LPC: > https://lpc.events/event/20/contributions/2392/ > And the series adding the attribute is here, with the first user being > kobject::release: > https://lore.kernel.org/lkml/20261119192520.1983406-1-irogers@google.com/ Thanks for the pointers. > The patches here come from a desire to try to capture this __must_init > behavior as much as possible. kobject::release showed issues with > users not initializing kobjects properly, these changes did not. I > think there are 3 things I can do: > > 1) try to adopt __must_init widely based on inspecting runtime code to > try to make runtime problems compile time ones (the approach here), > 2) adopt __must_init only when bugs were encountered and __must_init > would have prevented them, > 3) just avoiding __must_init altogether. > > For (2) it is also evidence that we can add runtime checks. For (3) > the feedback from people like Kees and Greg was that the attributes > were useful and we should add them. I can see it being useful for fields like .release and other callbacks not used during registration/probe, but for the first two patches here it really only helps a developer with recent clang before the very first test run (e.g. in the theoretical case that they forget to name their new bus or class). So maybe start with a variant of 1 by adding it to structs where there is a potential benefit? > I feel this change doesn't introduce much noise. There are advantages > in terms of documentation and for new users, so overall, I prefer the > change (and approach 1 in general). It does add some newlines and clutter to the declarations, but I guess that's not too much of an issue. > Do you feel the change is excessively noisy and creates churn, so you > don't want to see it land or are you just kind of meh on the > __must_init attribute idea? No, I'm fine with this. It was just seeing this applied to two instances where the benefit is essentially zero that threw me off. Johan