mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Ahern <dsahern@gmail.com>
To: Florian Fainelli <f.fainelli@gmail.com>, netdev@vger.kernel.org
Cc: edumazet@google.com, andrew@lunn.ch, cphealy@gmail.com,
	David Decotigny <decot@googlers.com>,
	"David S. Miller" <davem@davemloft.net>,
	Jamal Hadi Salim <jhs@mojatatu.com>,
	Cong Wang <xiyou.wangcong@gmail.com>,
	Jiri Pirko <jiri@resnulli.us>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Nikolay Aleksandrov <nikolay@cumulusnetworks.com>,
	Alexei Starovoitov <ast@fb.com>,
	Roopa Prabhu <roopa@cumulusnetworks.com>,
	Mahesh Bandewar <maheshb@google.com>,
	Vlad Yasevich <vyasevich@gmail.com>,
	Jakub Kicinski <jakub.kicinski@netronome.com>,
	Jonas Bonn <jonas@southpole.se>,
	stephen hemminger <stephen@networkplumber.org>,
	Hans Liljestrand <ishkamiel@gmail.com>,
	"Reshetova, Elena" <elena.reshetova@intel.com>,
	Kirill Tkhai <ktkhai@virtuozzo.com>,
	Andrey Vagin <avagin@openvz.org>, Florian Westphal <fw@strlen.de>,
	Xin Long <lucien.xin@gmail.com>,
	Matthias Schiffer <mschiffer@universe-factory.net>,
	Jiri Benc <jbenc@redhat.com>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH net-next] net: core: Expose number of link up/down transitions
Date: Wed, 17 Jan 2018 16:28:49 -0800	[thread overview]
Message-ID: <d4770873-9ce0-a102-520d-8e78b5d0b82a@gmail.com> (raw)
In-Reply-To: <20180117230704.21949-1-f.fainelli@gmail.com>

On 1/17/18 3:06 PM, Florian Fainelli wrote:
> diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
> index 7bf8b85ade16..9f732c3dc2ce 100644
> --- a/net/core/net-sysfs.c
> +++ b/net/core/net-sysfs.c
> @@ -295,10 +295,29 @@ static ssize_t carrier_changes_show(struct device *dev,
>  	struct net_device *netdev = to_net_dev(dev);
>  
>  	return sprintf(buf, fmt_dec,
> -		       atomic_read(&netdev->carrier_changes));
> +		       atomic_read(&netdev->count_link_up) +
> +		       atomic_read(&netdev->count_link_down));
>  }
>  static DEVICE_ATTR_RO(carrier_changes);
>  
> +static ssize_t count_link_up_show(struct device *dev,
> +				  struct device_attribute *attr, char *buf)
> +{
> +	struct net_device *netdev = to_net_dev(dev);
> +
> +	return sprintf(buf, fmt_dec, atomic_read(&netdev->count_link_up));
> +}
> +static DEVICE_ATTR_RO(count_link_up);
> +
> +static ssize_t count_link_down_show(struct device *dev,
> +				    struct device_attribute *attr, char *buf)
> +{
> +	struct net_device *netdev = to_net_dev(dev);
> +
> +	return sprintf(buf, fmt_dec, atomic_read(&netdev->count_link_down));
> +}
> +static DEVICE_ATTR_RO(count_link_down);
> +
>  /* read-write attributes */
>  
>  static int change_mtu(struct net_device *dev, unsigned long new_mtu)
> @@ -547,6 +566,8 @@ static struct attribute *net_class_attrs[] __ro_after_init = {
>  	&dev_attr_phys_port_name.attr,
>  	&dev_attr_phys_switch_id.attr,
>  	&dev_attr_proto_down.attr,
> +	&dev_attr_count_link_up.attr,
> +	&dev_attr_count_link_down.attr,
>  	NULL,
>  };
>  ATTRIBUTE_GROUPS(net_class);

Personally, I do not like adding any more sysfs files. As discussed in
the past sysfs is a huge contributor to the overhead of netdevs.

      parent reply	other threads:[~2018-01-18  0:28 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-17 23:06 Florian Fainelli
2018-01-17 23:17 ` Jakub Kicinski
2018-01-17 23:49 ` Andrei Vagin
2018-01-18  0:06   ` Andrew Lunn
2018-01-18  0:23     ` Andrei Vagin
2018-01-17 23:52 ` Jiri Pirko
2018-01-18  0:17   ` David Ahern
2018-01-18  0:28 ` David Ahern [this message]

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=d4770873-9ce0-a102-520d-8e78b5d0b82a@gmail.com \
    --to=dsahern@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=ast@fb.com \
    --cc=avagin@openvz.org \
    --cc=cphealy@gmail.com \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=decot@googlers.com \
    --cc=edumazet@google.com \
    --cc=elena.reshetova@intel.com \
    --cc=f.fainelli@gmail.com \
    --cc=fw@strlen.de \
    --cc=ishkamiel@gmail.com \
    --cc=jakub.kicinski@netronome.com \
    --cc=jbenc@redhat.com \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=jonas@southpole.se \
    --cc=ktkhai@virtuozzo.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lucien.xin@gmail.com \
    --cc=maheshb@google.com \
    --cc=mschiffer@universe-factory.net \
    --cc=netdev@vger.kernel.org \
    --cc=nikolay@cumulusnetworks.com \
    --cc=roopa@cumulusnetworks.com \
    --cc=stephen@networkplumber.org \
    --cc=vyasevich@gmail.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®