[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 1/4] target/i386: Use simple static property for
From: |
Eduardo Habkost |
Subject: |
Re: [Qemu-devel] [PATCH 1/4] target/i386: Use simple static property for "model-id" |
Date: |
Mon, 24 Jul 2017 20:04:58 -0300 |
User-agent: |
Mutt/1.8.0 (2017-02-23) |
On Mon, Jul 24, 2017 at 11:11:34PM +0200, Paolo Bonzini wrote:
> On 18/07/2017 13:29, Igor Mammedov wrote:
> >> It may add a few additional CPU cycles, but I really doubt we can
> >> find a workload where CPUID speed has measurable impact. See,
> >> for example, how expensive the kernel KVM CPUID code
> >> (kvm_cpuid(), kvm_find_cpuid_entry()) is.
> >
> > I don't expect that it would affect KVM, but for TCG any instruction
> > execution is 'fast' path, so I'd leave current cpu_x86_cpuid()
> > not to loose those few cycles, it's not worth sacrifice for the sake of
> > cleanup.
>
> It's not like this does a QOM property lookup or anything. I think the
> patch is a good idea.
>
> Even simpler way to write the cpuid code:
>
> int base = (index - 0x80000002) * 16;
> char model[16];
>
> if (strnlen(env->model_id, base) < base) {
> memset(model, 0, sizeof(model));
> } else {
> strncpy(model, env->model_id + base, sizeof(model));
> }
> *eax = ldl_le_p(&model[0]);
> *ebx = ldl_le_p(&model[4]);
> *ecx = ldl_le_p(&model[8]);
> *edx = ldl_le_p(&model[12]);
Neat. I will use it in v2. Thanks!
--
Eduardo
[Qemu-devel] [PATCH 2/4] target/i386: Use host_vendor_fms() in max_x86_cpu_initfn(), Eduardo Habkost, 2017/07/12
[Qemu-devel] [PATCH 3/4] target/i386: Define CPUID_MODEL_ID_SZ macro, Eduardo Habkost, 2017/07/12
[Qemu-devel] [PATCH 4/4] target/i386: Don't use x86_cpu_load_def() on "max" CPU model, Eduardo Habkost, 2017/07/12