[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 06/96] cpu-common.c: export cpu_get_free_index to be reused later
From: |
Nicholas Piggin |
Subject: |
[PULL 06/96] cpu-common.c: export cpu_get_free_index to be reused later |
Date: |
Fri, 26 Jul 2024 09:52:39 +1000 |
From: Harsh Prateek Bora <harshpb@linux.ibm.com>
This helper provides an easy way to identify the next available free cpu
index which can be used for vcpu creation. Until now, this is being
called at a very later stage and there is a need to be able to call it
earlier (for now, with ppc64) hence the need to export.
Suggested-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Harsh Prateek Bora <harshpb@linux.ibm.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
cpu-common.c | 7 ++++---
include/exec/cpu-common.h | 2 ++
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/cpu-common.c b/cpu-common.c
index 7ae136f98c..6b262233a3 100644
--- a/cpu-common.c
+++ b/cpu-common.c
@@ -57,14 +57,12 @@ void cpu_list_unlock(void)
qemu_mutex_unlock(&qemu_cpu_list_lock);
}
-static bool cpu_index_auto_assigned;
-static int cpu_get_free_index(void)
+int cpu_get_free_index(void)
{
CPUState *some_cpu;
int max_cpu_index = 0;
- cpu_index_auto_assigned = true;
CPU_FOREACH(some_cpu) {
if (some_cpu->cpu_index >= max_cpu_index) {
max_cpu_index = some_cpu->cpu_index + 1;
@@ -83,8 +81,11 @@ unsigned int cpu_list_generation_id_get(void)
void cpu_list_add(CPUState *cpu)
{
+ static bool cpu_index_auto_assigned;
+
QEMU_LOCK_GUARD(&qemu_cpu_list_lock);
if (cpu->cpu_index == UNASSIGNED_CPU_INDEX) {
+ cpu_index_auto_assigned = true;
cpu->cpu_index = cpu_get_free_index();
assert(cpu->cpu_index != UNASSIGNED_CPU_INDEX);
} else {
diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h
index 240ee04369..2e1b499cb7 100644
--- a/include/exec/cpu-common.h
+++ b/include/exec/cpu-common.h
@@ -35,6 +35,8 @@ void cpu_list_lock(void);
void cpu_list_unlock(void);
unsigned int cpu_list_generation_id_get(void);
+int cpu_get_free_index(void);
+
void tcg_iommu_init_notifier_list(CPUState *cpu);
void tcg_iommu_free_notifier_list(CPUState *cpu);
--
2.45.2
- [PULL 00/96] ppc-for-9.1-2 queue, Nicholas Piggin, 2024/07/25
- [PULL 01/96] tests/tcg: Skip failing ppc64 multi-threaded tests, Nicholas Piggin, 2024/07/25
- [PULL 02/96] spapr: Migrate ail-mode-3 spapr cap, Nicholas Piggin, 2024/07/25
- [PULL 03/96] spapr: Free stdout path, Nicholas Piggin, 2024/07/25
- [PULL 04/96] ppc/vof: Fix unaligned FDT property access, Nicholas Piggin, 2024/07/25
- [PULL 05/96] accel/kvm: Introduce kvm_create_and_park_vcpu() helper, Nicholas Piggin, 2024/07/25
- [PULL 06/96] cpu-common.c: export cpu_get_free_index to be reused later,
Nicholas Piggin <=
- [PULL 07/96] target/ppc: handle vcpu hotplug failure gracefully, Nicholas Piggin, 2024/07/25
- [PULL 08/96] target/ppc/arch_dump: set prstatus pid to cpuid, Nicholas Piggin, 2024/07/25
- [PULL 09/96] linux-header: PPC: KVM: Update one-reg ids for DEXCR, HASHKEYR and HASHPKEYR, Nicholas Piggin, 2024/07/25
- [PULL 10/96] target/ppc/cpu_init: Synchronize DEXCR with KVM for migration, Nicholas Piggin, 2024/07/25
- [PULL 11/96] target/ppc/cpu_init: Synchronize HASHKEYR with KVM for migration, Nicholas Piggin, 2024/07/25
- [PULL 12/96] target/ppc/cpu_init: Synchronize HASHPKEYR with KVM for migration, Nicholas Piggin, 2024/07/25
- [PULL 13/96] ppc/pnv: Update Power10's cfam id to use Power10 DD2, Nicholas Piggin, 2024/07/25
- [PULL 14/96] ppc/pnv: Fix loss of LPC SERIRQ interrupts, Nicholas Piggin, 2024/07/25
- [PULL 15/96] ppc/pnv: Implement POWER9 LPC PSI serirq outputs and auto-clear function, Nicholas Piggin, 2024/07/25