Re: [Xen-devel] [PATCH 04/10] x86/paravirt: use a single ops structure

2018-08-10 Thread Juergen Gross
On 10/08/18 14:06, Jan Beulich wrote:
 On 10.08.18 at 13:52,  wrote:
>> --- a/arch/x86/hyperv/mmu.c
>> +++ b/arch/x86/hyperv/mmu.c
>> @@ -228,9 +228,9 @@ void hyperv_setup_mmu_ops(void)
>>  
>>  if (!(ms_hyperv.hints & HV_X64_EX_PROCESSOR_MASKS_RECOMMENDED)) {
>>  pr_info("Using hypercall for remote TLB flush\n");
>> -pv_mmu_ops.flush_tlb_others = hyperv_flush_tlb_others;
>> +pv_ops.pv_mmu_ops.flush_tlb_others = hyperv_flush_tlb_others;
> 
> Taking just this as example, why not
> 
>   pv_ops.mmu.flush_tlb_others = hyperv_flush_tlb_others;
> 
> ? Both pv_ and _ops are redundant on the field names.

Good idea.


Juergen

___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [PATCH 04/10] x86/paravirt: use a single ops structure

2018-08-10 Thread Jan Beulich
>>> On 10.08.18 at 13:52,  wrote:
> --- a/arch/x86/hyperv/mmu.c
> +++ b/arch/x86/hyperv/mmu.c
> @@ -228,9 +228,9 @@ void hyperv_setup_mmu_ops(void)
>  
>   if (!(ms_hyperv.hints & HV_X64_EX_PROCESSOR_MASKS_RECOMMENDED)) {
>   pr_info("Using hypercall for remote TLB flush\n");
> - pv_mmu_ops.flush_tlb_others = hyperv_flush_tlb_others;
> + pv_ops.pv_mmu_ops.flush_tlb_others = hyperv_flush_tlb_others;

Taking just this as example, why not

pv_ops.mmu.flush_tlb_others = hyperv_flush_tlb_others;

? Both pv_ and _ops are redundant on the field names.

Jan



___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

[Xen-devel] [PATCH 04/10] x86/paravirt: use a single ops structure

2018-08-10 Thread Juergen Gross
Instead of using six globally visible paravirt ops structures combine
them in a single structure, keeping the original structures as
sub-structures.

This avoids the need to assemble struct paravirt_patch_template at
runtime on the stack each time apply_paravirt() is being called (i.e.
when loading a module).

Signed-off-by: Juergen Gross 
---
 arch/x86/hyperv/mmu.c |   4 +-
 arch/x86/include/asm/paravirt.h   |  51 ---
 arch/x86/include/asm/paravirt_types.h |  13 +-
 arch/x86/kernel/alternative.c |   2 +-
 arch/x86/kernel/asm-offsets.c |  14 +-
 arch/x86/kernel/asm-offsets_64.c  |   7 +-
 arch/x86/kernel/cpu/common.c  |   2 +-
 arch/x86/kernel/cpu/vmware.c  |   4 +-
 arch/x86/kernel/kvm.c |  18 ++-
 arch/x86/kernel/kvmclock.c|   4 +-
 arch/x86/kernel/paravirt-spinlocks.c  |  15 +-
 arch/x86/kernel/paravirt.c| 278 +-
 arch/x86/kernel/tsc.c |   2 +-
 arch/x86/kernel/vsmp_64.c |  11 +-
 arch/x86/xen/enlighten_pv.c   |  32 ++--
 arch/x86/xen/irq.c|   2 +-
 arch/x86/xen/mmu_hvm.c|   2 +-
 arch/x86/xen/mmu_pv.c |  28 ++--
 arch/x86/xen/spinlock.c   |  12 +-
 arch/x86/xen/time.c   |   4 +-
 drivers/xen/time.c|   2 +-
 21 files changed, 249 insertions(+), 258 deletions(-)

diff --git a/arch/x86/hyperv/mmu.c b/arch/x86/hyperv/mmu.c
index de27615c51ea..b34768cfb204 100644
--- a/arch/x86/hyperv/mmu.c
+++ b/arch/x86/hyperv/mmu.c
@@ -228,9 +228,9 @@ void hyperv_setup_mmu_ops(void)
 
if (!(ms_hyperv.hints & HV_X64_EX_PROCESSOR_MASKS_RECOMMENDED)) {
pr_info("Using hypercall for remote TLB flush\n");
-   pv_mmu_ops.flush_tlb_others = hyperv_flush_tlb_others;
+   pv_ops.pv_mmu_ops.flush_tlb_others = hyperv_flush_tlb_others;
} else {
pr_info("Using ext hypercall for remote TLB flush\n");
-   pv_mmu_ops.flush_tlb_others = hyperv_flush_tlb_others_ex;
+   pv_ops.pv_mmu_ops.flush_tlb_others = hyperv_flush_tlb_others_ex;
}
 }
diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
index 76b4b5c056f3..1b86bb319393 100644
--- a/arch/x86/include/asm/paravirt.h
+++ b/arch/x86/include/asm/paravirt.h
@@ -265,11 +265,11 @@ static inline void set_iopl_mask(unsigned mask)
 /* The paravirtualized I/O functions */
 static inline void slow_down_io(void)
 {
-   pv_cpu_ops.io_delay();
+   pv_ops.pv_cpu_ops.io_delay();
 #ifdef REALLY_SLOW_IO
-   pv_cpu_ops.io_delay();
-   pv_cpu_ops.io_delay();
-   pv_cpu_ops.io_delay();
+   pv_ops.pv_cpu_ops.io_delay();
+   pv_ops.pv_cpu_ops.io_delay();
+   pv_ops.pv_cpu_ops.io_delay();
 #endif
 }
 
@@ -432,7 +432,7 @@ static inline void ptep_modify_prot_commit(struct mm_struct 
*mm, unsigned long a
 {
if (sizeof(pteval_t) > sizeof(long))
/* 5 arg words */
-   pv_mmu_ops.ptep_modify_prot_commit(mm, addr, ptep, pte);
+   pv_ops.pv_mmu_ops.ptep_modify_prot_commit(mm, addr, ptep, pte);
else
PVOP_VCALL4(pv_mmu_ops.ptep_modify_prot_commit,
mm, addr, ptep, pte.pte);
@@ -453,7 +453,7 @@ static inline void set_pte_at(struct mm_struct *mm, 
unsigned long addr,
 {
if (sizeof(pteval_t) > sizeof(long))
/* 5 arg words */
-   pv_mmu_ops.set_pte_at(mm, addr, ptep, pte);
+   pv_ops.pv_mmu_ops.set_pte_at(mm, addr, ptep, pte);
else
PVOP_VCALL4(pv_mmu_ops.set_pte_at, mm, addr, ptep, pte.pte);
 }
@@ -663,7 +663,7 @@ static inline void arch_flush_lazy_mmu_mode(void)
 static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
phys_addr_t phys, pgprot_t flags)
 {
-   pv_mmu_ops.set_fixmap(idx, phys, flags);
+   pv_ops.pv_mmu_ops.set_fixmap(idx, phys, flags);
 }
 
 #if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS)
@@ -694,6 +694,9 @@ static __always_inline bool pv_vcpu_is_preempted(long cpu)
return PVOP_CALLEE1(bool, pv_lock_ops.vcpu_is_preempted, cpu);
 }
 
+void __raw_callee_save___native_queued_spin_unlock(struct qspinlock *lock);
+bool __raw_callee_save___native_vcpu_is_preempted(long cpu);
+
 #endif /* SMP && PARAVIRT_SPINLOCKS */
 
 #ifdef CONFIG_X86_32
@@ -862,7 +865,7 @@ extern void default_banner(void);
COND_POP(set, CLBR_RCX, rcx);   \
COND_POP(set, CLBR_RAX, rax)
 
-#define PARA_PATCH(struct, off)((PARAVIRT_PATCH_##struct + (off)) / 8)
+#define PARA_PATCH(off)((off) / 8)
 #define PARA_SITE(ptype, ops)  _PVSITE(ptype, ops, .quad, 8)
 #define PARA_INDIRECT(addr)*addr(%rip)
 #else
@@ -877,35 +880,35 @@ extern void default_banner(void);
COND_POP(set, CLBR_EDI, edi);   \
COND_POP(set,