Skip to content

Commit 55e544e

Browse files
Nischala Yelchuriliuw
authored andcommitted
x86/hyperv: Improve code for referencing hyperv_pcpu_input_arg
Several places in code for Hyper-V reference the per-CPU variable hyperv_pcpu_input_arg. Older code uses a multi-line sequence to reference the variable, and usually includes a cast. Newer code does a much simpler direct assignment. The latter is preferable as the complexity of the older code is unnecessary. Update older code to use the simpler direct assignment. Signed-off-by: Nischala Yelchuri <niyelchu@linux.microsoft.com> Link: https://lore.kernel.org/r/1687286438-9421-1-git-send-email-niyelchu@linux.microsoft.com Signed-off-by: Wei Liu <wei.liu@kernel.org>
1 parent a6fe043 commit 55e544e

File tree

5 files changed

+9
-27
lines changed

5 files changed

+9
-27
lines changed

arch/x86/hyperv/hv_apic.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ static bool cpu_is_self(int cpu)
107107
static bool __send_ipi_mask_ex(const struct cpumask *mask, int vector,
108108
bool exclude_self)
109109
{
110-
struct hv_send_ipi_ex **arg;
111110
struct hv_send_ipi_ex *ipi_arg;
112111
unsigned long flags;
113112
int nr_bank = 0;
@@ -117,9 +116,8 @@ static bool __send_ipi_mask_ex(const struct cpumask *mask, int vector,
117116
return false;
118117

119118
local_irq_save(flags);
120-
arg = (struct hv_send_ipi_ex **)this_cpu_ptr(hyperv_pcpu_input_arg);
119+
ipi_arg = *this_cpu_ptr(hyperv_pcpu_input_arg);
121120

122-
ipi_arg = *arg;
123121
if (unlikely(!ipi_arg))
124122
goto ipi_mask_ex_done;
125123

arch/x86/hyperv/ivm.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ EXPORT_SYMBOL_GPL(hv_ghcb_msr_read);
246246
static int hv_mark_gpa_visibility(u16 count, const u64 pfn[],
247247
enum hv_mem_host_visibility visibility)
248248
{
249-
struct hv_gpa_range_for_visibility **input_pcpu, *input;
249+
struct hv_gpa_range_for_visibility *input;
250250
u16 pages_processed;
251251
u64 hv_status;
252252
unsigned long flags;
@@ -262,9 +262,8 @@ static int hv_mark_gpa_visibility(u16 count, const u64 pfn[],
262262
}
263263

264264
local_irq_save(flags);
265-
input_pcpu = (struct hv_gpa_range_for_visibility **)
266-
this_cpu_ptr(hyperv_pcpu_input_arg);
267-
input = *input_pcpu;
265+
input = *this_cpu_ptr(hyperv_pcpu_input_arg);
266+
268267
if (unlikely(!input)) {
269268
local_irq_restore(flags);
270269
return -EINVAL;

arch/x86/hyperv/mmu.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ static void hyperv_flush_tlb_multi(const struct cpumask *cpus,
6161
const struct flush_tlb_info *info)
6262
{
6363
int cpu, vcpu, gva_n, max_gvas;
64-
struct hv_tlb_flush **flush_pcpu;
6564
struct hv_tlb_flush *flush;
6665
u64 status;
6766
unsigned long flags;
@@ -74,10 +73,7 @@ static void hyperv_flush_tlb_multi(const struct cpumask *cpus,
7473

7574
local_irq_save(flags);
7675

77-
flush_pcpu = (struct hv_tlb_flush **)
78-
this_cpu_ptr(hyperv_pcpu_input_arg);
79-
80-
flush = *flush_pcpu;
76+
flush = *this_cpu_ptr(hyperv_pcpu_input_arg);
8177

8278
if (unlikely(!flush)) {
8379
local_irq_restore(flags);
@@ -178,17 +174,13 @@ static u64 hyperv_flush_tlb_others_ex(const struct cpumask *cpus,
178174
const struct flush_tlb_info *info)
179175
{
180176
int nr_bank = 0, max_gvas, gva_n;
181-
struct hv_tlb_flush_ex **flush_pcpu;
182177
struct hv_tlb_flush_ex *flush;
183178
u64 status;
184179

185180
if (!(ms_hyperv.hints & HV_X64_EX_PROCESSOR_MASKS_RECOMMENDED))
186181
return HV_STATUS_INVALID_PARAMETER;
187182

188-
flush_pcpu = (struct hv_tlb_flush_ex **)
189-
this_cpu_ptr(hyperv_pcpu_input_arg);
190-
191-
flush = *flush_pcpu;
183+
flush = *this_cpu_ptr(hyperv_pcpu_input_arg);
192184

193185
if (info->mm) {
194186
/*

arch/x86/hyperv/nested.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
int hyperv_flush_guest_mapping(u64 as)
2121
{
22-
struct hv_guest_mapping_flush **flush_pcpu;
2322
struct hv_guest_mapping_flush *flush;
2423
u64 status;
2524
unsigned long flags;
@@ -30,10 +29,7 @@ int hyperv_flush_guest_mapping(u64 as)
3029

3130
local_irq_save(flags);
3231

33-
flush_pcpu = (struct hv_guest_mapping_flush **)
34-
this_cpu_ptr(hyperv_pcpu_input_arg);
35-
36-
flush = *flush_pcpu;
32+
flush = *this_cpu_ptr(hyperv_pcpu_input_arg);
3733

3834
if (unlikely(!flush)) {
3935
local_irq_restore(flags);
@@ -90,7 +86,6 @@ EXPORT_SYMBOL_GPL(hyperv_fill_flush_guest_mapping_list);
9086
int hyperv_flush_guest_mapping_range(u64 as,
9187
hyperv_fill_flush_list_func fill_flush_list_func, void *data)
9288
{
93-
struct hv_guest_mapping_flush_list **flush_pcpu;
9489
struct hv_guest_mapping_flush_list *flush;
9590
u64 status;
9691
unsigned long flags;
@@ -102,10 +97,8 @@ int hyperv_flush_guest_mapping_range(u64 as,
10297

10398
local_irq_save(flags);
10499

105-
flush_pcpu = (struct hv_guest_mapping_flush_list **)
106-
this_cpu_ptr(hyperv_pcpu_input_arg);
100+
flush = *this_cpu_ptr(hyperv_pcpu_input_arg);
107101

108-
flush = *flush_pcpu;
109102
if (unlikely(!flush)) {
110103
local_irq_restore(flags);
111104
goto fault;

drivers/hv/hv_balloon.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1628,7 +1628,7 @@ static int hv_free_page_report(struct page_reporting_dev_info *pr_dev_info,
16281628
WARN_ON_ONCE(nents > HV_MEMORY_HINT_MAX_GPA_PAGE_RANGES);
16291629
WARN_ON_ONCE(sgl->length < (HV_HYP_PAGE_SIZE << page_reporting_order));
16301630
local_irq_save(flags);
1631-
hint = *(struct hv_memory_hint **)this_cpu_ptr(hyperv_pcpu_input_arg);
1631+
hint = *this_cpu_ptr(hyperv_pcpu_input_arg);
16321632
if (!hint) {
16331633
local_irq_restore(flags);
16341634
return -ENOSPC;

0 commit comments

Comments
 (0)