All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC bpf-next 0/1] bpf: Add page cache iterator
@ 2021-04-07 21:46 Daniel Xu
  2021-04-07 21:46 ` [RFC bpf-next 1/1] bpf: Introduce iter_pagecache Daniel Xu
                   ` (3 more replies)
  0 siblings, 4 replies; 18+ messages in thread
From: Daniel Xu @ 2021-04-07 21:46 UTC (permalink / raw)
  To: bpf, linux-fsdevel, linux-mm
  Cc: Daniel Xu, linux-kernel, kernel-team, jolsa, hannes, yhs

There currently does not exist a way to answer the question: "What is in
the page cache?". There are various heuristics and counters but nothing
that can tell you anything like:

  * 3M from /home/dxu/foo.txt
  * 5K from ...
  * etc.

The answer to the question is particularly useful in the stacked
container world. Stacked containers implies multiple containers are run
on the same physical host. Memory is precious resource on some (if not
most) of these systems. On these systems, it's useful to know how much
duplicated data is in the page cache. Once you know the answer, you can
do something about it. One possible technique would be bind mount common
items from the root host into each container.

NOTES: 

  * This patch compiles and (maybe) works -- totally not fully tested
    or in a final state

  * I'm sending this early RFC to get comments on the general approach.
    I chatted w/ Johannes a little bit and it seems like the best way to
    do this is through superblock -> inode -> address_space iteration
    rather than going from numa node -> LRU iteration

  * I'll most likely add a page_hash() helper (or something) that hashes
    a page so that userspace can more easily tell which pages are
    duplicate

Daniel Xu (1):
  bpf: Introduce iter_pagecache

 kernel/bpf/Makefile         |   2 +-
 kernel/bpf/pagecache_iter.c | 293 ++++++++++++++++++++++++++++++++++++
 2 files changed, 294 insertions(+), 1 deletion(-)
 create mode 100644 kernel/bpf/pagecache_iter.c

-- 
2.26.3


^ permalink raw reply	[flat|nested] 18+ messages in thread
* Re: [RFC bpf-next 1/1] bpf: Introduce iter_pagecache
@ 2021-04-08  2:22 kernel test robot
  0 siblings, 0 replies; 18+ messages in thread
From: kernel test robot @ 2021-04-08  2:22 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 2338 bytes --]

CC: kbuild-all(a)lists.01.org
In-Reply-To: <22bededbd502e0df45326a54b3056941de65a101.1617831474.git.dxu(a)dxuuu.xyz>
References: <22bededbd502e0df45326a54b3056941de65a101.1617831474.git.dxu@dxuuu.xyz>
TO: Daniel Xu <dxu@dxuuu.xyz>

Hi Daniel,

[FYI, it's a private test report for your RFC patch.]
[auto build test WARNING on bpf-next/master]

url:    https://github.com/0day-ci/linux/commits/Daniel-Xu/bpf-Add-page-cache-iterator/20210408-054827
base:   https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
:::::: branch date: 5 hours ago
:::::: commit date: 5 hours ago
config: x86_64-randconfig-m001-20210407 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

smatch warnings:
kernel/bpf/pagecache_iter.c:29 goto_next_sb() warn: ignoring unreachable code.

vim +29 kernel/bpf/pagecache_iter.c

674847b59009ed Daniel Xu 2021-04-07  22  
674847b59009ed Daniel Xu 2021-04-07  23  static struct super_block *goto_next_sb(struct bpf_iter_seq_pagecache_info *info)
674847b59009ed Daniel Xu 2021-04-07  24  {
674847b59009ed Daniel Xu 2021-04-07  25  	struct super_block *sb = NULL;
674847b59009ed Daniel Xu 2021-04-07  26  	struct radix_tree_iter iter;
674847b59009ed Daniel Xu 2021-04-07  27  	void **slot;
674847b59009ed Daniel Xu 2021-04-07  28  
674847b59009ed Daniel Xu 2021-04-07 @29  	radix_tree_for_each_slot(slot, &info->superblocks, &iter,
674847b59009ed Daniel Xu 2021-04-07  30  				 ((unsigned long)info->cur_sb + 1)) {
674847b59009ed Daniel Xu 2021-04-07  31  		sb = (struct super_block *)iter.index;
674847b59009ed Daniel Xu 2021-04-07  32  		break;
674847b59009ed Daniel Xu 2021-04-07  33  	}
674847b59009ed Daniel Xu 2021-04-07  34  
674847b59009ed Daniel Xu 2021-04-07  35  	info->cur_sb = sb;
674847b59009ed Daniel Xu 2021-04-07  36  	info->cur_inode = NULL;
674847b59009ed Daniel Xu 2021-04-07  37  	info->cur_page_idx = 0;
674847b59009ed Daniel Xu 2021-04-07  38  	return sb;
674847b59009ed Daniel Xu 2021-04-07  39  }
674847b59009ed Daniel Xu 2021-04-07  40  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 38348 bytes --]

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

end of thread, other threads:[~2021-04-09  0:24 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-07 21:46 [RFC bpf-next 0/1] bpf: Add page cache iterator Daniel Xu
2021-04-07 21:46 ` [RFC bpf-next 1/1] bpf: Introduce iter_pagecache Daniel Xu
2021-04-08  6:14   ` Matthew Wilcox
2021-04-08 19:48     ` Daniel Xu
2021-04-08 21:29       ` Matthew Wilcox
2021-04-08  8:19   ` Christian Brauner
2021-04-08 20:44     ` Daniel Xu
2021-04-08 16:45   ` Al Viro
2021-04-08 20:49     ` Daniel Xu
2021-04-08 21:04       ` Al Viro
2021-04-08 22:11   ` Dave Chinner
2021-04-08  7:51 ` [RFC bpf-next 0/1] bpf: Add page cache iterator Christian Brauner
2021-04-08 16:08   ` Daniel Xu
2021-04-08 21:33 ` Shakeel Butt
2021-04-08 21:33   ` Shakeel Butt
2021-04-08 23:13 ` Darrick J. Wong
2021-04-09  0:24   ` Daniel Xu
2021-04-08  2:22 [RFC bpf-next 1/1] bpf: Introduce iter_pagecache kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.