[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAPm50aJv2_6321BgLXB6SWH1CcoYM4733fsovtB_5zhoP_7x+Q@mail.gmail.com>
Date: Tue, 20 Dec 2022 15:47:55 +0800
From: Hao Peng <flyingpenghao@...il.com>
To: Sean Christopherson <seanjc@...gle.com>
Cc: pbonzini@...hat.com, kvm@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] KVM: use unified srcu interface function
On Fri, Dec 9, 2022 at 9:22 AM Sean Christopherson <seanjc@...gle.com> wrote:
>
> On Thu, Dec 08, 2022, Hao Peng wrote:
> > From: Peng Hao <flyingpeng@...cent.com>
> >
> > kvm->irq_routing is protected by kvm->irq_srcu.
> >
> > Signed-off-by: Peng Hao <flyingpeng@...cent.com>
> > ---
> > virt/kvm/irqchip.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/virt/kvm/irqchip.c b/virt/kvm/irqchip.c
> > index 1e567d1f6d3d..90f54f04e37c 100644
> > --- a/virt/kvm/irqchip.c
> > +++ b/virt/kvm/irqchip.c
> > @@ -216,7 +216,8 @@ int kvm_set_irq_routing(struct kvm *kvm,
> > }
> >
> > mutex_lock(&kvm->irq_lock);
> > - old = rcu_dereference_protected(kvm->irq_routing, 1);
> > + old = srcu_dereference_check(kvm->irq_routing, &kvm->irq_srcu,
> > + lockdep_is_held(&kvm->irq_lock));
>
> Readers of irq_routing are protected via kvm->irq_srcu, but this writer is never
> called with kvm->irq_srcu held. I do like the of replacing '1' with
> lockdep_is_held(&kvm->irq_lock) to document the protection, so what about just
> doing that? I.e.
>
Sorry for the long delay in replying. Although kvm->irq_srcu is not required
to protect irq_routing here, this interface function srcu_dereference_check
indicates that irq_routing is protected by kvm->irq_srcu in the kvm subsystem.
Thanks.
> diff --git a/virt/kvm/irqchip.c b/virt/kvm/irqchip.c
> index 1e567d1f6d3d..77a18b4dc103 100644
> --- a/virt/kvm/irqchip.c
> +++ b/virt/kvm/irqchip.c
> @@ -216,7 +216,8 @@ int kvm_set_irq_routing(struct kvm *kvm,
> }
>
> mutex_lock(&kvm->irq_lock);
> - old = rcu_dereference_protected(kvm->irq_routing, 1);
> + old = rcu_dereference_protected(kvm->irq_routing,
> + lockdep_is_held(&kvm->irq_lock));
> rcu_assign_pointer(kvm->irq_routing, new);
> kvm_irq_routing_update(kvm);
> kvm_arch_irq_routing_update(kvm);
>
>
> > rcu_assign_pointer(kvm->irq_routing, new);
> > kvm_irq_routing_update(kvm);
> > kvm_arch_irq_routing_update(kvm);
> > --
> > 2.27.0
Powered by blists - more mailing lists