Re: O_DIRECT question

From: Erik Andersen
Date: Fri Jan 12 2007 - 17:35:47 EST


On Fri Jan 12, 2007 at 05:09:09PM -0500, Linus Torvalds wrote:
> I suspect a lot of people actually have other reasons to avoid caches.
>
> For example, the reason to do O_DIRECT may well not be that you want to
> avoid caching per se, but simply because you want to limit page cache
> activity. In which case O_DIRECT "works", but it's really the wrong thing
> to do. We could export other ways to do what people ACTUALLY want, that
> doesn't have the downsides.

I was rather fond of the old O_STREAMING patch by Robert Love,
which added an open() flag telling the kernel to not keep data
from the current file in cache by dropping pages from the
pagecache before the current index. O_STREAMING was very nice
for when you know you want to read a large file sequentially
without polluting the rest of the cache with GB of data that you
plan on only read once and discard. It worked nicely at doing
what many people want to use O_DIRECT for.

Using O_STREAMING you would get normal read/write semantics since
you still had the pagecache caching your data, but only the
not-yet-written write-behind data and the not-yet-read read-ahead
data. With the additional hint the kernel should drop free-able
pages from the pagecache behind the current position, because we
know we will never want them again. I thought that was a very
nice way of handling things.

-Erik

--
Erik B. Andersen http://codepoet-consulting.com/
--This message was written using 73% post-consumer electrons--
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/