qdisc: allow setting default queuing discipline
Subsystems (4)
PATCH 1/1 qdisc: allow setting default queuing discipline
By default, the pfifo_fast queue discipline has been used by default for all devices. But we have better choices now.
This patch allow setting the default queueing discipline with sysctl. This allows easy use of better queueing disciplines on all devices without having to use tc qdisc scripts. It is intended to allow an easy path for distributions to make fq_codel or sfq the default qdisc.
This patch also makes pfifo_fast more of a first class qdisc, since it is now possible to manually override the default and explicitly use pfifo_fast. The behavior for systems who do not use the sysctl is unchanged, they still get pfifo_fast
Also removes leftover random # in sysctl net core.
--- Documentation/sysctl/net.txt | 13 +++++++++ include/net/pkt_sched.h | 3 ++ include/net/sch_generic.h | 1 net/core/sysctl_net_core.c | 30 +++++++++++++++++++++- net/sched/sch_api.c | 58 +++++++++++++++++++++++++++++++++++++++++++ net/sched/sch_generic.c | 11 ++++---- net/sched/sch_mq.c | 2 - net/sched/sch_mqprio.c | 2 - 8 files changed, 112 insertions(+), 8 deletions(-)
net/core/sysctl_net_core.c +29 -1
@@ -20,6 +20,7 @@#include <net/sock.h> #include <net/net_ratelimit.h> #include <net/busy_poll.h> +#include <net/pkt_sched.h> static int zero =0 ;static int one =1 ;
@@ -193,6 +194,26 @@ static int flow_limit_table_len_sysctl(s }#endif /* CONFIG_NET_FLOW_LIMIT */ +#ifdef CONFIG_NET_SCHED +static int set_default_qdisc (struct ctl_table *table,int write, +void __user *buffer,size_t *lenp,loff_t *ppos) +{ +char id[IFNAMSIZ ]; +struct ctl_table tbl = { + .data = id, + .maxlen =IFNAMSIZ , + }; +int ret; + +qdisc_get_default (id,IFNAMSIZ ); + + ret =proc_dostring (&tbl, write, buffer, lenp, ppos); +if (write && ret ==0 ) + ret =qdisc_set_default (id); +return ret; +} +#endif + static struct ctl_table net_core_table[] = {#ifdef CONFIG_NET {
@@ -315,7 +336,14 @@ static struct ctl_table net_core_table[] .mode = 0644, .proc_handler = proc_dointvec }, -# +#endif +#ifdef CONFIG_NET_SCHED + { + .procname = "default_qdisc", + .mode = 0644, + .maxlen = IFNAMSIZ, + .proc_handler = set_default_qdisc + }, #endif #endif /* CONFIG_NET */ {
include/net/pkt_sched.h +3 -0
@@ -85,6 +85,9 @@ struct Qdisc *fifo_create_dflt(struct Qdint register_qdisc (struct Qdisc_ops *qops);int unregister_qdisc (struct Qdisc_ops *qops); +void qdisc_get_default (char *id,size_t len); +int qdisc_set_default (const char *id); +void qdisc_list_del (struct Qdisc *q);struct Qdisc *qdisc_lookup (struct net_device *dev,u32 handle);struct Qdisc *qdisc_lookup_class (struct net_device *dev,u32 handle);
include/net/sch_generic.h +1 -0
@@ -316,6 +316,7 @@ extern struct Qdisc noop_qdisc;extern struct Qdisc_ops noop_qdisc_ops;extern struct Qdisc_ops pfifo_fast_ops;extern struct Qdisc_ops mq_qdisc_ops; +extern const struct Qdisc_ops *default_qdisc_ops;struct Qdisc_class_common {u32 classid;
net/sched/sch_api.c +58 -0
76 lines not on this page · raw message
net/sched/sch_generic.c +6 -5
@@ -530,7 +530,6 @@ struct Qdisc_ops pfifo_fast_ops __read_m .dump = pfifo_fast_dump, .owner = THIS_MODULE, }; -EXPORT_SYMBOL (pfifo_fast_ops);static struct lock_class_key qdisc_tx_busylock;
@@ -584,6 +583,9 @@ struct Qdisc *qdisc_create_dflt(struct n {struct Qdisc *sch; +if (!try_module_get (ops->owner)) + goto errout; + sch =qdisc_alloc (dev_queue, ops);if (IS_ERR (sch)) goto errout;
@@ -687,7 +689,7 @@ static void attach_one_default_qdisc(strif (dev->tx_queue_len) { qdisc =qdisc_create_dflt (dev_queue, - &pfifo_fast_ops,TC_H_ROOT ); + default_qdisc_ops,TC_H_ROOT );if (!qdisc) {netdev_info (dev,"activation failed\n" );return ;
@@ -740,9 +742,8 @@ void dev_activate(struct net_device *devint need_watchdog;/* No queueing discipline is attached to device; -create default one i.e. pfifo_fast for devices, -which need queueing and noqueue_qdisc for -virtual interfaces +* create default one for devices, which need queueing +* and noqueue_qdisc for virtual interfaces */ if (dev->qdisc == &noop_qdisc)
net/sched/sch_mq.c +1 -1
@@ -57,7 +57,7 @@ static int mq_init(struct Qdisc *sch, stfor (ntx =0 ; ntx < dev->num_tx_queues; ntx++) { dev_queue =netdev_get_tx_queue (dev, ntx); - qdisc =qdisc_create_dflt (dev_queue, &pfifo_fast_ops, + qdisc =qdisc_create_dflt (dev_queue, default_qdisc_ops,TC_H_MAKE (TC_H_MAJ (sch->handle),TC_H_MIN (ntx +1 )));if (qdisc ==NULL )
net/sched/sch_mqprio.c +1 -1
@@ -124,7 +124,7 @@ static int mqprio_init(struct Qdisc *schfor (i =0 ; i < dev->num_tx_queues; i++) { dev_queue =netdev_get_tx_queue (dev, i); - qdisc =qdisc_create_dflt (dev_queue, &pfifo_fast_ops, + qdisc =qdisc_create_dflt (dev_queue, default_qdisc_ops,TC_H_MAKE (TC_H_MAJ (sch->handle),TC_H_MIN (i +1 )));if (qdisc ==NULL ) {
Documentation/sysctl/net.txt +13 -0
@@ -50,6 +50,19 @@ The maximum number of packets that kerne it's a Per-CPU variable. Default: 64 +default_qdisc +-------------- + +The default queuing discipline to use for network devices. This allows +overriding the default queue discipline of pfifo_fast with an +alternative. Since the default queuing discipline is created with the +no additional parameters so is best suited to queuing disciplines that +work well without configuration like stochastic fair queue (sfq), +CoDel (codel) or fair queue CoDel (fq_codel). Dont' use queuing disciplines +like Hierarchical Token Bucket or Deficit Round Robin which require setting +up classes and bandwidths. +Default: pfifo_fast + busy_read ---------------- Low latency busy poll timeout for socket reads. (needs CONFIG_NET_RX_BUSY_POLL)
Quoted 9 lines · Stephen Hemminger
By default, the
pfifo_fastqueue discipline has been used by default for all devices. But we have better choices now.This patch allow setting the default queueing discipline with sysctl. This allows easy use of better queueing disciplines on all devices without having to use tc qdisc scripts. It is intended to allow an easy path for distributions to make
fq_codelor sfq the default qdisc.
Quoted 8 lines
This patch also makes
pfifo_fastmore of a first class qdisc, since it is now possible to manually override the default and explicitly usepfifo_fast. The behavior for systems who do not use the sysctl is unchanged, they still getpfifo_fastAlso removes leftover random # in sysctl net core.
+CoDel (codel) or fair queue CoDel (
fq_codel). Dont' use queuing disciplines
nit: Don't has typo above....
Thanks,
Ben
Signature · 2 lines
Ben Greear <[email protected]> Candela Technologies Inc http://www.candelatech.com
David Miller
maintainerFrom: Ben Greear <[email protected]>
Date: Tue, 27 Aug 2013 16:22:52 -0700
Quoted 5 lines · Stephen Hemminger
Quoted 2 lines
+CoDel (codel) or fair queue CoDel (
fq_codel). Dont' use queuing disciplinesnit: Don't has typo above....
I fixed this when I commited Stephen's patch, thanks.
Quoted 14 lines · Stephen Hemminger
By default, the
pfifo_fastqueue discipline has been used by default for all devices. But we have better choices now.This patch allow setting the default queueing discipline with sysctl. This allows easy use of better queueing disciplines on all devices without having to use tc qdisc scripts. It is intended to allow an easy path for distributions to make
fq_codelor sfq the default qdisc.This patch also makes
pfifo_fastmore of a first class qdisc, since it is now possible to manually override the default and explicitly usepfifo_fast. The behavior for systems who do not use the sysctl is unchanged, they still getpfifo_fast
Quoted 5 lines
Also removes leftover random # in sysctl net core.
Signed-off-by Stephen Hemminger <[email protected]>---
I find this quite incredible, because I was going to write such patch tonight ;)
Now I can just relax, thanks so much Stephen !
Quoted 19 lines · Eric Dumazet
Quoted 18 lines · Stephen Hemminger
By default, the
pfifo_fastqueue discipline has been used by default for all devices. But we have better choices now.This patch allow setting the default queueing discipline with sysctl. This allows easy use of better queueing disciplines on all devices without having to use tc qdisc scripts. It is intended to allow an easy path for distributions to make
fq_codelor sfq the default qdisc.This patch also makes
pfifo_fastmore of a first class qdisc, since it is now possible to manually override the default and explicitly usepfifo_fast. The behavior for systems who do not use the sysctl is unchanged, they still getpfifo_fastAlso removes leftover random # in sysctl net core.
Signed-off-by Stephen Hemminger <[email protected]>
Quoted 9 lines
Quoted 1 line
---
I find this quite incredible, because I was going to write such patch tonight ;)
Now I can just relax, thanks so much Stephen !
Acked-by Eric Dumazet <[email protected]>
I was wondering if we also could redefine the pfifo default, used for example in HTB classes.
ie calls to qdisc_create_dflt( ... &pfifo_qdisc_ops )
/proc/sys/net/core/default_qdisc would 'define' the default pfifo_fast,
/proc/sys/net/core/default_pfifo_qdisc would 'define' the default pfifo,
Or something like that...
Quoted 33 lines · On Tue, 27 Aug 2013 21:57:50 -0700 Eric Dumazet <[email protected]> wrote:
Quoted 19 lines · Eric Dumazet
Quoted 18 lines · Stephen Hemminger
By default, the
pfifo_fastqueue discipline has been used by default for all devices. But we have better choices now.This patch allow setting the default queueing discipline with sysctl. This allows easy use of better queueing disciplines on all devices without having to use tc qdisc scripts. It is intended to allow an easy path for distributions to make
fq_codelor sfq the default qdisc.This patch also makes
pfifo_fastmore of a first class qdisc, since it is now possible to manually override the default and explicitly usepfifo_fast. The behavior for systems who do not use the sysctl is unchanged, they still getpfifo_fastAlso removes leftover random # in sysctl net core.
Signed-off-by Stephen Hemminger <[email protected]>Quoted 9 lines
Quoted 1 line
---
I find this quite incredible, because I was going to write such patch tonight ;)
Now I can just relax, thanks so much Stephen !
Acked-by Eric Dumazet <[email protected]>I was wondering if we also could redefine the pfifo default, used for example in HTB classes.
Quoted 7 lines
ie calls to qdisc_create_dflt( ...
&pfifo_qdisc_ops)
/proc/sys/net/core/default_qdiscwould 'define' the defaultpfifo_fast,
/proc/sys/net/core/default_pfifo_qdiscwould 'define' the default pfifo,Or something like that...
Although your idea adds completeness, not sure if it is worth it. The thing is if user is using HTB, they already are using tc commands to set it up, therefore the additional script steps to choose some other qdisc for the leaf nodes doesn't seem like a burden. Therefore the sysctl doesn't help much and might even create more confusion because there is now two places to update.
Quoted 6 lines · Stephen Hemminger
Although your idea adds completeness, not sure if it is worth it. The thing is if user is using HTB, they already are using tc commands to set it up, therefore the additional script steps to choose some other qdisc for the leaf nodes doesn't seem like a burden. Therefore the sysctl doesn't help much and might even create more confusion because there is now two places to update.
Well, I need such a facility because I cannot change HTB setup.
I can boot a new kernel, yet not really change user scripts, especially when tc setup is actually not a script, but a complex binary doing constant changes in a complex and dynamic HTB hierarchy.
Quoted 9 lines · On Wed, 28 Aug 2013 10:20:53 -0700 Eric Dumazet <[email protected]> wrote:
Quoted 6 lines · Stephen Hemminger
Although your idea adds completeness, not sure if it is worth it. The thing is if user is using HTB, they already are using tc commands to set it up, therefore the additional script steps to choose some other qdisc for the leaf nodes doesn't seem like a burden. Therefore the sysctl doesn't help much and might even create more confusion because there is now two places to update.
Quoted 8 lines
Well, I need such a facility because I cannot change HTB setup.
I can boot a new kernel, yet not really change user scripts, especially when tc setup is actually not a script, but a complex binary doing constant changes in a complex and dynamic HTB hierarchy.
Hate to say it but maybe module parameter to htb would be an alternative if you have to deal with that.
Quoted 3 lines · Stephen Hemminger
Hate to say it but maybe module parameter to htb would be an alternative if you have to deal with that.
Fair enough ;)
Anyway, it turned out all I needed was the MQ change ;)
From: Stephen Hemminger <[email protected]>
Date: Tue, 27 Aug 2013 16:19:08 -0700
Quoted 9 lines
By default, the
pfifo_fastqueue discipline has been used by default for all devices. But we have better choices now.This patch allow setting the default queueing discipline with sysctl. This allows easy use of better queueing disciplines on all devices without having to use tc qdisc scripts. It is intended to allow an easy path for distributions to make
fq_codelor sfq the default qdisc.
Quoted 8 lines
This patch also makes
pfifo_fastmore of a first class qdisc, since it is now possible to manually override the default and explicitly usepfifo_fast. The behavior for systems who do not use the sysctl is unchanged, they still getpfifo_fastAlso removes leftover random # in sysctl net core.
Signed-off-by Stephen Hemminger <[email protected]>
Applied, thanks Stpehen.