netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net v2] docs: netdev: document guidance on cleanup.h
@ 2024-08-30 17:14 Jakub Kicinski
  2024-08-30 20:31 ` Simon Horman
  2024-09-05  9:10 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Jakub Kicinski @ 2024-08-30 17:14 UTC (permalink / raw)
  To: davem
  Cc: netdev, edumazet, pabeni, Jakub Kicinski, Nikolay Aleksandrov,
	Andrew Lunn, horms, corbet, linux-doc

Document what was discussed multiple times on list and various
virtual / in-person conversations. guard() being okay in functions
<= 20 LoC is a bit of my own invention. If the function is trivial
it should be fine, but feel free to disagree :)

We'll obviously revisit this guidance as time passes and we and other
subsystems get more experience.

Reviewed-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Nikolay Aleksandrov <razor@blackwall.org>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: horms@kernel.org
CC: corbet@lwn.net
CC: linux-doc@vger.kernel.org

v2:
 - add sentence about revisiting later to commit msg
 - fix spelling
v1: https://lore.kernel.org/20240829152025.3203577-1-kuba@kernel.org
---
 Documentation/process/maintainer-netdev.rst | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/Documentation/process/maintainer-netdev.rst b/Documentation/process/maintainer-netdev.rst
index 30d24eecdaaa..c9edf9e7362d 100644
--- a/Documentation/process/maintainer-netdev.rst
+++ b/Documentation/process/maintainer-netdev.rst
@@ -375,6 +375,22 @@ When working in existing code which uses nonstandard formatting make
 your code follow the most recent guidelines, so that eventually all code
 in the domain of netdev is in the preferred format.
 
+Using device-managed and cleanup.h constructs
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Netdev remains skeptical about promises of all "auto-cleanup" APIs,
+including even ``devm_`` helpers, historically. They are not the preferred
+style of implementation, merely an acceptable one.
+
+Use of ``guard()`` is discouraged within any function longer than 20 lines,
+``scoped_guard()`` is considered more readable. Using normal lock/unlock is
+still (weakly) preferred.
+
+Low level cleanup constructs (such as ``__free()``) can be used when building
+APIs and helpers, especially scoped iterators. However, direct use of
+``__free()`` within networking core and drivers is discouraged.
+Similar guidance applies to declaring variables mid-function.
+
 Resending after review
 ~~~~~~~~~~~~~~~~~~~~~~
 
-- 
2.46.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net v2] docs: netdev: document guidance on cleanup.h
  2024-08-30 17:14 [PATCH net v2] docs: netdev: document guidance on cleanup.h Jakub Kicinski
@ 2024-08-30 20:31 ` Simon Horman
  2024-09-05  9:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Simon Horman @ 2024-08-30 20:31 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: davem, netdev, edumazet, pabeni, Nikolay Aleksandrov, Andrew Lunn,
	corbet, linux-doc

On Fri, Aug 30, 2024 at 10:14:42AM -0700, Jakub Kicinski wrote:
> Document what was discussed multiple times on list and various
> virtual / in-person conversations. guard() being okay in functions
> <= 20 LoC is a bit of my own invention. If the function is trivial
> it should be fine, but feel free to disagree :)
> 
> We'll obviously revisit this guidance as time passes and we and other
> subsystems get more experience.
> 
> Reviewed-by: Eric Dumazet <edumazet@google.com>
> Reviewed-by: Nikolay Aleksandrov <razor@blackwall.org>
> Reviewed-by: Andrew Lunn <andrew@lunn.ch>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> ---
> CC: horms@kernel.org
> CC: corbet@lwn.net
> CC: linux-doc@vger.kernel.org
> 
> v2:
>  - add sentence about revisiting later to commit msg
>  - fix spelling
> v1: https://lore.kernel.org/20240829152025.3203577-1-kuba@kernel.org

Thanks. I think this patch has enough tags, so I won't add another.
But, FTR, this version looks good to me.

...

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net v2] docs: netdev: document guidance on cleanup.h
  2024-08-30 17:14 [PATCH net v2] docs: netdev: document guidance on cleanup.h Jakub Kicinski
  2024-08-30 20:31 ` Simon Horman
@ 2024-09-05  9:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-09-05  9:10 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: davem, netdev, edumazet, pabeni, razor, andrew, horms, corbet,
	linux-doc

Hello:

This patch was applied to netdev/net.git (main)
by Paolo Abeni <pabeni@redhat.com>:

On Fri, 30 Aug 2024 10:14:42 -0700 you wrote:
> Document what was discussed multiple times on list and various
> virtual / in-person conversations. guard() being okay in functions
> <= 20 LoC is a bit of my own invention. If the function is trivial
> it should be fine, but feel free to disagree :)
> 
> We'll obviously revisit this guidance as time passes and we and other
> subsystems get more experience.
> 
> [...]

Here is the summary with links:
  - [net,v2] docs: netdev: document guidance on cleanup.h
    https://git.kernel.org/netdev/net/c/c82299fbbcce

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-09-05  9:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-30 17:14 [PATCH net v2] docs: netdev: document guidance on cleanup.h Jakub Kicinski
2024-08-30 20:31 ` Simon Horman
2024-09-05  9:10 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).