[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [XEN][PATCH] xen/evtchn: enable build optimization for evtchn_move_pirqs()/send_guest_pirq()


  • To: Grygorii Strashko <grygorii_strashko@xxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 17 Jul 2025 17:33:55 +0200
  • Autocrypt: addr=jbeulich@xxxxxxxx; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Roger Pau Monne <roger.pau@xxxxxxxxxx>, Ayan Kumar Halder <ayankuma@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Thu, 17 Jul 2025 15:34:23 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 17.07.2025 16:41, Grygorii Strashko wrote:
> 
> 
> On 17.07.25 16:10, Jan Beulich wrote:
>> On 17.07.2025 15:01, Grygorii Strashko wrote:
>>> --- a/xen/common/event_channel.c
>>> +++ b/xen/common/event_channel.c
>>> @@ -975,6 +975,9 @@ void send_guest_pirq(struct domain *d, const struct 
>>> pirq *pirq)
>>>       int port;
>>>       struct evtchn *chn;
>>>   
>>> +    if (!IS_ENABLED(CONFIG_HAS_PIRQ))
>>> +        return;
>>> +
>>>       /*
>>>        * PV guests: It should not be possible to race with 
>>> __evtchn_close(). The
>>>        *     caller of this function must synchronise with 
>>> pirq_guest_unbind().
>>
>> Isn't this function unreachable on Arm, and hence a Misra rule 2.1 violation,
>> requiring #ifdef around the entire function to address?
> 
> Yes. It's unused on Arm, only x86 is an user.
> I can put it under ifdef.
> 
>>
>>> @@ -1710,10 +1713,15 @@ void evtchn_destroy_final(struct domain *d)
>>>   void evtchn_move_pirqs(struct vcpu *v)
>>>   {
>>>       struct domain *d = v->domain;
>>> -    const cpumask_t *mask = cpumask_of(v->processor);
>>> +    const cpumask_t *mask;
>>
>> This change shouldn't be necessary; compilers ought to be able to DCE the
>> code.
> 
> Unfortunately not, with "-O1" more code is generated as cpumask_of() is 
> complicated inside.
> 
>>
>>>       unsigned int port;
>>>       struct evtchn *chn;
>>>   
>>> +    if (!IS_ENABLED(CONFIG_HAS_PIRQ))
>>
>> Nit (style): Missing blanks (see other nearby if()-s).
>>
>> I wonder though whether we wouldn't better have x86'es arch_move_irqs()
>> invoke this function, and then #ifdef it out here altogether as well.
> 
> Do you mean as in the below diff?

Along these lines, yes. I guess personally I wouldn't convert to an
out-of-line function. If an inline function fails to compile (and that
isn't easily fixable), use a macro instead.

Jan

> --- a/xen/arch/x86/include/asm/irq.h
> +++ b/xen/arch/x86/include/asm/irq.h
> @@ -224,7 +224,7 @@ void cleanup_domain_irq_mapping(struct domain *d);
>   
>   bool cpu_has_pending_apic_eoi(void);
>   
> -static inline void arch_move_irqs(struct vcpu *v) { }
> +void arch_move_irqs(struct vcpu *v);
>   
>   struct msi_info;
>   int allocate_and_map_gsi_pirq(struct domain *d, int index, int *pirq_p);
> diff --git a/xen/arch/x86/irq.c b/xen/arch/x86/irq.c
> index 556134f85aa0..b8d8f202119d 100644
> --- a/xen/arch/x86/irq.c
> +++ b/xen/arch/x86/irq.c
> @@ -1851,6 +1851,10 @@ void pirq_guest_unbind(struct domain *d, struct pirq 
> *pirq)
>           cleanup_domain_irq_pirq(d, irq, pirq);
>   }
>   
> +void arch_move_irqs(struct vcpu *v) {
> +    evtchn_move_pirqs(v);
> +}
> +
>   static bool pirq_guest_force_unbind(struct domain *d, struct pirq *pirq)
>   {
>       struct irq_desc *desc;
> diff --git a/xen/common/sched/core.c b/xen/common/sched/core.c
> index 13fdf57e57b9..ad6032fb2865 100644
> --- a/xen/common/sched/core.c
> +++ b/xen/common/sched/core.c
> @@ -642,7 +642,6 @@ int sched_init_vcpu(struct vcpu *v)
>   static void vcpu_move_irqs(struct vcpu *v)
>   {
>       arch_move_irqs(v);
> -    evtchn_move_pirqs(v);
>   }
> 
> 




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.