Skip to content

Commit

Permalink
hw/smbios: Fix smbios_smp_sockets caculation
Browse files Browse the repository at this point in the history
smp.sockets is the number of sockets which is configured by "-smp" (
otherwise, the default is 1). Trying to recalculate it here with another
rules leads to errors, such as:

1. 003f230 ("machine: Tweak the order of topology members in struct
   CpuTopology") changes the meaning of smp.cores but doesn't fix
   original smp.cores uses.

   With the introduction of cluster, now smp.cores means the number of
   cores in one cluster. So smp.cores * smp.threads just means the
   threads in a cluster not in a socket.

2. On the other hand, we shouldn't use smp.cpus here because it
   indicates the initial number of online CPUs at the boot time, and is
   not mathematically related to smp.sockets.

So stop reinventing the another wheel and use the topo values that
has been calculated.

Fixes: 003f230 ("machine: Tweak the order of topology members in struct CpuTopology")
Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
Message-Id: <20230628135437.1145805-3-zhao1.liu@linux.intel.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit d79a284)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
  • Loading branch information
trueptolemy authored and Michael Tokarev committed Sep 10, 2023
1 parent cfff72b commit c107dab
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions hw/smbios/smbios.c
Original file line number Diff line number Diff line change
Expand Up @@ -1088,8 +1088,7 @@ void smbios_get_tables(MachineState *ms,
smbios_build_type_2_table();
smbios_build_type_3_table();

smbios_smp_sockets = DIV_ROUND_UP(ms->smp.cpus,
ms->smp.cores * ms->smp.threads);
smbios_smp_sockets = ms->smp.sockets;
assert(smbios_smp_sockets >= 1);

for (i = 0; i < smbios_smp_sockets; i++) {
Expand Down

0 comments on commit c107dab

Please sign in to comment.