* difference between xip and o_direct
@ 2013-12-05 22:17 jon ernst
2013-12-05 23:51 ` Theodore Ts'o
0 siblings, 1 reply; 2+ messages in thread
From: jon ernst @ 2013-12-05 22:17 UTC (permalink / raw)
To: linux-fsdevel
Hi,
I am trying to understand difference between xip and o_direct.
For XIP, document xip.txt says
"instead of keeping
data in the page cache, the need to have a page cache copy is eliminated
completely. With execute-in-place, read&write type operations are performed
directly from/to the memory backed storage device."
For O_Direct,
" File I/O is done directly to/from user-
space buffers. " from manual of open(2)
So, are those 2 trying to do the same thing ? The difference I can
tell is, XIP option can be used when mounting fs. O_Direct is used in
open system-call.
Can anybody kindly teach me what are other differences?
thank you!
Jon
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: difference between xip and o_direct
2013-12-05 22:17 difference between xip and o_direct jon ernst
@ 2013-12-05 23:51 ` Theodore Ts'o
0 siblings, 0 replies; 2+ messages in thread
From: Theodore Ts'o @ 2013-12-05 23:51 UTC (permalink / raw)
To: jon ernst; +Cc: linux-fsdevel
On Thu, Dec 05, 2013 at 05:17:24PM -0500, jon ernst wrote:
> Hi,
> I am trying to understand difference between xip and o_direct.
>
> For XIP, document xip.txt says
> "instead of keeping
> data in the page cache, the need to have a page cache copy is eliminated
> completely. With execute-in-place, read&write type operations are performed
> directly from/to the memory backed storage device."
XIP is used when the storage device is already directly addressable
from the CPU. Most commonly, the file system image located on a PROM,
EPROM, or NOR FLASH. Normally, we need to copy the executable's text
segment from the HDD or other storage device into the page cache, and
then we map the page from the page cache into the process' page
tables.
But if the storage device is directly conncted to the CPU, then it's a
waste of memory to copy the data from the storage device into the page
cache; instead we can just "execute in place", and just map the memory
address of the read-only EPROM memory (or Flash, etc.) into the
process' page tables.
So XIP only can be used for certain storage devices.
> For O_Direct,
>
> " File I/O is done directly to/from user-
> space buffers. " from manual of open(2)
>
> So, are those 2 trying to do the same thing ? The difference I can
> tell is, XIP option can be used when mounting fs. O_Direct is used in
> open system-call.
O_DIRECT is also trying to bypass the page cache, but for diferrent
reasons. O_DIRECT is not used for text pages, but it is used for data
buffers which are written to disk. Normally, and write(2) system
calls copy the data to be written into the page cache, and then later
we write the data from the page cache to the hard drive (or other
storage device). The reason why we need to do this is because that
way the process doesn't have to make sure the user buffers are
properly aligned, and the process may not want to read and write in
file-system-block-sized-chunks.
However, if the process is willing to adhere to the restrictions
implied by O_DIRECT (see the man page for the open system call), then
read and write calls can bypass the page cache, and the I/O requests
can be sent directly to the hard drive.
So unlike XIP, O_DIRECT can work on any storage device, and it applies
to how data blocks are read and written, where as XIP is used for only
certain storage technologies, and applies only for text pages which
are mapped in read-only so we can execute out of the read-only memory.
Hope this helps,
- Ted
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-12-06 2:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-05 22:17 difference between xip and o_direct jon ernst
2013-12-05 23:51 ` Theodore Ts'o
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).