From: Guenter Roeck <linux@roeck-us.net>
To: "Pali Rohár" <pali.rohar@gmail.com>
Cc: Jean Delvare <jdelvare@suse.com>,
Oleksandr Natalenko <oleksandr@natalenko.name>,
Jonathan Buzzard <jonathan@buzzard.org.uk>,
Mario Limonciello <mario.limonciello@dell.com>,
linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [4/4] hwmon: (dell-smm) Measure time duration of SMM call around inlined asm
Date: Sat, 27 Jan 2018 09:51:45 -0800 [thread overview]
Message-ID: <20180127175145.GA12923@roeck-us.net> (raw)
In-Reply-To: <20180127162351.13858-1-pali.rohar@gmail.com>
On Sat, Jan 27, 2018 at 05:23:51PM +0100, Pali Rohár wrote:
> Measure only inlined asm code, not other functions to have as precise as
> possible measured time.
>
> Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
> ---
> drivers/hwmon/dell-smm-hwmon.c | 14 ++++++++++----
> 1 file changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c
> index bf3bb7e1adab..e001afd53f46 100644
> --- a/drivers/hwmon/dell-smm-hwmon.c
> +++ b/drivers/hwmon/dell-smm-hwmon.c
> @@ -147,14 +147,16 @@ static int i8k_smm_func(void *par)
> int ebx = regs->ebx;
> unsigned long duration;
> ktime_t calltime, delta, rettime;
> -
> - calltime = ktime_get();
> #endif
>
> /* SMM requires CPU 0 */
> if (smp_processor_id() != 0)
> return -EBUSY;
>
> +#ifdef DEBUG
> + calltime = ktime_get();
> +#endif
> +
> #if defined(CONFIG_X86_64)
> asm volatile("pushq %%rax\n\t"
> "movl 0(%%rax),%%edx\n\t"
> @@ -208,13 +210,17 @@ static int i8k_smm_func(void *par)
> : "a"(regs)
> : "%ebx", "%ecx", "%edx", "%esi", "%edi", "memory");
> #endif
> - if (rc != 0 || (regs->eax & 0xffff) == 0xffff || regs->eax == eax)
> - rc = -EINVAL;
>
> #ifdef DEBUG
> rettime = ktime_get();
> delta = ktime_sub(rettime, calltime);
> duration = ktime_to_ns(delta) >> 10;
> +#endif
> +
> + if (rc != 0 || (regs->eax & 0xffff) == 0xffff || regs->eax == eax)
> + rc = -EINVAL;
> +
> +#ifdef DEBUG
FWIW, the error introduced by dividing nS by 1,024 instead of 1,000 is
much worse than the improvements from moving the calls around. Using
specific numbers, the current code reports 500 mS as 488,281 uS.
So why bother ?
I would have suggested to use ktime_us_delta(ktime_get(), calltime)
instead to make the results more accurate. Sure, you get the offset from
the additional divide operation, but at least that would be a constant
and not a systematic error.
I'll hold this patch off for a bit. Please confirm that you want it
applied as-is. I applied the other patches from the series.
Thanks,
Guenter
next prev parent reply other threads:[~2018-01-27 17:51 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-27 16:22 [PATCH 0/4] hwmon: (dell-smm) Disable fan support on Inspiron 7720 and Vostro 3360 Pali Rohár
2018-01-27 16:22 ` [PATCH 1/4] hwmon: (dell-smm) Enable broken functionality via "force" module param Pali Rohár
2018-01-27 16:23 ` [PATCH 3/4] hwmon: (dell-smm) Disable fan support for Dell Vostro 3360 Pali Rohár
2018-01-27 16:23 ` [PATCH 4/4] hwmon: (dell-smm) Measure time duration of SMM call around inlined asm Pali Rohár
2018-01-27 17:51 ` Guenter Roeck [this message]
2018-01-29 8:46 ` [4/4] " Pali Rohár
2018-01-27 16:28 ` [PATCH 2/4] hwmon: (dell-smm) Disable fan support for Dell Inspiron 7720 Pali Rohár
2018-01-27 16:33 ` [PATCH 0/4] hwmon: (dell-smm) Disable fan support on Inspiron 7720 and Vostro 3360 Oleksandr Natalenko
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=20180127175145.GA12923@roeck-us.net \
--to=linux@roeck-us.net \
--cc=jdelvare@suse.com \
--cc=jonathan@buzzard.org.uk \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mario.limonciello@dell.com \
--cc=oleksandr@natalenko.name \
--cc=pali.rohar@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox