aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/sch_generic.h
diff options
context:
space:
mode:
authorEric Dumazet <eric.dumazet@gmail.com>2011-01-20 00:27:16 -0500
committerDavid S. Miller <davem@davemloft.net>2011-01-20 19:59:32 -0500
commitfd245a4adb5288eac37250875f237c40a20a1944 (patch)
tree1c16670c53dab9d9d05b26a7e7ae8a6a8267e847 /include/net/sch_generic.h
parent817fb15dfd988d8dda916ee04fa506f0c466b9d6 (diff)
net_sched: move TCQ_F_THROTTLED flag
In commit 371121057607e (net: QDISC_STATE_RUNNING dont need atomic bit ops) I moved QDISC_STATE_RUNNING flag to __state container, located in the cache line containing qdisc lock and often dirtied fields. I now move TCQ_F_THROTTLED bit too, so that we let first cache line read mostly, and shared by all cpus. This should speedup HTB/CBQ for example. Not using test_bit()/__clear_bit()/__test_and_set_bit allows to use an "unsigned int" for __state container, reducing by 8 bytes Qdisc size. Introduce helpers to hide implementation details. Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> CC: Patrick McHardy <kaber@trash.net> CC: Jesper Dangaard Brouer <hawk@diku.dk> CC: Jarek Poplawski <jarkao2@gmail.com> CC: Jamal Hadi Salim <hadi@cyberus.ca> CC: Stephen Hemminger <shemminger@vyatta.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/sch_generic.h')
-rw-r--r--include/net/sch_generic.h38
1 files changed, 28 insertions, 10 deletions
diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
index e9eee99d8b1f..f6345f55041c 100644
--- a/include/net/sch_generic.h
+++ b/include/net/sch_generic.h
@@ -31,7 +31,8 @@ enum qdisc_state_t {
31 * following bits are only changed while qdisc lock is held 31 * following bits are only changed while qdisc lock is held
32 */ 32 */
33enum qdisc___state_t { 33enum qdisc___state_t {
34 __QDISC___STATE_RUNNING, 34 __QDISC___STATE_RUNNING = 1,
35 __QDISC___STATE_THROTTLED = 2,
35}; 36};
36 37
37struct qdisc_size_table { 38struct qdisc_size_table {
@@ -46,10 +47,9 @@ struct Qdisc {
46 struct sk_buff * (*dequeue)(struct Qdisc *dev); 47 struct sk_buff * (*dequeue)(struct Qdisc *dev);
47 unsigned flags; 48 unsigned flags;
48#define TCQ_F_BUILTIN 1 49#define TCQ_F_BUILTIN 1
49#define TCQ_F_THROTTLED 2 50#define TCQ_F_INGRESS 2
50#define TCQ_F_INGRESS 4 51#define TCQ_F_CAN_BYPASS 4
51#define TCQ_F_CAN_BYPASS 8 52#define TCQ_F_MQROOT 8
52#define TCQ_F_MQROOT 16
53#define TCQ_F_WARN_NONWC (1 << 16) 53#define TCQ_F_WARN_NONWC (1 << 16)
54 int padded; 54 int padded;
55 struct Qdisc_ops *ops; 55 struct Qdisc_ops *ops;
@@ -78,25 +78,43 @@ struct Qdisc {
78 unsigned long state; 78 unsigned long state;
79 struct sk_buff_head q; 79 struct sk_buff_head q;
80 struct gnet_stats_basic_packed bstats; 80 struct gnet_stats_basic_packed bstats;
81 unsigned long __state; 81 unsigned int __state;
82 struct gnet_stats_queue qstats; 82 struct gnet_stats_queue qstats;
83 struct rcu_head rcu_head; 83 struct rcu_head rcu_head;
84 spinlock_t busylock; 84 spinlock_t busylock;
85}; 85};
86 86
87static inline bool qdisc_is_running(struct Qdisc *qdisc) 87static inline bool qdisc_is_running(const struct Qdisc *qdisc)
88{ 88{
89 return test_bit(__QDISC___STATE_RUNNING, &qdisc->__state); 89 return (qdisc->__state & __QDISC___STATE_RUNNING) ? true : false;
90} 90}
91 91
92static inline bool qdisc_run_begin(struct Qdisc *qdisc) 92static inline bool qdisc_run_begin(struct Qdisc *qdisc)
93{ 93{
94 return !__test_and_set_bit(__QDISC___STATE_RUNNING, &qdisc->__state); 94 if (qdisc_is_running(qdisc))
95 return false;
96 qdisc->__state |= __QDISC___STATE_RUNNING;
97 return true;
95} 98}
96 99
97static inline void qdisc_run_end(struct Qdisc *qdisc) 100static inline void qdisc_run_end(struct Qdisc *qdisc)
98{ 101{
99 __clear_bit(__QDISC___STATE_RUNNING, &qdisc->__state); 102 qdisc->__state &= ~__QDISC___STATE_RUNNING;
103}
104
105static inline bool qdisc_is_throttled(const struct Qdisc *qdisc)
106{
107 return (qdisc->__state & __QDISC___STATE_THROTTLED) ? true : false;
108}
109
110static inline void qdisc_throttled(struct Qdisc *qdisc)
111{
112 qdisc->__state |= __QDISC___STATE_THROTTLED;
113}
114
115static inline void qdisc_unthrottled(struct Qdisc *qdisc)
116{
117 qdisc->__state &= ~__QDISC___STATE_THROTTLED;
100} 118}
101 119
102struct Qdisc_class_ops { 120struct Qdisc_class_ops {