From: Shuya MAEDA <maeda-sxb@necst.nec.co.jp>
To: netdev <netdev@vger.kernel.org>
Subject: [PATCH] [PKT_SCHED]: PSCHED_TADD() and PSCHED_TADD2() can result,tv_usec >= 1000000
Date: Mon, 19 Jun 2006 16:05:05 +0900 [thread overview]
Message-ID: <44964CA1.8020505@necst.nec.co.jp> (raw)
I found two problems in PSCHED_TADD() and PSCHED_TADD2().
1) These function increment tv_sec if tv_usec > 1000000.
But I think it should "if tv_usec >= 1000000".
2) tv_usec became 1200000 or more when I used CBQ and
experimented it. It is not correct to exceed 1000000
because tv_usec is micro seconds.
To fix 2), I think that it should do "delta / 1000000",
add the quotient to tv_sec, and add the remainder to
tv_usec.
In both cases, because time when the transmission is restarted
reaches an illegal value, it is not possible to communicate at
the set rate.
To fix these problem I create following patch.
Are there any comments?
[Experiment]
* kernel: linux-2.6.15.5
* CBQ settings
----------------------------------------------------------
tc qdisc add dev $IF root handle 1:0 cbq bandwidth 100Mbit \
avpkt 1000 mpu 64 ewma 5 cell 8
tc class add dev $IF parent 1:0 classid 1:10 cbq rate 32Kbit \
prio 1 ewma 5 cell 8 avpkt 138 mpu 64 bandwidth 100Mbit \
minburst 25 maxburst 50 bounded isolated
tc filter add dev $IF parent 1:0 protocol ip prio 16 u32 match \
ip dport 4952 0xffff flowid 1:10
-----------------------------------------------------------
* Traffic
dst port 4952: 138byte per 20msec.
[Result]
* In cbq_ovl_classic():
cl->undertime = { tv_sec = 1150368540, tv_usec = 1208301 }
~~~~~~~~~~~~~~~~~~
q->now = { tv_sec = 1150368539, tv_usec = 878917 }
delay = 1329384
cl->avgidle = -14781
cl->offtime = 1295394
[Patch]
diff -Nur linux-2.6.17-rc6.orig/include/net/pkt_sched.h linux-2.6.17-rc6.mypatch/include/net/pkt_sched.h
--- linux-2.6.17-rc6.orig/include/net/pkt_sched.h 2006-06-06 09:57:02.000000000 +0900
+++ linux-2.6.17-rc6.mypatch/include/net/pkt_sched.h 2006-06-16 11:29:08.000000000 +0900
@@ -169,17 +169,31 @@
#define PSCHED_TADD2(tv, delta, tv_res) \
({ \
- int __delta = (tv).tv_usec + (delta); \
- (tv_res).tv_sec = (tv).tv_sec; \
- if (__delta > USEC_PER_SEC) { (tv_res).tv_sec++; __delta -= USEC_PER_SEC; } \
- (tv_res).tv_usec = __delta; \
+ int __delta = (delta); \
+ (tv_res) = (tv); \
+ if((delta) > USEC_PER_SEC) { \
+ (tv_res).tv_sec += (delta) / USEC_PER_SEC; \
+ __delta -= (delta) % USEC_PER_SEC; \
+ } \
+ (tv_res).tv_usec += __delta; \
+ if((tv_res).tv_usec >= USEC_PER_SEC) { \
+ (tv_res).tv_sec++; \
+ (tv_res).tv_usec -= USEC_PER_SEC; \
+ } \
})
#define PSCHED_TADD(tv, delta) \
({ \
- (tv).tv_usec += (delta); \
- if ((tv).tv_usec > USEC_PER_SEC) { (tv).tv_sec++; \
- (tv).tv_usec -= USEC_PER_SEC; } \
+ int __delta = (delta); \
+ if((delta) > USEC_PER_SEC) { \
+ (tv).tv_sec += (delta) / USEC_PER_SEC; \
+ __delta -= (delta) % USEC_PER_SEC; \
+ } \
+ (tv).tv_usec += __delta; \
+ if((tv).tv_usec >= USEC_PER_SEC) { \
+ (tv).tv_sec++; \
+ (tv).tv_usec -= USEC_PER_SEC; \
+ } \
})
/* Set/check that time is in the "past perfect";
--
Shuya Maeda
reply other threads:[~2006-06-19 7:05 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=44964CA1.8020505@necst.nec.co.jp \
--to=maeda-sxb@necst.nec.co.jp \
--cc=netdev@vger.kernel.org \
/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