mshyperv: Introduce hv_numa_node_to_pxm_info()
Subsystems (4)
PATCH v3 1/1 mshyperv: Introduce hv_numa_node_to_pxm_info()
Factor out logic for converting numa node to hv_proximity_domain_info into a helper function.
Change hv_proximity_domain_info to a struct to improve readability.
While at it, rename hv_add_logical_processor_* structs to the correct hv_input_/hv_output_ prefix, and remove the flags field which is not present in the ABI.
---
Changes in v3:
* Shorten function name to hv_numa_node_to_pxm_info()
* Correct hv_add_logical_processor_* naming, and remove flags
Changes in v2:
* Change hv_proximity_domain_info from union to struct to improve readability [Dave Hanson]
--- arch/x86/hyperv/hv_proc.c | 22 ++++------------------ include/asm-generic/hyperv-tlfs.h | 19 +++++++------------ include/asm-generic/mshyperv.h | 14 ++++++++++++++ 3 files changed, 25 insertions(+), 30 deletions(-)
arch/x86/hyperv/hv_proc.c +4 -18
@@ -3,7 +3,6 @@#include <linux/vmalloc.h> #include <linux/mm.h> #include <linux/clockchips.h> -#include <linux/acpi.h> #include <linux/hyperv.h> #include <linux/slab.h> #include <linux/cpuhotplug.h>
@@ -116,12 +115,11 @@ int hv_call_deposit_pages(int node, u64 partition_id, u32 num_pages)int hv_call_add_logical_proc (int node,u32 lp_index,u32 apic_id) { -struct hv_add_logical_processor_in *input; -struct hv_add_logical_processor_out *output; +struct hv_input_add_logical_processor *input; +struct hv_output_add_logical_processor *output;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 +135,7 @@ 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 =hv_numa_node_to_pxm_info (node); status =hv_do_hypercall (HVCALL_ADD_LOGICAL_PROCESSOR , input, output);local_irq_restore (flags);
@@ -166,7 +160,6 @@ int hv_call_create_vp(int node, u64 partition_id, u32 vp_index, u32 flags)u64 status;unsigned long irq_flags;int ret =HV_STATUS_SUCCESS ; -int pxm =node_to_pxm (node);/* Root VPs don't seem to need pages deposited */ if (partition_id != hv_current_partition_id) {
@@ -185,14 +178,7 @@ int hv_call_create_vp(int node, u64 partition_id, u32 vp_index, u32 flags) input->vp_index = vp_index; input->flags = flags; input->subnode_type = HvSubnodeAny; -if (node !=NUMA_NO_NODE ) { - 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 ; - }else { - input->proximity_domain_info.as_uint64 =0 ; - } + input->proximity_domain_info =hv_numa_node_to_pxm_info (node); status =hv_do_hypercall (HVCALL_CREATE_VP , input,NULL );local_irq_restore (irq_flags);
include/asm-generic/hyperv-tlfs.h +7 -12
@@ -512,13 +512,9 @@ struct hv_proximity_domain_flags { u32 proximity_info_valid : 1; } __packed; -/* Not a union in windows but useful for zeroing */ -union hv_proximity_domain_info { -struct { -u32 domain_id; -struct hv_proximity_domain_flags flags; - }; -u64 as_uint64; +struct hv_proximity_domain_info { +u32 domain_id; +struct hv_proximity_domain_flags flags; } __packed;struct hv_lp_startup_status {
@@ -532,14 +528,13 @@ struct hv_lp_startup_status { } __packed;/* HvAddLogicalProcessor hypercall */ -struct hv_add_logical_processor_in { +struct hv_input_add_logical_processor {u32 lp_index;u32 apic_id; -union hv_proximity_domain_info proximity_domain_info; -u64 flags; +struct hv_proximity_domain_info proximity_domain_info; } __packed; -struct hv_add_logical_processor_out { +struct hv_output_add_logical_processor {struct hv_lp_startup_status startup_status; } __packed;
@@ -560,7 +555,7 @@ struct hv_create_vp {u8 padding[3 ];u8 subnode_type;u64 subnode_id; -union hv_proximity_domain_info proximity_domain_info; +struct hv_proximity_domain_info proximity_domain_info;u64 flags; } __packed;
include/asm-generic/mshyperv.h +14 -0
@@ -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>
@@ -67,6 +68,19 @@ extern u64 hv_do_fast_hypercall8(u16 control, u64 input8);bool hv_isolation_type_snp (void );bool hv_isolation_type_tdx (void ); +static inline struct hv_proximity_domain_info hv_numa_node_to_pxm_info (int node) +{ +struct hv_proximity_domain_info pxm_info = {}; + +if (node !=NUMA_NO_NODE ) { + pxm_info.domain_id =node_to_pxm (node); + pxm_info.flags.proximity_info_valid =1 ; + pxm_info.flags.proximity_preferred =1 ; + } + +return pxm_info; +} +/* Helper functions that provide a consistent pattern for checking Hyper-V hypercall status. */ static inline int hv_result (u64 status) {
Signature · 1 line
2.25.1
Quoted 12 lines · Nuno Das Neves
Factor out logic for converting numa node to
hv_proximity_domain_infointo a helper function.Change
hv_proximity_domain_infoto a struct to improve readability.While at it, rename hv_add_logical_processor_* structs to the correct hv_input_/hv_output_ prefix, and remove the flags field which is not present in the ABI.
Signed-off-by Nuno Das Neves <[email protected]>Reviewed-by Wei Liu <[email protected]>
Queued for hyperv-fixes. Thanks.