]> xenbits.xensource.com Git - qemu-xen.git/commit
spapr: consolidate the VCPU id numbering logic in a single place
authorGreg Kurz <groug@kaod.org>
Wed, 14 Feb 2018 19:40:53 +0000 (20:40 +0100)
committerGreg Kurz <groug@kaod.org>
Tue, 22 May 2018 10:58:59 +0000 (12:58 +0200)
commite676038e606eb3daddd5bd18f7896921e3bc1e7d
tree73c4a2d2e550b9296a278a172364c0e07aa591b1
parent094706e69f12398c3ad5221c2cfc85410508d00c
spapr: consolidate the VCPU id numbering logic in a single place

Several places in the code need to calculate a VCPU id:

    (cpu_index / smp_threads) * spapr->vsmt + cpu_index % smp_threads
    (core_id / smp_threads) * spapr->vsmt (1 user)
    index * spapr->vsmt (2 users)

or guess that the VCPU id of a given VCPU is the first thread of a virtual
core:

    index % spapr->vsmt != 0

Even if the numbering logic isn't that complex, it is rather fragile to
have these assumptions open-coded in several places. FWIW this was
proved with recent issues related to VSMT.

This patch moves the VCPU id formula to a single function to be called
everywhere the code needs to compute one. It also adds an helper to
guess if a VCPU is the first thread of a VCORE.

Signed-off-by: Greg Kurz <groug@kaod.org>
[dwg: Rename spapr_is_vcore() to spapr_is_thread0_in_vcore() for clarity]
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
(cherry picked from commit 5d0fb1508e2d279da74ef4a103e8def9b52c6304)
Signed-off-by: Greg Kurz <groug@kaod.org>
hw/ppc/spapr.c