Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Yao Qi <yao@codesourcery.com>
Cc: Mark Kettenis <mark.kettenis@xs4all.nl>, gdb-patches@sourceware.org
Subject: Re: [PATCH 2/3] skip_prolgoue (amd64)
Date: Wed, 04 Dec 2013 12:08:00 -0000	[thread overview]
Message-ID: <529F1B1F.2040606@redhat.com> (raw)
In-Reply-To: <529E9462.9010001@codesourcery.com>

On 12/04/2013 02:33 AM, Yao Qi wrote:
> On 12/02/2013 03:32 PM, Yao Qi wrote:
>> > GDB target cache contains both code cache and stack cache.  GDB can
>> > know the JIT event by means of jit event breakpoint, but GDB can't know
>> > whether a thread's stack is modified (by other threads).  So we have
>> > to flush target cache before handling*every*  event :-/  I'll send a
>> > follow-up patch.
> When I finished the patch below, I wondered whether this is the right
> way to go.
>
> Nowadays, in non-stop mode, GDB flushes target cache between
> each command.  With the patch applied, GDB flushes target cache between
> each event.  Then, I realize that GDB flushes cache at any changes (GDB
> commands from user and events from inferior) in non-stop mode, so I
> can't figure out a case that cache can be used.  Do we still need target
> cache in non-stop mode?

It can still help for the duration of the command, or for the
duration of the event handling.  GDB might end up reading the
same locations more than once while doing either.  Also, the
overfetching can still help anyway.  E.g., in the prologue
analyzers while handling each event.

Actually "non-stop", vs "all-stop" here isn't the ideal
predicate.  The real predicate is "is any thread running".
"non-stop" is just being currently used in
prepare_execute_command as proxy for that, just because
that was the easiest.

On 12/04/2013 02:33 AM, Yao Qi wrote:

> @@ -2806,6 +2807,16 @@ fetch_inferior_event (void *client_data)
> 
>     overlay_cache_invalid = 1;
> 
> +  if (non_stop)
> +    {
> +      /* In non-stop mode, one thread stops and caches the contents of
> +	 stack or code, while other running threads may change the
> +	 code (through JIT) or stack.  The target cache can get stale
> +	 without us being able to detect it.  Flush target cache
> +	 before handling each event.  */
> +      target_dcache_invalidate ();
> +    }

I don't actually think this should be gated on non-stop.  It
should be unconditional.  I mentioned before that it'd be most
visible with non-stop, but that doesn't imply it's not
visible with all-stop.  If we're seeing or going to wait for
a target event, it's because the target was running,
irrespective of all-stop/non-stop.  I really think we
should invalidate the cache at all places we invalidate the
overlay cache (wait_for_inferior, etc.), not just fetch_inferior_event.

For all-stop, it shouldn't really make a difference to
performance, as we invalidate the cache on resumes anyway,
and in all-stop, there must always be a resume prior to
any stop...

-- 
Pedro Alves


  reply	other threads:[~2013-12-04 12:08 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 [this message]
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
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=529F1B1F.2040606@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