linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/4] cachestat: a new syscall for page cache state of files
@ 2022-12-05 17:51 Nhat Pham
  2022-12-05 17:51 ` [PATCH v2 1/4] workingset: fix confusion around eviction vs refault container Nhat Pham
                   ` (3 more replies)
  0 siblings, 4 replies; 23+ messages in thread
From: Nhat Pham @ 2022-12-05 17:51 UTC (permalink / raw)
  To: akpm; +Cc: hannes, linux-mm, linux-kernel, bfoster, willy, kernel-team

Changelog:
v2:
  * len == 0 means query to EOF. len < 0 is invalid.
    (patch 3) (suggested by Brian Foster)
  * Make cachestat extensible by adding the `cstat_size` argument in the
    syscall (patch 3)

There is currently no good way to query the page cache state of large
file sets and directory trees. There is mincore(), but it scales poorly:
the kernel writes out a lot of bitmap data that userspace has to
aggregate, when the user really doesn not care about per-page information
in that case. The user also needs to mmap and unmap each file as it goes
along, which can be quite slow as well.

This series of patches introduces a new system call, cachestat, that
summarizes the page cache statistics (number of cached pages, dirty
pages, pages marked for writeback, evicted pages etc.) of a file, in a
specified range of bytes. It also include a selftest suite that tests some
typical usage

This interface is inspired by past discussion and concerns with fincore,
which has a similar design (and as a result, issues) as mincore.
Relevant links:

https://lkml.indiana.edu/hypermail/linux/kernel/1302.1/04207.html
https://lkml.indiana.edu/hypermail/linux/kernel/1302.1/04209.html

For comparison with mincore, I ran both syscalls on a 2TB sparse file:

Using mincore:
real    0m37.510s
user    0m2.934s
sys     0m34.558s

Using cachestat:
real    0m0.009s
user    0m0.000s
sys     0m0.009s

This series consist of 4 patches:

Johannes Weiner (1):
  workingset: fix confusion around eviction vs refault container

Nhat Pham (3):
  workingset: refactor LRU refault to expose refault recency check
  cachestat: implement cachestat syscall
  selftests: Add selftests for cachestat

 MAINTAINERS                                   |   8 +
 arch/x86/entry/syscalls/syscall_32.tbl        |   1 +
 arch/x86/entry/syscalls/syscall_64.tbl        |   1 +
 include/linux/swap.h                          |   1 +
 include/linux/syscalls.h                      |   3 +
 include/uapi/asm-generic/unistd.h             |   5 +-
 include/uapi/linux/mman.h                     |   8 +
 kernel/sys_ni.c                               |   1 +
 mm/Makefile                                   |   2 +-
 mm/cachestat.c                                | 115 +++++++++++
 mm/workingset.c                               | 144 +++++++++-----
 tools/testing/selftests/Makefile              |   1 +
 tools/testing/selftests/cachestat/.gitignore  |   2 +
 tools/testing/selftests/cachestat/Makefile    |   7 +
 .../selftests/cachestat/test_cachestat.c      | 186 ++++++++++++++++++
 15 files changed, 438 insertions(+), 47 deletions(-)
 create mode 100644 mm/cachestat.c
 create mode 100644 tools/testing/selftests/cachestat/.gitignore
 create mode 100644 tools/testing/selftests/cachestat/Makefile
 create mode 100644 tools/testing/selftests/cachestat/test_cachestat.c

--
2.30.2

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2022-12-12 16:51 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-05 17:51 [PATCH v2 0/4] cachestat: a new syscall for page cache state of files Nhat Pham
2022-12-05 17:51 ` [PATCH v2 1/4] workingset: fix confusion around eviction vs refault container Nhat Pham
2022-12-05 17:51 ` [PATCH v2 2/4] workingset: refactor LRU refault to expose refault recency check Nhat Pham
2022-12-05 23:49   ` Yu Zhao
2022-12-06  1:19     ` Nhat Pham
2022-12-06  1:28       ` Yu Zhao
2022-12-06  2:22         ` Nhat Pham
2022-12-06  2:25           ` Yu Zhao
2022-12-08 18:07             ` Nhat Pham
2022-12-06 15:22   ` Matthew Wilcox
2022-12-07 17:28     ` Nhat Pham
2022-12-05 17:51 ` [PATCH v2 3/4] cachestat: implement cachestat syscall Nhat Pham
2022-12-05 23:15   ` kernel test robot
2022-12-06  4:48   ` kernel test robot
2022-12-06  4:59   ` kernel test robot
2022-12-07  1:42   ` kernel test robot
2022-12-10 23:51   ` Al Viro
2022-12-12 13:22     ` Brian Foster
2022-12-12 16:50       ` Nhat Pham
2022-12-12 16:23     ` Nhat Pham
2022-12-12 16:24       ` Matthew Wilcox
2022-12-12 16:37         ` Nhat Pham
2022-12-05 17:51 ` [PATCH v2 4/4] selftests: Add selftests for cachestat Nhat Pham

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).