Re: Linux page cache issue?



according to the chapter "Linux Kernel Overview" of the
kernelhacking-HOWTO the page cache holds pages associated with *open*
files:

The Page Cache

The page cache is made up of pages, each of which refers to a 4kB
portion of data associated with an open file. The data contained in a
page may come from several disk blocks, which may or may not be
physically neighbours on the disk. The page cache is largely used to
interface the requirements of the memory management subsystem (which
uses fixed, 4kB pages) to the VFS subsystem (which uses different size
blocks for different devices).

The page cache has two important data structures, a page hash table
and an inode queue. The page hash table is used to quickly find the
page descriptor of the page holding data associated with an inode and
offset within a file. The inode queue contains lists of page
descriptors relating to open files.

http://www.kernelhacking.org/docs/kernelhacking-HOWTO/indexs03.html

m.

El Wed, Mar 28, 2007 at 02:45:23AM -0400 Xin Zhao ha dit:

Hi,

If a Linux process opens and reads a file A, then it closes the file.
Will Linux keep the file A's data in cache for a while in case another
process opens and reads the same in a short time? I think that is what
I heard before.

But after I digged into the kernel code, I am confused.

When a process closes the file A, iput() will be called, which in turn
calls the follows two functions:
iput_final()->generic_drop_inode()

But from the following calling chain, we can see that file close will
eventually lead to evict and free all cached pages. Actually in
truncate_complete_page(), the pages will be freed. This seems to
imply that Linux has to re-read the same data from disk even if
another process B read the same file right after process A closes the
file. That does not make sense to me.

/***calling chain ***/
generic_delete_inode/generic_forget_inode()->
truncate_inode_pages()->truncate_inode_pages_range()->
truncate_complete_page()->remove_from_page_cache()->
__remove_from_page_cache()->radix_tree_delete()

Am I missing something? Can someone please provide some advise?

Thanks a lot
-x
-
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/

--
For to be free is not merely to cast off
one's chains, but to live in a way that
respects and enhances the freedom of others
(Nelson Mandela)
.''`.
using free software / Debian GNU/Linux | http://debian.org : :' :
`. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4 `-
-
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/



Relevant Pages

  • Re: broken linuxulator in -current as of Jan 8 17:51:45 CET
    ... the open trace shows REAL path ie. after possible prefixing with /compat/linux ... ie. it opens the right library but IGNORES it and the iterates through the rest ... This may not be a _new_ bug in the kernel. ... It may be the case that the introduction of a new linux syscall ...
    (freebsd-current)
  • Re: broken linuxulator in -current as of Jan 8 17:51:45 CET
    ... the open trace shows REAL path ie. after possible prefixing with /compat/linux ... ie. it opens the right library but IGNORES it and the iterates through the rest ... This may not be a _new_ bug in the kernel. ... It may be the case that the introduction of a new linux syscall ...
    (freebsd-current)
  • Re: O_DIRECT question
    ... writes to a file and don't pollute cache memory without using O_DIRECT? ... modern disk drives with and without write cache (WCE=bit in the ... that's definitely a kernel bug. ... page cache, and set some flag saying "can't do normal opens, we're ...
    (Linux-Kernel)
  • Why align .text to 1MB on x86_64?
    ... Under a widespread Linux distribution, AT_PAGESZ is 4KB on both systems, ... Linux suffers randomly lower cache performance because the kernel does not ... still have 16:1 chances for non-optimal usage by 4KB pages. ...
    (comp.os.linux.development.system)
  • Re: ide write cache issue? [Re: Something corrupts raid5 disks slightly during reboot]
    ... >> kernel, other than that it would rule out some strange kernel bug that is ... It could have been a long standing bug in the IDE ... I vaguely recall some ide write cache flushing code was fixed some time ago, ... > chance that it's caused by anything except linux itself. ...
    (Linux-Kernel)