Skip to content

Commit

Permalink
Improved PTM overhead calculation.
Browse files Browse the repository at this point in the history
  • Loading branch information
chromi committed Sep 28, 2016
1 parent 8678083 commit f9f8a71
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions sch_cake.c
Original file line number Diff line number Diff line change
Expand Up @@ -571,11 +571,8 @@ static inline u32 cake_overhead(struct cake_sched_data *q, u32 in)
out /= 48;
out *= 53;
} else if(q->rate_flags & CAKE_FLAG_PTM) {
// the actual overhead is 1 bit per 64-bit block
// the following adds one byte per 64 bytes or part thereof
// and rounds up to 64-bit blocks
// this is conservative and easier to calculate
out = (out & ~7) + 8 * !!(out & 7);
// this is conservative and easier to calculate than the precise value
out += (out / 64) + !!(out % 64);
}

Expand Down

7 comments on commit f9f8a71

@moeller0
Copy link
Collaborator

@moeller0 moeller0 commented on f9f8a71 Oct 4, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems rather unfortunate to incur one gratuitous division per packet. Since the 64/65 encoding is happening independent of data being send it seems much more efficient to adjust the shaper rate by multiplying with (64/65) and flooring that result, an operation which can be performed in the tc front-end and would not require (additional) per-packet processing. Since I believe I have brought this up as comment to the original PTM patch I wonder why you choose to solve this in this expensive fashion? Especially since for most users the shaper rate number will be larger than the packet size which will cause less rounding error...

@chromi
Copy link
Collaborator Author

@chromi chromi commented on f9f8a71 Oct 4, 2016 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@moeller0
Copy link
Collaborator

@moeller0 moeller0 commented on f9f8a71 Oct 4, 2016 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chromi
Copy link
Collaborator Author

@chromi chromi commented on f9f8a71 Oct 4, 2016 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@moeller0
Copy link
Collaborator

@moeller0 moeller0 commented on f9f8a71 Oct 4, 2016 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chromi
Copy link
Collaborator Author

@chromi chromi commented on f9f8a71 Oct 4, 2016 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@moeller0
Copy link
Collaborator

@moeller0 moeller0 commented on f9f8a71 Oct 4, 2016 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.