From: "Toke Høiland-Jørgensen" <toke@toke.dk>
To: cake@lists.bufferbloat.net
Cc: "Toke Høiland-Jørgensen" <toke@toke.dk>
Subject: [Cake] [PATCH v3] Split tin stats to its own structure to decrease size of tc_cake_xstats
Date: Sun, 11 Feb 2018 18:26:17 +0100 [thread overview]
Message-ID: <20180211172618.13297-1-toke@toke.dk> (raw)
In-Reply-To: <20180127130542.25817-1-toke@toke.dk>
This splits out the tin stats from tc_cake_xstats, which seems like the
least intrusive way of decreasing the size of the stats structure. This
way, we can send only the statistics corresponding to the actual number of
allocated tins, rather than having the xstats structure always be allocated
for the full number of tins.
Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk>
---
Updated in v3:
- Keep the version field in place in the xstats structure, and set it to
a value higher than 0xFF, which will make old versions of tc ignore
it. This means old versions of tc simply won't print statistics,
rather than print garbled statistics because the struct layout is
wrong.
- Actually tested the code :)
pkt_sched.h | 52 +++++++++++++++++++++++++++++-----------------------
sch_cake.c | 58 +++++++++++++++++++++++++++++++---------------------------
2 files changed, 60 insertions(+), 50 deletions(-)
diff --git a/pkt_sched.h b/pkt_sched.h
index ed7c111..3a86d60 100644
--- a/pkt_sched.h
+++ b/pkt_sched.h
@@ -964,33 +964,39 @@ struct tc_cake_traffic_stats {
};
#define TC_CAKE_MAX_TINS (8)
-struct tc_cake_xstats {
- __u16 version; /* == 5, increments when struct extended */
- __u8 max_tins; /* == TC_CAKE_MAX_TINS */
- __u8 tin_cnt; /* <= TC_CAKE_MAX_TINS */
+struct tc_cake_tin_stats {
+
+ __u32 threshold_rate;
+ __u32 target_us;
+ struct tc_cake_traffic_stats sent;
+ struct tc_cake_traffic_stats dropped;
+ struct tc_cake_traffic_stats ecn_marked;
+ struct tc_cake_traffic_stats backlog;
+ __u32 interval_us;
+ __u32 way_indirect_hits;
+ __u32 way_misses;
+ __u32 way_collisions;
+ __u32 peak_delay_us; /* ~= bulk flow delay */
+ __u32 avge_delay_us;
+ __u32 base_delay_us; /* ~= sparse flows delay */
+ __u16 sparse_flows;
+ __u16 bulk_flows;
+ __u16 unresponse_flows; /* v4 - was u32 last_len */
+ __u16 spare; /* v4 - split last_len */
+ __u32 max_skblen;
+ struct tc_cake_traffic_stats ack_drops; /* v5 */
+};
- __u32 threshold_rate[TC_CAKE_MAX_TINS];
- __u32 target_us[TC_CAKE_MAX_TINS];
- struct tc_cake_traffic_stats sent[TC_CAKE_MAX_TINS];
- struct tc_cake_traffic_stats dropped[TC_CAKE_MAX_TINS];
- struct tc_cake_traffic_stats ecn_marked[TC_CAKE_MAX_TINS];
- struct tc_cake_traffic_stats backlog[TC_CAKE_MAX_TINS];
- __u32 interval_us[TC_CAKE_MAX_TINS];
- __u32 way_indirect_hits[TC_CAKE_MAX_TINS];
- __u32 way_misses[TC_CAKE_MAX_TINS];
- __u32 way_collisions[TC_CAKE_MAX_TINS];
- __u32 peak_delay_us[TC_CAKE_MAX_TINS]; /* ~= bulk flow delay */
- __u32 avge_delay_us[TC_CAKE_MAX_TINS];
- __u32 base_delay_us[TC_CAKE_MAX_TINS]; /* ~= sparse flows delay */
- __u16 sparse_flows[TC_CAKE_MAX_TINS];
- __u16 bulk_flows[TC_CAKE_MAX_TINS];
- __u16 unresponse_flows[TC_CAKE_MAX_TINS]; /* v4 - was u32 last_len */
- __u16 spare[TC_CAKE_MAX_TINS]; /* v4 - split last_len */
- __u32 max_skblen[TC_CAKE_MAX_TINS];
+struct tc_cake_xstats {
+ __u16 version;
+ __u16 tin_stats_size; /* == sizeof(struct tc_cake_tin_stats) */
__u32 capacity_estimate; /* version 2 */
__u32 memory_limit; /* version 3 */
__u32 memory_used; /* version 3 */
- struct tc_cake_traffic_stats ack_drops[TC_CAKE_MAX_TINS]; /* v5 */
+ __u8 tin_cnt; /* <= TC_CAKE_MAX_TINS */
+
+ struct tc_cake_tin_stats tin_stats[0]; /* keep last */
};
+
#endif
diff --git a/sch_cake.c b/sch_cake.c
index 7f6ff8e..62b67e7 100644
--- a/sch_cake.c
+++ b/sch_cake.c
@@ -2478,51 +2478,55 @@ nla_put_failure:
static int cake_dump_stats(struct Qdisc *sch, struct gnet_dump *d)
{
struct cake_sched_data *q = qdisc_priv(sch);
- struct tc_cake_xstats *st = kvzalloc(sizeof(*st), GFP_KERNEL);
+ struct tc_cake_xstats *st;
+ size_t size = sizeof(*st) + sizeof(struct tc_cake_tin_stats) * q->tin_cnt;
int i;
+ st = kvzalloc(size, GFP_KERNEL);
+
if (!st)
return -ENOMEM;
- st->version = 5;
- st->max_tins = TC_CAKE_MAX_TINS;
+ st->version = 0xFF + 1; /* old userspace code discards versions > 0xFF */
+ st->tin_stats_size = sizeof(struct tc_cake_tin_stats);
st->tin_cnt = q->tin_cnt;
for (i = 0; i < q->tin_cnt; i++) {
struct cake_tin_data *b = &q->tins[q->tin_order[i]];
+ struct tc_cake_tin_stats *tstat = &st->tin_stats[i];
- st->threshold_rate[i] = b->tin_rate_bps;
- st->target_us[i] = cobalt_time_to_us(b->cparams.target);
- st->interval_us[i] = cobalt_time_to_us(b->cparams.interval);
+ tstat->threshold_rate = b->tin_rate_bps;
+ tstat->target_us = cobalt_time_to_us(b->cparams.target);
+ tstat->interval_us = cobalt_time_to_us(b->cparams.interval);
/* TODO FIXME: add missing aspects of these composite stats */
- st->sent[i].packets = b->packets;
- st->sent[i].bytes = b->bytes;
- st->dropped[i].packets = b->tin_dropped;
- st->ecn_marked[i].packets = b->tin_ecn_mark;
- st->backlog[i].bytes = b->tin_backlog;
- st->ack_drops[i].packets = b->ack_drops;
-
- st->peak_delay_us[i] = cobalt_time_to_us(b->peak_delay);
- st->avge_delay_us[i] = cobalt_time_to_us(b->avge_delay);
- st->base_delay_us[i] = cobalt_time_to_us(b->base_delay);
-
- st->way_indirect_hits[i] = b->way_hits;
- st->way_misses[i] = b->way_misses;
- st->way_collisions[i] = b->way_collisions;
-
- st->sparse_flows[i] = b->sparse_flow_count +
+ tstat->sent.packets = b->packets;
+ tstat->sent.bytes = b->bytes;
+ tstat->dropped.packets = b->tin_dropped;
+ tstat->ecn_marked.packets = b->tin_ecn_mark;
+ tstat->backlog.bytes = b->tin_backlog;
+ tstat->ack_drops.packets = b->ack_drops;
+
+ tstat->peak_delay_us = cobalt_time_to_us(b->peak_delay);
+ tstat->avge_delay_us = cobalt_time_to_us(b->avge_delay);
+ tstat->base_delay_us = cobalt_time_to_us(b->base_delay);
+
+ tstat->way_indirect_hits = b->way_hits;
+ tstat->way_misses = b->way_misses;
+ tstat->way_collisions = b->way_collisions;
+
+ tstat->sparse_flows = b->sparse_flow_count +
b->decaying_flow_count;
- st->bulk_flows[i] = b->bulk_flow_count;
- st->unresponse_flows[i] = b->unresponsive_flow_count;
- st->spare[i] = 0;
- st->max_skblen[i] = b->max_skblen;
+ tstat->bulk_flows = b->bulk_flow_count;
+ tstat->unresponse_flows = b->unresponsive_flow_count;
+ tstat->spare = 0;
+ tstat->max_skblen = b->max_skblen;
}
st->capacity_estimate = q->avg_peak_bandwidth;
st->memory_limit = q->buffer_limit;
st->memory_used = q->buffer_max_used;
- i = gnet_stats_copy_app(d, st, sizeof(*st));
+ i = gnet_stats_copy_app(d, st, size);
cake_free(st);
return i;
}
--
2.16.1
next prev parent reply other threads:[~2018-02-11 17:27 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-26 15:08 [Cake] [PATCH] " Toke Høiland-Jørgensen
2017-12-26 16:28 ` Dave Taht
2017-12-26 16:32 ` Toke Høiland-Jørgensen
2018-01-27 13:05 ` [Cake] [PATCH v2] " Toke Høiland-Jørgensen
2018-02-09 12:58 ` Jonathan Morton
2018-02-09 13:08 ` Toke Høiland-Jørgensen
2018-02-11 17:26 ` Toke Høiland-Jørgensen [this message]
2018-02-11 17:26 ` [Cake] [PATCH] q_cake: Update xstats format to use per-tin structure Toke Høiland-Jørgensen
2018-03-01 11:02 ` Jonathan Morton
2018-03-01 11:06 ` Sebastian Moeller
2018-03-01 13:59 ` Toke Høiland-Jørgensen
2018-03-05 23:08 ` Jonathan Morton
2018-03-06 11:17 ` Toke Høiland-Jørgensen
2018-03-06 11:46 ` Jonathan Morton
2018-03-06 12:10 ` Sebastian Moeller
2018-03-06 13:08 ` Jonathan Morton
2018-03-06 13:18 ` Sebastian Moeller
2018-03-01 13:59 ` Toke Høiland-Jørgensen
2018-03-04 11:14 ` Toke Høiland-Jørgensen
2018-03-06 15:56 ` Stephen Hemminger
2018-03-06 18:33 ` Toke Høiland-Jørgensen
2018-03-06 21:06 ` Toke Høiland-Jørgensen
2018-03-06 22:31 ` Jonathan Morton
2018-03-07 8:50 ` Toke Høiland-Jørgensen
2018-03-07 10:08 ` Kevin Darbyshire-Bryant
2018-03-07 10:31 ` Toke Høiland-Jørgensen
2018-03-07 10:36 ` Toke Høiland-Jørgensen
2018-03-07 11:08 ` Kevin Darbyshire-Bryant
2018-03-07 11:28 ` Toke Høiland-Jørgensen
2018-03-07 11:59 ` Kevin Darbyshire-Bryant
2018-03-07 12:59 ` Toke Høiland-Jørgensen
2018-03-07 14:21 ` Sebastian Moeller
2018-03-07 14:30 ` Toke Høiland-Jørgensen
2018-03-07 15:25 ` Dave Taht
2018-03-07 15:52 ` Toke Høiland-Jørgensen
2018-03-07 17:26 ` Dave Taht
2018-03-08 22:29 ` Pete Heist
2018-03-07 18:27 ` Kevin Darbyshire-Bryant
2018-03-07 18:35 ` Kevin Darbyshire-Bryant
2018-03-07 18:37 ` Jonathan Morton
2018-03-07 21:34 ` Toke Høiland-Jørgensen
2018-03-08 0:49 ` Jonathan Morton
2018-03-08 7:59 ` Kevin Darbyshire-Bryant
2018-03-08 9:21 ` Kevin Darbyshire-Bryant
2018-03-08 10:32 ` Toke Høiland-Jørgensen
[not found] ` <D8A90884-6DAE-42A6-A680-CD11599DDD97@darbyshire-bryant.me.uk>
2018-03-08 10:57 ` Toke Høiland-Jørgensen
2018-03-08 11:09 ` Kevin Darbyshire-Bryant
2018-03-08 11:14 ` Kevin Darbyshire-Bryant
2018-03-08 11:21 ` Toke Høiland-Jørgensen
2018-03-08 18:32 ` Georgios Amanakis
2018-03-10 15:56 ` Kevin Darbyshire-Bryant
2018-03-10 16:30 ` Luis E. Garcia
2018-03-07 11:07 ` Kevin Darbyshire-Bryant
2018-03-07 11:19 ` Sebastian Moeller
2018-03-07 11:31 ` Toke Høiland-Jørgensen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://lists.bufferbloat.net/postorius/lists/cake.lists.bufferbloat.net/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180211172618.13297-1-toke@toke.dk \
--to=toke@toke.dk \
--cc=cake@lists.bufferbloat.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox