From: Christian Borntraeger <borntraeger@de.ibm.com>
To: rutu.shah.26@gmail.com, qemu-devel@nongnu.org
Cc: kraxel@redhat.com, samuel.thibault@ens-lyon.org,
stefanha@redhat.com, kwolf@redhat.com, pbonzini@redhat.com,
crosthwaite.peter@gmail.com, rth@twiddle.net, mst@redhat.com,
imammedo@redhat.com, peter.maydell@linaro.org, balrogg@gmail.com,
jsnow@redhat.com, alistair.francis@xilinx.com, agraf@suse.de,
jasowang@redhat.com, blauwirbel@gmail.co,
mark.cave-ayland@ilande.co.uk, cornelia.huck@de.ibm.com,
lcapitulino@redhat.com, armbru@redhat.com, qemu-block@nongnu.org,
qemu-arm@nongnu.org, qemu-ppc@nongnu.org, kvm@vger.kernel.org
Subject: Re: [PATCH] Replacing (and removing) get_ticks_per_sec() function with NANOSECONDS_PER_SECOND Signed-off-by: Rutuja Shah <rutu.shah.26@gmail.com>
Date: Fri, 11 Mar 2016 12:44:33 +0100 [thread overview]
Message-ID: <56E2AFA1.5010201@de.ibm.com> (raw)
In-Reply-To: <1457638209-14218-1-git-send-email-rutu.shah.26@gmail.com>
On 03/10/2016 08:30 PM, rutu.shah.26@gmail.com wrote:
> From: Rutuja Shah <rutu.shah.26@gmail.com>
[...]
> - s->tick_offset_vmstate = s->tick_offset + delta / get_ticks_per_sec();
> + s->tick_offset_vmstate = s->tick_offset + delta / NANOSECONDS_PER_SECOND;
[...]
While technically correct, I do not like these changes. The interfaces expect "ticks",
and the fact that this happens to be a nanosecond does not help regarding
readability.
Lets look at the snippet from above. The variable is called TICK_offset_vmstate.
so, the first line (-) makes sense when reading, the 2nd line (+) does not.
A reader that does not know the timer code will ask itself: "Why do we use
NANOSECONDS_PER_SECOND to calculate ticks?" The reader has to know that a tick
is a nanosecond to understand that line. So the cleanup makes the code harder to
read in my opinion.
If - for some reason - we want to replace a function with a MACRO, then
please introduce TICKS_PER_SECOND which just feels better when reading the code.
It would also fix the >80 chars per line problem.
On the other hand get_ticks_per_sec is a static inline function:
- it will get inlined, no overhead over a macro
- it will add type safety if we ever change things (e.g. somebody might introduce
a tick_t)
So I would prefer to not change things.
Christian
WARNING: multiple messages have this Message-ID (diff)
From: Christian Borntraeger <borntraeger@de.ibm.com>
To: rutu.shah.26@gmail.com, qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, kvm@vger.kernel.org, mst@redhat.com,
jasowang@redhat.com, mark.cave-ayland@ilande.co.uk,
lcapitulino@redhat.com, kraxel@redhat.com, qemu-block@nongnu.org,
agraf@suse.de, samuel.thibault@ens-lyon.org, balrogg@gmail.com,
alistair.francis@xilinx.com, qemu-arm@nongnu.org,
stefanha@redhat.com, pbonzini@redhat.com,
cornelia.huck@de.ibm.com, rth@twiddle.net, kwolf@redhat.com,
crosthwaite.peter@gmail.com, armbru@redhat.com,
blauwirbel@gmail.co, qemu-ppc@nongnu.org, imammedo@redhat.com
Subject: Re: [PATCH] Replacing (and removing) get_ticks_per_sec() function with NANOSECONDS_PER_SECOND Signed-off-by: Rutuja Shah <rutu.shah.26@gmail.com>
Date: Fri, 11 Mar 2016 12:44:33 +0100 [thread overview]
Message-ID: <56E2AFA1.5010201@de.ibm.com> (raw)
In-Reply-To: <1457638209-14218-1-git-send-email-rutu.shah.26@gmail.com>
On 03/10/2016 08:30 PM, rutu.shah.26@gmail.com wrote:
> From: Rutuja Shah <rutu.shah.26@gmail.com>
[...]
> - s->tick_offset_vmstate = s->tick_offset + delta / get_ticks_per_sec();
> + s->tick_offset_vmstate = s->tick_offset + delta / NANOSECONDS_PER_SECOND;
[...]
While technically correct, I do not like these changes. The interfaces expect "ticks",
and the fact that this happens to be a nanosecond does not help regarding
readability.
Lets look at the snippet from above. The variable is called TICK_offset_vmstate.
so, the first line (-) makes sense when reading, the 2nd line (+) does not.
A reader that does not know the timer code will ask itself: "Why do we use
NANOSECONDS_PER_SECOND to calculate ticks?" The reader has to know that a tick
is a nanosecond to understand that line. So the cleanup makes the code harder to
read in my opinion.
If - for some reason - we want to replace a function with a MACRO, then
please introduce TICKS_PER_SECOND which just feels better when reading the code.
It would also fix the >80 chars per line problem.
On the other hand get_ticks_per_sec is a static inline function:
- it will get inlined, no overhead over a macro
- it will add type safety if we ever change things (e.g. somebody might introduce
a tick_t)
So I would prefer to not change things.
Christian
WARNING: multiple messages have this Message-ID (diff)
From: Christian Borntraeger <borntraeger@de.ibm.com>
To: rutu.shah.26@gmail.com, qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, kvm@vger.kernel.org, mst@redhat.com,
jasowang@redhat.com, mark.cave-ayland@ilande.co.uk,
lcapitulino@redhat.com, kraxel@redhat.com, qemu-block@nongnu.org,
agraf@suse.de, samuel.thibault@ens-lyon.org,
alistair.francis@xilinx.com, qemu-arm@nongnu.org,
stefanha@redhat.com, pbonzini@redhat.com,
cornelia.huck@de.ibm.com, jsnow@redhat.com, rth@twiddle.net,
kwolf@redhat.com, crosthwaite.peter@gmail.com, armbru@redhat.com,
blauwirbel@gmail.co, qemu-ppc@nongnu.org, imammedo@redhat.com
Subject: Re: [Qemu-devel] [PATCH] Replacing (and removing) get_ticks_per_sec() function with NANOSECONDS_PER_SECOND Signed-off-by: Rutuja Shah <rutu.shah.26@gmail.com>
Date: Fri, 11 Mar 2016 12:44:33 +0100 [thread overview]
Message-ID: <56E2AFA1.5010201@de.ibm.com> (raw)
In-Reply-To: <1457638209-14218-1-git-send-email-rutu.shah.26@gmail.com>
On 03/10/2016 08:30 PM, rutu.shah.26@gmail.com wrote:
> From: Rutuja Shah <rutu.shah.26@gmail.com>
[...]
> - s->tick_offset_vmstate = s->tick_offset + delta / get_ticks_per_sec();
> + s->tick_offset_vmstate = s->tick_offset + delta / NANOSECONDS_PER_SECOND;
[...]
While technically correct, I do not like these changes. The interfaces expect "ticks",
and the fact that this happens to be a nanosecond does not help regarding
readability.
Lets look at the snippet from above. The variable is called TICK_offset_vmstate.
so, the first line (-) makes sense when reading, the 2nd line (+) does not.
A reader that does not know the timer code will ask itself: "Why do we use
NANOSECONDS_PER_SECOND to calculate ticks?" The reader has to know that a tick
is a nanosecond to understand that line. So the cleanup makes the code harder to
read in my opinion.
If - for some reason - we want to replace a function with a MACRO, then
please introduce TICKS_PER_SECOND which just feels better when reading the code.
It would also fix the >80 chars per line problem.
On the other hand get_ticks_per_sec is a static inline function:
- it will get inlined, no overhead over a macro
- it will add type safety if we ever change things (e.g. somebody might introduce
a tick_t)
So I would prefer to not change things.
Christian
next prev parent reply other threads:[~2016-03-11 11:44 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-10 19:30 [PATCH] Replacing (and removing) get_ticks_per_sec() function with NANOSECONDS_PER_SECOND Signed-off-by: Rutuja Shah <rutu.shah.26@gmail.com> rutu.shah.26
2016-03-10 19:30 ` [Qemu-devel] " rutu.shah.26
2016-03-10 21:10 ` [Qemu-arm] " Eric Blake
2016-03-10 21:10 ` Eric Blake
2016-03-10 21:10 ` Eric Blake
2016-03-11 6:57 ` rutuja shah
2016-03-11 6:57 ` rutuja shah
2016-03-11 6:57 ` rutuja shah
2016-03-11 11:01 ` Stefan Hajnoczi
2016-03-11 11:01 ` [Qemu-devel] " Stefan Hajnoczi
2016-03-11 11:01 ` Stefan Hajnoczi
2016-03-11 11:44 ` Christian Borntraeger [this message]
2016-03-11 11:44 ` [Qemu-devel] " Christian Borntraeger
2016-03-11 11:44 ` Christian Borntraeger
2016-03-11 12:07 ` Paolo Bonzini
2016-03-11 12:07 ` [Qemu-devel] " Paolo Bonzini
2016-03-11 12:12 ` [Qemu-arm] " Christian Borntraeger
2016-03-11 12:12 ` [Qemu-devel] " Christian Borntraeger
2016-03-11 12:12 ` Christian Borntraeger
2016-03-11 12:26 ` Paolo Bonzini
2016-03-11 12:26 ` [Qemu-devel] " Paolo Bonzini
2016-03-11 13:22 ` Christian Borntraeger
2016-03-11 13:22 ` [Qemu-devel] " Christian Borntraeger
2016-03-11 13:22 ` Christian Borntraeger
2016-03-12 16:20 ` [Qemu-arm] " rutuja shah
2016-03-12 16:20 ` [Qemu-devel] " rutuja shah
2016-03-12 16:20 ` rutuja shah
2016-03-15 10:08 ` [Qemu-ppc] " Laurent Vivier
2016-03-15 10:08 ` [Qemu-devel] " Laurent Vivier
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=56E2AFA1.5010201@de.ibm.com \
--to=borntraeger@de.ibm.com \
--cc=agraf@suse.de \
--cc=alistair.francis@xilinx.com \
--cc=armbru@redhat.com \
--cc=balrogg@gmail.com \
--cc=blauwirbel@gmail.co \
--cc=cornelia.huck@de.ibm.com \
--cc=crosthwaite.peter@gmail.com \
--cc=imammedo@redhat.com \
--cc=jasowang@redhat.com \
--cc=jsnow@redhat.com \
--cc=kraxel@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=kwolf@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=rth@twiddle.net \
--cc=rutu.shah.26@gmail.com \
--cc=samuel.thibault@ens-lyon.org \
--cc=stefanha@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.