From: Timur Tabi <timur@codeaurora.org>
To: Ashwin Chaugule <ashwin.chaugule@linaro.org>
Cc: Prashanth Prakash <pprakash@codeaurora.org>,
"Rafael J. Wysocki" <rjw@rjwysocki.net>,
linux acpi <linux-acpi@vger.kernel.org>,
Linaro ACPI Mailman List <linaro-acpi@lists.linaro.org>,
Alexey Klimov <alexey.klimov@arm.com>
Subject: Re: [PATCH V3 1/4] ACPI / CPPC: Optimize PCC Read Write operations
Date: Wed, 10 Feb 2016 15:57:45 -0600 [thread overview]
Message-ID: <56BBB259.2030600@codeaurora.org> (raw)
In-Reply-To: <CAJ5Y-eZ7u7WdC3BX7ok=cvck9pOREOJzzB4J0cKsQt2rgK8LHQ@mail.gmail.com>
Ashwin Chaugule wrote:
> ..Only to be re substituted by the macro all over again. So, there
> really is no value in replacing this with a macro. Also,
> readx_relaxed_poll_timeout() has a usleep(), which will kill all the
> optimization here. Its also horribly wrong in this context.
>
> The alternative readx_poll_timeout_atomic() has a udelay() but it also
> adds way more conditionals than this code. So, there is no need to
> change things for the sake of cosmetic reasons.
This is not a cosmetic change. Calling a built-in macro instead of
re-inventing the wheel is not cosmetic. That's like saying that people
shouldn't bother using min() or max() because they can just calculate
the minimum and maximum themselves. The macros exist for a reason, and
people should be using them when applicable.
Also, the number of conditionals is not really much of an issue, I think.
The while loop has two conditionals:
1) The while-expression !ktime_after(ktime_get(), next_deadline)
2) The if-statement readw_relaxed(&generic_comm_base->status) &
PCC_CMD_COMPLETE
readl_relaxed_poll_timeout_atomic() has four:
1) if (cond) break;
2) if (timeout_us && ktime_compare(ktime_get(), timeout) > 0)
3) if (delay_us) udelay(delay_us);
4) (cond) ? 0 : -ETIMEDOUT; \
The third one is compiled-out because delay_us is a constant. The
fourth test is to handle the race condition between timeout and success.
If we time out, but the register value changes at the last
microsecond, then we report success anyway.
And since this is a macro instead of a function, the code is generally
optimized better. The compiler typically can optimize macros better
than functions, so there's still a chance that the macro version will be
more optimized than the function anyway.
Finally, there's the convention of using a built-in macro/function over
hand-coding something, even if it's not quite as optimized. I don't
think check_pcc_chan() is that time-critical that a single additional
conditional is really a problem. This while-loop really does re-invent
the wheel.
Anyway, I don't want to belabor this point. The decision is Rafael's now.
--
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora
Forum, a Linux Foundation collaborative project.
next prev parent reply other threads:[~2016-02-10 21:57 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-10 20:05 [PATCH V3 0/4] acpi: cppc optimization patches Prashanth Prakash
2016-02-10 20:05 ` [PATCH V3 1/4] ACPI / CPPC: Optimize PCC Read Write operations Prashanth Prakash
2016-02-10 20:42 ` Timur Tabi
2016-02-10 21:15 ` Ashwin Chaugule
2016-02-10 21:57 ` Timur Tabi [this message]
2016-02-10 22:17 ` Ashwin Chaugule
2016-02-15 16:37 ` Alexey Klimov
2016-02-16 18:47 ` Ashwin Chaugule
2016-02-16 19:10 ` Rafael J. Wysocki
2016-02-16 19:33 ` Ashwin Chaugule
2016-02-16 19:39 ` Rafael J. Wysocki
2016-02-29 17:39 ` Alexey Klimov
2016-02-29 19:20 ` Prakash, Prashanth
2016-02-10 20:06 ` [PATCH V3 2/4] acpi: cppc: optimized cpc_read and cpc_write Prashanth Prakash
2016-02-10 20:06 ` [PATCH V3 3/4] mailbox: pcc: optimized pcc_send_data Prashanth Prakash
2016-02-10 20:06 ` [PATCH V3 4/4] acpi: cppc: replace writeX/readX to PCC with relaxed version Prashanth Prakash
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=56BBB259.2030600@codeaurora.org \
--to=timur@codeaurora.org \
--cc=alexey.klimov@arm.com \
--cc=ashwin.chaugule@linaro.org \
--cc=linaro-acpi@lists.linaro.org \
--cc=linux-acpi@vger.kernel.org \
--cc=pprakash@codeaurora.org \
--cc=rjw@rjwysocki.net \
/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;
as well as URLs for NNTP newsgroup(s).