Fix premature usage of loom_get_cpu()

When loading CPUs for the loom, we cannot use loom_get_cpu() to access
the CPUs of the loom by their logical index, as it is not yet populated.
The check comes from load_cpus() which tries to prevent duplicated
entries in CPU logical indices, but this check is already performed when
building the cpus_array, so it is not needed.

Tested-by: Arnau Cinca <arnau.cinca@bsc.es>
This commit is contained in:
Rodrigo Arias 2025-07-24 14:48:16 +02:00
parent ce01675e9e
commit 4778b8c9ab
2 changed files with 8 additions and 9 deletions

View File

@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Fixed
- Fix a bug in ovniemu when loading loom CPUs from multiple threads.
## [1.12.0] - 2025-05-08
### Changed

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2021-2024 Barcelona Supercomputing Center (BSC)
/* Copyright (c) 2021-2025 Barcelona Supercomputing Center (BSC)
* SPDX-License-Identifier: GPL-3.0-or-later */
#include "loom.h"
@ -117,14 +117,6 @@ load_cpus(struct loom *loom, JSON_Object *meta)
continue;
}
/* If we reach this point, there shouldn't be a CPU with the
* same index either, as otherwise the phyid should have matched
* before. So it is an error. */
if (loom_get_cpu(loom, index) != NULL) {
err("cpu index %d redefined with another phyid", index);
return -1;
}
cpu = calloc(1, sizeof(struct cpu));
if (cpu == NULL) {
err("calloc failed:");
@ -189,6 +181,9 @@ loom_find_cpu(struct loom *loom, int phyid)
struct cpu *
loom_get_cpu(struct loom *loom, int index)
{
if (loom->cpus_array == NULL)
die("cpus_array not yet populated");
if (index == -1)
return &loom->vcpu;