From: David Ahern <dsahern@gmail.com>
To: Tony Lu <tonylu@linux.alibaba.com>, davem@davemloft.net
Cc: xiyou.wangcong@gmail.com, eric.dumazet@gmail.com,
shemminger@osdl.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/2] net: add trace events for net_device refcnt
Date: Tue, 12 Nov 2019 08:27:31 -0700 [thread overview]
Message-ID: <ea3bf073-68af-d899-2664-fef54953a68d@gmail.com> (raw)
In-Reply-To: <20191112130510.91570-2-tonylu@linux.alibaba.com>
On 11/12/19 6:05 AM, Tony Lu wrote:
> diff --git a/include/trace/events/net.h b/include/trace/events/net.h
> index 3b28843652d2..3bf6dd738882 100644
> --- a/include/trace/events/net.h
> +++ b/include/trace/events/net.h
> @@ -326,6 +326,47 @@ DEFINE_EVENT(net_dev_rx_exit_template, netif_receive_skb_list_exit,
> TP_ARGS(ret)
> );
>
> +DECLARE_EVENT_CLASS(net_dev_refcnt_template,
> +
> + TP_PROTO(struct net_device *dev, void *location),
> +
> + TP_ARGS(dev, location),
> +
> + TP_STRUCT__entry(
> + __string( name, dev->name )
> + __field( int, refcnt )
> + __field( void *, location )
> + ),
> +
> + TP_fast_assign(
> + int i, refcnt = 0;
> +
> + for_each_possible_cpu(i)
> + refcnt += *per_cpu_ptr(dev->pcpu_refcnt, i);
Rather than copying the definition of netdev_refcnt_read here, so just
use it.
> +
> + __assign_str(name, dev->name);
> + __entry->refcnt = refcnt;
> + __entry->location = location;
> + ),
> +
> + TP_printk("dev=%s refcnt=%d location=%p",
> + __get_str(name), __entry->refcnt, __entry->location)
> +);
> +
> +DEFINE_EVENT(net_dev_refcnt_template, net_dev_put,
> +
> + TP_PROTO(struct net_device *dev, void *location),
> +
> + TP_ARGS(dev, location)
> +);
> +
> +DEFINE_EVENT(net_dev_refcnt_template, net_dev_hold,
> +
> + TP_PROTO(struct net_device *dev, void *location),
> +
> + TP_ARGS(dev, location)
> +);
> +
> #endif /* _TRACE_NET_H */
>
The location alone does nothing for resolving reference count leaks; you
really have to use stack traces to pair up the hold and put and to give
context for what are repetitive locations for the hold and put.
next prev parent reply other threads:[~2019-11-12 15:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-12 13:05 [PATCH v2 1/2] net: remove static inline from dev_put()/dev_hold() Tony Lu
2019-11-12 13:05 ` [PATCH v2 2/2] net: add trace events for net_device refcnt Tony Lu
2019-11-12 15:27 ` David Ahern [this message]
2019-11-16 19:47 ` Cong Wang
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=ea3bf073-68af-d899-2664-fef54953a68d@gmail.com \
--to=dsahern@gmail.com \
--cc=davem@davemloft.net \
--cc=eric.dumazet@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=shemminger@osdl.org \
--cc=tonylu@linux.alibaba.com \
--cc=xiyou.wangcong@gmail.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
all inboxes | Powered by JetHome®