On Mon, Feb 10, 2025 at 02:34:00PM +0100, Matteo Croce wrote:
> From: xiaofeidu <[email protected]>
>
> mu is a new tool which shows the amount of data that a set of files
> are keeping into the cache.
> mu uses the new cachestat() syscall introduced with Linux 6.5.
>
> Example usage, we use mu over gcc libraries, before and after calling
> gcc for the first time after boot:
>
> $ src/mu --all --human-readable --threshold=1 /usr/lib/gcc/
>
> $ gcc /dev/null -o /dev/zero
> /usr/bin/ld: /usr/lib64/crt1.o: in function `__wrap_main':
> (.text+0x38): undefined reference to `main'
> collect2: error: ld returned 1 exit status
>
> $ src/mu --all --human-readable --threshold=1 /usr/lib/gcc/
> 4.0K /usr/lib/gcc/aarch64-redhat-linux/14/crtbegin.o
> 4.0K /usr/lib/gcc/aarch64-redhat-linux/14/crtend.o
> 128K /usr/lib/gcc/aarch64-redhat-linux/14/libgcc.a
> 4.0K /usr/lib/gcc/aarch64-redhat-linux/14/libgcc_s.so
> 140K /usr/lib/gcc/aarch64-redhat-linux/14
> 140K /usr/lib/gcc/aarch64-redhat-linux
> 140K /usr/lib/gcc/
Sounds very similar to fidcore(1) that we already have in util-linux
(since v2.30, June 2017). It was originally based on mincore() and was
extended two years ago to use cachestat().
$ fincore /usr/lib/gcc/x86_64-redhat-linux/14/crt*
RES PAGES SIZE FILE
4K 1 2.7K /usr/lib/gcc/x86_64-redhat-linux/14/crtbegin.o
4K 1 2.9K /usr/lib/gcc/x86_64-redhat-linux/14/crtbeginS.o
4K 1 3.2K /usr/lib/gcc/x86_64-redhat-linux/14/crtbeginT.o
4K 1 1.4K /usr/lib/gcc/x86_64-redhat-linux/14/crtend.o
4K 1 1.4K /usr/lib/gcc/x86_64-redhat-linux/14/crtendS.o
0B 0 1.8K /usr/lib/gcc/x86_64-redhat-linux/14/crtfastmath.o
0B 0 1.6K /usr/lib/gcc/x86_64-redhat-linux/14/crtoffloadbegin.o
0B 0 1.6K /usr/lib/gcc/x86_64-redhat-linux/14/crtoffloadend.o
0B 0 1.8K /usr/lib/gcc/x86_64-redhat-linux/14/crtoffloadtable.o
0B 0 1.8K /usr/lib/gcc/x86_64-redhat-linux/14/crtoffloadtableS.o
0B 0 1.8K /usr/lib/gcc/x86_64-redhat-linux/14/crtprec32.o
0B 0 1.8K /usr/lib/gcc/x86_64-redhat-linux/14/crtprec64.o
0B 0 1.8K /usr/lib/gcc/x86_64-redhat-linux/14/crtprec80.o
For more details, see misc-utils/fincore.c in the util-linux tree.
Maybe there is something we can improve to match your requirements
(and motivation) for "mu".
Karel
--
Karel Zak <[email protected]>
http://karelzak.blogspot.com