]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
Replace 2 jiffies with sysctl netdev_budget_usecs to enable softirq tuning
authorMatthew Whitehead <tedheadster@gmail.com>
Wed, 19 Apr 2017 16:37:10 +0000 (12:37 -0400)
committerDavid S. Miller <davem@davemloft.net>
Fri, 21 Apr 2017 17:22:34 +0000 (13:22 -0400)
Constants used for tuning are generally a bad idea, especially as hardware
changes over time. Replace the constant 2 jiffies with sysctl variable
netdev_budget_usecs to enable sysadmins to tune the softirq processing.
Also document the variable.

For example, a very fast machine might tune this to 1000 microseconds,
while my regression testing 486DX-25 needs it to be 4000 microseconds on
a nearly idle network to prevent time_squeeze from being incremented.

Version 2: changed jiffies to microseconds for predictable units.

Signed-off-by: Matthew Whitehead <tedheadster@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Documentation/sysctl/net.txt
include/linux/netdevice.h
include/uapi/linux/sysctl.h
kernel/sysctl_binary.c
net/core/dev.c
net/core/sysctl_net_core.c

index 2ebabc93014a2442824d2da7c79b28d53eaa4b41..14db18c970b1b048c0ecc50d75e10efb674715ca 100644 (file)
@@ -188,7 +188,16 @@ netdev_budget
 
 Maximum number of packets taken from all interfaces in one polling cycle (NAPI
 poll). In one polling cycle interfaces which are registered to polling are
-probed in a round-robin manner.
+probed in a round-robin manner. Also, a polling cycle may not exceed
+netdev_budget_usecs microseconds, even if netdev_budget has not been
+exhausted.
+
+netdev_budget_usecs
+---------------------
+
+Maximum number of microseconds in one NAPI polling cycle. Polling
+will exit when either netdev_budget_usecs have elapsed during the
+poll cycle or the number of packets processed reaches netdev_budget.
 
 netdev_max_backlog
 ------------------
index 0f3c38ce54171e1141ed4db3dd937066aedca5e5..c49cf21f2b3137524883bb31afe86bc1dadd5649 100644 (file)
@@ -3296,6 +3296,7 @@ static __always_inline int ____dev_forward_skb(struct net_device *dev,
 void dev_queue_xmit_nit(struct sk_buff *skb, struct net_device *dev);
 
 extern int             netdev_budget;
+extern unsigned int    netdev_budget_usecs;
 
 /* Called by rtnetlink.c:rtnl_unlock() */
 void netdev_run_todo(void);
index e13d48058b8d0e5cf36e458e68e257d73a9a1e8f..177f5f139b36997d7128be5932b6745cec15e6ce 100644 (file)
@@ -274,6 +274,7 @@ enum
        NET_CORE_AEVENT_ETIME=20,
        NET_CORE_AEVENT_RSEQTH=21,
        NET_CORE_WARNINGS=22,
+       NET_CORE_BUDGET_USECS=23,
 };
 
 /* /proc/sys/net/ethernet */
index ece4b177052baa8a2ba9a5aded7f9694594eb4e5..4ee3e49530d2e1d468fe04917cd824cf991f8d26 100644 (file)
@@ -197,6 +197,7 @@ static const struct bin_table bin_net_core_table[] = {
        { CTL_INT,      NET_CORE_AEVENT_ETIME,  "xfrm_aevent_etime" },
        { CTL_INT,      NET_CORE_AEVENT_RSEQTH, "xfrm_aevent_rseqth" },
        { CTL_INT,      NET_CORE_WARNINGS,      "warnings" },
+       { CTL_INT,      NET_CORE_BUDGET_USECS,  "netdev_budget_usecs" },
        {},
 };
 
index 5d33e2baab2bd210a7535c99fcce17de9b0d95aa..1c53c055b1971177f28fda2f4d3032d77cad25d4 100644 (file)
@@ -3441,6 +3441,7 @@ EXPORT_SYMBOL(netdev_max_backlog);
 
 int netdev_tstamp_prequeue __read_mostly = 1;
 int netdev_budget __read_mostly = 300;
+unsigned int __read_mostly netdev_budget_usecs = 2000;
 int weight_p __read_mostly = 64;           /* old backlog weight */
 int dev_weight_rx_bias __read_mostly = 1;  /* bias for backlog weight */
 int dev_weight_tx_bias __read_mostly = 1;  /* bias for output_queue quota */
@@ -5307,7 +5308,8 @@ out_unlock:
 static __latent_entropy void net_rx_action(struct softirq_action *h)
 {
        struct softnet_data *sd = this_cpu_ptr(&softnet_data);
-       unsigned long time_limit = jiffies + 2;
+       unsigned long time_limit = jiffies +
+               usecs_to_jiffies(netdev_budget_usecs);
        int budget = netdev_budget;
        LIST_HEAD(list);
        LIST_HEAD(repoll);
index 7f9cc400eca08c01c9014476aa4daf0852505b20..ea23254b2457cf15eeae495130dab437090f8e2e 100644 (file)
@@ -452,6 +452,14 @@ static struct ctl_table net_core_table[] = {
                .extra1         = &one,
                .extra2         = &max_skb_frags,
        },
+       {
+               .procname       = "netdev_budget_usecs",
+               .data           = &netdev_budget_usecs,
+               .maxlen         = sizeof(unsigned int),
+               .mode           = 0644,
+               .proc_handler   = proc_dointvec_minmax,
+               .extra1         = &zero,
+       },
        { }
 };