On 02/26/2012 05:59 AM, Alexander Graf wrote:
> 
> On 25.02.2012, at 00:40, Scott Wood wrote:
> 
>> On 02/24/2012 08:26 AM, Alexander Graf wrote:
>>> +static void kvmppc_fill_pt_regs(struct kvm_vcpu *vcpu, struct pt_regs 
>>> *regs)
>>> {
>>> -   int r = RESUME_HOST;
>>> +   int i;
>>>
>>> -   /* update before a new last_exit_type is rewritten */
>>> -   kvmppc_update_timing_stats(vcpu);
>>> +   for (i = 0; i < 32; i++)
>>> +           regs->gpr[i] = kvmppc_get_gpr(vcpu, i);
>>> +   regs->nip = vcpu->arch.pc;
>>> +   regs->msr = vcpu->arch.shared->msr;
>>> +   regs->ctr = vcpu->arch.ctr;
>>> +   regs->link = vcpu->arch.lr;
>>> +   regs->xer = kvmppc_get_xer(vcpu);
>>> +   regs->ccr = kvmppc_get_cr(vcpu);
>>> +   regs->dar = get_guest_dear(vcpu);
>>> +   regs->dsisr = get_guest_esr(vcpu);
>>> +}
>>
>> How much overhead does this add to every interrupt?  Can't we keep this
>> to the minimum that perf cares about?
> 
> I would rather not make assumptions on what perf cares about - maybe we want 
> to one day implement "perf kvm" and then perf could rely on pretty much 
> anything in there.

In that case I think we should be populating a real pt_regs from the
start, as in my original patchset.

I only agreed to take it out because I thought the set of things we'd
copy would be minimal.  This seems like a lot of overhead.

I'm not familiar with "perf kvm", but if it's kvm-specific surely the
KVM code should know/dictate what it can rely on?  Or maybe there can be
a debug option that enables full pt_regs (similar to exit timing)?

Could we just set regs to NULL when the debug option isn't enabled?

>>> +static void kvmppc_restart_interrupt(struct kvm_vcpu *vcpu,
>>> +                                unsigned int exit_nr)
>>> +{
>>> +   struct pt_regs regs = *current->thread.regs;
>>>
>>> +   kvmppc_fill_pt_regs(vcpu, &regs);
>>
>> Why are you copying out of current->thread.regs?  That's old junk data,
>> set by some previous exception and possibly overwritten since.
> 
> Because it gives us good default values for anything we don't set. Do you 
> have other recommendations?

It does not give good default values for anything.  It is junk,
unallocated memory, overwritten by who knows what.  Same as the memory
you're copying to.

To avoid garbage in fields we don't set, fill it with zeroes first.

-Scott

_______________________________________________
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Reply via email to