lkml.org 
[lkml]   [2004]   [Mar]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH] fadvise invalidating range fix
From
On Mon, Mar 08, 2004 at 12:03:22PM -0800, Andrew Morton wrote:
> WU Fengguang <wfg@mail.ustc.edu.cn> wrote:
> >
> >
> > - When 'offset' and/or 'offset+len' do no align to page boundary, we must
> > decide whether to abandon the partial page at the beginning/end of the range.
> > My patch assumes that the application is scanning forward,
> > which is the most common case.
> > So 'end_index' is set to the page just before the ending partial page.
>
> If you're going to preserve the partial page at `end' (which seems
> reasonable) then you should also preserve the partial page at `start', don't
> you agree?
>
> - start_index = offset >> PAGE_CACHE_SHIFT;
> + start_index = (offset + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
>
In fact, it depends on the access pattern.
I would expect the normal usage of fadvise to be:

for() {
read() and consume() data in [offset, offset+LEN);
fadvise(fd, offset, LEN, POSIX_FADV_DONTNEED);
offset += LEN; /*scanning forward*/
}

In this case, the partial page at `start' should be freed.
Certainly there may be other patterns.

I wonder the best solution in kernel is to code in favor of the normal case,
and the best(safe and portable) practice in usermode code is to always align
'offset' and 'offset+len' to page boundaries.
And some comment in the manual page of posix_fadvise is recommended.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 14:01    [W:0.088 / U:0.004 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site