Skip to content

Commit 416ef9b

Browse files
Jakub Kicinskidavem330
authored andcommitted
net: sched: red: don't reset the backlog on every stat dump
Commit 0dfb33a ("sch_red: report backlog information") copied child's backlog into RED's backlog. Back then RED did not maintain its own backlog counts. This has changed after commit 2ccccf5 ("net_sched: update hierarchical backlog too") and commit d7f4f33 ("sch_red: update backlog as well"). Copying is no longer necessary. Tested: $ tc -s qdisc show dev veth0 qdisc red 1: root refcnt 2 limit 400000b min 30000b max 30000b ecn Sent 20942 bytes 221 pkt (dropped 0, overlimits 0 requeues 0) backlog 1260b 14p requeues 14 marked 0 early 0 pdrop 0 other 0 qdisc tbf 2: parent 1: rate 1Kbit burst 15000b lat 3585.0s Sent 20942 bytes 221 pkt (dropped 0, overlimits 138 requeues 0) backlog 1260b 14p requeues 14 Recently RED offload was added. We need to make sure drivers don't depend on resetting the stats. This means backlog should be treated like any other statistic: total_stat = new_hw_stat - prev_hw_stat; Adjust mlxsw. Signed-off-by: Jakub Kicinski <[email protected]> Acked-by: Nogah Frankel <[email protected]> Acked-by: Jiri Pirko <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 2d83619 commit 416ef9b

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@ mlxsw_sp_setup_tc_qdisc_red_clean_stats(struct mlxsw_sp_port *mlxsw_sp_port,
247247

248248
stats_base->overlimits = red_base->prob_drop + red_base->prob_mark;
249249
stats_base->drops = red_base->prob_drop + red_base->pdrop;
250+
251+
stats_base->backlog = 0;
250252
}
251253

252254
static int
@@ -306,6 +308,19 @@ mlxsw_sp_qdisc_red_replace(struct mlxsw_sp_port *mlxsw_sp_port,
306308
max, prob, p->is_ecn);
307309
}
308310

311+
static void
312+
mlxsw_sp_qdisc_red_unoffload(struct mlxsw_sp_port *mlxsw_sp_port,
313+
struct mlxsw_sp_qdisc *mlxsw_sp_qdisc,
314+
void *params)
315+
{
316+
struct tc_red_qopt_offload_params *p = params;
317+
u64 backlog;
318+
319+
backlog = mlxsw_sp_cells_bytes(mlxsw_sp_port->mlxsw_sp,
320+
mlxsw_sp_qdisc->stats_base.backlog);
321+
p->qstats->backlog -= backlog;
322+
}
323+
309324
static int
310325
mlxsw_sp_qdisc_get_red_xstats(struct mlxsw_sp_port *mlxsw_sp_port,
311326
struct mlxsw_sp_qdisc *mlxsw_sp_qdisc,
@@ -338,7 +353,7 @@ mlxsw_sp_qdisc_get_red_stats(struct mlxsw_sp_port *mlxsw_sp_port,
338353
struct mlxsw_sp_qdisc *mlxsw_sp_qdisc,
339354
struct tc_qopt_offload_stats *stats_ptr)
340355
{
341-
u64 tx_bytes, tx_packets, overlimits, drops;
356+
u64 tx_bytes, tx_packets, overlimits, drops, backlog;
342357
u8 tclass_num = mlxsw_sp_qdisc->tclass_num;
343358
struct mlxsw_sp_qdisc_stats *stats_base;
344359
struct mlxsw_sp_port_xstats *xstats;
@@ -354,14 +369,18 @@ mlxsw_sp_qdisc_get_red_stats(struct mlxsw_sp_port *mlxsw_sp_port,
354369
stats_base->overlimits;
355370
drops = xstats->wred_drop[tclass_num] + xstats->tail_drop[tclass_num] -
356371
stats_base->drops;
372+
backlog = xstats->backlog[tclass_num];
357373

358374
_bstats_update(stats_ptr->bstats, tx_bytes, tx_packets);
359375
stats_ptr->qstats->overlimits += overlimits;
360376
stats_ptr->qstats->drops += drops;
361377
stats_ptr->qstats->backlog +=
362-
mlxsw_sp_cells_bytes(mlxsw_sp_port->mlxsw_sp,
363-
xstats->backlog[tclass_num]);
378+
mlxsw_sp_cells_bytes(mlxsw_sp_port->mlxsw_sp,
379+
backlog) -
380+
mlxsw_sp_cells_bytes(mlxsw_sp_port->mlxsw_sp,
381+
stats_base->backlog);
364382

383+
stats_base->backlog = backlog;
365384
stats_base->drops += drops;
366385
stats_base->overlimits += overlimits;
367386
stats_base->tx_bytes += tx_bytes;
@@ -375,6 +394,7 @@ static struct mlxsw_sp_qdisc_ops mlxsw_sp_qdisc_ops_red = {
375394
.type = MLXSW_SP_QDISC_RED,
376395
.check_params = mlxsw_sp_qdisc_red_check_params,
377396
.replace = mlxsw_sp_qdisc_red_replace,
397+
.unoffload = mlxsw_sp_qdisc_red_unoffload,
378398
.destroy = mlxsw_sp_qdisc_red_destroy,
379399
.get_stats = mlxsw_sp_qdisc_get_red_stats,
380400
.get_xstats = mlxsw_sp_qdisc_get_red_xstats,

include/net/pkt_cls.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,7 @@ struct tc_red_qopt_offload_params {
748748
u32 max;
749749
u32 probability;
750750
bool is_ecn;
751+
struct gnet_stats_queue *qstats;
751752
};
752753

753754
struct tc_red_qopt_offload {

net/sched/sch_red.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ static int red_offload(struct Qdisc *sch, bool enable)
167167
opt.set.max = q->parms.qth_max >> q->parms.Wlog;
168168
opt.set.probability = q->parms.max_P;
169169
opt.set.is_ecn = red_use_ecn(q);
170+
opt.set.qstats = &sch->qstats;
170171
} else {
171172
opt.command = TC_RED_DESTROY;
172173
}
@@ -322,7 +323,6 @@ static int red_dump(struct Qdisc *sch, struct sk_buff *skb)
322323
};
323324
int err;
324325

325-
sch->qstats.backlog = q->qdisc->qstats.backlog;
326326
err = red_dump_offload_stats(sch, &opt);
327327
if (err)
328328
goto nla_put_failure;

0 commit comments

Comments
 (0)