From: Igor Mammedov <imammedo@redhat.com>
To: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
Cc: qemu-devel@nongnu.org, "Eduardo Habkost" <ehabkost@redhat.com>,
"Andreas Färber" <afaerber@suse.de>
Subject: Re: [Qemu-devel] [RFC 1/3] using CPUMASK bitmaps to calculate cpu index
Date: Thu, 22 May 2014 15:26:25 +0200 [thread overview]
Message-ID: <20140522152625.493022e3@nial.usersys.redhat.com> (raw)
In-Reply-To: <ee656155f39eaa9da06bf6827acf2c041998d22a.1399974281.git.chen.fan.fnst@cn.fujitsu.com>
On Tue, 13 May 2014 18:08:47 +0800
Chen Fan <chen.fan.fnst@cn.fujitsu.com> wrote:
> instead of seeking the number of CPUs, using CPUMASK bitmaps to
> calculate the cpu index, also would be a gread benefit to remove
> cpu index.
How would it help to remove cpu_index?
What if there is only one CPU at start nad there is a need to add
CPU with cpu_index==10?
Bitmap hardly changes here anything, it's just another way of
doing:
cpu_index = 0;
CPU_FOREACH(some_cpu) {
cpu_index++;
}
What would help however is replacing cpu_index at read points with
CPUClass->get_arch_id()
Then targets that need sparse index could override default
get_arch_id() to suite their needs and use their own properties
to set arch_id value.
Caution: this change would cause migration breakage for target-i386,
so x86_cpu_get_arch_id() should take care about it when used with old
machine types.
>
> Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
> ---
> exec.c | 9 ++++-----
> include/qom/cpu.h | 9 +++++++++
> include/sysemu/sysemu.h | 7 -------
> 3 files changed, 13 insertions(+), 12 deletions(-)
>
> diff --git a/exec.c b/exec.c
> index cf12049..2948841 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -473,16 +473,15 @@ void cpu_exec_init(CPUArchState *env)
> {
> CPUState *cpu = ENV_GET_CPU(env);
> CPUClass *cc = CPU_GET_CLASS(cpu);
> - CPUState *some_cpu;
> int cpu_index;
>
> #if defined(CONFIG_USER_ONLY)
> cpu_list_lock();
> #endif
> - cpu_index = 0;
> - CPU_FOREACH(some_cpu) {
> - cpu_index++;
> - }
> + cpu_index = find_first_zero_bit(cc->cpu_present_mask,
> + MAX_CPUMASK_BITS);
> + set_bit(cpu_index, cc->cpu_present_mask);
> +
> cpu->cpu_index = cpu_index;
> cpu->numa_node = 0;
> QTAILQ_INIT(&cpu->breakpoints);
> diff --git a/include/qom/cpu.h b/include/qom/cpu.h
> index df977c8..b8f46b1 100644
> --- a/include/qom/cpu.h
> +++ b/include/qom/cpu.h
> @@ -70,6 +70,13 @@ typedef void (*CPUUnassignedAccess)(CPUState *cpu, hwaddr addr,
>
> struct TranslationBlock;
>
> +/* The following shall be true for all CPUs:
> + * cpu->cpu_index < max_cpus <= MAX_CPUMASK_BITS
> + *
> + * Note that cpu->get_arch_id() may be larger than MAX_CPUMASK_BITS.
> + */
> +#define MAX_CPUMASK_BITS 255
> +
> /**
> * CPUClass:
> * @class_by_name: Callback to map -cpu command line model name to an
> @@ -142,6 +149,8 @@ typedef struct CPUClass {
> const struct VMStateDescription *vmsd;
> int gdb_num_core_regs;
> const char *gdb_core_xml_file;
> +
> + DECLARE_BITMAP(cpu_present_mask, MAX_CPUMASK_BITS);
> } CPUClass;
>
> #ifdef HOST_WORDS_BIGENDIAN
> diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
> index ba5c7f8..04edb8b 100644
> --- a/include/sysemu/sysemu.h
> +++ b/include/sysemu/sysemu.h
> @@ -134,13 +134,6 @@ extern QEMUClockType rtc_clock;
>
> #define MAX_NODES 64
>
> -/* The following shall be true for all CPUs:
> - * cpu->cpu_index < max_cpus <= MAX_CPUMASK_BITS
> - *
> - * Note that cpu->get_arch_id() may be larger than MAX_CPUMASK_BITS.
> - */
> -#define MAX_CPUMASK_BITS 255
> -
> extern int nb_numa_nodes;
> extern uint64_t node_mem[MAX_NODES];
> extern unsigned long *node_cpumask[MAX_NODES];
next prev parent reply other threads:[~2014-05-22 13:26 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-13 10:08 [Qemu-devel] [RFC 0/3] cpu: add device_add foo-x86_64-cpu support Chen Fan
2014-05-13 10:08 ` [Qemu-devel] [RFC 1/3] using CPUMASK bitmaps to calculate cpu index Chen Fan
2014-05-22 13:26 ` Igor Mammedov [this message]
2014-05-13 10:08 ` [Qemu-devel] [RFC 2/3] cpu: introduce CpuTopoInfo structure for argument simplification Chen Fan
2014-05-13 10:08 ` [Qemu-devel] [RFC 3/3] cpu: add device_add foo-x86_64-cpu support Chen Fan
2014-05-22 13:55 ` Igor Mammedov
2014-05-22 2:33 ` [Qemu-devel] [RFC 0/3] " chen.fan.fnst
2014-05-22 10:49 ` Andreas Färber
2014-05-22 14:52 ` Eduardo Habkost
2014-05-22 13:33 ` Igor Mammedov
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=20140522152625.493022e3@nial.usersys.redhat.com \
--to=imammedo@redhat.com \
--cc=afaerber@suse.de \
--cc=chen.fan.fnst@cn.fujitsu.com \
--cc=ehabkost@redhat.com \
--cc=qemu-devel@nongnu.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).