2022-04-22 14:53:17

by Heiko Carstens

[permalink] [raw]
Subject: Re: [PATCH v8 1/2] s390x: KVM: guest support for topology function

> +static inline bool kvm_s390_topology_changed(struct kvm_vcpu *vcpu)
> +{
> + if (!test_kvm_facility(vcpu->kvm, 11))
> + return false;
> +
> + /* A new vCPU has been hotplugged */
> + if (vcpu->arch.prev_cpu == S390_KVM_TOPOLOGY_NEW_CPU)
> + return true;
> +
> + /* The real CPU backing up the vCPU moved to another socket */
> + if (cpumask_test_cpu(vcpu->cpu,
> + topology_core_cpumask(vcpu->arch.prev_cpu)))
> + return true;
> +
> + return false;
> +}

This seems to be wrong. I'd guess that you need

if (cpumask_test_cpu(vcpu->cpu,
topology_core_cpumask(vcpu->arch.prev_cpu)))
--> return false;
--> return true;


2022-04-22 18:04:30

by Claudio Imbrenda

[permalink] [raw]
Subject: Re: [PATCH v8 1/2] s390x: KVM: guest support for topology function

On Wed, 20 Apr 2022 14:05:00 +0200
Heiko Carstens <[email protected]> wrote:

> > +static inline bool kvm_s390_topology_changed(struct kvm_vcpu *vcpu)
> > +{
> > + if (!test_kvm_facility(vcpu->kvm, 11))
> > + return false;
> > +
> > + /* A new vCPU has been hotplugged */
> > + if (vcpu->arch.prev_cpu == S390_KVM_TOPOLOGY_NEW_CPU)
> > + return true;
> > +
> > + /* The real CPU backing up the vCPU moved to another socket */
> > + if (cpumask_test_cpu(vcpu->cpu,
> > + topology_core_cpumask(vcpu->arch.prev_cpu)))
> > + return true;
> > +
> > + return false;
> > +}
>
> This seems to be wrong. I'd guess that you need
>
> if (cpumask_test_cpu(vcpu->cpu,
> topology_core_cpumask(vcpu->arch.prev_cpu)))
> --> return false;
> --> return true;

so if the CPU moved to a different socket, it's not a change?
and if nothing happened, it is a change?

2022-04-22 19:50:48

by Heiko Carstens

[permalink] [raw]
Subject: Re: [PATCH v8 1/2] s390x: KVM: guest support for topology function

On Wed, Apr 20, 2022 at 03:22:41PM +0200, Claudio Imbrenda wrote:
> On Wed, 20 Apr 2022 14:05:00 +0200
> Heiko Carstens <[email protected]> wrote:
>
> > > +static inline bool kvm_s390_topology_changed(struct kvm_vcpu *vcpu)
> > > +{
> > > + if (!test_kvm_facility(vcpu->kvm, 11))
> > > + return false;
> > > +
> > > + /* A new vCPU has been hotplugged */
> > > + if (vcpu->arch.prev_cpu == S390_KVM_TOPOLOGY_NEW_CPU)
> > > + return true;
> > > +
> > > + /* The real CPU backing up the vCPU moved to another socket */
> > > + if (cpumask_test_cpu(vcpu->cpu,
> > > + topology_core_cpumask(vcpu->arch.prev_cpu)))
> > > + return true;
> > > +
> > > + return false;
> > > +}
> >
> > This seems to be wrong. I'd guess that you need
> >
> > if (cpumask_test_cpu(vcpu->cpu,
> > topology_core_cpumask(vcpu->arch.prev_cpu)))
> > --> return false;
> > --> return true;
>
> so if the CPU moved to a different socket, it's not a change?
> and if nothing happened, it is a change?

How do you translate the above code to your statement?