mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-19 20:22:46 +00:00
hv:Replace dynamic memory with static for pcpu
--remove 'calloc' for pcpu, change it to static array --rename 'init_percpu_data_area' to 'init_percpu_lapic_id' Tracked-On: #861 Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com> Reviewed-by: Li, Fei1 <fei1.li@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
parent
4afb6666b9
commit
dff441a0d5
@ -19,7 +19,7 @@ static spinlock_t up_count_spinlock = {
|
||||
.tail = 0U
|
||||
};
|
||||
|
||||
struct per_cpu_region *per_cpu_data_base_ptr;
|
||||
struct per_cpu_region per_cpu_data[CONFIG_MAX_PCPU_NUM] __aligned(CPU_PAGE_SIZE);
|
||||
uint16_t phys_cpu_num = 0U;
|
||||
static uint64_t pcpu_sync = 0UL;
|
||||
static volatile uint16_t up_count = 0U;
|
||||
@ -273,14 +273,6 @@ static int hardware_detect_support(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void alloc_phy_cpu_data(uint16_t pcpu_num)
|
||||
{
|
||||
phys_cpu_num = pcpu_num;
|
||||
|
||||
per_cpu_data_base_ptr = calloc(pcpu_num, sizeof(struct per_cpu_region));
|
||||
ASSERT(per_cpu_data_base_ptr != NULL, "");
|
||||
}
|
||||
|
||||
uint16_t __attribute__((weak)) parse_madt(uint32_t lapic_id_array[CONFIG_MAX_PCPU_NUM])
|
||||
{
|
||||
static const uint32_t lapic_id[] = {0U, 2U, 4U, 6U};
|
||||
@ -293,7 +285,7 @@ uint16_t __attribute__((weak)) parse_madt(uint32_t lapic_id_array[CONFIG_MAX_PCP
|
||||
return ((uint16_t)ARRAY_SIZE(lapic_id));
|
||||
}
|
||||
|
||||
static void init_percpu_data_area(void)
|
||||
static void init_percpu_lapic_id(void)
|
||||
{
|
||||
uint16_t i;
|
||||
uint16_t pcpu_num = 0U;
|
||||
@ -306,7 +298,7 @@ static void init_percpu_data_area(void)
|
||||
ASSERT(false);
|
||||
}
|
||||
|
||||
alloc_phy_cpu_data(pcpu_num);
|
||||
phys_cpu_num = pcpu_num;
|
||||
|
||||
for (i = 0U; (i < pcpu_num) && (i < CONFIG_MAX_PCPU_NUM); i++) {
|
||||
per_cpu(lapic_id, i) = lapic_id_array[i];
|
||||
@ -414,7 +406,7 @@ void bsp_boot_init(void)
|
||||
|
||||
early_init_lapic();
|
||||
|
||||
init_percpu_data_area();
|
||||
init_percpu_lapic_id();
|
||||
|
||||
load_gdtr_and_tr();
|
||||
|
||||
|
@ -56,14 +56,14 @@ struct per_cpu_region {
|
||||
#endif
|
||||
} __aligned(CPU_PAGE_SIZE); /* per_cpu_region size aligned with CPU_PAGE_SIZE */
|
||||
|
||||
extern struct per_cpu_region *per_cpu_data_base_ptr;
|
||||
extern struct per_cpu_region per_cpu_data[];
|
||||
extern uint16_t phys_cpu_num;
|
||||
extern uint64_t pcpu_active_bitmap;
|
||||
/*
|
||||
* get percpu data for pcpu_id.
|
||||
*/
|
||||
#define per_cpu(name, pcpu_id) \
|
||||
(per_cpu_data_base_ptr[(pcpu_id)].name)
|
||||
(per_cpu_data[(pcpu_id)].name)
|
||||
|
||||
/* get percpu data for current pcpu */
|
||||
#define get_cpu_var(name) per_cpu(name, get_cpu_id())
|
||||
|
Loading…
Reference in New Issue
Block a user