Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Ulrich Weigand" <uweigand@de.ibm.com>
To: jan.kratochvil@redhat.com (Jan Kratochvil)
Cc: gdb-patches@sourceware.org
Subject: Re: [patch] Fix gcore writer for -Wl,-z,relro (PR corefiles/11804)
Date: Thu, 23 Sep 2010 14:48:00 -0000	[thread overview]
Message-ID: <201009231242.o8NCgex0019394@d12av02.megacenter.de.ibm.com> (raw)
In-Reply-To: <20100922213245.GA25769@host1.dyn.jankratochvil.net> from "Jan Kratochvil" at Sep 22, 2010 11:32:45 PM

Jan Kratochvil wrote:

> There was a hint
> 	http://sourceware.org/bugzilla/show_bug.cgi?id=11804#c12
> it may not always work right but that would be just a Linux kernel bug so that
> GDB part should be OK.  Also it cannot be a regression, only more pages may be
> written out with this patch.

[ I've been tracking down a Linux on z customer problem that turns out to be
exactly the same issue -- thanks for working on this! ]

It appears there are at least two problems with this approach currently
being discussed:

- The "dirty" pages count in /proc/.../smaps is sometimes wrong.  This is
  because the kernel currently only checks the per-PTE dirty bit, and not
  the per-page dirty bit.  This is drastically wrong on System z, because
  the platform *only* has a per-page hardware dirty bit; per-PTE dirty bit
  checks will always return "clean".  But on other systems there's a chance
  of mis-indication of the dirty state as well (e.g. if the page was dirtied
  by a syscall, or if a dirty page was swapped out, swapped back in, and
  subsequently removed from swap).

  This can indeed be considered a pure kernel bug that needs to be fixed.

- Even with the dirty accounting fixed, there are *still* cases where a page
  is genuinely clean as far as memory-management is concerned, but it was
  modified as compared to the file contents anyway.

  This happens if a page was swapped out and back in, but its contents
  remain present in swap space until the latter is reused (so-called "swap
  cache" pages).  These are legitimately considered clean pages because
  they can be simply dropped if needed -- the content is still there on
  the swap device.


To fix the second problem, it seems GDB will need to pursue a different
approach, for example by checking whether a mapping contains only file-backed
or also any anonymous pages (I'm told by kernel folks that swap cache pages
also count as anonymous).  However, this information is not readily available
in the general case (it's in /proc/kpageflags, but that's root-only, and it
is also in /proc/.../numa_maps, but only if NUMA support is enabled ...).

One proposal is to add a count of anonymous pages to /proc/.../smaps:
http://marc.info/?l=linux-kernel&m=128460743123381&w=2

If that goes in, I guess your patch should consider the new Anonymous:
field instead of (or maybe in addition to?) Shared_Dirty and Private_Dirty.
(Swap needs to be considered as well in either case.)

Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


  reply	other threads:[~2010-09-23 12:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-30  9:15 Jan Kratochvil
2010-08-31 17:29 ` Jan Kratochvil
2010-09-23 14:47   ` Jan Kratochvil
2010-09-23 14:48     ` Ulrich Weigand [this message]
2010-09-23 18:52       ` suspended: " Jan Kratochvil

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=201009231242.o8NCgex0019394@d12av02.megacenter.de.ibm.com \
    --to=uweigand@de.ibm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jan.kratochvil@redhat.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