aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2004-07-22 23:45:21 -0700
committerDavid S. Miller <davem@nuts.davemloft.net>2004-07-22 23:45:21 -0700
commit9fc483264296adb8b22d743ec315787539439c29 (patch)
tree4c64c0cf48066a547a17e71def25c2e2a405a97a /net
parent7862e912a5e00b7f08ef108b8199cd079101b913 (diff)
downloadhistory-9fc483264296adb8b22d743ec315787539439c29.tar.gz
[PKT_SCHED]: Make clock source configurable
Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@redhat.com>
Diffstat (limited to 'net')
-rw-r--r--net/sched/Kconfig55
-rw-r--r--net/sched/sch_api.c8
-rw-r--r--net/sched/sch_hfsc.c10
-rw-r--r--net/sched/sch_htb.c10
4 files changed, 74 insertions, 9 deletions
diff --git a/net/sched/Kconfig b/net/sched/Kconfig
index 54817b8ec7f009..57b2cc4761e38f 100644
--- a/net/sched/Kconfig
+++ b/net/sched/Kconfig
@@ -1,6 +1,61 @@
#
# Traffic control configuration.
#
+choice
+ prompt "Packet scheduler clock source"
+ depends on NET_SCHED
+ default NET_SCH_CLK_JIFFIES
+ help
+ Packet schedulers need a monotonic clock that increments at a static
+ rate. The kernel provides several suitable interfaces, each with
+ different properties:
+
+ - high resolution (us or better)
+ - fast to read (minimal locking, no i/o access)
+ - synchronized on all processors
+ - handles cpu clock frequency changes
+
+ but nothing provides all of the above.
+
+config NET_SCH_CLK_JIFFIES
+ bool "Timer interrupt"
+ help
+ Say Y here if you want to use the timer interrupt (jiffies) as clock
+ source. This clock source is fast, synchronized on all processors and
+ handles cpu clock frequency changes, but its resolution is too low
+ for accurate shaping except at very low speed.
+
+config NET_SCH_CLK_GETTIMEOFDAY
+ bool "gettimeofday"
+ help
+ Say Y here if you want to use gettimeofday as clock source. This clock
+ source has high resolution, is synchronized on all processors and
+ handles cpu clock frequency changes, but it is slow.
+
+ Choose this if you need a high resolution clock source but can't use
+ the CPU's cycle counter.
+
+config NET_SCH_CLK_CPU
+ bool "CPU cycle counter"
+ depends on X86_TSC || X86_64 || ALPHA || SPARC64 || PPC64 || IA64
+ help
+ Say Y here if you want to use the CPU's cycle counter as clock source.
+ This is a cheap and high resolution clock source, but on some
+ architectures it is not synchronized on all processors and doesn't
+ handle cpu clock frequency changes.
+
+ The useable cycle counters are:
+
+ x86/x86_64 - Timestamp Counter
+ alpha - Cycle Counter
+ sparc64 - %ticks register
+ ppc64 - Time base
+ ia64 - Interval Time Counter
+
+ Choose this if your CPU's cycle counter is working properly.
+
+endchoice
+
config NET_SCH_CBQ
tristate "CBQ packet scheduler"
depends on NET_SCHED
diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
index fb7c4f0b81d1bf..1ce72ab7a68964 100644
--- a/net/sched/sch_api.c
+++ b/net/sched/sch_api.c
@@ -1088,7 +1088,7 @@ static struct file_operations psched_fops = {
};
#endif
-#if PSCHED_CLOCK_SOURCE == PSCHED_GETTIMEOFDAY
+#ifdef CONFIG_NET_SCH_CLK_GETTIMEOFDAY
int psched_tod_diff(int delta_sec, int bound)
{
int delta;
@@ -1103,7 +1103,7 @@ int psched_tod_diff(int delta_sec, int bound)
EXPORT_SYMBOL(psched_tod_diff);
#endif
-#if PSCHED_CLOCK_SOURCE == PSCHED_CPU
+#ifdef CONFIG_NET_SCH_CLK_CPU
psched_tdiff_t psched_clock_per_hz;
int psched_clock_scale;
EXPORT_SYMBOL(psched_clock_per_hz);
@@ -1169,10 +1169,10 @@ static int __init pktsched_init(void)
{
struct rtnetlink_link *link_p;
-#if PSCHED_CLOCK_SOURCE == PSCHED_CPU
+#ifdef CONFIG_NET_SCH_CLK_CPU
if (psched_calibrate_clock() < 0)
return -1;
-#elif PSCHED_CLOCK_SOURCE == PSCHED_JIFFIES
+#elif defined(CONFIG_NET_SCH_CLK_JIFFIES)
psched_tick_per_us = HZ<<PSCHED_JSCALE;
psched_us_per_tick = 1000000;
#endif
diff --git a/net/sched/sch_hfsc.c b/net/sched/sch_hfsc.c
index ce91e23134e805..a6e559c1670d7b 100644
--- a/net/sched/sch_hfsc.c
+++ b/net/sched/sch_hfsc.c
@@ -193,7 +193,7 @@ struct hfsc_sched
/*
* macros
*/
-#if PSCHED_CLOCK_SOURCE == PSCHED_GETTIMEOFDAY
+#ifdef CONFIG_NET_SCH_CLK_GETTIMEOFDAY
#include <linux/time.h>
#undef PSCHED_GET_TIME
#define PSCHED_GET_TIME(stamp) \
@@ -429,10 +429,10 @@ actlist_get_minvt(struct hfsc_class *cl, u64 cur_time)
* ism: (psched_us/byte) << ISM_SHIFT
* dx: psched_us
*
- * Time source resolution
- * PSCHED_JIFFIES: for 48<=HZ<=1534 resolution is between 0.63us and 1.27us.
- * PSCHED_CPU: resolution is between 0.5us and 1us.
- * PSCHED_GETTIMEOFDAY: resolution is exactly 1us.
+ * Clock source resolution (CONFIG_NET_SCH_CLK_*)
+ * JIFFIES: for 48<=HZ<=1534 resolution is between 0.63us and 1.27us.
+ * CPU: resolution is between 0.5us and 1us.
+ * GETTIMEOFDAY: resolution is exactly 1us.
*
* sm and ism are scaled in order to keep effective digits.
* SM_SHIFT and ISM_SHIFT are selected to keep at least 4 effective
diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
index 65797b3306cccb..415369672f44dd 100644
--- a/net/sched/sch_htb.c
+++ b/net/sched/sch_htb.c
@@ -856,8 +856,13 @@ static void htb_charge_class(struct htb_sched *q,struct htb_class *cl,
if (net_ratelimit())
printk(KERN_ERR "HTB: bad diff in charge, cl=%X diff=%lX now=%Lu then=%Lu j=%lu\n",
cl->classid, diff,
+#ifdef CONFIG_NET_SCH_CLK_GETTIMEOFDAY
+ q->now.tv_sec * 1000000ULL + q->now.tv_usec,
+ cl->t_c.tv_sec * 1000000ULL + cl->t_c.tv_usec,
+#else
(unsigned long long) q->now,
(unsigned long long) cl->t_c,
+#endif
q->jiffies);
diff = 1000;
}
@@ -927,8 +932,13 @@ static long htb_do_events(struct htb_sched *q,int level)
if (net_ratelimit())
printk(KERN_ERR "HTB: bad diff in events, cl=%X diff=%lX now=%Lu then=%Lu j=%lu\n",
cl->classid, diff,
+#ifdef CONFIG_NET_SCH_CLK_GETTIMEOFDAY
+ q->now.tv_sec * 1000000ULL + q->now.tv_usec,
+ cl->t_c.tv_sec * 1000000ULL + cl->t_c.tv_usec,
+#else
(unsigned long long) q->now,
(unsigned long long) cl->t_c,
+#endif
q->jiffies);
diff = 1000;
}