Skip to content

Commit 526f5fb

Browse files
edumazetkuba-moo
authored andcommitted
net: sched: claim one cache line in Qdisc
Replace state2 field with a boolean. Move it to a hole between qstats and state so that we shrink Qdisc by a full cache line. Signed-off-by: Eric Dumazet <[email protected]> Reviewed-by: Kuniyuki Iwashima <[email protected]> Reviewed-by: Toke Høiland-Jørgensen <[email protected]> Tested-by: Jamal Hadi Salim <[email protected]> Acked-by: Jamal Hadi Salim <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 178ca30 commit 526f5fb

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

include/net/sch_generic.h

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,6 @@ enum qdisc_state_t {
4141
__QDISC_STATE_DRAINING,
4242
};
4343

44-
enum qdisc_state2_t {
45-
/* Only for !TCQ_F_NOLOCK qdisc. Never access it directly.
46-
* Use qdisc_run_begin/end() or qdisc_is_running() instead.
47-
*/
48-
__QDISC_STATE2_RUNNING,
49-
};
50-
5144
#define QDISC_STATE_MISSED BIT(__QDISC_STATE_MISSED)
5245
#define QDISC_STATE_DRAINING BIT(__QDISC_STATE_DRAINING)
5346

@@ -117,8 +110,8 @@ struct Qdisc {
117110
struct qdisc_skb_head q;
118111
struct gnet_stats_basic_sync bstats;
119112
struct gnet_stats_queue qstats;
113+
bool running; /* must be written under qdisc spinlock */
120114
unsigned long state;
121-
unsigned long state2; /* must be written under qdisc spinlock */
122115
struct Qdisc *next_sched;
123116
struct sk_buff_head skb_bad_txq;
124117

@@ -167,7 +160,7 @@ static inline bool qdisc_is_running(struct Qdisc *qdisc)
167160
{
168161
if (qdisc->flags & TCQ_F_NOLOCK)
169162
return spin_is_locked(&qdisc->seqlock);
170-
return test_bit(__QDISC_STATE2_RUNNING, &qdisc->state2);
163+
return READ_ONCE(qdisc->running);
171164
}
172165

173166
static inline bool nolock_qdisc_is_empty(const struct Qdisc *qdisc)
@@ -210,7 +203,10 @@ static inline bool qdisc_run_begin(struct Qdisc *qdisc)
210203
*/
211204
return spin_trylock(&qdisc->seqlock);
212205
}
213-
return !__test_and_set_bit(__QDISC_STATE2_RUNNING, &qdisc->state2);
206+
if (READ_ONCE(qdisc->running))
207+
return false;
208+
WRITE_ONCE(qdisc->running, true);
209+
return true;
214210
}
215211

216212
static inline void qdisc_run_end(struct Qdisc *qdisc)
@@ -228,7 +224,7 @@ static inline void qdisc_run_end(struct Qdisc *qdisc)
228224
&qdisc->state)))
229225
__netif_schedule(qdisc);
230226
} else {
231-
__clear_bit(__QDISC_STATE2_RUNNING, &qdisc->state2);
227+
WRITE_ONCE(qdisc->running, false);
232228
}
233229
}
234230

0 commit comments

Comments
 (0)