qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH for-6.2 v2 04/11] machine: Use the computed parameters to cal


From: wangyanan (Y)
Subject: Re: [PATCH for-6.2 v2 04/11] machine: Use the computed parameters to calculate omitted cpus
Date: Thu, 22 Jul 2021 23:45:39 +0800
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.4.0

On 2021/7/22 23:05, Andrew Jones wrote:
On Thu, Jul 22, 2021 at 10:59:11PM +0800, wangyanan (Y) wrote:
Ok. If we remove the rounding, then the calculation code has to be modified
to be like the following. We have to separately consider the case that cpus
and maxcpus are both omitted (e.g. -smp sockets=16).

maxcpus = maxcpus > 0 ? maxcpus : cpus;

if (cpus == 0 && maxcpus == 0) {
     sockets = sockets > 0 ? sockets : 1;
     cores = cores > 0 ? cores : 1;
     threads = threads > 0 ? threads : 1;
     goto cal;
}

if (sockets == 0) {
...
} else if (cores == 0) {
...
} else if (threads == 0) {
...
}

cal:
maxcpus = maxcpus > 0 ? maxcpus : sockets * cores * threads;
cpus = cpus > 0 ? cpus : maxcpus;
Whatever works, but hopefully you can avoid an ugly goto.

Well, it can be avoided.

Thanks,
Yanan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]