* Re: [PKT_SCHED]: PSCHED_TADD() and PSCHED_TADD2() can result,tv_usec >= 1000000
[not found] <449637EE.4020608@necst.nec.co.jp>
@ 2006-06-20 6:51 ` David Miller
2006-06-21 0:16 ` Shuya MAEDA
0 siblings, 1 reply; 5+ messages in thread
From: David Miller @ 2006-06-20 6:51 UTC (permalink / raw)
To: maeda-sxb; +Cc: netdev
From: Shuya MAEDA <maeda-sxb@necst.nec.co.jp>
Date: Mon, 19 Jun 2006 14:36:46 +0900
> #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; \
> + } \
> })
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.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PKT_SCHED]: PSCHED_TADD() and PSCHED_TADD2() can result,tv_usec >= 1000000
2006-06-20 6:51 ` [PKT_SCHED]: PSCHED_TADD() and PSCHED_TADD2() can result,tv_usec >= 1000000 David Miller
@ 2006-06-21 0:16 ` Shuya MAEDA
2006-06-27 20:32 ` David Miller
0 siblings, 1 reply; 5+ messages in thread
From: Shuya MAEDA @ 2006-06-21 0:16 UTC (permalink / raw)
To: David Miller; +Cc: netdev
Thank you for the comment.
I made the patch that used the loop instead of the divide and modulus.
Are there any comments?
David Miller wrote:
> From: Shuya MAEDA <maeda-sxb@necst.nec.co.jp>
> Date: Mon, 19 Jun 2006 14:36:46 +0900
>
>> #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; \
>> + } \
>> })
>
> 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.
Signed-off-by: Shuya MAEDA <maeda-sxb@necst.nec.co.jp>
diff -Nur linux-2.6.17.orig/include/net/pkt_sched.h linux-2.6.17.mypatch/include/net/pkt_sched.h
--- linux-2.6.17.orig/include/net/pkt_sched.h 2006-06-18 10:49:35.000000000 +0900
+++ linux-2.6.17.mypatch/include/net/pkt_sched.h 2006-06-20 17:17:34.000000000 +0900
@@ -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";
--
Shuya MAEDA
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PKT_SCHED]: PSCHED_TADD() and PSCHED_TADD2() can result,tv_usec >= 1000000
2006-06-21 0:16 ` Shuya MAEDA
@ 2006-06-27 20:32 ` David Miller
2006-06-28 8:38 ` Shuya MAEDA
0 siblings, 1 reply; 5+ messages in thread
From: David Miller @ 2006-06-27 20:32 UTC (permalink / raw)
To: maeda-sxb; +Cc: netdev
From: Shuya MAEDA <maeda-sxb@necst.nec.co.jp>
Date: Wed, 21 Jun 2006 09:16:03 +0900
> 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.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PKT_SCHED]: PSCHED_TADD() and PSCHED_TADD2() can result,tv_usec >= 1000000
2006-06-27 20:32 ` David Miller
@ 2006-06-28 8:38 ` Shuya MAEDA
2006-06-28 8:41 ` David Miller
0 siblings, 1 reply; 5+ messages in thread
From: Shuya MAEDA @ 2006-06-28 8:38 UTC (permalink / raw)
To: David Miller; +Cc: netdev
[-- Attachment #1: Type: text/plain, Size: 2387 bytes --]
Excuse me for the corrupted patch. I will send the patch as an
attachment this time.
Thank you very much.
David Miller wrote:
> From: Shuya MAEDA <maeda-sxb@necst.nec.co.jp>
> Date: Wed, 21 Jun 2006 09:16:03 +0900
>
>> 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.
>
> Shuya MAEDA wrote:
>> Thank you for the comment.
>> I made the patch that used the loop instead of the divide and modulus.
>> Are there any comments?
>>
>> David Miller wrote:
>>> From: Shuya MAEDA <maeda-sxb@necst.nec.co.jp>
>>> Date: Mon, 19 Jun 2006 14:36:46 +0900
>>>
>>>> #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; \
>>>> + } \
>>>> })
>>>
>>> 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.
Signed-off-by: Shuya MAEDA <maeda-sxb@necst.nec.co.jp>
--
Shuya MAEDA
[-- Attachment #2: mypatch.patch --]
[-- Type: text/x-patch, Size: 1086 bytes --]
diff -Nur linux-2.6.17.orig/include/net/pkt_sched.h linux-2.6.17.mypatch/include/net/pkt_sched.h
--- linux-2.6.17.orig/include/net/pkt_sched.h 2006-06-18 10:49:35.000000000 +0900
+++ linux-2.6.17.mypatch/include/net/pkt_sched.h 2006-06-20 17:17:34.000000000 +0900
@@ -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";
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PKT_SCHED]: PSCHED_TADD() and PSCHED_TADD2() can result,tv_usec >= 1000000
2006-06-28 8:38 ` Shuya MAEDA
@ 2006-06-28 8:41 ` David Miller
0 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2006-06-28 8:41 UTC (permalink / raw)
To: maeda-sxb; +Cc: netdev
From: Shuya MAEDA <maeda-sxb@necst.nec.co.jp>
Date: Wed, 28 Jun 2006 17:38:56 +0900
> 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.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2006-06-28 8:41 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <449637EE.4020608@necst.nec.co.jp>
2006-06-20 6:51 ` [PKT_SCHED]: PSCHED_TADD() and PSCHED_TADD2() can result,tv_usec >= 1000000 David Miller
2006-06-21 0:16 ` Shuya MAEDA
2006-06-27 20:32 ` David Miller
2006-06-28 8:38 ` Shuya MAEDA
2006-06-28 8:41 ` 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).