All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Breno Leitao <leitao@debian.org>
Cc: "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
	Amerigo Wang <amwang@redhat.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel-team@meta.com
Subject: Re: [PATCH net] netpoll: guard __netpoll_send_skb() with RCU read lock
Date: Wed, 5 Mar 2025 08:07:40 -0800	[thread overview]
Message-ID: <20250305080740.68749058@kernel.org> (raw)
In-Reply-To: <20250305-tamarin-of-amusing-luck-b9c84f@leitao>

On Wed, 5 Mar 2025 01:09:49 -0800 Breno Leitao wrote:
> On Tue, Mar 04, 2025 at 05:47:32PM -0800, Jakub Kicinski wrote:
> > On Mon, 03 Mar 2025 03:44:12 -0800 Breno Leitao wrote:  
> > > +	guard(rcu)();  
> > 
> > Scoped guards if you have to.
> > Preferably just lock/unlock like a normal person..  
> 
> Sure, I thought that we would be moving to scoped guards all across the
> board, at least that was my reading for a similar patch I sent a while
> ago:
> 
> 	https://lore.kernel.org/all/20250224123016.GA17456@noisy.programming.kicks-ass.net/
> 
> Anyway, in which case should I use scoped guard instead 

We are certainly not moving to guards in networking. Too C++-sy.
Just lock / unlock please, correctly around the variable you actually
intend to protect.

Quoting documentation:

  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.
  
See: https://www.kernel.org/doc/html/next/process/maintainer-netdev.html#using-device-managed-and-cleanup-h-constructs

  reply	other threads:[~2025-03-05 16:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-03 11:44 [PATCH net] netpoll: guard __netpoll_send_skb() with RCU read lock Breno Leitao
2025-03-05  1:47 ` Jakub Kicinski
2025-03-05  9:09   ` Breno Leitao
2025-03-05 16:07     ` Jakub Kicinski [this message]
2025-03-05 16:09     ` Andrew Lunn
2025-03-05 18:51       ` Breno Leitao

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=20250305080740.68749058@kernel.org \
    --to=kuba@kernel.org \
    --cc=amwang@redhat.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kernel-team@meta.com \
    --cc=leitao@debian.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.