Re: [PATCH 02/22] kvm: mmu: Introduce tdp_iter

From: Paolo Bonzini
Date: Wed Sep 30 2020 - 02:24:26 EST


On 30/09/20 07:24, Sean Christopherson wrote:
> Maybe use the params, if only to avoid the line wrap?
>
> iter->gfn = goal_gfn - (goal_gfn % KVM_PAGES_PER_HPAGE(root_level));
>
> Actually, peeking further into the file, this calculation is repeated in both
> try_step_up and try_step_down, probably worth adding a helper of some form.

Also it's written more concisely as

iter->gfn = goal_gfn & -KVM_PAGES_PER_HPAGE(iter->level);

>
>
> bool done;
>
> if (try_step_down(iter))
> return;
>
> do {
> done = try_step_side(iter);
> } while (!done && try_step_up(iter));
>
> iter->valid = done;

I pointed out something similar in my review, my version was

bool done;

if (try_step_down(iter))
return;

do {
if (try_step_side(iter))
return;
} while (try_step_up(iter));
iter->valid = false;

Paolo