KVM Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v3] kvm/x86 : Remove redundant function implement
@ 2020-05-21  5:57 彭浩(Richard)
  2020-05-21  9:27 ` Vitaly Kuznetsov
  2020-05-21 13:36 ` Paolo Bonzini
  0 siblings, 2 replies; 4+ messages in thread
From: 彭浩(Richard) @ 2020-05-21  5:57 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: linux-kernel, kvm

pic_in_kernel(),ioapic_in_kernel() and irqchip_kernel() have the
same implementation.

Signed-off-by: Peng Hao <richard.peng@oppo.com>
---
 arch/x86/kvm/ioapic.h  |  8 ++------
 arch/x86/kvm/irq.h     | 14 ++++----------
 arch/x86/kvm/lapic.c   |  1 +
 arch/x86/kvm/mmu/mmu.c |  1 +
 arch/x86/kvm/x86.c     |  1 +
 5 files changed, 9 insertions(+), 16 deletions(-)

diff --git a/arch/x86/kvm/ioapic.h b/arch/x86/kvm/ioapic.h
index 2fb2e3c..7a3c53b 100644
--- a/arch/x86/kvm/ioapic.h
+++ b/arch/x86/kvm/ioapic.h
@@ -5,7 +5,7 @@
 #include <linux/kvm_host.h>

 #include <kvm/iodev.h>
-
+#include "irq.h"
 struct kvm;
 struct kvm_vcpu;

