Skip to content

Commit

Permalink
cpus: Introduce cpu_list_generation_id
Browse files Browse the repository at this point in the history
Introduce cpu_list_generation_id to track cpu list generation so
that cpu hotplug/unplug can be detected during measurement of
dirty page rate.

cpu_list_generation_id could be used to detect changes of cpu
list, which is prepared for dirty page rate measurement.

Signed-off-by: Hyman Huang(黄勇) <[email protected]>
Reviewed-by: Peter Xu <[email protected]>
Message-Id: <06e1f1362b2501a471dce796abb065b04f320fa5.1656177590.git.huangy81@chinatelecom.cn>
Signed-off-by: Dr. David Alan Gilbert <[email protected]>
  • Loading branch information
Hyman Huang(黄勇) authored and dagrh committed Jul 20, 2022
1 parent 1667e2b commit ab1a161
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cpus-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ static int cpu_get_free_index(void)
}

CPUTailQ cpus = QTAILQ_HEAD_INITIALIZER(cpus);
static unsigned int cpu_list_generation_id;

unsigned int cpu_list_generation_id_get(void)
{
return cpu_list_generation_id;
}

void cpu_list_add(CPUState *cpu)
{
Expand All @@ -84,6 +90,7 @@ void cpu_list_add(CPUState *cpu)
assert(!cpu_index_auto_assigned);
}
QTAILQ_INSERT_TAIL_RCU(&cpus, cpu, node);
cpu_list_generation_id++;
}

void cpu_list_remove(CPUState *cpu)
Expand All @@ -96,6 +103,7 @@ void cpu_list_remove(CPUState *cpu)

QTAILQ_REMOVE_RCU(&cpus, cpu, node);
cpu->cpu_index = UNASSIGNED_CPU_INDEX;
cpu_list_generation_id++;
}

CPUState *qemu_get_cpu(int index)
Expand Down
1 change: 1 addition & 0 deletions include/exec/cpu-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ extern intptr_t qemu_host_page_mask;
void qemu_init_cpu_list(void);
void cpu_list_lock(void);
void cpu_list_unlock(void);
unsigned int cpu_list_generation_id_get(void);

void tcg_flush_softmmu_tlb(CPUState *cs);

Expand Down

0 comments on commit ab1a161

Please sign in to comment.