[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5347c7b2-cbd3-4fc2-9794-6dcad4b9aae7@blackwall.org>
Date: Thu, 29 Aug 2024 18:27:50 +0300
From: Nikolay Aleksandrov <razor@...ckwall.org>
To: Jakub Kicinski <kuba@...nel.org>, davem@...emloft.net
Cc: netdev@...r.kernel.org, edumazet@...gle.com, pabeni@...hat.com,
andrew@...n.ch, corbet@....net, linux-doc@...r.kernel.org
Subject: Re: [PATCH net] docs: netdev: document guidance on cleanup.h
On 29/08/2024 18:20, 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 my own invention. If the function is trivial it should
> be fine, but feel free to disagree :)
>
> Signed-off-by: Jakub Kicinski <kuba@...nel.org>
> ---
> CC: andrew@...n.ch
> CC: corbet@....net
> CC: linux-doc@...r.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 fe8616397d63..ccd6c96a169b 100644
> --- a/Documentation/process/maintainer-netdev.rst
> +++ b/Documentation/process/maintainer-netdev.rst
> @@ -392,6 +392,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 interators. However, direct use of
> +``__free()`` within networking core and drivers is discouraged.
> +Similar guidance applies to declaring variables mid-function.
> +
> Resending after review
> ~~~~~~~~~~~~~~~~~~~~~~
>
Definitely and strongly agree.
Reviewed-by: Nikolay Aleksandrov <razor@...ckwall.org>
Powered by blists - more mailing lists