From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932142AbeARA2y (ORCPT ); Wed, 17 Jan 2018 19:28:54 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:36025 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753688AbeARA2w (ORCPT ); Wed, 17 Jan 2018 19:28:52 -0500 X-Google-Smtp-Source: ACJfBovQBCzuj6H/oSRD1AsYFZ2jaLYSAArku50fhTBG4iubC/T4GthRhy74xAp8LAXp0ppJka7AMQ== Subject: Re: [PATCH net-next] net: core: Expose number of link up/down transitions To: Florian Fainelli , netdev@vger.kernel.org Cc: edumazet@google.com, andrew@lunn.ch, cphealy@gmail.com, David Decotigny , "David S. Miller" , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Daniel Borkmann , Nikolay Aleksandrov , Alexei Starovoitov , Roopa Prabhu , Mahesh Bandewar , Vlad Yasevich , Jakub Kicinski , Jonas Bonn , stephen hemminger , Hans Liljestrand , "Reshetova, Elena" , Kirill Tkhai , Andrey Vagin , Florian Westphal , Xin Long , Matthias Schiffer , Jiri Benc , open list References: <20180117230704.21949-1-f.fainelli@gmail.com> From: David Ahern Message-ID: Date: Wed, 17 Jan 2018 16:28:49 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: <20180117230704.21949-1-f.fainelli@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.