From: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
To: Julien Grall <julien.grall@arm.com>, xen-devel@lists.xen.org
Cc: sstabellini@kernel.org
Subject: Re: [PATCH 5/6] xen/arm: smccc: Add wrapper to automatically select the calling convention
Date: Tue, 28 Aug 2018 17:40:03 +0300 [thread overview]
Message-ID: <064131ee-e1d3-e641-a3dd-5ca8cbde92bd@epam.com> (raw)
In-Reply-To: <8d0077e1-4724-ddfe-e30e-173d45618427@arm.com>
Hi Julien,
On 28.08.18 17:05, Julien Grall wrote:
> Hi Volodymyr,
>
> On 27/08/18 17:50, Volodymyr Babchuk wrote:
>> On 27.08.18 18:29, Julien Grall wrote:
>>> On 27/08/2018 15:15, Volodymyr Babchuk wrote:
>>>> On 24.08.18 19:58, Julien Grall wrote:
>>>>> Signed-off-by: Julien Grall <julien.grall@arm.com>
>>> This is indeed increasing the size of the function, but with a better
>>> performance when you perform an SMC with 1.1.
>>>
>>> The main goal of SMCCC 1.1 is to limit the number of registers saved
>>> when calling an SMC. So if you provide provide a wrapper using a
>>> function, then you are better off sticking with SMCCC 1.0.
>>>
>>> The idea of this code is to provide a faster call on the presence of
>>> SMCCC 1.1 while providing a fallback for other case. The function
>>> cpus_have_const_cap is implemented using an ALTERNATIVE (similar to
>>> static key) that will make if close to a NOP. I am saying close
>>> because this is not quite a static key as we don't have it in Xen.
>>> Instead, you replace a memory load by a constant.
>> Ah, yes, true.
>>
>> I checked how static keys are working. Seems, they use asm goto
>> feature. Now I think: can we optimize this more? Something like that:
>>
>> #define arm_smccc_smc(...)
>> do {
>>
>> asm goto (ALTERNATIVE(nop",
>> "b %l[smccc_1_1]",
>> ARM_SMCCC_1_1));
>
> You would need to list the label in GotoLabels (see 6.45.2.7 [1]).
Yes, but as you said, we can use __LINE__ there.
>> arm_smccc_1_0_smc(__VA_ARGS__);
>> break;
>> smccc_1_1:
> The label will get redefined if you have multiple SMC call in the same
> function. We could possibly generate label based on the file/line.
>
>> arm_smccc_1_1_smc(__VA_ARGS__);
>> } while ( 0 )
>>
>> This will save use additional conditional branch.
> The code with this patch looks like:
>
> mov x0, #0 mov x0, #1
> cbz w0, label cbz w0, label
>
> The mov + conditional branch is likely to be negligible over the cost of
> switching to EL3. Overall, I am not really convinced that it would be
> worth the cost of open-coding it. I would prefer if we keep the call to
> cpus_have_const_cap() and see if it can be optimized.
Okay. I'm fine with this. I just saw one more way to optimize and wanted
to share it with you. Anyways:
Reviewed-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
> I have looked at cpus_have_const_cap() and haven't found good way to
> optimize it with the current infrastructure in Xen. Feel free to suggest
> improvement.
Another thing: maybe it is worth to branch to 1.0 code and leave 1.1 in
a straight path of execution? This will save you one more instruction
for SMCCC 1.1 call.
--
Volodymyr Babchuk
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2018-08-28 14:40 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-24 16:58 [PATCH 0/6] xen/arm: SMCCC fixup and improvement Julien Grall
2018-08-24 16:58 ` [PATCH 1/6] xen/arm: smccc-1.1: Make return values unsigned long Julien Grall
2018-08-27 14:03 ` Volodymyr Babchuk
2018-08-27 15:23 ` Julien Grall
2018-08-27 16:33 ` Volodymyr Babchuk
2018-08-24 16:58 ` [PATCH 2/6] xen/arm: smccc-1.1: Handle function result as parameters Julien Grall
2018-08-27 14:05 ` Volodymyr Babchuk
2018-08-24 16:58 ` [PATCH 3/6] xen/arm: add SMC wrapper that is compatible with SMCCC v1.0 Julien Grall
2018-08-24 16:58 ` [PATCH 4/6] xen/arm: cpufeature: Add helper to check constant caps Julien Grall
2018-08-30 17:43 ` Volodymyr Babchuk
2018-09-25 16:53 ` Julien Grall
2018-08-24 16:58 ` [PATCH 5/6] xen/arm: smccc: Add wrapper to automatically select the calling convention Julien Grall
2018-08-27 14:15 ` Volodymyr Babchuk
2018-08-27 15:29 ` Julien Grall
2018-08-27 16:50 ` Volodymyr Babchuk
2018-08-28 14:05 ` Julien Grall
2018-08-28 14:40 ` Volodymyr Babchuk [this message]
2018-08-28 14:43 ` Julien Grall
2018-08-28 15:10 ` Volodymyr Babchuk
2018-08-28 15:27 ` Julien Grall
2018-08-28 15:50 ` Volodymyr Babchuk
2018-08-28 15:57 ` Julien Grall
2018-08-30 17:45 ` Volodymyr Babchuk
2018-08-24 16:58 ` [PATCH 6/6] xen/arm: Replace call_smc with arm_smccc_smc Julien Grall
2018-08-27 13:53 ` Volodymyr Babchuk
2018-08-30 16:41 ` [PATCH 0/6] xen/arm: SMCCC fixup and improvement Volodymyr Babchuk
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=064131ee-e1d3-e641-a3dd-5ca8cbde92bd@epam.com \
--to=volodymyr_babchuk@epam.com \
--cc=julien.grall@arm.com \
--cc=sstabellini@kernel.org \
--cc=xen-devel@lists.xen.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.