Skip to contentSkip to conversation

hfsc: add link layer overhead adaption

PATCH In review Jussi Kivilinna 2 participants 7 messages Jun 23, 2008

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hfsc: add link layer overhead adaption

CBQ and HTB have options for emulating overhead of underlying link layer (mpu/overhead/linklayer options). This patch makes sch_hfsc use rate table to emulate link layer overhead.

Patch uses rate table to convert packet length to emulated link layer packet length using qdisc_l2t() in get_linklayer_len(). Converted packet length is passed to hfsc calculations instead of real. If rate table isn't passed to kernel, hfsc works as before.

---

 include/linux/pkt_sched.h |    2 +
 net/sched/sch_hfsc.c      |  125 ++++++++++++++++++++++++++++++++++++---------
 2 files changed, 102 insertions(+), 25 deletions(-)
include/linux/pkt_sched.h +2 -0
index dbb7ac3..1d2cb24 100644
@@ -316,6 +316,8 @@ enum
 	TCA_HFSC_RSC,
 	TCA_HFSC_FSC,
 	TCA_HFSC_USC,
+	TCA_HFSC_RATEOPTS,
+	TCA_HFSC_RTAB,
 	__TCA_HFSC_MAX,
 };
 
net/sched/sch_hfsc.c +100 -25

245 lines not on this page · raw message

#1 lore raw
Quoted 16 lines · Jussi Kivilinna

CBQ and HTB have options for emulating overhead of underlying link layer (mpu/overhead/linklayer options). This patch makes sch_hfsc use rate table to emulate link layer overhead.

Patch uses rate table to convert packet length to emulated link layer packet length using qdisc_l2t() in get_linklayer_len(). Converted packet length is passed to hfsc calculations instead of real. If rate table isn't passed to kernel, hfsc works as before.

net/sched/sch_hfsc.c +3 -0
index fdfaa3f..94fd130 100644
+/* convert packet length to link layer packet length */
+static unsigned int get_linklayer_len(struct hfsc_class *cl, unsigned int len)
+{

net/sched/sch_hfsc.c sc2isc(struct tc_service_curve *sc, struct internal_sc *isc) · line 513

Quoted 10 lines
net/sched/sch_hfsc.c +10 -0
+	u64 ll_len;
+	if (likely(len) && unlikely(cl->rtab)) {
+		ll_len = qdisc_l2t(cl->rtab, len);
+		if (unlikely(cl->rtab->rate.rate != PSCHED_TICKS_PER_SEC))
+			ll_len = div_u64(ll_len * cl->rtab->rate.rate,
+							PSCHED_TICKS_PER_SEC);
+		return (unsigned int)ll_len;
+	}
+	return len;
+}

This looks like an abuse of rate tables, which usually convert packet sizes to transmission times. You undo that above using expensive calculations.

I think this should be done by performing the length calculation in the kernel directly.

#2 lore raw

Quoting Patrick McHardy <[email protected]>:

Quoted 33 lines
Quoted 17 lines · Jussi Kivilinna

CBQ and HTB have options for emulating overhead of underlying link layer (mpu/overhead/linklayer options). This patch makes sch_hfsc use rate table to emulate link layer overhead.

Patch uses rate table to convert packet length to emulated link layer packet length using qdisc_l2t() in get_linklayer_len(). Converted packet length is passed to hfsc calculations instead of real. If rate table isn't passed to kernel, hfsc works as before.

net/sched/sch_hfsc.c +2 -0
index fdfaa3f..94fd130 100644
+/* convert packet length to link layer packet length */
+static unsigned int get_linklayer_len(struct hfsc_class *cl,   

unsigned int len)

net/sched/sch_hfsc.c +1 -0
+{

net/sched/sch_hfsc.c sc2isc(struct tc_service_curve *sc, struct internal_sc *isc) · line 513

Quoted 10 lines
net/sched/sch_hfsc.c +10 -0
+	u64 ll_len;
+	if (likely(len) && unlikely(cl->rtab)) {
+		ll_len = qdisc_l2t(cl->rtab, len);
+		if (unlikely(cl->rtab->rate.rate != PSCHED_TICKS_PER_SEC))
+			ll_len = div_u64(ll_len * cl->rtab->rate.rate,
+							PSCHED_TICKS_PER_SEC);
+		return (unsigned int)ll_len;
+	}
+	return len;
+}

This looks like an abuse of rate tables, which usually convert packet sizes to transmission times. You undo that above using expensive calculations.

Quoted 2 lines

I think this should be done by performing the length calculation in the kernel directly.

Yes, it's abuse, and actually table is created using false rate (rate = PSCHED_TICKS_PER_SEC) so div_u64 is avoided. Div_u64 is there just in case something goes wrong in userspace. Using rate table allows changes/updates to link layer emulation with only userspace updates avoiding, but maybe abuse of rate table isn't right way to do this after all.

So would it be better if I add 'length table' to kernel&userspace and use it instead?

- Jussi

#3 lore raw
Quoted 6 lines · Jussi Kivilinna

Quoting Patrick McHardy <[email protected]>:

Quoted 5 lines

This looks like an abuse of rate tables, which usually convert packet sizes to transmission times. You undo that above using expensive calculations.

Quoted 6 lines
Quoted 2 lines

I think this should be done by performing the length calculation in the kernel directly.

Yes, it's abuse, and actually table is created using false rate (rate = PSCHED_TICKS_PER_SEC) so div_u64 is avoided. Div_u64 is there just in case something goes wrong in userspace. Using rate table allows changes/updates to link layer emulation with only userspace updates avoiding, but maybe abuse of rate table isn't right way to do this after all.

So would it be better if I add 'length table' to kernel&userspace and use it instead?

Yes, I even posted an unfinished patch for this one or two years ago, in response to the overhead calculation patches for HTB etc.

I can't find it right now, but haven't tried too hard. It was called qdisc STABs (for size tables), you should be able to find it in the archives.

#4 lore raw

Quoting Patrick McHardy <[email protected]>:

Quoted 9 lines
Quoted 2 lines

So would it be better if I add 'length table' to kernel&userspace and use it instead?

Yes, I even posted an unfinished patch for this one or two years ago, in response to the overhead calculation patches for HTB etc.

I can't find it right now, but haven't tried too hard. It was called qdisc STABs (for size tables), you should be able to find it in the archives.

Well, my LTAB didn't end up being exactly same your earlier STAB, but I renamed LTAB to STAB as it sounds better. Hope you don't mind :]

#5 lore raw
Quoted 5 lines · Jussi Kivilinna

Quoting Patrick McHardy <[email protected]>:

Quoted 3 lines
Quoted 2 lines

So would it be better if I add 'length table' to kernel&userspace and use it instead?

Quoted 8 lines
Quoted 6 lines

Yes, I even posted an unfinished patch for this one or two years ago, in response to the overhead calculation patches for HTB etc.

I can't find it right now, but haven't tried too hard. It was called qdisc STABs (for size tables), you should be able to find it in the archives.

Well, my LTAB didn't end up being exactly same your earlier STAB, but I renamed LTAB to STAB as it sounds better. Hope you don't mind :]

Not at all :) Did you already post that patch?

#6 lore raw
Quoted 4 lines
Quoted 2 lines

Well, my LTAB didn't end up being exactly same your earlier STAB, but I renamed LTAB to STAB as it sounds better. Hope you don't mind
:]

Not at all :) Did you already post that patch?

Need to do some more testing, I'll post patch(es) tomorrow.