[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH] cpu: break out when a right cpuCandidate found



On Thu, Feb 13, 2014 at 07:44:20 +0000, Wangyufei (James) wrote:
> >From 8123c5d64f940fa0fb0de32fc5e68035980b6b01 Mon Sep 17 00:00:00 2001
> From: WangYufei <james wangyufei huawei com>
> Date: Thu, 13 Feb 2014 07:17:11 +0000
> Subject: [PATCH] cpu: break out when a right cpuCandidate found
> 
> In function x86Decode there's a code segment in while cycle like this:
>         if (cpuModel == NULL
>             || cpuModel->nfeatures > cpuCandidate->nfeatures) {
>             virCPUDefFree(cpuModel);
>             cpuModel = cpuCandidate;
>             cpuData = candidate->data;
>         } else {
>             virCPUDefFree(cpuCandidate);
>         }
> when it finds the right cpuCandidate, it doesn't break out the cycle, but continues
> run in it, and cpuModel will never get a new value, it's meaningless. It should
> break out when a right cpuCndidate found.

That's mainly because we don't know we already have the right candidate.
The next one may actually be better. On other words, the cpuCandidate we
get in later iterations may satisfy the

    cpuModel->nfeatures > cpuCandidate->nfeatures

and thus it may be better than cpuModel stored in earlier iterations.

What are you trying to fix here? Are you just trying to optimize the
code or do you see a wrong CPU model to be selected in some situations?

Jirka


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]