From: Dave Hansen <haveblue@us.ibm.com>
To: mpm@selenic.com
Cc: linux-mm@kvack.org, Dave Hansen <haveblue@us.ibm.com>
Subject: [PATCH 4/9] pagemap: remove open-coded sizeof(unsigned long)
Date: Wed, 22 Aug 2007 16:18:08 -0700 [thread overview]
Message-ID: <20070822231808.B64AC11E@kernel> (raw)
In-Reply-To: <20070822231804.1132556D@kernel>
I think the code gets easier to read when we give symbolic names
to some of the operations we're performing. I was sure we needed
this when I saw the header being built like this:
...
buf[2] = sizeof(unsigned long)
buf[3] = sizeof(unsigned long)
I really couldn't remember what either field did ;(
This particular use is gone (because of removing the header, but
this patch is still a really good idea to clarify the code).
Signed-off-by: Dave Hansen <haveblue@us.ibm.com>
---
lxc-dave/fs/proc/task_mmu.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff -puN fs/proc/task_mmu.c~pagemap-use-ENTRY_SIZE fs/proc/task_mmu.c
--- lxc/fs/proc/task_mmu.c~pagemap-use-ENTRY_SIZE 2007-08-22 16:16:52.000000000 -0700
+++ lxc-dave/fs/proc/task_mmu.c 2007-08-22 16:16:52.000000000 -0700
@@ -508,14 +508,16 @@ struct pagemapread {
unsigned long __user *out;
};
+#define PM_ENTRY_BYTES sizeof(unsigned long)
+
static int add_to_pagemap(unsigned long addr, unsigned long pfn,
struct pagemapread *pm)
{
__put_user(pfn, pm->out);
pm->out++;
- pm->pos += sizeof(unsigned long);
- pm->count -= sizeof(unsigned long);
pm->next = addr + PAGE_SIZE;
+ pm->pos += PM_ENTRY_BYTES;
+ pm->count -= PM_ENTRY_BYTES;
return 0;
}
@@ -601,13 +603,13 @@ static ssize_t pagemap_read(struct file
goto out;
ret = -EIO;
- svpfn = src / sizeof(unsigned long);
+ svpfn = src / PM_ENTRY_BYTES;
addr = PAGE_SIZE * svpfn;
- if (svpfn * sizeof(unsigned long) != src)
+ if (svpfn * PM_ENTRY_BYTES != src)
goto out;
evpfn = min((src + count) / sizeof(unsigned long) - 1,
((~0UL) >> PAGE_SHIFT) + 1);
- count = (evpfn - svpfn) * sizeof(unsigned long);
+ count = (evpfn - svpfn) * PM_ENTRY_BYTES;
end = PAGE_SIZE * evpfn;
//printk("src %ld svpfn %d evpfn %d count %d\n", src, svpfn, evpfn, count);
_
--
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-22 23:18 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-22 23:18 [PATCH 1/9] /proc/pid/pagemap update (v2) Dave Hansen
2007-08-22 23:18 ` [PATCH 2/9] pagemap: remove file header Dave Hansen
2007-08-22 23:18 ` [PATCH 3/9] pagemap: use PAGE_MASK/PAGE_ALIGN() Dave Hansen
2007-08-22 23:18 ` Dave Hansen [this message]
2007-08-22 23:18 ` [PATCH 5/9] introduce TASK_SIZE_OF() for all arches Dave Hansen
2007-08-22 23:18 ` [PATCH 6/9] pagemap: give -1's a name Dave Hansen
2007-08-22 23:18 ` [PATCH 7/9] pagewalk: add handler for empty ranges Dave Hansen
2007-08-22 23:18 ` [PATCH 8/9] pagemap: use page walker pte_hole() helper Dave Hansen
2007-08-22 23:54 ` Matt Mackall
2007-08-22 23:18 ` [PATCH 9/9] pagemap: export swap ptes Dave Hansen
2007-08-24 0:29 ` Matt Mackall
2007-08-24 16:19 ` Dave Hansen
2007-08-24 16:56 ` 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=20070822231808.B64AC11E@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