From: David Ahern <dsahern@gmail.com>
To: netdev@vger.kernel.org
Cc: roopa@cumulusnetworks.com, f.fainelli@gmail.com,
nicolas.dichtel@6wind.com, David Ahern <dsahern@gmail.com>
Subject: [PATCH RFC net-next 4/6] net: Do not intialize kobject for lightweight netdevs
Date: Sat, 6 May 2017 10:07:32 -0600 [thread overview]
Message-ID: <20170506160734.47084-5-dsahern@gmail.com> (raw)
In-Reply-To: <20170506160734.47084-1-dsahern@gmail.com>
Lightweight netdevices are not added to sysfs; bypass kobject
initialization.
Signed-off-by: David Ahern <dsahern@gmail.com>
---
include/linux/netdevice.h | 3 +++
net/core/dev.c | 9 ++++++---
net/core/net-sysfs.c | 14 +++++++++++---
3 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 08151fd34973..4ddd0ac7e1cb 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -4282,6 +4282,9 @@ static inline const char *netdev_reg_state(const struct net_device *dev)
static inline struct kobject *netdev_kobject(struct net_device *dev)
{
+ if (netif_is_lwd(dev))
+ return NULL;
+
return &dev->dev.kobj;
}
diff --git a/net/core/dev.c b/net/core/dev.c
index 48a0252037d5..52bb01041d12 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -7993,7 +7993,8 @@ void free_netdev(struct net_device *dev)
dev->reg_state = NETREG_RELEASED;
/* will free via device release */
- put_device(&dev->dev);
+ if (!netif_is_lwd(dev))
+ put_device(&dev->dev);
}
EXPORT_SYMBOL(free_netdev);
@@ -8179,8 +8180,10 @@ int dev_change_net_namespace(struct net_device *dev, struct net *net, const char
netdev_adjacent_add_links(dev);
/* Fixup kobjects */
- err = device_rename(&dev->dev, dev->name);
- WARN_ON(err);
+ if (!netif_is_lwd(dev)) {
+ err = device_rename(&dev->dev, dev->name);
+ WARN_ON(err);
+ }
/* Add the device back in the hashes */
list_netdevice(dev);
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 9df53b688f5b..725348cdeb3b 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -1559,18 +1559,22 @@ EXPORT_SYMBOL(of_find_net_device_by_node);
*/
void netdev_unregister_kobject(struct net_device *ndev)
{
+ struct kobject *kobj = netdev_kobject(ndev);
struct device *dev = &(ndev->dev);
if (!atomic_read(&dev_net(ndev)->count))
dev_set_uevent_suppress(dev, 1);
- kobject_get(&dev->kobj);
+ if (kobj)
+ kobject_get(kobj);
- remove_queue_kobjects(ndev);
+ if (!netif_is_lwd(ndev))
+ remove_queue_kobjects(ndev);
pm_runtime_set_memalloc_noio(dev, false);
- device_del(dev);
+ if (!netif_is_lwd(ndev))
+ device_del(dev);
}
/* Create sysfs entries for network device. */
@@ -1580,6 +1584,9 @@ int netdev_register_kobject(struct net_device *ndev)
const struct attribute_group **groups = ndev->sysfs_groups;
int error = 0;
+ if (netif_is_lwd(ndev))
+ goto pm;
+
device_initialize(dev);
dev->class = &net_class;
dev->platform_data = ndev;
@@ -1614,6 +1621,7 @@ int netdev_register_kobject(struct net_device *ndev)
return error;
}
+pm:
pm_runtime_set_memalloc_noio(dev, true);
return error;
--
2.11.0 (Apple Git-81)
next prev parent reply other threads:[~2017-05-06 16:07 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-06 16:07 [PATCH RFC net-next 0/6] net: reducing memory footprint of network devices David Ahern
2017-05-06 16:07 ` [PATCH RFC net-next 1/6] net: Add accessor for kboject in a net_device David Ahern
2017-05-06 16:07 ` [PATCH RFC net-next 2/6] net: Add flags argument to alloc_netdev_mqs David Ahern
2017-05-06 16:07 ` [PATCH RFC net-next 3/6] net: Introduce IFF_LWT_NETDEV flag David Ahern
2017-05-08 8:55 ` Johannes Berg
2017-05-08 20:11 ` David Miller
2017-05-08 21:37 ` Roopa Prabhu
2017-05-09 0:57 ` David Ahern
2017-05-09 5:04 ` Roopa Prabhu
2017-05-06 16:07 ` David Ahern [this message]
2017-05-08 17:26 ` [PATCH RFC net-next 4/6] net: Do not intialize kobject for lightweight netdevs Florian Fainelli
2017-05-06 16:07 ` [PATCH RFC net-next 5/6] net: Delay initializations for lightweight devices David Ahern
2017-05-08 17:31 ` Florian Fainelli
2017-05-06 16:07 ` [PATCH RFC net-next 6/6] net: add uapi for creating " David Ahern
2017-05-08 17:35 ` [PATCH RFC net-next 0/6] net: reducing memory footprint of network devices Florian Fainelli
2017-05-09 9:50 ` Nicolas Dichtel
2017-05-09 15:42 ` David Ahern
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=20170506160734.47084-5-dsahern@gmail.com \
--to=dsahern@gmail.com \
--cc=f.fainelli@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=nicolas.dichtel@6wind.com \
--cc=roopa@cumulusnetworks.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;
as well as URLs for NNTP newsgroup(s).