lkml.org 
[lkml]   [2008]   [Feb]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 2/6] fs/direct-io.c: Use DIV_ROUND_UP
Hi Nishanth,

On Thu, Feb 14, 2008 at 7:38 PM, Nishanth Aravamudan <nacc@us.ibm.com> wrote:
> Is it just me, or does
>
> ((user_addr + iov[seg].iov_len + PAGE_SIZE - 1)/PAGE_SIZE - user_addr/PAGE_SIZE)
>
> not simplify to
>
> = ((iov[seg].iov_len + PAGE_SIZE - 1)/PAGE_SIZE + user_addr/PAGE_SIZE - user_addr/PAGE_SIZE)
>
> = ((iov[seg].iov_len + PAGE_SIZE - 1)/PAGE_SIZE)
>
> = DIV_ROUND_UP(iov[seg].iov_len, PAGE_SIZE)
>
> CMIIW.

I double-checked this and I believe you're correct. It's simpler to
see when you do:

x = user_addr
y = iov[seg].iov_len
z = PAGE_SIZE

So

(x + y + z - 1)/z - x/z

= [x + (y + z - 1)]/z - x/z

= [xz + z(y + z - 1)]/z^2 - x/z

= x/z + (y + z - 1)/z - x/z

And the rest follows from your simplifications.

Pekka


\
 
 \ /
  Last update: 2008-02-14 19:21    [W:0.357 / U:0.172 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site