net: make struct net_device::tx_queue_len unsigned int
authorAlexey Dobriyan <adobriyan@gmail.com>
Wed, 17 May 2017 10:30:44 +0000 (13:30 +0300)
committerDavid S. Miller <davem@davemloft.net>
Thu, 18 May 2017 14:19:30 +0000 (10:19 -0400)
4 billion packet queue is something unthinkable so use 32-bit value
for now.

Space savings on x86_64:

add/remove: 0/0 grow/shrink: 3/70 up/down: 16/-131 (-115)
function                                     old     new   delta
change_tx_queue_len                           94     108     +14
qdisc_create                                1176    1177      +1
alloc_netdev_mqs                            1124    1125      +1
xenvif_alloc                                 533     532      -1
x25_asy_setup                                167     166      -1
...
tun_queue_resize                             945     940      -5
pfifo_fast_enqueue                           167     162      -5
qfq_init_qdisc                               168     158     -10
tap_queue_resize                             810     799     -11
transmit                                     719     698     -21

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/wan/hdlc_raw_eth.c
include/linux/netdevice.h
net/core/net-sysfs.c
net/core/rtnetlink.c

index 2f11836078ab5abf7f415642c3fe5db2e275b571..8bd3ed9058132627f053280194070a1367002483 100644 (file)
@@ -57,7 +57,8 @@ static int raw_eth_ioctl(struct net_device *dev, struct ifreq *ifr)
        const size_t size = sizeof(raw_hdlc_proto);
        raw_hdlc_proto new_settings;
        hdlc_device *hdlc = dev_to_hdlc(dev);
-       int result, old_qlen;
+       unsigned int old_qlen;
+       int result;
 
        switch (ifr->ifr_settings.type) {
        case IF_GET_PROTO:
index 3f39d27decf4d72e734734edec4403b00ca95657..0150b2dd3031d6514b783493bd698d2a375b3ab4 100644 (file)
@@ -1824,7 +1824,7 @@ struct net_device {
 #ifdef CONFIG_NET_SCHED
        DECLARE_HASHTABLE       (qdisc_hash, 4);
 #endif
-       unsigned long           tx_queue_len;
+       unsigned int            tx_queue_len;
        spinlock_t              tx_global_lock;
        int                     watchdog_timeo;
 
index 65ea0ff4017c166fea648f3ef3db57966f44aa66..58e6cc70500d7c68245a6bf7c3c345b59c57bbad 100644 (file)
@@ -323,7 +323,11 @@ NETDEVICE_SHOW_RW(flags, fmt_hex);
 
 static int change_tx_queue_len(struct net_device *dev, unsigned long new_len)
 {
-       int res, orig_len = dev->tx_queue_len;
+       unsigned int orig_len = dev->tx_queue_len;
+       int res;
+
+       if (new_len != (unsigned int)new_len)
+               return -ERANGE;
 
        if (new_len != orig_len) {
                dev->tx_queue_len = new_len;
@@ -349,7 +353,7 @@ static ssize_t tx_queue_len_store(struct device *dev,
 
        return netdev_store(dev, attr, buf, len, change_tx_queue_len);
 }
-NETDEVICE_SHOW_RW(tx_queue_len, fmt_ulong);
+NETDEVICE_SHOW_RW(tx_queue_len, fmt_dec);
 
 static int change_gro_flush_timeout(struct net_device *dev, unsigned long val)
 {
index d7f82c3450b124948db66b6191a67bfc9b817305..f759f22af0af21bd4f614f601dce13097388ba75 100644 (file)
@@ -2046,8 +2046,8 @@ static int do_setlink(const struct sk_buff *skb,
        }
 
        if (tb[IFLA_TXQLEN]) {
-               unsigned long value = nla_get_u32(tb[IFLA_TXQLEN]);
-               unsigned long orig_len = dev->tx_queue_len;
+               unsigned int value = nla_get_u32(tb[IFLA_TXQLEN]);
+               unsigned int orig_len = dev->tx_queue_len;
 
                if (dev->tx_queue_len ^ value) {
                        dev->tx_queue_len = value;