* [PATCH 1/2] pkt_sched: Use PSCHED_SHIFT in PSCHED time conversion
@ 2009-06-09 8:05 Jarek Poplawski
2009-06-09 12:21 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Jarek Poplawski @ 2009-06-09 8:05 UTC (permalink / raw)
To: David Miller
Cc: Patrick McHardy, Antonio Almeida, Stephen Hemminger, netdev,
Martin Devera, Eric Dumazet, Vladimir Ivashchenko,
Badalian Vyacheslav
Use PSCHED_SHIFT constant instead of '10' in PSCHED_US2NS() and
PSCHED_NS2US() macros to enable changing this value later.
Additionally use PSCHED_SHIFT in sch_hfsc SM_SHIFT and ISM_SHIFT
definitions. This part of the patch is based on feedback from
Patrick McHardy <kaber@trash.net>.
Reported-by: Antonio Almeida <vexwek@gmail.com>
Tested-by: Antonio Almeida <vexwek@gmail.com>
Signed-off-by: Jarek Poplawski <jarkao2@gmail.com>
---
include/net/pkt_sched.h | 5 +++--
net/sched/sch_hfsc.c | 8 +++++---
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/include/net/pkt_sched.h b/include/net/pkt_sched.h
index e37fe31..cd0e026 100644
--- a/include/net/pkt_sched.h
+++ b/include/net/pkt_sched.h
@@ -42,8 +42,9 @@ typedef u64 psched_time_t;
typedef long psched_tdiff_t;
/* Avoid doing 64 bit divide by 1000 */
-#define PSCHED_US2NS(x) ((s64)(x) << 10)
-#define PSCHED_NS2US(x) ((x) >> 10)
+#define PSCHED_SHIFT 10
+#define PSCHED_US2NS(x) ((s64)(x) << PSCHED_SHIFT)
+#define PSCHED_NS2US(x) ((x) >> PSCHED_SHIFT)
#define PSCHED_TICKS_PER_SEC PSCHED_NS2US(NSEC_PER_SEC)
#define PSCHED_PASTPERFECT 0
diff --git a/net/sched/sch_hfsc.c b/net/sched/sch_hfsc.c
index 5022f9c..362c281 100644
--- a/net/sched/sch_hfsc.c
+++ b/net/sched/sch_hfsc.c
@@ -372,7 +372,7 @@ cftree_update(struct hfsc_class *cl)
* ism: (psched_us/byte) << ISM_SHIFT
* dx: psched_us
*
- * The clock source resolution with ktime is 1.024us.
+ * The clock source resolution with ktime and PSCHED_SHIFT 10 is 1.024us.
*
* sm and ism are scaled in order to keep effective digits.
* SM_SHIFT and ISM_SHIFT are selected to keep at least 4 effective
@@ -383,9 +383,11 @@ cftree_update(struct hfsc_class *cl)
* bytes/1.024us 12.8e-3 128e-3 1280e-3 12800e-3 128000e-3
*
* 1.024us/byte 78.125 7.8125 0.78125 0.078125 0.0078125
+ *
+ * So, for PSCHED_SHIFT 10 we need: SM_SHIFT 20, ISM_SHIFT 18.
*/
-#define SM_SHIFT 20
-#define ISM_SHIFT 18
+#define SM_SHIFT (30 - PSCHED_SHIFT)
+#define ISM_SHIFT (8 + PSCHED_SHIFT)
#define SM_MASK ((1ULL << SM_SHIFT) - 1)
#define ISM_MASK ((1ULL << ISM_SHIFT) - 1)
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 1/2] pkt_sched: Use PSCHED_SHIFT in PSCHED time conversion
2009-06-09 8:05 [PATCH 1/2] pkt_sched: Use PSCHED_SHIFT in PSCHED time conversion Jarek Poplawski
@ 2009-06-09 12:21 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2009-06-09 12:21 UTC (permalink / raw)
To: jarkao2; +Cc: kaber, vexwek, shemminger, netdev, devik, dada1, hazard, slavon
From: Jarek Poplawski <jarkao2@gmail.com>
Date: Tue, 9 Jun 2009 08:05:00 +0000
> Use PSCHED_SHIFT constant instead of '10' in PSCHED_US2NS() and
> PSCHED_NS2US() macros to enable changing this value later.
>
> Additionally use PSCHED_SHIFT in sch_hfsc SM_SHIFT and ISM_SHIFT
> definitions. This part of the patch is based on feedback from
> Patrick McHardy <kaber@trash.net>.
>
> Reported-by: Antonio Almeida <vexwek@gmail.com>
> Tested-by: Antonio Almeida <vexwek@gmail.com>
> Signed-off-by: Jarek Poplawski <jarkao2@gmail.com>
Applied.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-06-09 12:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-09 8:05 [PATCH 1/2] pkt_sched: Use PSCHED_SHIFT in PSCHED time conversion Jarek Poplawski
2009-06-09 12:21 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).