From: Nathan Froyd <froydnj@codesourcery.com>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] Re: [PATCH] fix gdbstub support for multiple threads in usermode
Date: Tue, 19 May 2009 11:01:10 -0700 [thread overview]
Message-ID: <20090519180110.GE23911@codesourcery.com> (raw)
In-Reply-To: <4A12E418.4040403@web.de>
On Tue, May 19, 2009 at 06:53:44PM +0200, Jan Kiszka wrote:
> Nathan Froyd wrote:
> > The best way I can think of to do this is to maintain a
> > separately-chained list of CPUStates (through a new field similar to
> > next_cpu) ordered by gdbstub_index. Grabbing a new gdbstub_index then
> > walks through the list, looking for "holes" between adjacent entries in
> > the list. A new gdbstub_index is then picked if we find a hole; we die
> > if we can't find a hole.
>
> Why creating a new list? Just generate a new index and then walk through
> all so far registered CPUStates until no collision is found.
Do you mean something like:
new_index = 0
restart:
for cpu in all_cpus:
if new_index == cpu.gdbstub_index
new_index += 1
goto restart;
new_cpu.gdbstub_index = new_index
I was trying to keep it a linear-time algorithm, and the above is
potentially quadratic. (Not merely an academic exercise, either;
spinning up your first N threads will be enough to trigger quadratic
behavior.) I don't think you can say:
new_index = 0
for cpu in all_cpus:
if new_index == cpu.gdbstub_index
new_index = cpu.gdbstub_index + 1
new_cpu.gdbstub_index = new_index
(i.e. maximum+1 of all existing cpus) either, since that fails for a
list that looks like:
1 -> 0
You could iterate, of course, but then you're just back to quadratic
behavior.
Nothing promises that the cpu list will be kept in sorted order
according to some criteria. (A quick examination of things indicates
the list might be accidentally sorted by time of creation--and thereby
by gdbstub_index--but that falls apart once you wrap gdbstub_index, of
course.) AFAICS, you need the cpus sorted by their gdbstub_index to
keep linear time bounds. If using a quadratic algorithm is OK, then
I'll just do that, but that doesn't seem like a good idea, especially
since you're imposing a large slowdown on everything for debugging
support which might never get used.
Apologies if I'm missing something obvious here.
-Nathan
next prev parent reply other threads:[~2009-05-19 18:01 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-12 19:35 [Qemu-devel] [PATCH] fix gdbstub support for multiple threads in usermode Nathan Froyd
2009-05-12 20:53 ` [Qemu-devel] " Jan Kiszka
2009-05-13 5:08 ` vibisreenivasan
2009-05-13 14:13 ` vibisreenivasan
2009-05-19 14:59 ` Nathan Froyd
2009-05-21 8:19 ` vibi sreenivasan
2009-05-19 15:06 ` Nathan Froyd
2009-05-19 16:53 ` Jan Kiszka
2009-05-19 18:01 ` Nathan Froyd [this message]
2009-05-20 6:39 ` Jan Kiszka
2009-05-20 15:27 ` Jamie Lokier
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=20090519180110.GE23911@codesourcery.com \
--to=froydnj@codesourcery.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).