: PSCHED_TADD() and PSCHED_TADD2() can result,tv_usec >= 1000000
Subsystems (3)
David Miller
maintainerFrom: Shuya MAEDA <[email protected]>
Date: Mon, 19 Jun 2006 14:36:46 +0900
Quoted 8 lines
#define
PSCHED_TADD2(tv, delta, tv_res)\
({ \(quoted diff) +2
-4- 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); \
Review
Quoted 10 lines
(quoted diff) +9
-0+ 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; \ + } \ })
Divide and modulus can be extremely expensive on some systems, so let's try to avoid using them.
It is probably sufficient to adjust the passed in delta only once if it is >= USEC_PER_SEC, but if you feel that is an unsafe assumption then please use a simply loop like this:
while (__delta >= USEC_PER_SEC) {
(tv_res).tv_sec++;
__delta -= USEC_PER_SEC;
}And please provide a proper "Signed-off-by: " line in your next patch submission.
Thank you very much.
Thank you for the comment.
I made the patch that used the loop instead of the divide and modulus. Are there any comments?
Quoted 34 lines · David Miller
From: Shuya MAEDA <[email protected]>
Date: Mon, 19 Jun 2006 14:36:46 +0900Quoted 8 lines
#define
PSCHED_TADD2(tv, delta, tv_res)\
({ \(quoted diff) +2
-4- 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); \Review
Quoted 10 lines
(quoted diff) +9
-0+ 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; \ + } \ })Divide and modulus can be extremely expensive on some systems, so let's try to avoid using them.
It is probably sufficient to adjust the passed in delta only once if it is >=
USEC_PER_SEC, but if you feel that is an unsafe assumption then please use a simply loop like this:while (__delta >= USEC_PER_SEC) { (tv_res).tv_sec++; __delta -= USEC_PER_SEC; }
Quoted 4 lines
And please provide a proper "Signed-off-by: " line in your next patch submission.
Thank you very much.
include/net/pkt_sched.h 2006-06-20 17:17:34.000000000 +0900 renamed from include/net/pkt_sched.h 2006-06-18 10:49:35.000000000 +0900 +12 -6
@@ -169,17 +169,23 @@ #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; } \ + int __delta = (delta); \ + (tv_res) = (tv); \ + while(__delta >= USEC_PER_SEC){ \ + (tv_res).tv_sec++; \ + __delta -= USEC_PER_SEC; \ + } \ (tv_res).tv_usec = __delta; \ }) #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); \ + while(__delta >= USEC_PER_SEC){ \ + (tv).tv_sec++; \ + __delta -= USEC_PER_SEC; \ + } \ + (tv).tv_usec = __delta; \ }) /* Set/check that time is in the "past perfect";
Signature · 1 line
Shuya MAEDA
David Miller
maintainerFrom: Shuya MAEDA <[email protected]>
Date: Wed, 21 Jun 2006 09:16:03 +0900
Quoted 3 lines
Thank you for the comment.
I made the patch that used the loop instead of the divide and modulus. Are there any comments?
Your email client has corrupted the patch, turning tab characters into spaces, and also turning lines containing only spaces into empty lines.
Therefore, I cannot apply your patch, please send your patch properly so that I may apply it.
Thank you.
Excuse me for the corrupted patch. I will send the patch as an attachment this time.
Thank you very much.
Quoted 11 lines · David Miller
From: Shuya MAEDA <[email protected]>
Date: Wed, 21 Jun 2006 09:16:03 +0900Quoted 3 lines
Thank you for the comment.
I made the patch that used the loop instead of the divide and modulus. Are there any comments?Your email client has corrupted the patch, turning tab characters into spaces, and also turning lines containing only spaces into empty lines.
Quoted 50 lines
Therefore, I cannot apply your patch, please send your patch properly so that I may apply it.
Thank you.
Quoted 44 lines · Shuya MAEDA
Thank you for the comment.
I made the patch that used the loop instead of the divide and modulus. Are there any comments?Quoted 39 lines · David Miller
From: Shuya MAEDA <[email protected]>
Date: Mon, 19 Jun 2006 14:36:46 +0900Quoted 9 lines
#define
PSCHED_TADD2(tv, delta, tv_res)\
({ \(quoted diff) +2
-5- 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); \Review
Quoted 10 lines
(quoted diff) +9
-0+ 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; \ + } \ })Divide and modulus can be extremely expensive on some systems, so let's try to avoid using them.
It is probably sufficient to adjust the passed in delta only once if it is >=
USEC_PER_SEC, but if you feel that is an unsafe assumption then please use a simply loop like this:while (__delta >= USEC_PER_SEC) { (tv_res).tv_sec++; __delta -= USEC_PER_SEC; }And please provide a proper "Signed-off-by: " line in your next patch submission.
Thank you very much.
--
Shuya MAEDA
include/net/pkt_sched.h +12 -6
@@ -169,17 +169,23 @@#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; } \ + int __delta = (delta); \ + (tv_res) = (tv); \ + while(__delta >= USEC_PER_SEC){ \ + (tv_res).tv_sec++; \ + __delta -= USEC_PER_SEC; \ + } \ (tv_res).tv_usec = __delta; \ })#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); \ + while(__delta >= USEC_PER_SEC){ \ + (tv).tv_sec++; \ + __delta -= USEC_PER_SEC; \ + } \ + (tv).tv_usec = __delta; \ })/* Set/check that time is in the "past perfect";
David Miller
maintainerFrom: Shuya MAEDA <[email protected]>
Date: Wed, 28 Jun 2006 17:38:56 +0900
Quoted 4 lines
Excuse me for the corrupted patch. I will send the patch as an attachment this time.
Thank you very much.
Patch applied, thanks a lot.