Page-based direct I/O
Posted Aug 27, 2009 22:10 UTC (Thu) by giraffedata
Parent article: Page-based direct I/O
Developers use direct memory for either (or both) of two reasons: (1) they believe they can manage caching of file contents better than the kernel can, or (2) they want to avoid overflowing the page cache with data which is unlikely to be of use in the near future.
I agree that's what they use it for, but neither of these is really the point of direct I/O. Developers use it for this side effect, because Linux doesn't offer what they really want: simply a cache replacement policy that says, "try not to keep anything for this file in cache."
The reasons for direct I/O per se are different. I believe there are two: 1) something besides this kernel image is accessing the file, so there's no way for the user space program and this other thing to synchronize with kernel caching in the mix. 2) you want to save the expense of an extra copy of data through the kernel's cache. (You can get this with mmap too, but it has drawbacks compared to read/write).
to post comments)