Netdev List
 help / color / mirror / Atom feed
From: Meghana Malladi <m-malladi@ti.com>
To: Simon Horman <horms@kernel.org>,
	Marco Crivellari <marco.crivellari@suse.com>
Cc: <kees+treewide@kernel.org>, <laixiangwu@cmss.chinamobile.com>,
	<philippe.schenker@impulsing.ch>, <haokexin@gmail.com>,
	<devnexen@gmail.com>, <jacob.e.keller@intel.com>,
	<sdf@fomichev.me>, <john.fastabend@gmail.com>, <hawk@kernel.org>,
	<daniel@iogearbox.net>, <ast@kernel.org>, <pabeni@redhat.com>,
	<kuba@kernel.org>, <edumazet@kernel.org>, <davem@davemloft.net>,
	<andrew+netdev@lunn.ch>, <bpf@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <netdev@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>, <srk@ti.com>,
	Vignesh Raghavendra <vigneshr@ti.com>, <danishanwar@ti.com>
Subject: Re: [PATCH net-next 2/2] net: ti: icssg-prueth: Add ethtool RX flow classification support
Date: Thu, 26 Nov 2026 11:40:55 +0530	[thread overview]
Message-ID: <b32f88cf-292f-4bf9-b118-d11f3e6af402@ti.com> (raw)
In-Reply-To: <20261125113634.GT31322@horms.kernel.org>

Hi Marco, Simon,

On 11/25/26 17:06, Simon Horman wrote:
> On Thu, Nov 19, 2026 at 10:19:48AM +0100, Marco Crivellari wrote:
>> Hi,
>>
>> On Wed, Nov 18, 2026 at 7:50 PM Meghana Malladi <m-malladi@ti.com> wrote:
>>> [...]
>>> +       mutex_lock(&emac->rxnfc.rxnfc_lock);
>>> +
>>> +       /* Check max rules */
>>> +       if (emac->rxnfc.rxnfc_rule_count >= ICSSG_RXNFC_MAX_RULES) {
>>> +               ret = -ENOSPC;
>>> +               goto unlock;
>>> +       }
>>>   [...]
>>> +
>>> +unlock:
>>> +       mutex_unlock(&emac->rxnfc.rxnfc_lock);
>>> +       return ret;
>>> +}
>>> +EXPORT_SYMBOL_GPL(icssg_rxnfc_rule_add);
>>
>> nit: instead of mutex_lock() you can use guard() [1]:
>>
>>      guard(mutex)(&emac->rxnfc.rxnfc_lock)
>>
>> and remove all the "goto unlock", returning directly. This handles the
>> automatic cleanup.
>>
>> Same for other places where you're using mutex_lock() / mutex_unlock().
>>
>> - [1] https://docs.kernel.org/core-api/cleanup.html
> 
> Thanks Marco,
> 
> That may be good general advice.
> But for networking code the explicit approach taken by this patch
> is still preferred.
> 
>    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.
> 
>    Link: https://docs.kernel.org/process/maintainer-netdev.html#using-device-managed-and-cleanup-h-constructs

Thanks for the insights! I had actually just implemented Marco's 
suggestion locally, so I'll revert that back now :/ I'll definitely give 
the netdev documentation a good read as well.

  parent reply	other threads:[~2026-11-26  6:15 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18 18:47 [PATCH net-next 0/2] net: ti: icssg: Multi-flow RX and ethtool RX flow classification Meghana Malladi
2026-11-18 18:47 ` [PATCH net-next 1/2] net: ti: icssg-prueth: Add multi-flow RX support with per-flow NAPI Meghana Malladi
2026-11-22 19:01   ` netdev-bot+sashiko
2026-11-25 12:11     ` Simon Horman
2026-11-26  5:59       ` Meghana Malladi
2026-11-26 15:25         ` Simon Horman
2026-11-18 18:47 ` [PATCH net-next 2/2] net: ti: icssg-prueth: Add ethtool RX flow classification support Meghana Malladi
2026-11-19  9:19   ` Marco Crivellari
2026-11-25 11:36     ` Simon Horman
2026-11-25 13:14       ` Marco Crivellari
2026-11-26  6:10       ` Meghana Malladi [this message]
2026-11-22 19:01   ` netdev-bot+sashiko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b32f88cf-292f-4bf9-b118-d11f3e6af402@ti.com \
    --to=m-malladi@ti.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=danishanwar@ti.com \
    --cc=davem@davemloft.net \
    --cc=devnexen@gmail.com \
    --cc=edumazet@kernel.org \
    --cc=haokexin@gmail.com \
    --cc=hawk@kernel.org \
    --cc=horms@kernel.org \
    --cc=jacob.e.keller@intel.com \
    --cc=john.fastabend@gmail.com \
    --cc=kees+treewide@kernel.org \
    --cc=kuba@kernel.org \
    --cc=laixiangwu@cmss.chinamobile.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marco.crivellari@suse.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=philippe.schenker@impulsing.ch \
    --cc=sdf@fomichev.me \
    --cc=srk@ti.com \
    --cc=vigneshr@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox