* [RFC][PATCH 2/5] pagemap: use PAGE_MASK/PAGE_ALIGN()
2007-08-07 22:33 [RFC][PATCH 1/5] pagemap: remove file header Dave Hansen
@ 2007-08-07 22:33 ` Dave Hansen
2007-08-08 1:54 ` Matt Mackall
0 siblings, 1 reply; 4+ messages in thread
From: Dave Hansen @ 2007-08-07 22:33 UTC (permalink / raw)
To: mpm; +Cc: linux-kernel, serue, Dave Hansen
Use existing macros (PAGE_MASK/PAGE_ALIGN()) instead of
open-coding them.
Signed-off-by: Dave Hansen <haveblue@us.ibm.com>
---
lxc-dave/fs/proc/task_mmu.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff -puN fs/proc/task_mmu.c~pagemap-use-PAGE_MASK fs/proc/task_mmu.c
--- lxc/fs/proc/task_mmu.c~pagemap-use-PAGE_MASK 2007-08-07 15:30:52.000000000 -0700
+++ lxc-dave/fs/proc/task_mmu.c 2007-08-07 15:30:52.000000000 -0700
@@ -669,9 +669,9 @@ static ssize_t pagemap_read(struct file
goto out;
ret = -ENOMEM;
- uaddr = (unsigned long)buf & ~(PAGE_SIZE-1);
+ uaddr = (unsigned long)buf & PAGE_MASK;
uend = (unsigned long)(buf + count);
- pagecount = (uend - uaddr + PAGE_SIZE-1) / PAGE_SIZE;
+ pagecount = (uend - PAGE_ALIGN(uaddr)) / PAGE_SIZE;
pages = kmalloc(pagecount * sizeof(struct page *), GFP_KERNEL);
if (!pages)
goto out_task;
_
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC][PATCH 2/5] pagemap: use PAGE_MASK/PAGE_ALIGN()
2007-08-07 22:33 ` [RFC][PATCH 2/5] pagemap: use PAGE_MASK/PAGE_ALIGN() Dave Hansen
@ 2007-08-08 1:54 ` Matt Mackall
0 siblings, 0 replies; 4+ messages in thread
From: Matt Mackall @ 2007-08-08 1:54 UTC (permalink / raw)
To: Dave Hansen; +Cc: linux-kernel, serue
On Tue, Aug 07, 2007 at 03:33:01PM -0700, Dave Hansen wrote:
>
> Use existing macros (PAGE_MASK/PAGE_ALIGN()) instead of
> open-coding them.
Absolutely.
Acked-by: Matt Mackall <mpm@selenic.com>
--
Mathematics is the supreme nostalgia of our time.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC][PATCH 2/5] pagemap: use PAGE_MASK/PAGE_ALIGN()
[not found] ` <8PFSA-6mt-1@gated-at.bofh.it>
@ 2007-08-08 7:38 ` Christian Ehrhardt
2007-08-08 15:11 ` Dave Hansen
0 siblings, 1 reply; 4+ messages in thread
From: Christian Ehrhardt @ 2007-08-08 7:38 UTC (permalink / raw)
To: Dave Hansen; +Cc: linux-kernel, serue, Dave Hansen
In linux.kernel, you wrote:
>
> Use existing macros (PAGE_MASK/PAGE_ALIGN()) instead of
> open-coding them.
>
> Signed-off-by: Dave Hansen <haveblue@us.ibm.com>
> ---
>
> lxc-dave/fs/proc/task_mmu.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff -puN fs/proc/task_mmu.c~pagemap-use-PAGE_MASK fs/proc/task_mmu.c
> --- lxc/fs/proc/task_mmu.c~pagemap-use-PAGE_MASK 2007-08-07 15:30:52.000000000 -0700
> +++ lxc-dave/fs/proc/task_mmu.c 2007-08-07 15:30:52.000000000 -0700
> @@ -669,9 +669,9 @@ static ssize_t pagemap_read(struct file
> goto out;
>
> ret = -ENOMEM;
> - uaddr = (unsigned long)buf & ~(PAGE_SIZE-1);
> + uaddr = (unsigned long)buf & PAGE_MASK;
> uend = (unsigned long)(buf + count);
> - pagecount = (uend - uaddr + PAGE_SIZE-1) / PAGE_SIZE;
> + pagecount = (uend - PAGE_ALIGN(uaddr)) / PAGE_SIZE;
Unless I'm missing something the PAGE_ALIGN as ist stands is now a NOP
because uaddr is already page aligned. You probably wanted to
PAGE_ALIGN(uend). However, this will likely add an additional instruction
to the generated code.
regards Christian
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC][PATCH 2/5] pagemap: use PAGE_MASK/PAGE_ALIGN()
2007-08-08 7:38 ` [RFC][PATCH 2/5] pagemap: use PAGE_MASK/PAGE_ALIGN() Christian Ehrhardt
@ 2007-08-08 15:11 ` Dave Hansen
0 siblings, 0 replies; 4+ messages in thread
From: Dave Hansen @ 2007-08-08 15:11 UTC (permalink / raw)
To: Christian Ehrhardt; +Cc: linux-kernel, serue
On Wed, 2007-08-08 at 09:38 +0200, Christian Ehrhardt wrote:
>
> > ret = -ENOMEM;
> > - uaddr = (unsigned long)buf & ~(PAGE_SIZE-1);
> > + uaddr = (unsigned long)buf & PAGE_MASK;
> > uend = (unsigned long)(buf + count);
> > - pagecount = (uend - uaddr + PAGE_SIZE-1) / PAGE_SIZE;
> > + pagecount = (uend - PAGE_ALIGN(uaddr)) / PAGE_SIZE;
>
> Unless I'm missing something the PAGE_ALIGN as ist stands is now a NOP
> because uaddr is already page aligned. You probably wanted to
> PAGE_ALIGN(uend). However, this will likely add an additional instruction
> to the generated code.
Yeah, I aligned the wrong thing. I'll fix that up.
-- Dave
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-08-08 15:11 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <8PFSA-6mt-3@gated-at.bofh.it>
[not found] ` <8PFSA-6mt-1@gated-at.bofh.it>
2007-08-08 7:38 ` [RFC][PATCH 2/5] pagemap: use PAGE_MASK/PAGE_ALIGN() Christian Ehrhardt
2007-08-08 15:11 ` Dave Hansen
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).