From: lijun <junmuzi@gmail.com>
To: qemu-devel@nongnu.org
Cc: aliguori@amazon.com
Subject: Re: [Qemu-devel] [PATCH] qemu will core dump with "-smp 254, sockets=2, cores=3, threads=2"
Date: Sun, 15 Dec 2013 01:21:34 +0800 [thread overview]
Message-ID: <52AC939E.9060706@gmail.com> (raw)
In-Reply-To: <52A9FC0C.3040509@gmail.com>
Hi all,
As qemu core dump cause by "sockets=2,cores=3,threads=2", so add
this patch to check whether cores and threads is a power of 2.
The following is the realization of apicid_from_topo_ids function
in file target-i386/topology.h. It uses shift to get the values of
pkg_id and core_id. nr_cores and nr_threads is related to this shift.
static inline apic_id_t apicid_from_topo_ids(unsigned nr_cores,
unsigned nr_threads,
unsigned pkg_id,
unsigned core_id,
unsigned smt_id)
{
return (pkg_id << apicid_pkg_offset(nr_cores, nr_threads)) |
(core_id << apicid_core_offset(nr_cores, nr_threads)) |
smt_id;
}
----
So should add a check for smp_cores and smp_threads in smp_parse
function in file vl.c. Check whether smp_cores and smp_threads is a
power of 2, so nr_cores and nr_threads is a power of 2. When return
from apicid_from_topo_ids function, apic_id and id could get the correct
values(apic_id is in file "hw/i386/acpi-build.c" and id is in file
"hw/acpi/piix4.c") .
Without this check for smp_cores and smp_threads, specify "-smp
160,sockets=2,cores=3,threads=2", qemu will core dump too.
--- a/vl.c 2013-12-14 23:46:58.991076467 +0800
+++ b/vl.c 2013-12-15 00:40:31.653800907 +0800
@@ -1384,6 +1384,19 @@
},
};
+/**
+ * This function will return whether @num is power of 2.
+ *
+ * Returns: 1 indicate @num is power of 2, 0 indicate @num is not.
+ */
+static int is_2_power(int num)
+{
+ if (num < 0 || num > 256)
+ return 1;
+
+ return !(num & (num - 1));
+}
+
static void smp_parse(QemuOpts *opts)
{
if (opts) {
@@ -1418,6 +1431,12 @@
}
+ /* check whether smp_cores and smp_threads is a power of 2 */
+ if (!is_2_power(smp_cores) || !is_2_power(smp_threads)) {
+ smp_cores = 1;
+ smp_threads = 1;
+ }
+
if (max_cpus == 0) {
max_cpus = smp_cpus;
}
Best Regards,
Jun Li
next prev parent reply other threads:[~2013-12-14 17:22 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-12 18:10 [Qemu-devel] [PATCH] qemu will core dump with "-smp 254, sockets=2, cores=3, threads=2" lijun
2013-12-14 17:21 ` lijun [this message]
2013-12-14 19:10 ` Peter Maydell
2013-12-16 14:43 ` Eric Blake
2013-12-16 16:55 ` Eduardo Habkost
-- strict thread matches above, loose matches on Subject: below --
2013-12-16 6:18 jun muzi
2013-12-16 7:54 jun muzi
2013-12-16 16:53 ` Eduardo Habkost
2013-12-17 15:16 [Qemu-devel] [PATCH] qemu will core dump with "-smp 254, , " lijun
2013-12-17 15:51 ` Eduardo Habkost
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=52AC939E.9060706@gmail.com \
--to=junmuzi@gmail.com \
--cc=aliguori@amazon.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 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.