From: lijun <junmuzi@gmail.com>
To: qemu-devel@nongnu.org
Cc: blauwirbel@gmail.com, afaerber@suse.de, ehabkost@redhat.com,
rth@twiddle.net
Subject: Re: [Qemu-devel] [PATCH] qemu will core dump with "-smp 254, , sockets=2, cores=3, threads=2"
Date: Tue, 17 Dec 2013 23:16:30 +0800 [thread overview]
Message-ID: <52B06ACE.3050901@gmail.com> (raw)
As Eric and Eduardo's suggestions, use is_power_of_2 to check whether
nr_cores
and nr_threads is the power of 2 in function x86_apicid_from_cpu_idx in file
target-i386/topology.h. This check is very simple, I prefer add it in a
function to write a new function. Thanks for Eric and Eduardo.
Best Regards,
Jun Li
Signed-off-by: Jun Li <junmuzi@gmail.com>
---
target-i386/topology.h | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/target-i386/topology.h b/target-i386/topology.h
index 07a6c5f..ff21a98 100644
--- a/target-i386/topology.h
+++ b/target-i386/topology.h
@@ -126,6 +126,14 @@ static inline apic_id_t
x86_apicid_from_cpu_idx(unsigned nr_cores,
unsigned cpu_index)
{
unsigned pkg_id, core_id, smt_id;
+
+ /* Check whether nr_cores and nr_threads is a power of 2.
+ * If not, 1 is assigned to them.
+ */
+ nr_cores = is_power_of_2(nr_cores) > 0 ? nr_cores : 1;
+ nr_threads = is_power_of_2(nr_threads) > 0 ? nr_threads : 1;
+
+
x86_topo_ids_from_idx(nr_cores, nr_threads, cpu_index,
&pkg_id, &core_id, &smt_id);
return apicid_from_topo_ids(nr_cores, nr_threads, pkg_id, core_id,
smt_id);
--
1.8.3.1
next reply other threads:[~2013-12-17 15:16 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-17 15:16 lijun [this message]
2013-12-17 15:51 ` [Qemu-devel] [PATCH] qemu will core dump with "-smp 254, , sockets=2, cores=3, threads=2" Eduardo Habkost
-- strict thread matches above, loose matches on Subject: below --
2013-12-16 7:54 [Qemu-devel] [PATCH] qemu will core dump with "-smp 254, " jun muzi
2013-12-16 16:53 ` Eduardo Habkost
2013-12-16 6:18 jun muzi
2013-12-12 18:10 lijun
2013-12-14 17:21 ` lijun
2013-12-14 19:10 ` Peter Maydell
2013-12-16 14:43 ` Eric Blake
2013-12-16 16:55 ` 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=52B06ACE.3050901@gmail.com \
--to=junmuzi@gmail.com \
--cc=afaerber@suse.de \
--cc=blauwirbel@gmail.com \
--cc=ehabkost@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
/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.