Re: [GIT PULL] KVM fixes for v4.12-rc2

From: Radim KrÄmÃÅ
Date: Mon May 22 2017 - 10:37:25 EST


2017-05-20 12:52+0200, Juergen Gross:
> On 20/05/17 00:21, Linus Torvalds wrote:
> > So I noticed that my diffstat didn't match either the KVM or the Xen pull.
> >
> > The *reason* seems to be that both Radim and Juergen have enabled the
> > "patience" diff, because if I add "--patience" to the diff line, I get
> > the same numbers you guys report.
>
> In my case it was a patch which was much easier to review using the
> patience diff. I just didn't switch back afterwards (what I did now).

Similar here. I have the 'histogram' algorithm in the global config for
few years now.
Using the same algorithm for pull diffstat would be best, though;
I added "algorithm = default" to the repo config.


---
This KVM pull shows the reason why I abandoned 'myers' -- it can
obfuscate simple cut & paste. (I don't recall the case that brought
'histogram' and there apparently were no significant improvements to be
gained by switching since then.)

The patch in question is 76d837a4c0f9 ("KVM: PPC: Book3S PR: Don't
include SPAPR TCE code on non-pseries platforms"), see trimmed output of
both algorithms below.

First, the important hunks of the 'histogram' diff:

@@ -244,20 +262,6 @@ static int kvmppc_h_pr_protect(struct kvm_vcpu *vcpu)
return EMULATE_DONE;
}

-static int kvmppc_h_pr_put_tce(struct kvm_vcpu *vcpu)
-{
- unsigned long liobn = kvmppc_get_gpr(vcpu, 4);
- unsigned long ioba = kvmppc_get_gpr(vcpu, 5);
- unsigned long tce = kvmppc_get_gpr(vcpu, 6);
- long rc;
-
- rc = kvmppc_h_put_tce(vcpu, liobn, ioba, tce);
- if (rc == H_TOO_HARD)
- return EMULATE_FAIL;
- kvmppc_set_gpr(vcpu, 3, rc);
- return EMULATE_DONE;
-}
-
static int kvmppc_h_pr_logical_ci_load(struct kvm_vcpu *vcpu)
{
long rc;
@@ -280,6 +284,21 @@ static int kvmppc_h_pr_logical_ci_store(struct kvm_vcpu *vcpu)
return EMULATE_DONE;
}

+#ifdef CONFIG_SPAPR_TCE_IOMMU
+static int kvmppc_h_pr_put_tce(struct kvm_vcpu *vcpu)
+{
+ unsigned long liobn = kvmppc_get_gpr(vcpu, 4);
+ unsigned long ioba = kvmppc_get_gpr(vcpu, 5);
+ unsigned long tce = kvmppc_get_gpr(vcpu, 6);
+ long rc;
+
+ rc = kvmppc_h_put_tce(vcpu, liobn, ioba, tce);
+ if (rc == H_TOO_HARD)
+ return EMULATE_FAIL;
+ kvmppc_set_gpr(vcpu, 3, rc);
+ return EMULATE_DONE;
+}
+
static int kvmppc_h_pr_put_tce_indirect(struct kvm_vcpu *vcpu)
{
unsigned long liobn = kvmppc_get_gpr(vcpu, 4);


and now the same change with the 'myers' algorithm:

@@ -244,36 +262,37 @@ static int kvmppc_h_pr_protect(struct kvm_vcpu *vcpu)
return EMULATE_DONE;
}

-static int kvmppc_h_pr_put_tce(struct kvm_vcpu *vcpu)
+static int kvmppc_h_pr_logical_ci_load(struct kvm_vcpu *vcpu)
{
- unsigned long liobn = kvmppc_get_gpr(vcpu, 4);
- unsigned long ioba = kvmppc_get_gpr(vcpu, 5);
- unsigned long tce = kvmppc_get_gpr(vcpu, 6);
long rc;

- rc = kvmppc_h_put_tce(vcpu, liobn, ioba, tce);
+ rc = kvmppc_h_logical_ci_load(vcpu);
if (rc == H_TOO_HARD)
return EMULATE_FAIL;
kvmppc_set_gpr(vcpu, 3, rc);
return EMULATE_DONE;
}

-static int kvmppc_h_pr_logical_ci_load(struct kvm_vcpu *vcpu)
+static int kvmppc_h_pr_logical_ci_store(struct kvm_vcpu *vcpu)
{
long rc;

- rc = kvmppc_h_logical_ci_load(vcpu);
+ rc = kvmppc_h_logical_ci_store(vcpu);
if (rc == H_TOO_HARD)
return EMULATE_FAIL;
kvmppc_set_gpr(vcpu, 3, rc);
return EMULATE_DONE;
}

-static int kvmppc_h_pr_logical_ci_store(struct kvm_vcpu *vcpu)
+#ifdef CONFIG_SPAPR_TCE_IOMMU
+static int kvmppc_h_pr_put_tce(struct kvm_vcpu *vcpu)
{
+ unsigned long liobn = kvmppc_get_gpr(vcpu, 4);
+ unsigned long ioba = kvmppc_get_gpr(vcpu, 5);
+ unsigned long tce = kvmppc_get_gpr(vcpu, 6);
long rc;

- rc = kvmppc_h_logical_ci_store(vcpu);
+ rc = kvmppc_h_put_tce(vcpu, liobn, ioba, tce);
if (rc == H_TOO_HARD)
return EMULATE_FAIL;
kvmppc_set_gpr(vcpu, 3, rc);


The move of kvmppc_h_pr_put_tce() under #ifdef is not so simple anymore.