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>,
	"Juan Quintela" <quintela@redhat.com>,
	Hyman <huangy81@chinatelecom.cn>,
	"David Hildenbrand" <david@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 v22 2/8] cpus: Introduce cpu_list_generation_id
Date: Fri,  1 Apr 2022 01:49:18 +0800	[thread overview]
Message-ID: <c9e36ac516c6c85164ae2afb1a534567b96f7200.1648748793.git.huangy81@chinatelecom.cn> (raw)
In-Reply-To: <cover.1648748793.git.huangy81@chinatelecom.cn>
In-Reply-To: <cover.1648748793.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.

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(黄勇) <huangy81@chinatelecom.cn>
Reviewed-by: Peter Xu <peterx@redhat.com>
---
 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 db459b4..793364d 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 50a7d29..7cba376 100644
--- a/include/exec/cpu-common.h
+++ b/include/exec/cpu-common.h
@@ -32,6 +32,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-03-31 17:54 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-31 17:49 [PATCH v22 0/8] support dirty restraint on vCPU huangy81
2022-03-31 17:49 ` [PATCH v22 1/8] accel/kvm/kvm-all: Refactor per-vcpu dirty ring reaping huangy81
2022-03-31 17:49 ` huangy81 [this message]
2022-03-31 17:49 ` [PATCH v22 3/8] migration/dirtyrate: Refactor dirty page rate calculation huangy81
2022-03-31 17:49 ` [PATCH v22 4/8] softmmu/dirtylimit: Implement vCPU dirtyrate calculation periodically huangy81
2022-03-31 17:49 ` [PATCH v22 5/8] accel/kvm/kvm-all: Introduce kvm_dirty_ring_size function huangy81
2022-03-31 17:49 ` [PATCH v22 6/8] softmmu/dirtylimit: Implement virtual CPU throttle huangy81
2022-03-31 17:49 ` [PATCH v22 7/8] softmmu/dirtylimit: Implement dirty page rate limit huangy81
2022-03-31 17:49 ` [PATCH v22 8/8] tests: Add dirty page rate limit test huangy81
2022-03-31 18:33   ` Peter Xu
2022-04-24 16:52 ` [PATCH v22 0/8] support dirty restraint on vCPU Hyman
2022-04-24 21:55   ` Peter Xu
2022-04-27  6:21     ` Markus Armbruster

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=c9e36ac516c6c85164ae2afb1a534567b96f7200.1648748793.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.