[03/15] mshyperv: Introduce numa_node_to_proximity_domain_info
Commit Message
Factor out logic for converting numa node to proximity domain info into
a helper function, and export it.
Signed-off-by: Nuno Das Neves <nunodasneves@linux.microsoft.com>
---
arch/x86/hyperv/hv_proc.c | 8 ++------
drivers/acpi/numa/srat.c | 1 +
include/asm-generic/mshyperv.h | 18 ++++++++++++++++++
3 files changed, 21 insertions(+), 6 deletions(-)
Comments
On Thu, Jul 27, 2023 at 12:54:38PM -0700, Nuno Das Neves wrote:
> Factor out logic for converting numa node to proximity domain info into
> a helper function, and export it.
>
> Signed-off-by: Nuno Das Neves <nunodasneves@linux.microsoft.com>
Reviewed-by: Wei Liu <wei.liu@kernel.org>
> ---
> arch/x86/hyperv/hv_proc.c | 8 ++------
> drivers/acpi/numa/srat.c | 1 +
> include/asm-generic/mshyperv.h | 18 ++++++++++++++++++
> 3 files changed, 21 insertions(+), 6 deletions(-)
>
[...]
> diff --git a/drivers/acpi/numa/srat.c b/drivers/acpi/numa/srat.c
> index 1f4fc5f8a819..0cf9f0574495 100644
> --- a/drivers/acpi/numa/srat.c
> +++ b/drivers/acpi/numa/srat.c
> @@ -48,6 +48,7 @@ int node_to_pxm(int node)
> return PXM_INVAL;
> return node_to_pxm_map[node];
> }
> +EXPORT_SYMBOL(node_to_pxm);
Rafael and Len, I would like to get an ACK from you on this one line
change. I see a lot of other functions in that file are already
exported, so I hope this is okay, too.
It's user is the function below numa_node_to_proximity_domain_info.
Thanks,
Wei.
>
> static void __acpi_map_pxm_to_node(int pxm, int node)
> {
> diff --git a/include/asm-generic/mshyperv.h b/include/asm-generic/mshyperv.h
> index 233c976344e5..447e7ebe67ee 100644
> --- a/include/asm-generic/mshyperv.h
> +++ b/include/asm-generic/mshyperv.h
> @@ -21,6 +21,7 @@
> #include <linux/types.h>
> #include <linux/atomic.h>
> #include <linux/bitops.h>
> +#include <acpi/acpi_numa.h>
> #include <linux/cpumask.h>
> #include <linux/nmi.h>
> #include <asm/ptrace.h>
> @@ -28,6 +29,23 @@
>
> #define VTPM_BASE_ADDRESS 0xfed40000
>
> +static inline union hv_proximity_domain_info
> +numa_node_to_proximity_domain_info(int node)
> +{
> + union hv_proximity_domain_info proximity_domain_info;
> +
> + if (node != NUMA_NO_NODE) {
> + proximity_domain_info.domain_id = node_to_pxm(node);
> + proximity_domain_info.flags.reserved = 0;
> + proximity_domain_info.flags.proximity_info_valid = 1;
> + proximity_domain_info.flags.proximity_preferred = 1;
> + } else {
> + proximity_domain_info.as_uint64 = 0;
> + }
> +
> + return proximity_domain_info;
> +}
> +
> struct ms_hyperv_info {
> u32 features;
> u32 priv_high;
> --
> 2.25.1
>
@@ -121,7 +121,6 @@ int hv_call_add_logical_proc(int node, u32 lp_index, u32 apic_id)
u64 status;
unsigned long flags;
int ret = HV_STATUS_SUCCESS;
- int pxm = node_to_pxm(node);
/*
* When adding a logical processor, the hypervisor may return
@@ -137,11 +136,8 @@ int hv_call_add_logical_proc(int node, u32 lp_index, u32 apic_id)
input->lp_index = lp_index;
input->apic_id = apic_id;
- input->flags = 0;
- input->proximity_domain_info.domain_id = pxm;
- input->proximity_domain_info.flags.reserved = 0;
- input->proximity_domain_info.flags.proximity_info_valid = 1;
- input->proximity_domain_info.flags.proximity_preferred = 1;
+ input->proximity_domain_info =
+ numa_node_to_proximity_domain_info(node);
status = hv_do_hypercall(HVCALL_ADD_LOGICAL_PROCESSOR,
input, output);
local_irq_restore(flags);
@@ -48,6 +48,7 @@ int node_to_pxm(int node)
return PXM_INVAL;
return node_to_pxm_map[node];
}
+EXPORT_SYMBOL(node_to_pxm);
static void __acpi_map_pxm_to_node(int pxm, int node)
{
@@ -21,6 +21,7 @@
#include <linux/types.h>
#include <linux/atomic.h>
#include <linux/bitops.h>
+#include <acpi/acpi_numa.h>
#include <linux/cpumask.h>
#include <linux/nmi.h>
#include <asm/ptrace.h>
@@ -28,6 +29,23 @@
#define VTPM_BASE_ADDRESS 0xfed40000
+static inline union hv_proximity_domain_info
+numa_node_to_proximity_domain_info(int node)
+{
+ union hv_proximity_domain_info proximity_domain_info;
+
+ if (node != NUMA_NO_NODE) {
+ proximity_domain_info.domain_id = node_to_pxm(node);
+ proximity_domain_info.flags.reserved = 0;
+ proximity_domain_info.flags.proximity_info_valid = 1;
+ proximity_domain_info.flags.proximity_preferred = 1;
+ } else {
+ proximity_domain_info.as_uint64 = 0;
+ }
+
+ return proximity_domain_info;
+}
+
struct ms_hyperv_info {
u32 features;
u32 priv_high;