xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Julien Grall <julien.grall@arm.com>
To: Volodymyr Babchuk <volodymyr_babchuk@epam.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 16:57:03 +0100	[thread overview]
Message-ID: <18febf9b-7ad5-2238-e0ad-9d27e48e016b@arm.com> (raw)
In-Reply-To: <76a634d3-b0b6-76fe-c265-bbe414b9b51a@epam.com>



On 28/08/18 16:50, Volodymyr Babchuk wrote:
> Hi Julien,

Hi,

> 
> On 28.08.18 18:27, Julien Grall wrote:
>> Hi Volodymyr,
>>
>> On 28/08/18 16:10, Volodymyr Babchuk wrote:
>>>
>>>
>>> On 28.08.18 17:43, Julien Grall wrote:
>>> [...]
>>>
>>>>
>>>>>> 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.
>>>>
>>>> I am not sure to understand your suggestion here. Could you expand?
>>>
>>> +#define arm_smccc_smc(...)                                      \
>>> +    do {                                                        \
>>> +        if ( cpus_have_const_cap(ARM_SMCCC_1_1) )              \
>>> +            arm_smccc_1_1_smc(__VA_ARGS__);                     \
>>> +        else                                                    \
>>> +            arm_smccc_1_0_smc(__VA_ARGS__);                     \
>>> +    } while ( 0 )
>>>
>>>
>>>> However, why SMCCC 1.1 should be in the straight path of execution?
>>>
>>> It is easier to read - no negation in if(). 
>>
>> I can do that. I will also probably add an unlikely in 
>> cpus_have_const_cap(...).
> That would  be great.
> 
>>
>>> Also, I think, branch predictor would be happy. At least, if the 
>>> following is true:
>>>
>>> " If the branch information is not contained in the BTAC, static 
>>> branch prediction is used, whereby we assume the branch will be taken 
>>> if the branch is a conditional backwards branch or not taken if the 
>>> branch is a conditional forwards branch." [1]
>>
>> The Arm Arm does not provide any details on the branch predictor 
>> implementation. An implementer is free to do whatever he wants and 
>> could design a branch predicator doing the opposite as this statement.
> Generally speaking - yes. But, AFAIK, most static predictors behave in 
> the way described above. Anyways, as you pointed below, better to leave 
> hint for the compiler.

Spectre would not have existed if the branch predictor was so easy ;).

> 
>>
>> You also can't assume how the compiler will compile the code, it may 
>> end up to generate the else branch first because it is predicted to be 
>> taken more often. This is why GCC provide __builtin_expect (commonly 
>> used as unlikely/likely) to influence the compiler choice for branch 
>> prediction.
> Yes, this is the good point. So, you can add likely/unlikely not only in 
> cpus_have_const_cap(...) but also in #define arm_smccc_smc(...)

There are no need to have likely/unlikely in arm_smccc_smc if it is 
already present in cpus_have_const_cap.

Cheers,

-- 
Julien Grall

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2018-08-28 15:57 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
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 [this message]
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=18febf9b-7ad5-2238-e0ad-9d27e48e016b@arm.com \
    --to=julien.grall@arm.com \
    --cc=sstabellini@kernel.org \
    --cc=volodymyr_babchuk@epam.com \
    --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 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).