From: Dave Hansen <haveblue@us.ibm.com>
To: mpm@selenic.com
Cc: linux-mm@kvack.org, Dave Hansen <haveblue@us.ibm.com>
Subject: [RFC][PATCH 2/9] pagemap: remove file header
Date: Tue, 21 Aug 2007 13:42:48 -0700 [thread overview]
Message-ID: <20070821204248.1F535365@kernel> (raw)
In-Reply-To: <20070821204248.0F506A29@kernel>
The /proc/<pid>/pagemap file has a header containing:
* first byte: 0 for big endian, 1 for little
* second byte: page shift (eg 12 for 4096 byte pages)
* third byte: entry size in bytes (currently either 4 or 8)
* fourth byte: header size
The endianness is only useful when examining a raw dump of
pagemap from a different machine when you don't know the
source of the file. This is pretty rare, and the programs
or scripts doing the copying off-machine can certainly be
made to hold this information.
The page size is available in userspace at least with libc's
getpagesize(). This will also never vary across processes,
so putting it in a per-process file doesn't make any difference.
If we need a "kernel's page size" exported to userspace,
perhaps we can put it in /proc/meminfo.
The entry size is the really tricky one. This can't just
be sizeof(unsigned long) from userspace because we can have
32-bit processes on 64-bit kernels. But, userspace can
certainly derive this value if it lseek()s to the end of
the file, and divides the file position by the size of its
virtual address space.
In any case, I believe this information is redundant, and
can be removed.
Signed-off-by: Dave Hansen <haveblue@us.ibm.com>
---
lxc-dave/fs/proc/task_mmu.c | 14 +++-----------
1 file changed, 3 insertions(+), 11 deletions(-)
diff -puN fs/proc/task_mmu.c~pagemap-no-header fs/proc/task_mmu.c
--- lxc/fs/proc/task_mmu.c~pagemap-no-header 2007-08-21 13:30:50.000000000 -0700
+++ lxc-dave/fs/proc/task_mmu.c 2007-08-21 13:30:50.000000000 -0700
@@ -601,12 +601,12 @@ static ssize_t pagemap_read(struct file
goto out;
ret = -EIO;
- svpfn = src / sizeof(unsigned long) - 1;
+ svpfn = src / sizeof(unsigned long);
addr = PAGE_SIZE * svpfn;
- if ((svpfn + 1) * sizeof(unsigned long) != src)
+ if (svpfn * sizeof(unsigned long) != src)
goto out;
evpfn = min((src + count) / sizeof(unsigned long) - 1,
- ((~0UL) >> PAGE_SHIFT) + 1) - 1;
+ ((~0UL) >> PAGE_SHIFT) + 1);
count = (evpfn - svpfn) * sizeof(unsigned long);
end = PAGE_SIZE * evpfn;
//printk("src %ld svpfn %d evpfn %d count %d\n", src, svpfn, evpfn, count);
@@ -638,14 +638,6 @@ static ssize_t pagemap_read(struct file
pm.count = count;
pm.out = (unsigned long __user *)buf;
- if (svpfn == -1) {
- put_user((char)(ntohl(1) != 1), buf);
- put_user((char)PAGE_SHIFT, buf + 1);
- put_user((char)sizeof(unsigned long), buf + 2);
- put_user((char)sizeof(unsigned long), buf + 3);
- add_to_pagemap(pm.next, page[0], &pm);
- }
-
down_read(&mm->mmap_sem);
vma = find_vma(mm, pm.next);
while (pm.count > 0 && vma) {
_
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2007-08-21 20:42 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-21 20:42 [RFC][PATCH 1/9] /proc/pid/pagemap update Dave Hansen
2007-08-21 20:42 ` Dave Hansen [this message]
2007-08-21 21:24 ` [RFC][PATCH 2/9] pagemap: remove file header Matt Mackall
2007-08-21 20:42 ` [RFC][PATCH 3/9] pagemap: use PAGE_MASK/PAGE_ALIGN() Dave Hansen
2007-08-21 21:25 ` Matt Mackall
2007-08-21 20:42 ` [RFC][PATCH 4/9] pagemap: remove open-coded sizeof(unsigned long) Dave Hansen
2007-08-21 21:26 ` Matt Mackall
2007-08-21 20:42 ` [RFC][PATCH 5/9] introduce TASK_SIZE_OF() for all arches Dave Hansen
2007-08-21 20:42 ` [RFC][PATCH 6/9] pagemap: give -1's a name Dave Hansen
2007-08-21 21:27 ` Matt Mackall
2007-08-21 20:42 ` [RFC][PATCH 7/9] pagewalk: add handler for empty ranges Dave Hansen
2007-08-30 7:28 ` Nick Piggin
2007-09-03 12:32 ` Matt Mackall
2007-08-21 20:42 ` [RFC][PATCH 8/9] pagemap: use page walker pte_hole() helper Dave Hansen
2007-08-21 22:01 ` Matt Mackall
2007-08-21 22:38 ` Dave Hansen
2007-08-21 20:42 ` [RFC][PATCH 9/9] pagemap: export swap ptes Dave Hansen
2007-08-21 21:49 ` Matt Mackall
2007-08-21 22:26 ` Dave Hansen
2007-08-21 21:23 ` [RFC][PATCH 1/9] /proc/pid/pagemap update Matt Mackall
2007-08-21 21:26 ` Dave Hansen
2007-08-21 22:07 ` Matt Mackall
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=20070821204248.1F535365@kernel \
--to=haveblue@us.ibm.com \
--cc=linux-mm@kvack.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