[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <MWHPR21MB15933CFA486898817B7E396AD7D79@MWHPR21MB1593.namprd21.prod.outlook.com>
Date: Sat, 11 Sep 2021 15:06:18 +0000
From: Michael Kelley <mikelley@...rosoft.com>
To: Wei Liu <wei.liu@...nel.org>,
Linux on Hyper-V List <linux-hyperv@...r.kernel.org>
CC: KY Srinivasan <kys@...rosoft.com>,
Haiyang Zhang <haiyangz@...rosoft.com>,
Dexuan Cui <decui@...rosoft.com>,
Stephen Hemminger <sthemmin@...rosoft.com>,
Arnd Bergmann <arnd@...db.de>,
"open list:GENERIC INCLUDE/ASM HEADER FILES"
<linux-arch@...r.kernel.org>,
open list <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH v2 1/2] asm-generic/hyperv: provide
cpumask_to_vpset_noself
From: Wei Liu <wei.liu@...nel.org> Sent: Friday, September 10, 2021 11:57 AM
>
> This is a new variant which removes `self' cpu from the vpset. It will
> be used in Hyper-V enlightened IPI code.
>
> Signed-off-by: Wei Liu <wei.liu@...nel.org>
> ---
> Provide a new variant instead of adding a new parameter because it makes
> it easier to backport -- we don't need to fix the users of
> cpumask_to_vpset.
>
> v2:
> 1. Rename function
> 2. Add preemptible check
> ---
> include/asm-generic/mshyperv.h | 21 +++++++++++++++++++--
> 1 file changed, 19 insertions(+), 2 deletions(-)
>
> diff --git a/include/asm-generic/mshyperv.h b/include/asm-generic/mshyperv.h
> index 9a000ba2bb75..9a134806f1d5 100644
> --- a/include/asm-generic/mshyperv.h
> +++ b/include/asm-generic/mshyperv.h
> @@ -184,10 +184,12 @@ static inline int hv_cpu_number_to_vp_number(int cpu_number)
> return hv_vp_index[cpu_number];
> }
>
> -static inline int cpumask_to_vpset(struct hv_vpset *vpset,
> - const struct cpumask *cpus)
> +static inline int __cpumask_to_vpset(struct hv_vpset *vpset,
> + const struct cpumask *cpus,
> + bool exclude_self)
> {
> int cpu, vcpu, vcpu_bank, vcpu_offset, nr_bank = 1;
> + int this_cpu = smp_processor_id();
>
> /* valid_bank_mask can represent up to 64 banks */
> if (hv_max_vp_index / 64 >= 64)
> @@ -205,6 +207,8 @@ static inline int cpumask_to_vpset(struct hv_vpset *vpset,
> * Some banks may end up being empty but this is acceptable.
> */
> for_each_cpu(cpu, cpus) {
> + if (exclude_self && cpu == this_cpu)
> + continue;
> vcpu = hv_cpu_number_to_vp_number(cpu);
> if (vcpu == VP_INVAL)
> return -1;
> @@ -219,6 +223,19 @@ static inline int cpumask_to_vpset(struct hv_vpset *vpset,
> return nr_bank;
> }
>
> +static inline int cpumask_to_vpset(struct hv_vpset *vpset,
> + const struct cpumask *cpus)
> +{
> + return __cpumask_to_vpset(vpset, cpus, false);
> +}
> +
> +static inline int cpumask_to_vpset_noself(struct hv_vpset *vpset,
> + const struct cpumask *cpus)
> +{
> + WARN_ON_ONCE(preemptible());
> + return __cpumask_to_vpset(vpset, cpus, true);
> +}
> +
> void hyperv_report_panic(struct pt_regs *regs, long err, bool in_die);
> bool hv_is_hyperv_initialized(void);
> bool hv_is_hibernation_supported(void);
> --
> 2.30.2
Reviewed-by: Michael Kelley <mikelley@...rosoft.com>
Powered by blists - more mailing lists