The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Dave Hansen <haveblue@us.ibm.com>
To: mpm@selenic.com
Cc: linux-kernel@vger.kernel.org, serue@us.ibm.com,
	Dave Hansen <haveblue@us.ibm.com>
Subject: [RFC][PATCH 3/5] pagemap: remove open-coded sizeof(unsigned long)
Date: Tue, 07 Aug 2007 15:33:02 -0700	[thread overview]
Message-ID: <20070807223302.B275F4FC@kernel> (raw)
In-Reply-To: <20070807223300.9228E0E0@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 ;(

Signed-off-by: Dave Hansen <haveblue@us.ibm.com>
---

 lxc-dave/fs/proc/task_mmu.c |   13 +++++++------
 1 file changed, 7 insertions(+), 6 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-07 15:30:53.000000000 -0700
+++ lxc-dave/fs/proc/task_mmu.c	2007-08-07 15:30:53.000000000 -0700
@@ -560,14 +560,15 @@ struct pagemapread {
 	unsigned long __user *out;
 };
 
+#define PAGEMAP_ENTRY_SIZE_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 += PAGEMAP_ENTRY_SIZE_BYTES;
+	pm->count -= PAGEMAP_ENTRY_SIZE_BYTES;
 	return 0;
 }
 
@@ -653,13 +654,13 @@ static ssize_t pagemap_read(struct file 
 		goto out;
 
 	ret = -EIO;
-	svpfn = src / sizeof(unsigned long);
+	svpfn = src / PAGEMAP_ENTRY_SIZE_BYTES;
 	addr = PAGE_SIZE * svpfn;
-	if (svpfn * sizeof(unsigned long) != src)
+	if (svpfn * PAGEMAP_ENTRY_SIZE_BYTES != src)
 		goto out;
 	evpfn = min((src + count) / sizeof(unsigned long),
 		    ((~0UL) >> PAGE_SHIFT) + 1);
-	count = (evpfn - svpfn) * sizeof(unsigned long);
+	count = (evpfn - svpfn) * PAGEMAP_ENTRY_SIZE_BYTES;
 	end = PAGE_SIZE * evpfn;
 	//printk("src %ld svpfn %d evpfn %d count %d\n", src, svpfn, evpfn, count);
 
_

  parent reply	other threads:[~2007-08-07 22:34 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-07 22:33 [RFC][PATCH 1/5] pagemap: remove file header Dave Hansen
2007-08-07 22:33 ` [RFC][PATCH 2/5] pagemap: use PAGE_MASK/PAGE_ALIGN() Dave Hansen
2007-08-08  1:54   ` Matt Mackall
2007-08-07 22:33 ` Dave Hansen [this message]
2007-08-07 23:40   ` [RFC][PATCH 3/5] pagemap: remove open-coded sizeof(unsigned long) Matt Mackall
2007-08-07 23:55     ` Dave Hansen
2007-08-08  2:01       ` Matt Mackall
2007-08-07 22:33 ` [RFC][PATCH 4/5] introduce TASK_SIZE_OF() for all arches Dave Hansen
2007-08-08  2:03   ` Matt Mackall
2007-08-08 18:19     ` Dave Hansen
2007-08-07 22:33 ` [RFC][PATCH 5/5] pagemap: add walker for empty areas Dave Hansen
2007-08-08  1:16 ` [RFC][PATCH 1/5] pagemap: remove file header Matt Mackall
2007-08-08  1:31   ` Alan Cox
2007-08-08  3:51     ` Matt Mackall
2007-08-08 16:34     ` Dave Hansen
2007-08-08 16:53       ` Dave Hansen

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=20070807223302.B275F4FC@kernel \
    --to=haveblue@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpm@selenic.com \
    --cc=serue@us.ibm.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