All of lore.kernel.org
 help / color / mirror / Atom feed
From: Willem Jan Withagen <wjw@digiware.nl>
To: Matt Benjamin <mbenjamin@redhat.com>,
	Erwan Velu <evelu@redhat.com>,
	"Adam C. Emerson" <aemerson@redhat.com>,
	Ceph Development <ceph-devel@vger.kernel.org>,
	Sage Weil <sweil@redhat.com>
Subject: Re: About ceph_clock_now()
Date: Mon, 25 Jan 2016 20:38:35 +0100	[thread overview]
Message-ID: <56A679BB.4090801@digiware.nl> (raw)
In-Reply-To: <1523354716.24670379.1453744826329.JavaMail.zimbra@redhat.com>

On 25-1-2016 19:00, Matt Benjamin wrote:
> Hi Willem,
> 
> This commit is by Adam.
Hi Matt,

Sorry about that, I'll send my personal remaks agin to him.

The point you raise here is a more generic question:
 -- How to wrap OS specifics into more generic code?

Sometimes overloading would be usefull. But in this case the function is
exactly oke, only the names of const values differ, and as such that
will not work. So a ceph::clock_gettime() would still have the same
problem.
Alternative is make different functions, but that would a lot of
functions, just to work around the naming.

> I have in OTHER PROJECTS mapped Linux CLOCK_MONOTONIC_COARSE to
> FreeBSD's CLOCK_MONOTONIC_FAST, but that's it.  In my Ceph code, I've
> been using clock_gettime() explicitly, but also
> CLOCK_MONOTONIC_COARSE, on the expectation to have this change in
> future.

'mmm sort of lost on what part of the code I then triggered and ended up
commenting on your code..

1)
Currently the code in Adam's looks like:
#if defined(CLOCK_MONOTONIC_COARSE)
        // Linux systems have _COARSE clocks.
        clock_gettime(CLOCK_MONOTONIC_COARSE, &ts);
#elif defined(CLOCK_MONOTONIC_FAST)
        // BSD systems have _FAST clocks.
        clock_gettime(CLOCK_MONOTONIC_FAST, &ts);
#else
        // And if we find neither, you may wish to consult your system's
        // documentation.
#warning Falling back to CLOCK_MONOTONIC, may be slow.
        clock_gettime(CLOCK_MONOTONIC, &ts);
#endif

And this is repeated in a few more locations.
Moreover, it will be required to do that a few times everytime
clock_getime is used.

Perhaps Matt solution is crude, but more convenient, which I think went
like:
#if defined(__FreeBSD__)
#define CLOCK_MONOTONIC_COARSE CLOCK_MONOTONIC_FAST
#endif
I keeps the code looking very Linux like, which works for this case.
But there could very well be that there is more difference than just
nameing, and tricky details of the implementation could bite.
It would also not work when there is more that just a nameing difference.

Put this in the compat.h or ceph_time.h file and this can tackle this
specific problem

> If you think the clock definition should be different, please suggest
> corrections (but again, I'm not the author of this proposed change).

I'm at the middle of the road of which version I like best.
The first one is 100% clear and obvious, but also very verbose.
The second one shines in elegance, but is not very transparent value wise.

If the second solution was put in ceph_time.h I think that that would
have my preference

--WjW


  parent reply	other threads:[~2016-01-25 19:39 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <177186823.10053087.1452614184109.JavaMail.zimbra@redhat.com>
2016-01-12 15:59 ` About ceph_clock_now() Erwan Velu
2016-01-12 17:32   ` Adam C. Emerson
2016-01-13 10:41     ` Erwan Velu
2016-01-13 13:48       ` Sage Weil
2016-01-13 14:52         ` Matt Benjamin
2016-01-14 16:10         ` Erwan Velu
2016-01-14 16:14           ` Adam C. Emerson
2016-01-19 16:17         ` Erwan Velu
2016-01-19 16:29           ` Adam C. Emerson
2016-01-19 16:57             ` Erwan Velu
2016-01-21 19:22             ` Erwan Velu
2016-01-22 16:00               ` Erwan Velu
2016-01-22 17:35                 ` Adam C. Emerson
2016-01-26 14:12                   ` Erwan Velu
2016-01-23 11:49                 ` Willem Jan Withagen
2016-01-23 20:20                   ` Matt Benjamin
2016-01-23 21:55                     ` Adam C. Emerson
2016-01-24 11:53                       ` Willem Jan Withagen
2016-01-24 12:51                         ` Willem Jan Withagen
2016-01-25  0:03                           ` Adam C. Emerson
2016-01-25  9:08                             ` Willem Jan Withagen
2016-01-25  9:58                               ` Erwan Velu
2016-01-25 10:57                                 ` Willem Jan Withagen
2016-01-25 17:22                                   ` Adam C. Emerson
     [not found]                                     ` <56A66099.4030501@digiware.nl>
     [not found]                                       ` <1523354716.24670379.1453744826329.JavaMail.zimbra@redhat.com>
2016-01-25 19:38                                         ` Willem Jan Withagen [this message]
2016-01-25 20:14                                           ` Adam C. Emerson
2016-01-25 20:18                                             ` Matt Benjamin
2016-01-25 20:22                                             ` Willem Jan Withagen
2016-01-13 15:28       ` Adam C. Emerson

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=56A679BB.4090801@digiware.nl \
    --to=wjw@digiware.nl \
    --cc=aemerson@redhat.com \
    --cc=ceph-devel@vger.kernel.org \
    --cc=evelu@redhat.com \
    --cc=mbenjamin@redhat.com \
    --cc=sweil@redhat.com \
    /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.