From: Pedro Alves <palves@redhat.com>
To: Yao Qi <yao@codesourcery.com>
Cc: Pedro Alves <palves@redhat.com>,
Mark Kettenis <mark.kettenis@xs4all.nl>,
gdb-patches@sourceware.org
Subject: Re: [PATCH 2/3] skip_prolgoue (amd64)
Date: Thu, 05 Dec 2013 14:37:00 -0000 [thread overview]
Message-ID: <52A08FA4.9000002@redhat.com> (raw)
In-Reply-To: <52A0888B.5000309@codesourcery.com>
On 12/05/2013 02:07 PM, Yao Qi wrote:
> On 12/05/2013 08:00 PM, Pedro Alves wrote:
>> I think we can. My view here is that handling an event
>> is a quick and short lived operation. GDB bursts a few reads
>> in sequence, and then moves on to the next event. In that
>> scenario, you get as much stale results with or without a cache.
>
> I disagree. Results may be staled with cache, but results may be
> different, not staled, without cache. They are different because they
> are red on different times, but all of them are valid. It is a snapshot
> of a piece of memory on a certain moment.
Sigh, I don't know why I wrote "stale" there. I meant "wrong,
inconsistent, useless, whatnot". As in, if a thread changes
memory while GDB is reading it, you can get incoherent/self-inconsistent
results. E.g,. even if between the inferior's threads, writes to
'struct { int a, int b} ab;' are coordinated, say, with a mutex,
when printing 'ab', GDB can end up reading a chunk of the
structure's contents before the write, and another chunk after
the write, and present that frankenstein value to the user.
You can get such undefined results with or without a cache,
because the "certain moment" will be different for each of
the partial reads. Even each partial read is not guaranteed
to be atomic.
>> IOW, even without the cache, running threads can change memory as
>> GDB reads it, and so the chances of hitting stale data with or
>> without a cache are practically the same. OTOH, distinct target
>> events (and commands, etc.) can trigger quite apart (time-wise),
>> and that break the odd balance -- not flushing the cache
>> between events increases the changes of hitting stale data,
>
> I suspect you meant "chances" instead of "changes".
Yes.
>
>> compared to not having a cache.
>
> Flushing the cache decreases likelihood of getting staled data, but
> can't completely remove it.
Right. The trick IMO, is selecting flush points that make it so
that that chances of getting an incoherent value/memory chunk
are practically the same with or without a cache. Places where
GDB needs to be sure to get a coherent, instantaneous
snapshot view of memory need to handle that specially (we do
that nowhere presently), e.g., by pausing all (affected) threads,
or perhaps even something else smarter (say, with kernel help,
the debugger declares intention of reading a memory range,
and the kernel makes sure the associated pages don't change
from the debugger's view, COW pages if some inferior threads
wants to change them while the debugger is accessing them).
> I am fine to use cache in non-stop mode, as
> it helps performance, so we have to compromise.
Right.
>>>> Beside the predicate "is any thread running", another is "no thread is
>>>> resumed since last flushing". Cache should be flushed when either is
>>>> true.
>> Not sure I understood that.
>
> I meant, even "none of threads is running now", we may have to flush
> cache if "they were resumed" (and all stopped now).
OK, I see what you mean. I was assuming "all stopped now"
means "we've seen all threads report stops", but there are
indeed other ways to implement that predicate, and indeed
that case needs to be considered.
--
Pedro Alves
next prev parent reply other threads:[~2013-12-05 14:37 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-29 14:27 [PATCH 0/3] Use target_read_code in skip_prologue Yao Qi
2013-11-29 14:27 ` [PATCH 2/3] skip_prolgoue (amd64) Yao Qi
2013-11-29 14:38 ` Mark Kettenis
2013-11-29 18:55 ` Mark Kettenis
2013-11-30 3:40 ` Yao Qi
2013-11-30 12:01 ` Pedro Alves
2013-12-02 7:34 ` Yao Qi
2013-12-03 18:28 ` Pedro Alves
2013-12-04 2:34 ` Yao Qi
2013-12-04 12:08 ` Pedro Alves
2013-12-04 15:38 ` Tom Tromey
2013-12-04 18:31 ` Doug Evans
2013-12-05 11:31 ` Pedro Alves
2013-12-05 1:21 ` Yao Qi
2013-12-05 12:08 ` Pedro Alves
2013-12-05 14:08 ` Yao Qi
2013-12-05 14:37 ` Pedro Alves [this message]
2013-12-08 8:01 ` Yao Qi
2013-12-08 8:26 ` Doug Evans
2013-12-09 1:45 ` Yao Qi
2013-12-09 11:32 ` Pedro Alves
2013-12-09 11:53 ` Pedro Alves
2013-12-09 13:03 ` Yao Qi
2013-12-09 13:13 ` Pedro Alves
2013-12-09 13:58 ` Yao Qi
2013-12-09 15:34 ` Pedro Alves
2013-12-10 0:57 ` Yao Qi
2013-12-10 10:23 ` Pedro Alves
2013-12-10 12:02 ` Yao Qi
2013-12-04 17:42 ` Doug Evans
2013-12-04 18:00 ` Doug Evans
2013-12-04 17:54 ` Doug Evans
2013-12-05 1:39 ` Yao Qi
2013-12-05 11:47 ` Pedro Alves
2013-11-29 14:36 ` [PATCH 1/3] Use target_read_code in skip_prologue (i386) Yao Qi
2013-11-30 11:43 ` Pedro Alves
2013-11-29 14:38 ` [PATCH 3/3] Perf test case: skip-prologue Yao Qi
2013-12-03 7:34 ` Yao Qi
2013-12-10 12:45 ` Yao Qi
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=52A08FA4.9000002@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=mark.kettenis@xs4all.nl \
--cc=yao@codesourcery.com \
/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