All of lore.kernel.org
 help / color / mirror / Atom feed
From: huangy81@chinatelecom.cn
To: qemu-devel <qemu-devel@nongnu.org>
Cc: "Eduardo Habkost" <eduardo@habkost.net>,
	"David Hildenbrand" <david@redhat.com>,
	Hyman <huangy81@chinatelecom.cn>,
	"Juan Quintela" <quintela@redhat.com>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Markus ArmBruster" <armbru@redhat.com>,
	"Peter Xu" <peterx@redhat.com>,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>
Subject: [PATCH v14 2/7] cpus: Introduce cpu_list_generation_id
Date: Fri, 11 Feb 2022 00:17:36 +0800	[thread overview]
Message-ID: <f38e0fba747bcbe534fb6669c989a9455eef1f46.1644509582.git.huangy81@chinatelecom.cn> (raw)
In-Reply-To: <cover.1644509582.git.huangy81@chinatelecom.cn>
In-Reply-To: <cover.1644509582.git.huangy81@chinatelecom.cn>

From: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>

Introduce cpu_list_generation_id to track cpu list generation so
that cpu hotplug/unplug can be detected during measurement of
dirty page rate.

Signed-off-by: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
---
 cpus-common.c             | 8 ++++++++
 include/exec/cpu-common.h | 1 +
 2 files changed, 9 insertions(+)

diff --git a/cpus-common.c b/cpus-common.c
index 6e73d3e..31c6415 100644
--- a/cpus-common.c
+++ b/cpus-common.c
@@ -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)
 {
@@ -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)
@@ -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)
diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h
index de5f444..eb33642 100644
--- a/include/exec/cpu-common.h
+++ b/include/exec/cpu-common.h
@@ -20,6 +20,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);
 
-- 
1.8.3.1



  parent reply	other threads:[~2022-02-10 19:31 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-10 16:17 [PATCH v14 0/7] support dirty restraint on vCPU huangy81
2022-02-10 16:17 ` [PATCH v14 1/7] accel/kvm/kvm-all: Refactor per-vcpu dirty ring reaping huangy81
2022-02-14  7:57   ` Peter Xu
2022-02-10 16:17 ` huangy81 [this message]
2022-02-14  7:59   ` [PATCH v14 2/7] cpus: Introduce cpu_list_generation_id Peter Xu
2022-02-10 16:17 ` [PATCH v14 3/7] migration/dirtyrate: Refactor dirty page rate calculation huangy81
2022-02-14  7:57   ` Peter Xu
2022-02-14  8:40     ` Hyman Huang
2022-02-14  9:47       ` Peter Xu
2022-02-10 16:17 ` [PATCH v14 4/7] softmmu/dirtylimit: Implement vCPU dirtyrate calculation periodically huangy81
2022-02-14  8:01   ` Peter Xu
2022-02-10 16:17 ` [PATCH v14 5/7] accel/kvm/kvm-all: Introduce kvm_dirty_ring_size function huangy81
2022-02-14  8:02   ` Peter Xu
2022-02-10 16:17 ` [PATCH v14 6/7] softmmu/dirtylimit: Implement virtual CPU throttle huangy81
2022-02-14  8:20   ` Peter Xu
2022-02-14  9:05     ` Hyman Huang
2022-02-14  9:51       ` Peter Xu
2022-02-14  9:22     ` Hyman Huang
2022-02-10 16:17 ` [PATCH v14 7/7] softmmu/dirtylimit: Implement dirty page rate limit huangy81
2022-02-11 13:40   ` Markus Armbruster
2022-02-14  8:25   ` Peter Xu
2022-02-14  9:24     ` Hyman Huang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f38e0fba747bcbe534fb6669c989a9455eef1f46.1644509582.git.huangy81@chinatelecom.cn \
    --to=huangy81@chinatelecom.cn \
    --cc=armbru@redhat.com \
    --cc=david@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=eduardo@habkost.net \
    --cc=pbonzini@redhat.com \
    --cc=peterx@redhat.com \
    --cc=philmd@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    --cc=richard.henderson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.