From: Thomas Gleixner <tglx@linutronix.de>
To: "K. Y. Srinivasan" <kys@microsoft.com>
Cc: gregkh@suse.de, linux-kernel@vger.kernel.org,
devel@linuxdriverproject.org, johnstul@us.ibm.com,
hch@infradead.org, Hank Janssen <hjanssen@microsoft.com>,
Haiyang Zhang <haiyangz@microsoft.com>
Subject: Re: [PATCH 1/1] Clocksource: Move the Hyper-V clocksource driver out of staging
Date: Wed, 25 May 2011 00:43:02 +0200 (CEST) [thread overview]
Message-ID: <alpine.LFD.2.02.1105250015360.3078@ionos> (raw)
In-Reply-To: <1306272773-4572-1-git-send-email-kys@microsoft.com>
On Tue, 24 May 2011, K. Y. Srinivasan wrote:
> --- a/arch/x86/Kconfig
> +++ b/arch/x86/Kconfig
> @@ -595,6 +595,9 @@ config X86_CYCLONE_TIMER
> def_bool y
> depends on X86_32_NON_STANDARD
>
> +config HYPERV_CLKSRC
> + def_bool y
Errm, why do we need another random config switch for every other
feature of hyperv?
> +#include <linux/clocksource.h>
> +#include <linux/time.h>
Why do you need time.h?
> +#include <asm/hyperv.h>
> +#include <asm/mshyperv.h>
> +#include <asm/hypervisor.h>
Can we please have one sensible asm/hyperwtf.h include for all of this ?
> +
> +static cycle_t read_hv_clock(struct clocksource *arg)
> +{
> + cycle_t current_tick;
> + /*
> + * Read the partition counter to get the current tick count. This count
> + * is set to 0 when the partition is created and is incremented in
> + * 100 nanosecond units.
> + */
Please move that comment above the function. That's really irritating
to read.
> + rdmsrl(HV_X64_MSR_TIME_REF_COUNT, current_tick);
> + return current_tick;
> +}
> +
> +static struct clocksource hyperv_cs = {
> + .name = "hyperv_clocksource",
> + .rating = 400, /* use this when running on Hyperv*/
That tail comment is pretty useless.
> + .read = read_hv_clock,
> + .mask = CLOCKSOURCE_MASK(64),
> +};
> +
> +static int __init init_hv_clocksource(void)
> +{
> + unsigned long hv_period = 100; /* 100 ns granularity clocksource */
unsigned long period_ns = 100;
would make the horrible tail comment go away and make it obvious to
the reader what the variable is for. Also please stop adding extra
useless noise to local variables by adding hv_ or whatever the heck to
them.
> + u32 hv_freq;
Newline between declarations and code please.
> + if ((x86_hyper != &x86_hyper_ms_hyperv) ||
> + !(ms_hyperv.features & HV_X64_MSR_TIME_REF_COUNT_AVAILABLE))
> + return -ENODEV;
> +
> + hv_freq = NSEC_PER_SEC;
> + do_div(hv_freq, hv_period);
ROTFL. Do you really need runtime evaluation of 10^9/10^2 ?
#define HV_CLK_FREQ (NSEC_PER_SEC/100)
would solve that problem with 5 lines less source code and a even
larger reduction of binary size.
> +
> + printk(KERN_INFO "Registering Hyper-V clock source\n");
How is that interesting ?
> + return clocksource_register_hz(&hyperv_cs, hv_freq);
> +}
And if you remove that useless stuff then the ten remaining lines
should go to arch/x86/ into a file which will contain more than those
ten lines. It's pretty unlikely that anything else than MSHV will
reuse that code.
Thanks,
tglx
next prev parent reply other threads:[~2011-05-24 22:43 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-24 21:32 [PATCH 1/1] Clocksource: Move the Hyper-V clocksource driver out of staging K. Y. Srinivasan
2011-05-24 22:43 ` Thomas Gleixner [this message]
2011-05-25 0:29 ` KY Srinivasan
2011-05-25 6:58 ` Thomas Gleixner
-- strict thread matches above, loose matches on Subject: below --
2011-05-23 17:12 K. Y. Srinivasan
2011-05-23 18:15 ` Thomas Gleixner
2011-05-23 18:50 ` KY Srinivasan
2011-05-23 19:17 ` Thomas Gleixner
2011-05-23 18:40 ` john stultz
2011-05-23 18:43 ` KY Srinivasan
2011-05-23 18:42 ` Christoph Hellwig
2011-05-23 19:05 ` KY Srinivasan
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=alpine.LFD.2.02.1105250015360.3078@ionos \
--to=tglx@linutronix.de \
--cc=devel@linuxdriverproject.org \
--cc=gregkh@suse.de \
--cc=haiyangz@microsoft.com \
--cc=hch@infradead.org \
--cc=hjanssen@microsoft.com \
--cc=johnstul@us.ibm.com \
--cc=kys@microsoft.com \
--cc=linux-kernel@vger.kernel.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.