Re: difference between xip and o_direct

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux