[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CANn89i+ySFS5C24guM9E9UsPWfQBL69-OoRDbOGfih9vLGxDJg@mail.gmail.com>
Date: Thu, 6 Feb 2025 16:24:50 +0100
From: Eric Dumazet <edumazet@...gle.com>
To: Antonio Quartulli <a@...table.cc>
Cc: Marek Lindner <marek.lindner@...lbox.org>, Simon Wunderlich <sw@...onwunderlich.de>,
Sven Eckelmann <sven@...fation.org>, b.a.t.m.a.n@...ts.open-mesh.org,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>, netdev@...r.kernel.org,
eric.dumazet@...il.com
Subject: Re: [PATCH net-next] batman-adv: adopt netdev_hold() / netdev_put()
On Thu, Feb 6, 2025 at 3:13 PM Antonio Quartulli <a@...table.cc> wrote:
>
> On 06/02/2025 15:04, Eric Dumazet wrote:
> > Add a device tracker to struct batadv_hard_iface to help
> > debugging of network device refcount imbalances.
> >
> > Signed-off-by: Eric Dumazet <edumazet@...gle.com>
> > ---
> > net/batman-adv/hard-interface.c | 14 +++++---------
> > net/batman-adv/types.h | 3 +++
> > 2 files changed, 8 insertions(+), 9 deletions(-)
> >
> > diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
> > index 96a412beab2de9069c0f88e4cd844fbc0922aa18..9a3ae567eb12d0c65b25292d020462b6ad60b699 100644
> > --- a/net/batman-adv/hard-interface.c
> > +++ b/net/batman-adv/hard-interface.c
> > @@ -51,7 +51,7 @@ void batadv_hardif_release(struct kref *ref)
> > struct batadv_hard_iface *hard_iface;
> >
> > hard_iface = container_of(ref, struct batadv_hard_iface, refcount);
> > - dev_put(hard_iface->net_dev);
> > + netdev_put(hard_iface->net_dev, &hard_iface->dev_tracker);
> >
> > kfree_rcu(hard_iface, rcu);
> > }
> > @@ -875,15 +875,16 @@ batadv_hardif_add_interface(struct net_device *net_dev)
> > ASSERT_RTNL();
> >
> > if (!batadv_is_valid_iface(net_dev))
> > - goto out;
> > + return NULL;
> >
> > - dev_hold(net_dev);
> >
> > hard_iface = kzalloc(sizeof(*hard_iface), GFP_ATOMIC);
> > if (!hard_iface)
> > - goto release_dev;
> > + return NULL;
> >
> > + netdev_hold(net_dev, &hard_iface->dev_tracker, GFP_ATOMIC);
> > hard_iface->net_dev = net_dev;
> > +
> > hard_iface->soft_iface = NULL;
> > hard_iface->if_status = BATADV_IF_NOT_IN_USE;
> >
> > @@ -909,11 +910,6 @@ batadv_hardif_add_interface(struct net_device *net_dev)
> > batadv_hardif_generation++;
> >
> > return hard_iface;
> > -
> > -release_dev:
> > - dev_put(net_dev);
> > -out:
> > - return NULL;
> > }
> >
> > static void batadv_hardif_remove_interface(struct batadv_hard_iface *hard_iface)
> > diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
> > index f491bff8c51b8bf68eb11dbbeb1a434d446c25f0..a73fc3ab7dd28ae2c8484c0d198a15437d49ea73 100644
> > --- a/net/batman-adv/types.h
> > +++ b/net/batman-adv/types.h
> > @@ -186,6 +186,9 @@ struct batadv_hard_iface {
> > /** @net_dev: pointer to the net_device */
> > struct net_device *net_dev;
> >
> > + /** @dev_tracker device tracker for @net_dev */
> > + netdevice_tracker dev_tracker;
>
> There are two blanks between type and member name. Is that intended?
Not intended. Also a : is missing :
I can submit a V2 if you want, or feel free to make the changes.
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
index a73fc3ab7dd28ae2c8484c0d198a15437d49ea73..8ac061379b6f72ef7f1d4e191888db2cc56376da
100644
--- a/net/batman-adv/types.h
+++ b/net/batman-adv/types.h
@@ -186,8 +186,8 @@ struct batadv_hard_iface {
/** @net_dev: pointer to the net_device */
struct net_device *net_dev;
- /** @dev_tracker device tracker for @net_dev */
- netdevice_tracker dev_tracker;
+ /** @dev_tracker: device tracker for @net_dev */
+ netdevice_tracker dev_tracker;
/** @refcount: number of contexts the object is used */
struct kref refcount;
>
> > +
> > /** @refcount: number of contexts the object is used */
> > struct kref refcount;
> >
>
> We also have hard_iface->soft_iface storing a pointer to the soft_iface
> (batX) netdev.
>
> How about converting that to netdev_put/hold as well?
> See batadv_hardif_enable_interface() / batadv_hardif_disable_interface()
>
Sure, feel free to submit a patch for this one as well.
Thanks.
Powered by blists - more mailing lists