From: Dave Hansen <hansendc@us.ibm.com>
To: Matt Mackall <mpm@selenic.com>
Cc: Andrew Morton <akpm@linux-foundation.org>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 13/13] maps#2: Add /proc/kpagemap interface
Date: Thu, 19 Apr 2007 13:25:25 -0700 [thread overview]
Message-ID: <1177014325.12599.166.camel@localhost.localdomain> (raw)
In-Reply-To: <20070419200226.GG11115@waste.org>
On Thu, 2007-04-19 at 15:02 -0500, Matt Mackall wrote:
> On Thu, Apr 19, 2007 at 12:06:38PM -0700, Dave Hansen wrote:
> > On Fri, 2007-04-06 at 17:03 -0500, Matt Mackall wrote:
> > >
> > > +static ssize_t kpagemap_read(struct file *file, char __user *buf,
> > > + size_t count, loff_t *ppos)
> > > +{
> > ...
> > > + for (; i < 2 * chunk / KPMSIZE; i += 2, pfn++) {
> > > + ppage = pfn_to_page(pfn);
> > > + if (!ppage) {
> > > + page[i] = 0;
> > > + page[i + 1] = 0;
> > > + } else {
> > > + page[i] = ppage->flags;
> > > + page[i + 1] = atomic_read(&ppage->_count);
> > > + }
> > > + }
> >
> > I think this needs a pfn_valid() check for sparse/discontig systems. I
> > think we'll oops if we have holes because we don't check pfn_valid()
> > inside of pfn_to_page().
>
> Are there cases where pfn_valid is true but pfn_to_page doesn't work?
> In other words, do I still only need two cases?
pfn_valid() will at least guarantee that pfn_to_page() will give you
_some_ 'struct page' back.
However, it isn't an absolute guarantee that there is actual physical
memory backing that struct page. For your use here, it should be OK,
but it might be a bit confusing if anyone ever ends up with more entries
in that /proc file than they have pages of total memory.
But, this is a pretty low-level debugging mechanism, and I'm not sure
this is very easy to solve in an arch-independent way.
I'd probably just leave it looking something like this:
+ for (; i < 2 * chunk / KPMSIZE; i += 2, pfn++) {
+ if (!pfn_valid(pfn)) {
+ page[i] = 0;
+ page[i + 1] = 0;
+ } else {
+ ppage = pfn_to_page(pfn);
+ page[i] = ppage->flags;
+ page[i + 1] = atomic_read(&ppage->_count);
+ }
+ }
BTW, page->flags can be quite config-dependent on how stuff is stored in
there, especially with the zone, node, and section information encoded
in there. Do you, perhaps, want to just spit out the bits that are
actual PageFoo() flags?
-- Dave
prev parent reply other threads:[~2007-04-19 20:25 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-06 22:03 [PATCH 0/13] maps#2: pagemap, kpagemap, and related cleanups take 2 Matt Mackall
2007-04-06 22:03 ` [PATCH 1/13] maps#2: Uninline some functions in the page walker Matt Mackall
2007-04-06 22:03 ` [PATCH 2/13] maps#2: Eliminate the pmd_walker struct " Matt Mackall
2007-04-06 22:03 ` [PATCH 3/13] maps#2: Remove vma from args " Matt Mackall
2007-04-06 22:03 ` [PATCH 4/13] maps#2: Propagate errors from callback in " Matt Mackall
2007-04-06 22:03 ` [PATCH 5/13] maps#2: Add callbacks for each level to " Matt Mackall
2007-04-06 22:03 ` [PATCH 6/13] maps#2: Move the page walker code to lib/ Matt Mackall
2007-04-11 6:35 ` Nick Piggin
2007-04-11 7:17 ` Andrew Morton
2007-04-11 7:33 ` Nick Piggin
2007-04-11 14:40 ` Matt Mackall
2007-04-12 6:38 ` Nick Piggin
2007-04-17 20:45 ` Matt Mackall
2007-04-17 21:26 ` Permanent Kgdb integration into the kernel - lets get with it Jason Wessel
2007-04-17 22:09 ` Andi Kleen
2007-04-06 22:03 ` [PATCH 7/13] maps#2: Simplify interdependence of /proc/pid/maps and smaps Matt Mackall
2007-04-06 22:03 ` [PATCH 8/13] maps#2: Move clear_refs code to task_mmu.c Matt Mackall
2007-04-06 22:03 ` [PATCH 9/13] maps#2: Regroup task_mmu by interface Matt Mackall
2007-04-06 22:03 ` [PATCH 10/13] maps#2: Make /proc/pid/smaps optional under CONFIG_EMBEDDED Matt Mackall
2007-04-06 22:03 ` [PATCH 11/13] maps#2: Make /proc/pid/clear_refs option " Matt Mackall
2007-04-07 5:41 ` David Rientjes
2007-04-06 22:03 ` [PATCH 12/13] maps#2: Add /proc/pid/pagemap interface Matt Mackall
2007-04-07 6:55 ` Andrew Morton
2007-04-07 16:36 ` Matt Mackall
2007-04-19 19:12 ` Dave Hansen
2007-04-19 19:58 ` Matt Mackall
2007-04-06 22:03 ` [PATCH 13/13] maps#2: Add /proc/kpagemap interface Matt Mackall
2007-04-19 19:06 ` Dave Hansen
2007-04-19 20:02 ` Matt Mackall
2007-04-19 20:25 ` Dave Hansen [this message]
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=1177014325.12599.166.camel@localhost.localdomain \
--to=hansendc@us.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mpm@selenic.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
Powered by JetHome