From: Jason Gunthorpe <jgg-uk2M96/98Pc@public.gmane.org>
To: "Michael J. Ruhl"
<michael.j.ruhl-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH v2 4/4] ibacm: Use MONOTONIC time base to avoid timer expiration issues
Date: Mon, 13 Nov 2017 20:04:14 -0700 [thread overview]
Message-ID: <20171114030414.GP22610@ziepe.ca> (raw)
In-Reply-To: <20171113212454.24293.68783.stgit-K+u1se/DcYrLESAwzcoQNrvm/XP+8Wra@public.gmane.org>
On Mon, Nov 13, 2017 at 04:25:04PM -0500, Michael J. Ruhl wrote:
Sorry, noticed a few more wonky things:
> #define event_signal(e) pthread_cond_signal(&(e)->cond)
> #define ONE_SEC_IN_NSEC 1000000000
That should be 1000000000ULL so math doesn't accidental truncate
> + clock_gettime(CLOCK_MONOTONIC, &wait);
> + wait.tv_sec = wait.tv_sec + ((unsigned) timeout) / 1000;
> + wait.tv_nsec = (wait.tv_nsec + (((unsigned) timeout) % 1000) * 1000000);
Why the odd casts to (unsigned) ? That should be (unsigned int)
> - return (uint64_t) curtime.tv_sec * 1000000 + (uint64_t) curtime.tv_usec;
> + struct timespec t;
> + clock_gettime(CLOCK_MONOTONIC, &t);
> + return ((uint64_t)t.tv_sec * ONE_SEC_IN_NSEC + (uint64_t)t.tv_nsec) / 1000;
These casts to uint64_t are also wrong, time is technically
signed. The change to ONE_SEC_IN_NSEC should remove the need
for the casting.
Jason
--
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
prev parent reply other threads:[~2017-11-14 3:04 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-13 21:23 [PATCH v2 0/4] ibacm: acmp retry issues Michael J. Ruhl
[not found] ` <20171113212220.24293.97479.stgit-K+u1se/DcYrLESAwzcoQNrvm/XP+8Wra@public.gmane.org>
2017-11-13 21:24 ` [PATCH v2 1/4] ibacm: Fix an incorrect expiration check for the retry timer Michael J. Ruhl
2017-11-13 21:24 ` [PATCH v2 2/4] ibacm: Calculate correct tv_nsec value in event_wait() Michael J. Ruhl
2017-11-13 21:24 ` [PATCH v2 3/4] ibacm: Fix a retry loop calculation race condition Michael J. Ruhl
2017-11-13 21:25 ` [PATCH v2 4/4] ibacm: Use MONOTONIC time base to avoid timer expiration issues Michael J. Ruhl
[not found] ` <20171113212454.24293.68783.stgit-K+u1se/DcYrLESAwzcoQNrvm/XP+8Wra@public.gmane.org>
2017-11-14 3:04 ` Jason Gunthorpe [this message]
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=20171114030414.GP22610@ziepe.ca \
--to=jgg-uk2m96/98pc@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=michael.j.ruhl-ral2JQCrhuEAvxtiuMwx3w@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox