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=1796204248; b=vBPPYQkyfKUyAwchVGkntwd49rit9RDgitiANiFGtwmKxCXq1JoVPNy7K10o9xtw2hrf NqUOC82CZM+yZQI8ZJGL9ORSiHC8TJt+TR/aLrYUrQZmBCUrQHbZ0ZCxKEr0Ii6LwPZ/b 3Jq89zi4wMbAS5u9aae/8RqymqPBB1jH4FnoN3uFO3GDXmy4h3ufMcm12FMUvLGvgojhL lxsr+LssBn/XaaIkacUk5DC40AokkKu7bwbC4fQZoVjp5bk3/nrmUkvjpY3T1oGanvYdw kS7AFBp3Hu9q6YyOl0eCSKc5vg9IYzX1HtlFGVPNI7kvKX6fec3DA+zKqExP1bJAANQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796204248; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=zD7HRHmFDRR0eCef9A3a14Jf6qExzTTX4Xappx3Ox90=; b=5JTxUNG8JKTXVcOVsJON8Omb0kKGmXgJvx26MFUf0KjP1AsJdLo7A8JZFZ/cnyJaOUxk hsdoZuNudESY4I9T49tqeDb2Uo42o2380KdE6JlnOpFQ0+tibjqX2/Zm6rgWDKLtKep2O OG6A7WHlyGN14MLJ0lu3yXVZTDOZdL6FxSnidEPpjljm+JLxP8wbvtW+wWrrCREuRVJiA /O54lVsUq52MU+qAC5UvGaWocNcaQJQkixOLYJQd6WAlbNy+85TLRwvdb5U2VXVCyQC4O YD1PabqRBn+9CrLn8YkjD0FObuC3U4YeZRkNVIH7NshbDsIEUJHFEdRkbM/lkQFt1lQ== 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=Wss1+Bfy; 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 3CE90606A325; Wed, 2 Dec 2026 09:37:28 +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=Wss1+Bfy Received: by smtp.kernel.org (Postfix) with ESMTPSA id 426DB1F008A0; Wed, 2 Dec 2026 09:37:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796204247; bh=zD7HRHmFDRR0eCef9A3a14Jf6qExzTTX4Xappx3Ox90=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=Wss1+BfyzaqlV0BlcyLW/johNgphjwUcvE0+k4ZArlqNWO7vaAj6xQUJ875dmn6bc b8ezJfpll8sMlfd0UvVstzno+oFd3OZUfnH3mJ6myYgquxGu4x9Jz3bImghEeMs2RE i4wQRALIBEEEg8PRtd92DOn3+n+MpZGxk2OdiK7HtsMFOYDubENwvtaoPDkUaNOMgj k5hcg7jyWlAqrtes8cPwFYNnwTMv59LvvmKtNhY1AbB/j2NiIwiRtiM58c+6zReysn BRXZeiLUrwOnK9FJYdLmqaKTWzrlhPzl8NXSHNrqlf9oTGRptcCsJ7Wj2G0WhDXfRZ 2KluWmExoeMYA== Date: Wed, 2 Dec 2026 10:36:39 +0100 From: Joel Granados To: Linus Torvalds Cc: Kees Cook , Alexey Gladkov , David Laight , Wen Yang , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, netdev@vger.kernel.org Subject: Re: [PATCH RFC 1/9] sysctl: Add struct ctl_table_tmpl as a distinct template type Message-ID: References: <20261126-lklm-sysctl-ctx-flatarray-v1-0-d7fc9cc9b03e@kernel.org> <20261126-lklm-sysctl-ctx-flatarray-v1-1-d7fc9cc9b03e@kernel.org> X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="shzvw6gp52lynawk" Content-Disposition: inline In-Reply-To: --shzvw6gp52lynawk Content-Type: text/plain; protected-headers=v1; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Subject: Re: [PATCH RFC 1/9] sysctl: Add struct ctl_table_tmpl as a distinct template type MIME-Version: 1.0 On Thu, Nov 26, 2026 at 09:04:40AM -0800, Linus Torvalds wrote: > On Thu, 26 Nov 2026 at 03:47, Joel Granados wr= ote: > > > > +/* Template version of struct ctl_table. Used for registering ctl_tabl= e templates */ > > +struct ctl_table_tmpl { > > + struct ctl_table t; > > +}; >=20 > So I really don't like members named 't'. >=20 > I see why you are doing it, but maybe you aren't aware that we already > enabled ms-extensions, and you can actually use *unnamed* structs in > templates. >=20 > So you can do >=20 > struct ctl_table_tmpl { struct ctl_table; } >=20 > and that gives you a new type that you can use without any "t." kind > of thing, but is still distinct from 'struct ctl_table". That looks cleaner; I'll try to use it for the V1. >=20 > Note: being unnamed is very convenient in some situations, less so in > others. If you actually then want to access not the individual fields > (which is very easy), but get from the template to an actual "struct > ctl_table", you'd have to use some explicit helper wrapper, something > like >=20 > static inline struct ctl_table *template_to_inner(struct ctl_table_tmp= l *a) > { return container_of(&a->procname, struct ctl_table, procname); } >=20 > or whatever. >=20 > Honestly, right now you seem to do something really ugly: you have > that 'template', but then you hardly ever *use* it as anything but a > top-level interface, and you turn it into a 'struct ctl_table *' very > early. And that looks like it's done exactly to avoid the whole > messiness with the 't' member - but it also measn that internally that > "template" has lost almost all meaning, and it looks like a regular > ctl_table. I used the ctl_table_tmpl type as a way for the caller to signal the type of registration. I agree, it is superficial. And the caller already signals it buy using the template registration function. >=20 > Maybe that's fine. But it feels like the template is less of a real > template than just a wrapper that is only used at the top-level > wrapper and then never again. That does *not* work well if you were to > add a few extra fields to the template (that is then *not* in the > struct ctl_table. because they are only used to set it up). Hmm? >=20 > Linus Thx for the review. I'll either remove the template altogether and just have a ""context" registration function that accepts two ctl_table and inits the context or I'll make more use of the template in sysctl core as I might have missed an advantage to having the template within the sysctl core. Best --shzvw6gp52lynawk Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQGzBAABCgAdFiEErkcJVyXmMSXOyyeQupfNUreWQU8FAmsP5pMACgkQupfNUreW QU+3ewv/ZF8UXw+ghOokDd4QECIvblmO2MzsVAUWRrEYPSoc9PhjL3EAggfdHfaV +Lo7TAY3mStJ22HvZaSIpeuLxhguTXVx1V8CacDHIXxDYY5QdvItOK2bQRKu/khD NwqEsjFcUM9BwtcCha552EC2YRqPlMSr+uFTnLH8uf2gsdu0gkg96gfYIgof+9Lb N6xJza0KHtGIyt5+50worlLqwhjm3ZJxXlzGKM87b13GkMdGWwP7Qtly+M112ArK Ww8gil0peJpZ5W11AWd6SZOrztvdAgMKwAXyWcDnmYzQJLX+aqHUFPf+lDTnHS/A 1RkFkAxLBHKilZvCuwvJIPY/oF4tJdpIeAt77gauM38W26E/8ewko2SEzQ0B2dMn GGHW3q1JkNfM9DMt5XPTyYTEMJstIIYdt+6DJqAEu8XjkGwD99yAsqvJl+7M6y7w JBEMmmYVYiHaY3tB5bjFXg+5l8Hrqmt1j1VXLu8XEAsxG4348mcM0XzeSG585z96 QVZrg5+X =c/KX -----END PGP SIGNATURE----- --shzvw6gp52lynawk--