@@ -108,11 +108,7 @@ do {\

 static inline int ioapic_in_kernel(struct kvm *kvm)
 {
-int mode = kvm->arch.irqchip_mode;
-
-/* Matches smp_wmb() when setting irqchip_mode */
-smp_rmb();
-return mode == KVM_IRQCHIP_KERNEL;
+return irqchip_kernel(kvm);
 }

 void kvm_rtc_eoi_tracking_restore_one(struct kvm_vcpu *vcpu);
diff --git a/arch/x86/kvm/irq.h b/arch/x86/kvm/irq.h
index f173ab6..e133c1a 100644
--- a/arch/x86/kvm/irq.h
+++ b/arch/x86/kvm/irq.h
@@ -16,7 +16,6 @@
 #include <linux/spinlock.h>

 #include <kvm/iodev.h>
-#include "ioapic.h"
 #include "lapic.h"

 #define PIC_NUM_PINS 16
@@ -66,15 +65,6 @@ void kvm_pic_destroy(struct kvm *kvm);
 int kvm_pic_read_irq(struct kvm *kvm);
 void kvm_pic_update_irq(struct kvm_pic *s);

-static inline int pic_in_kernel(struct kvm *kvm)
-{
-int mode = kvm->arch.irqchip_mode;
-
-/* Matches smp_wmb() when setting irqchip_mode */
-smp_rmb();
-return mode == KVM_IRQCHIP_KERNEL;
-}
-
 static inline int irqchip_split(struct kvm *kvm)
 {
 int mode = kvm->arch.irqchip_mode;
@@ -93,6 +83,10 @@ static inline int irqchip_kernel(struct kvm *kvm)
 return mode == KVM_IRQCHIP_KERNEL;
 }

+static inline int pic_in_kernel(struct kvm *kvm)
+{
+return irqchip_kernel(kvm);
+}
 static inline int irqchip_in_kernel(struct kvm *kvm)
 {
 int mode = kvm->arch.irqchip_mode;
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index 9af25c9..de4d046 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -36,6 +36,7 @@
 #include <linux/jump_label.h>
 #include "kvm_cache_regs.h"
 #include "irq.h"
+#include "ioapic.h"
 #include "trace.h"
 #include "x86.h"
 #include "cpuid.h"
diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
index 8071952..6133f69 100644
--- a/arch/x86/kvm/mmu/mmu.c
+++ b/arch/x86/kvm/mmu/mmu.c
@@ -16,6 +16,7 @@
  */

 #include "irq.h"
+#include "ioapic.h"
 #include "mmu.h"
 #include "x86.h"
 #include "kvm_cache_regs.h"
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index d786c7d..c8b62ac 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -18,6 +18,7 @@

 #include <linux/kvm_host.h>
 #include "irq.h"
+#include "ioapic.h"
 #include "mmu.h"
 #include "i8254.h"
 #include "tss.h"
--
2.7.4

________________________________
OPPO

本电子邮件及其附件含有OPPO公司的保密信息,仅限于邮件指明的收件人使用(包含个人及群组)。禁止任何人在未经授权的情况下以任何形式使用。如果您错收了本邮件,请立即以电子邮件通知发件人并删除本邮件及其附件。

This e-mail and its attachments contain confidential information from OPPO, which is intended only for the person or entity whose address is listed above. Any use of the information contained herein in any way (including, but not limited to, total or partial disclosure, reproduction, or dissemination) by persons other than the intended recipient(s) is prohibited. If you receive this e-mail in error, please notify the sender by phone or email immediately and delete it!

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] kvm/x86 : Remove redundant function implement
  2020-05-21  5:57 [PATCH v3] kvm/x86 : Remove redundant function implement 彭浩(Richard)
@ 2020-05-21  9:27 ` Vitaly Kuznetsov
  2020-05-21 13:36   ` Paolo Bonzini
  2020-05-21 13:36 ` Paolo Bonzini
  1 sibling, 1 reply; 4+ messages in thread
From: Vitaly Kuznetsov @ 2020-05-21  9:27 UTC (permalink / raw)
  To: 彭浩(Richard); +Cc: linux-kernel, kvm, Paolo Bonzini

彭浩(Richard) <richard.peng@oppo.com> writes:

> pic_in_kernel(),ioapic_in_kernel() and irqchip_kernel() have the
> same implementation.

'pic_in_kernel()' name is misleading, one may think this is about lapic
and it's not. Also, ioapic_in_kernel() doesn't have that many users, can
we maybe converge on using irqchip_*() functions everywhere?

>
> Signed-off-by: Peng Hao <richard.peng@oppo.com>
> ---
>  arch/x86/kvm/ioapic.h  |  8 ++------
>  arch/x86/kvm/irq.h     | 14 ++++----------
>  arch/x86/kvm/lapic.c   |  1 +
>  arch/x86/kvm/mmu/mmu.c |  1 +
>  arch/x86/kvm/x86.c     |  1 +
>  5 files changed, 9 insertions(+), 16 deletions(-)
>
> diff --git a/arch/x86/kvm/ioapic.h b/arch/x86/kvm/ioapic.h
> index 2fb2e3c..7a3c53b 100644
> --- a/arch/x86/kvm/ioapic.h
> +++ b/arch/x86/kvm/ioapic.h
> @@ -5,7 +5,7 @@
>  #include <linux/kvm_host.h>
>
>  #include <kvm/iodev.h>
> -
> +#include "irq.h"
>  struct kvm;
>  struct kvm_vcpu;
>
> @@ -108,11 +108,7 @@ do {\
>
>  static inline int ioapic_in_kernel(struct kvm *kvm)
>  {
> -int mode = kvm->arch.irqchip_mode;
> -
> -/* Matches smp_wmb() when setting irqchip_mode */
> -smp_rmb();
> -return mode == KVM_IRQCHIP_KERNEL;
> +return irqchip_kernel(kvm);
>  }
>
>  void kvm_rtc_eoi_tracking_restore_one(struct kvm_vcpu *vcpu);
> diff --git a/arch/x86/kvm/irq.h b/arch/x86/kvm/irq.h
> index f173ab6..e133c1a 100644
> --- a/arch/x86/kvm/irq.h
> +++ b/arch/x86/kvm/irq.h
> @@ -16,7 +16,6 @@
>  #include <linux/spinlock.h>
>
>  #include <kvm/iodev.h>
> -#include "ioapic.h"
>  #include "lapic.h"
>
>  #define PIC_NUM_PINS 16
> @@ -66,15 +65,6 @@ void kvm_pic_destroy(struct kvm *kvm);
>  int kvm_pic_read_irq(struct kvm *kvm);
>  void kvm_pic_update_irq(struct kvm_pic *s);
>
> -static inline int pic_in_kernel(struct kvm *kvm)
> -{
> -int mode = kvm->arch.irqchip_mode;
> -
> -/* Matches smp_wmb() when setting irqchip_mode */
> -smp_rmb();
> -return mode == KVM_IRQCHIP_KERNEL;
> -}
> -
>  static inline int irqchip_split(struct kvm *kvm)
>  {
>  int mode = kvm->arch.irqchip_mode;
> @@ -93,6 +83,10 @@ static inline int irqchip_kernel(struct kvm *kvm)
>  return mode == KVM_IRQCHIP_KERNEL;
>  }
>
> +static inline int pic_in_kernel(struct kvm *kvm)
> +{
> +return irqchip_kernel(kvm);
> +}
>  static inline int irqchip_in_kernel(struct kvm *kvm)
>  {
>  int mode = kvm->arch.irqchip_mode;
> diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
> index 9af25c9..de4d046 100644
> --- a/arch/x86/kvm/lapic.c
> +++ b/arch/x86/kvm/lapic.c
> @@ -36,6 +36,7 @@
>  #include <linux/jump_label.h>
>  #include "kvm_cache_regs.h"
>  #include "irq.h"
> +#include "ioapic.h"
>  #include "trace.h"
>  #include "x86.h"
>  #include "cpuid.h"
> diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
> index 8071952..6133f69 100644
> --- a/arch/x86/kvm/mmu/mmu.c
> +++ b/arch/x86/kvm/mmu/mmu.c
> @@ -16,6 +16,7 @@
>   */
>
>  #include "irq.h"
> +#include "ioapic.h"
>  #include "mmu.h"
>  #include "x86.h"
>  #include "kvm_cache_regs.h"
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index d786c7d..c8b62ac 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -18,6 +18,7 @@
>
>  #include <linux/kvm_host.h>
>  #include "irq.h"
> +#include "ioapic.h"
>  #include "mmu.h"
>  #include "i8254.h"
>  #include "tss.h"
> --
> 2.7.4
>
> ________________________________
> OPPO
>
> 本电子邮件及其附件含有OPPO公司的保密信息,仅限于邮件指明的收件人使用(包含个人及群组)。禁止任何人在未经授权的情况下以任何形式使用。如果您错收了本邮件,请立即以电子邮件通知发件人并删除本邮件及其附件。
>
> This e-mail and its attachments contain confidential information from OPPO, which is intended only for the person or entity whose address is listed above. Any use of the information contained herein in any way (including, but not limited to, total or partial disclosure, reproduction, or dissemination) by persons other than the intended recipient(s) is prohibited. If you receive this e-mail in error, please notify the sender by phone or email immediately and delete it!

-- 
Vitaly


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] kvm/x86 : Remove redundant function implement
  2020-05-21  9:27 ` Vitaly Kuznetsov
@ 2020-05-21 13:36   ` Paolo Bonzini
  0 siblings, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2020-05-21 13:36 UTC (permalink / raw)
  To: Vitaly Kuznetsov, 彭浩(Richard); +Cc: linux-kernel, kvm

On 21/05/20 11:27, Vitaly Kuznetsov wrote:
> 彭浩(Richard) <richard.peng@oppo.com> writes:
> 
>> pic_in_kernel(),ioapic_in_kernel() and irqchip_kernel() have the
>> same implementation.
> 'pic_in_kernel()' name is misleading, one may think this is about lapic
> and it's not. Also, ioapic_in_kernel() doesn't have that many users, can
> we maybe converge on using irqchip_*() functions everywhere?
> 

Richard's patch was my recommendation actually.

PIC is not the LAPIC and not the IOAPIC; even though right now the
implementation is the same for pic_in_kernel and ioapic_in_kernel and
irqchip_kernel(), that's more or less an implementation detail.

Paolo


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] kvm/x86 : Remove redundant function implement
  2020-05-21  5:57 [PATCH v3] kvm/x86 : Remove redundant function implement 彭浩(Richard)
  2020-05-21  9:27 ` Vitaly Kuznetsov
@ 2020-05-21 13:36 ` Paolo Bonzini
  1 sibling, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2020-05-21 13:36 UTC (permalink / raw)
  To: 彭浩(Richard); +Cc: linux-kernel, kvm

On 21/05/20 07:57, 彭浩(Richard) wrote:
> pic_in_kernel(),ioapic_in_kernel() and irqchip_kernel() have the
> same implementation.
> 
> Signed-off-by: Peng Hao <richard.peng@oppo.com>
> ---
>  arch/x86/kvm/ioapic.h  |  8 ++------
>  arch/x86/kvm/irq.h     | 14 ++++----------
>  arch/x86/kvm/lapic.c   |  1 +
>  arch/x86/kvm/mmu/mmu.c |  1 +
>  arch/x86/kvm/x86.c     |  1 +
>  5 files changed, 9 insertions(+), 16 deletions(-)
> 
> diff --git a/arch/x86/kvm/ioapic.h b/arch/x86/kvm/ioapic.h
> index 2fb2e3c..7a3c53b 100644
> --- a/arch/x86/kvm/ioapic.h
> +++ b/arch/x86/kvm/ioapic.h
> @@ -5,7 +5,7 @@
>  #include <linux/kvm_host.h>
> 
>  #include <kvm/iodev.h>
> -
> +#include "irq.h"
>  struct kvm;
>  struct kvm_vcpu;
> 
> @@ -108,11 +108,7 @@ do {\
> 
>  static inline int ioapic_in_kernel(struct kvm *kvm)
>  {
> -int mode = kvm->arch.irqchip_mode;
> -
> -/* Matches smp_wmb() when setting irqchip_mode */
> -smp_rmb();
> -return mode == KVM_IRQCHIP_KERNEL;
> +return irqchip_kernel(kvm);
>  }
> 
>  void kvm_rtc_eoi_tracking_restore_one(struct kvm_vcpu *vcpu);
> diff --git a/arch/x86/kvm/irq.h b/arch/x86/kvm/irq.h
> index f173ab6..e133c1a 100644
> --- a/arch/x86/kvm/irq.h
> +++ b/arch/x86/kvm/irq.h
> @@ -16,7 +16,6 @@
>  #include <linux/spinlock.h>
> 
>  #include <kvm/iodev.h>
> -#include "ioapic.h"
>  #include "lapic.h"
> 
>  #define PIC_NUM_PINS 16
> @@ -66,15 +65,6 @@ void kvm_pic_destroy(struct kvm *kvm);
>  int kvm_pic_read_irq(struct kvm *kvm);
>  void kvm_pic_update_irq(struct kvm_pic *s);
> 
> -static inline int pic_in_kernel(struct kvm *kvm)
> -{
> -int mode = kvm->arch.irqchip_mode;
> -
> -/* Matches smp_wmb() when setting irqchip_mode */
> -smp_rmb();
> -return mode == KVM_IRQCHIP_KERNEL;
> -}
> -
>  static inline int irqchip_split(struct kvm *kvm)
>  {
>  int mode = kvm->arch.irqchip_mode;
> @@ -93,6 +83,10 @@ static inline int irqchip_kernel(struct kvm *kvm)
>  return mode == KVM_IRQCHIP_KERNEL;
>  }
> 
> +static inline int pic_in_kernel(struct kvm *kvm)
> +{
> +return irqchip_kernel(kvm);
> +}
>  static inline int irqchip_in_kernel(struct kvm *kvm)
>  {
>  int mode = kvm->arch.irqchip_mode;
> diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
> index 9af25c9..de4d046 100644
> --- a/arch/x86/kvm/lapic.c
> +++ b/arch/x86/kvm/lapic.c
> @@ -36,6 +36,7 @@
>  #include <linux/jump_label.h>
>  #include "kvm_cache_regs.h"
>  #include "irq.h"
> +#include "ioapic.h"
>  #include "trace.h"
>  #include "x86.h"
>  #include "cpuid.h"
> diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
> index 8071952..6133f69 100644
> --- a/arch/x86/kvm/mmu/mmu.c
> +++ b/arch/x86/kvm/mmu/mmu.c
> @@ -16,6 +16,7 @@
>   */
> 
>  #include "irq.h"
> +#include "ioapic.h"
>  #include "mmu.h"
>  #include "x86.h"
>  #include "kvm_cache_regs.h"
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index d786c7d..c8b62ac 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -18,6 +18,7 @@
> 
>  #include <linux/kvm_host.h>
>  #include "irq.h"
> +#include "ioapic.h"
>  #include "mmu.h"
>  #include "i8254.h"
>  #include "tss.h"
> --
> 2.7.4
> 
> ________________________________
> OPPO
> 
> 本电子邮件及其附件含有OPPO公司的保密信息,仅限于邮件指明的收件人使用(包含个人及群组)。禁止任何人在未经授权的情况下以任何形式使用。如果您错收了本邮件,请立即以电子邮件通知发件人并删除本邮件及其附件。
> 
> This e-mail and its attachments contain confidential information from OPPO, which is intended only for the person or entity whose address is listed above. Any use of the information contained herein in any way (including, but not limited to, total or partial disclosure, reproduction, or dissemination) by persons other than the intended recipient(s) is prohibited. If you receive this e-mail in error, please notify the sender by phone or email immediately and delete it!
> 

Queued, thanks.

Paolo


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-21  5:57 [PATCH v3] kvm/x86 : Remove redundant function implement 彭浩(Richard)
2020-05-21  9:27 ` Vitaly Kuznetsov
2020-05-21 13:36   ` Paolo Bonzini
2020-05-21 13:36 ` Paolo Bonzini

KVM Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/kvm/0 kvm/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 kvm kvm/ https://lore.kernel.org/kvm \
		kvm@vger.kernel.org
	public-inbox-index kvm

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.kvm


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git