From: Jiri Pirko <jiri@resnulli.us>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: netdev@vger.kernel.org, jhs@mojatatu.com, victor@mojatatu.com,
kuba@kernel.org, pctammela@mojatatu.com, martin@strongswan.org,
horms@kernel.org, Johannes Berg <johannes.berg@intel.com>
Subject: Re: [PATCH net-next v2 1/2] rtnetlink: add guard for RTNL
Date: Tue, 2 Apr 2024 14:31:31 +0200 [thread overview]
Message-ID: <Zgv6o3rcgFu1DXpV@nanopsycho> (raw)
In-Reply-To: <20240328082748.b6003379b15b.I9da87266ad39fff647828b5822e6ac8898857b71@changeid>
Thu, Mar 28, 2024 at 08:27:49AM CET, johannes@sipsolutions.net wrote:
>From: Johannes Berg <johannes.berg@intel.com>
>
>The new guard/scoped_gard can be useful for the RTNL as well,
>so add a guard definition for it. It gets used like
>
> {
> guard(rtnl)();
> // RTNL held until end of block
> }
>
>or
>
> scoped_guard(rtnl) {
> // RTNL held in this block
> }
>
>as with any other guard/scoped_guard.
>
>Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Since you add couple of helpers, I believe it is a nice custom to add a
couple of patches that actually uses them. Would that make sense?
>---
>v2: resend
>---
> include/linux/rtnetlink.h | 3 +++
> 1 file changed, 3 insertions(+)
>
>diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h
>index cdfc897f1e3c..a7da7dfc06a2 100644
>--- a/include/linux/rtnetlink.h
>+++ b/include/linux/rtnetlink.h
>@@ -7,6 +7,7 @@
> #include <linux/netdevice.h>
> #include <linux/wait.h>
> #include <linux/refcount.h>
>+#include <linux/cleanup.h>
> #include <uapi/linux/rtnetlink.h>
>
> extern int rtnetlink_send(struct sk_buff *skb, struct net *net, u32 pid, u32 group, int echo);
>@@ -46,6 +47,8 @@ extern int rtnl_is_locked(void);
> extern int rtnl_lock_killable(void);
> extern bool refcount_dec_and_rtnl_lock(refcount_t *r);
>
>+DEFINE_LOCK_GUARD_0(rtnl, rtnl_lock(), rtnl_unlock())
>+
> extern wait_queue_head_t netdev_unregistering_wq;
> extern atomic_t dev_unreg_count;
> extern struct rw_semaphore pernet_ops_rwsem;
>--
>2.44.0
>
next prev parent reply other threads:[~2024-04-02 12:31 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-28 7:27 [PATCH net-next v2 1/2] rtnetlink: add guard for RTNL Johannes Berg
2024-03-28 7:27 ` [PATCH net-next v2 2/2] netdevice: add DEFINE_FREE() for dev_put Johannes Berg
2024-04-02 8:28 ` Simon Horman
2024-04-02 8:27 ` [PATCH net-next v2 1/2] rtnetlink: add guard for RTNL Simon Horman
2024-04-02 12:31 ` Jiri Pirko [this message]
2024-04-02 15:04 ` Jakub Kicinski
2024-04-03 9:00 ` patchwork-bot+netdevbpf
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=Zgv6o3rcgFu1DXpV@nanopsycho \
--to=jiri@resnulli.us \
--cc=horms@kernel.org \
--cc=jhs@mojatatu.com \
--cc=johannes.berg@intel.com \
--cc=johannes@sipsolutions.net \
--cc=kuba@kernel.org \
--cc=martin@strongswan.org \
--cc=netdev@vger.kernel.org \
--cc=pctammela@mojatatu.com \
--cc=victor@mojatatu.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;
as well as URLs for NNTP newsgroup(s).