From: Yevgeny Kliteynik <kliteyn-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
To: Sasha Khapyorsky <sashak-smomgflXvOZWk0Htik3J/w@public.gmane.org>
Cc: Linux RDMA <linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Tzachi Dar <tzachid-VPRAkNaXOzVS1MOuV/RT9w@public.gmane.org>
Subject: [PATCH] complib/cl_timer.c: fixing cl_timer calculation
Date: Mon, 23 Aug 2010 17:38:00 +0300 [thread overview]
Message-ID: <4C7287C8.1040106@dev.mellanox.co.il> (raw)
When calculating p_timer->timeout.tv_sec and p_timer->timeout.tv_nsec,
the carry was ignored, resulting in wrong value in p_timer->timeout.tv_sec,
and value > 10^9 in p_timer->timeout.tv_nsec (illegal value).
Signed-off-by: Yevgeny Kliteynik <kliteyn-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
---
opensm/complib/cl_timer.c | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/opensm/complib/cl_timer.c b/opensm/complib/cl_timer.c
index 2acdb51..09a5584 100644
--- a/opensm/complib/cl_timer.c
+++ b/opensm/complib/cl_timer.c
@@ -299,7 +299,8 @@ cl_status_t cl_timer_start(IN cl_timer_t * const p_timer,
{
struct timeval curtime;
cl_list_item_t *p_list_item;
- uint32_t delta_time = time_ms;
+ uint32_t delta_time_sec = time_ms / 1000;
+ uint32_t delta_time_usec = (time_ms % 1000) * 1000;
CL_ASSERT(p_timer);
CL_ASSERT(p_timer->state == CL_INITIALIZED);
@@ -324,9 +325,10 @@ cl_status_t cl_timer_start(IN cl_timer_t * const p_timer,
/* if (delta_time < 1000.0) {delta_time = 1000;} */
/* Calculate the timeout. */
- p_timer->timeout.tv_sec = curtime.tv_sec + (delta_time / 1000);
+ p_timer->timeout.tv_sec = curtime.tv_sec + delta_time_sec +
+ ((curtime.tv_usec + delta_time_usec) / 1000000);
p_timer->timeout.tv_nsec =
- (curtime.tv_usec + ((delta_time % 1000) * 1000)) * 1000;
+ ((curtime.tv_usec + delta_time_usec) % 1000000) * 1000;
/* Add the timer to the queue. */
if (cl_is_qlist_empty(&gp_timer_prov->queue)) {
--
1.6.2.4
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next reply other threads:[~2010-08-23 14:38 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-23 14:38 Yevgeny Kliteynik [this message]
[not found] ` <4C7287C8.1040106-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2010-08-23 18:55 ` [PATCH] complib/cl_timer.c: fixing cl_timer calculation Sasha Khapyorsky
2010-08-24 11:55 ` Yevgeny Kliteynik
[not found] ` <4C73B333.3080007-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2010-08-24 12:01 ` Yevgeny Kliteynik
[not found] ` <4C73B4B3.1030204-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2010-08-25 16:07 ` Sasha Khapyorsky
2010-08-25 19:15 ` Yevgeny Kliteynik
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=4C7287C8.1040106@dev.mellanox.co.il \
--to=kliteyn-ldsdmyg8hgv8yrgs2mwiifqbs+8scbdb@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=sashak-smomgflXvOZWk0Htik3J/w@public.gmane.org \
--cc=tzachid-VPRAkNaXOzVS1MOuV/RT9w@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.