Skip to contentSkip to conversation

the /proc/filecache interface

RFC Pavel Machek 5 participants 7 messages Jun 14, 2006 – Jun 15, 2006 2 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

Hi!

Quoted 5 lines

The /proc/filecache support has been half done. And I'd like to hear early comments on the interface.

(The patch is not quite ready for code reviews. It is attached in case someone are interested to have it a try.)

I guess this is going to be nice for loading cache after suspend-to-disk and for the fast boot, but...

Quoted 23 lines

SAMPLE OUTPUT

root ~# echo -n ALL > /proc/filecache
root ~# head /proc/filecache

# file ALL
#      ino       size   cached cached%  state   refcnt  uid     gid     dev             file
    413605         23       24    100   --      0       0       0       03:00(hda)      /sbin/modprobe
    381701         17       20    100   --      1       0       0       03:00(hda)      /bin/cat
    398088          1        4    100   --      0       0       0       03:00(hda)      /root/bin/checkpath
    381698        611      612    100   --      1       0       0       03:00(hda)      /bin/bash
    159498          1        4    100   --      0       0       0       03:00(hda)      /etc/mtab
    381719         30       32    100   --      0       0       0       03:00(hda)      /bin/rm
    335993          4        4    100   --      0       0       43      03:00(hda)      /var/run/utmp
         0    3687424      828      0   --      0       0       0       00:02(bdev)     03:00
    159701          5        8    100   --      0       0       0       03:00(hda)      /etc/modprobe.d/aliases
     31866       1238     1240    100   --      4       0       0       03:00(hda)      /lib/tls/libc-2.3.5.so
    381705         51       52    100   --      0       0       0       03:00(hda)      /bin/cp
     31814         27       28    100   --      0       0       0       03:00(hda)      /lib/libblkid.so.1.0
    159534         17       20    100   --      0       0       0       03:00(hda)      /etc/ld.so.cache
[...]

root ~# echo -n /lib/tls/libc-2.3.5.so > /proc/filecache root ~# head /proc/filecache

Quoted 10 lines
# file /lib/tls/libc-2.3.5.so
# flags LK:locked ER:error RF:referenced UD:uptodate DT:dirty AC:active SL:slab CK:checked A1:arch_1 RS:reserved PV:private WB:writeback NS:nosave CP:compound SC:swapcache MD:mappedtodisk RC:reclaim ns:nosave_free RA:readahead MM:mmap
# idx   len                     state                   	refcnt  location
0       21      ____RFUD__AC__________________MD______MM        4       0.0.Normal
21      1       ____RFUD__AC__________________MD______MM        3       0.0.Normal
22      3       ______UD______________________MD________        1       0.0.Normal
25      1       ____RFUD__AC__________________MD______MM        2       0.0.Normal
26      2       ______UD______________________MD________        1       0.0.Normal
28      1       ______UD______________________MD____RA__        1       0.0.Normal
29      2       ______UD______________________MD________        1       0.0.Normal

The interface is really too ugly to live. How do you expect it being used from two programs, simultaneously?

We don't really want to do ascii pretty-printing in kernel, sorry. It probably needs to go into /sys , and be redesigned to provide "one value per file" rule...

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#2 lore raw

Hi Pavel,

Quoted 8 lines · Pavel Machek
Quoted 5 lines

The /proc/filecache support has been half done. And I'd like to hear early comments on the interface.

(The patch is not quite ready for code reviews. It is attached in case someone are interested to have it a try.)

I guess this is going to be nice for loading cache after suspend-to-disk and for the fast boot, but...

Thanks.

Quoted 34 lines
Quoted 23 lines

SAMPLE OUTPUT

root ~# echo -n ALL > /proc/filecache
root ~# head /proc/filecache

# file ALL
#      ino       size   cached cached%  state   refcnt  uid     gid     dev             file
    413605         23       24    100   --      0       0       0       03:00(hda)      /sbin/modprobe
    381701         17       20    100   --      1       0       0       03:00(hda)      /bin/cat
    398088          1        4    100   --      0       0       0       03:00(hda)      /root/bin/checkpath
    381698        611      612    100   --      1       0       0       03:00(hda)      /bin/bash
    159498          1        4    100   --      0       0       0       03:00(hda)      /etc/mtab
    381719         30       32    100   --      0       0       0       03:00(hda)      /bin/rm
    335993          4        4    100   --      0       0       43      03:00(hda)      /var/run/utmp
         0    3687424      828      0   --      0       0       0       00:02(bdev)     03:00
    159701          5        8    100   --      0       0       0       03:00(hda)      /etc/modprobe.d/aliases
     31866       1238     1240    100   --      4       0       0       03:00(hda)      /lib/tls/libc-2.3.5.so
    381705         51       52    100   --      0       0       0       03:00(hda)      /bin/cp
     31814         27       28    100   --      0       0       0       03:00(hda)      /lib/libblkid.so.1.0
    159534         17       20    100   --      0       0       0       03:00(hda)      /etc/ld.so.cache
[...]

root ~# echo -n /lib/tls/libc-2.3.5.so > /proc/filecache root ~# head /proc/filecache

Quoted 10 lines
# file /lib/tls/libc-2.3.5.so
# flags LK:locked ER:error RF:referenced UD:uptodate DT:dirty AC:active SL:slab CK:checked A1:arch_1 RS:reserved PV:private WB:writeback NS:nosave CP:compound SC:swapcache MD:mappedtodisk RC:reclaim ns:nosave_free RA:readahead MM:mmap
# idx   len                     state                   	refcnt  location
0       21      ____RFUD__AC__________________MD______MM        4       0.0.Normal
21      1       ____RFUD__AC__________________MD______MM        3       0.0.Normal
22      3       ______UD______________________MD________        1       0.0.Normal
25      1       ____RFUD__AC__________________MD______MM        2       0.0.Normal
26      2       ______UD______________________MD________        1       0.0.Normal
28      1       ______UD______________________MD____RA__        1       0.0.Normal
29      2       ______UD______________________MD________        1       0.0.Normal
Quoted 2 lines

