From: Sven Eckelmann <sven@narfation.org>
To: "B.A.T.M.A.N" <b.a.t.m.a.n@lists.open-mesh.net>
Subject: Re: [B.A.T.M.A.N.] Use of ref_get_unless_zero() ?
Date: Fri, 04 Mar 2016 17:00:57 +0100 [thread overview]
Message-ID: <1639130.GsDHf0QkkJ@sven-edge> (raw)
In-Reply-To: <2378940.op5bKN67gL@sven-edge>
[-- Attachment #1: Type: text/plain, Size: 2177 bytes --]
On Friday 04 March 2016 16:50:43 Sven Eckelmann wrote:
> On Friday 04 March 2016 16:21:32 Andrew Lunn wrote:
> > Hi
> >
> > I'm sometimes getting a crash after removing a hard interface when the
> > batadv_send_outstanding_bat_org_packet() is called in a work queue.
> > It calls
> >
> > static void batadv_iv_ogm_aggregate_new(const unsigned char *packet_buff,
> >
> > int packet_len, unsigned long
> >
> > send_time, bool direct_link,
> >
> > struct batadv_hard_iface
> >
> > *if_incoming, struct batadv_hard_iface *if_outgoing, int own_packet)
> > {
> >
> > struct batadv_priv *bat_priv =
> > netdev_priv(if_incoming->soft_iface);
> >
> > struct batadv_forw_packet *forw_packet_aggr;
> >
> > unsigned char *skb_buff;
> > unsigned int skb_size;
> >
> > if (!kref_get_unless_zero(&if_incoming->refcount))
> >
> > return;
> >
> > if (!kref_get_unless_zero(&if_outgoing->refcount))
> >
> > goto out_free_incoming;
> >
> > Given that we have:
> >
> > static inline void batadv_hardif_put(struct batadv_hard_iface *hard_iface)
> > {
> >
> > kref_put(&hard_iface->refcount, batadv_hardif_release);
> >
> > }
> >
> > does using kref_get_unless_zero() make sense? If it is zero, hasn't it
> > been freed by the kref_put that set it to zero?
Maybe it would be easier to understand when this would be replaced with
kref_get and the if_outgoing loop in batadv_iv_ogm_schedule would be replaced
with:
rcu_read_lock();
list_for_each_entry_rcu(tmp_hard_iface, &batadv_hardif_list, list) {
if (tmp_hard_iface->soft_iface != hard_iface->soft_iface)
continue;
/* make sure only still valid interfaces are used in queue */
if (!kref_get_unless_zero(&tmp_hard_iface->refcount))
continue;
batadv_iv_ogm_queue_add(bat_priv, *ogm_buff,
*ogm_buff_len, hard_iface,
tmp_hard_iface, 1, send_time);
batadv_hardif_put(tmp_hard_iface);
}
rcu_read_unlock();
Sorry for being in noisy-mail mode. I will stop sending mails for today.
Kind regards,
Sven
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2016-03-04 16:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-04 15:21 [B.A.T.M.A.N.] Use of ref_get_unless_zero() ? Andrew Lunn
2016-03-04 15:37 ` Antonio Quartulli
2016-03-04 15:50 ` Sven Eckelmann
2016-03-04 15:53 ` Sven Eckelmann
2016-03-04 16:00 ` Sven Eckelmann [this message]
2016-03-04 16:21 ` Andrew Lunn
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=1639130.GsDHf0QkkJ@sven-edge \
--to=sven@narfation.org \
--cc=b.a.t.m.a.n@lists.open-mesh.net \
/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