On Mon, Nov 28, 2011 at 08:41:00PM +0800, Xiao Guangrong wrote:
> +static void kvm_mmu_audit(struct kvm_vcpu *vcpu, int point)
>  {
>       static DEFINE_RATELIMIT_STATE(ratelimit_state, 5 * HZ, 10);
> 
> -     if (!__ratelimit(&ratelimit_state))
> -             return;
> +     if (static_branch((&mmu_audit_key))) {
> +             if (!__ratelimit(&ratelimit_state))
> +                     return;
> 
> -     vcpu->kvm->arch.audit_point = point;
> -     audit_all_active_sps(vcpu->kvm);
> -     audit_vcpu_spte(vcpu);
> +             vcpu->kvm->arch.audit_point = point;
> +             audit_all_active_sps(vcpu->kvm);
> +             audit_vcpu_spte(vcpu);
> +     }
>  }

hmmm..this always going to do a call to 'kvm_mmu_audit' and then return.
I think you want to avoid the function call altogether. You could do
something like:

#define kvm_mmu_audit()
        if (static_branch((&mmu_audit_key))) {
                __kvm_mmu_audit();
        }

and s/kvm_mmu_audit/__kvm_mmu_audit

That should give you a single nop for the case where kvm_mmu_audit is
disabled instead of a function call.

Thanks,

-Jason
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to