The interface is really too ugly to live. How do you expect it being used from two programs, simultaneously?

Yes, it can be used by two programs without interfering each other :) The trick goes in this way:
- program A, B each opened the /proc/filecache for querying
- A calls fdA = open("/proc/filecache")
- B calls fdB = open("/proc/filecache")
- A calls write(fdA, "file /lib/tls/libc-2.3.5.so") to set parameter, which will be stored in fileA->f_version.
- the same for B
- so A, B each has its own working parameter.

There is also a global parameter, which will be used if the program has not call write() to set his own parameter. I'll take care so that programs that query the interface do not pollute the global default parameter:
- open(); write(); close()
save the private parameter as the global default
- open(); write(); ...; read(); close()
do not touch the global parameter
- open(); read(); close()
initialize the private parameter with the global default

Quoted 1 line

We don't really want to do ascii pretty-printing in kernel, sorry. It

You mean the page flags? I bet sysadms would like it ;) Another consideration of not using hex numbers is to prevent PG_referenced being adapted to 12 someday.

And I never mean to expose so much flags. If any page flag is supposed to be useless for the user(i.e. SL:slab), please let me know, thanks.

Quoted 2 lines

probably needs to go into /sys , and be redesigned to provide "one value per file" rule...

I choose not to use /sys to avoid overheads. It requires allocating much more structs, and injecting hooks to respond to inode create/remove events.

Thanks,
Wu

#3 lore raw
In reply to a message not in the archive
Quoted 2 lines · Fengguang Wu

The /proc/filecache support has been half done. And I'd like to hear early comments on the interface.

Hi,

I haven't been following this closely, so I apologise if I'm out of my depth. It would be a useful add-on to be able to use this interface to force something _out_ of the page cache also. For example, for performance tests, or selectively ditching pages before software suspending.

I realise it'd probably be much more work and more intrusive than the current patch - though perhaps just considering the possibility of this in the interface, so that the interface could be reused if the feature was added later?

Kind regards,

Bernard.

#4 lore raw

Hi Bernard,

Quoted 5 lines · Bernard Blackham

I haven't been following this closely, so I apologise if I'm out of my depth. It would be a useful add-on to be able to use this interface to force something _out_ of the page cache also. For example, for performance tests, or selectively ditching pages before software suspending.

Sure we can add more related commands into it.

For example, the functions in fs/drop_caches.c are well suited for this interface. The current sysctl interface is a quick hacking:

/* A global variable is a bit ugly, but it keeps the code simple */ int sysctl_drop_caches;

The following scheme may be more reasonable:

# echo -n "drop files" > /proc/filecache
# echo -n "drop slabs" > /proc/filecache

As for the "selectively ditching pages" function, my original scheme is to
- query /proc/filecache to answer the question of "which pages are cached, and their status(referenced/active etc.)"
- run "fadvise filename page-offset pages" to ditch pages
Do you think it as convenient?

Thanks,
Wu

A message that is not in the archive (sent off-list or not yet received): [email protected]

#6 lore raw
Quoted 6 lines · Fengguang Wu

As for the "selectively ditching pages" function, my original scheme is to
- query /proc/filecache to answer the question of "which pages are cached, and their status(referenced/active etc.)"
- run "fadvise filename page-offset pages" to ditch pages
Do you think it as convenient?

Certainly. That would be a great feature to have! And in this age of pushing every man and his cat out to userspace, a userspace binary that identifies the specific pages that need to go will probably keep the some of the kernel folk happy.

Thanks,

Bernard.

#7 lore raw
In reply to a message not in the archive
Quoted 5 lines · Fengguang Wu

Hello,

The /proc/filecache support has been half done. And I'd like to hear early comments on the interface.

Wu,

Interesting work. But I am worried that, this is getting over-designed. Lets go back to basics - what is the actual problem we are trying to solve here ? What are mininum requirements ? How does it help solve the problem ? Who & How one uses this ? Yes. I understand - these just provide stats on filecache, but we can provide all the nitty details - which are not really relevant or useful.

Don't get me wrong - I really need better understanding of whats there in pagecache. Infact, I need a better way to control how much filecache in pagecache.

(BTW, I like your patch for "educational" purposes - but I am not sure how useful it is for practical purpose).

Thanks,
Badari

#8 lore raw
Quoted 7 lines · Badari Pulavarty

Interesting work. But I am worried that, this is getting over-designed. Lets go back to basics - what is the actual problem we are trying to solve here ? What are mininum requirements ? How does it help solve the problem ? Who & How one uses this ? Yes. I understand - these just provide stats on filecache, but we can provide all the nitty details - which are not really relevant or useful.

Quoted 6 lines

Don't get me wrong - I really need better understanding of whats there in pagecache. Infact, I need a better way to control how much filecache in pagecache.

(BTW, I like your patch for "educational" purposes - but I am not sure how useful it is for practical purpose).

Badari,

Thanks for the comment. The interface does provides some more details than I will actually need. The intention is to show the possibilities in the first place, and trim down / expand a bit based on feedbacks.

For the GUI pre-caching stuffs I'm working on, the following features will be essential ones:
- file list view
- sorted roughly on the first access time
- the size/cached/dev/file attributes
- page list view
- the idx/len/state attributes
- the referenced/active/mmap page flags

Thanks,
Wu