vfs.add_to_page_cache not working anymore?

Daire Byrne daire@dneg.com
Tue Jun 13 16:39:08 GMT 2023


On Tue, 13 Jun 2023 at 16:22, William Cohen <wcohen@redhat.com> wrote:>
> Switching to systemtap-4.9 is probably not going to change the results
> in this case as there are no changes in tapset/linux/vfs.stp between
> 4.8 and 4.9.

Good to know, I can skip trying to compile that then...

> Unfortunately, the kernels changes over time and some functions probed
> by the tapset change over time or the way they are used by other parts
> of the kernel changes.  The vfs.add_to_page cache in the vfs.stp has
> three possible functions it probes: add_to_page_cache_locked,
> add_to_page_cache_lru, and add_to_page_cache.  The first two functions
> were added due to kernel commit f00654007fe1c15.  Did some git commit
> archeology and only add_to_page_cache_lru is in the kernel due to
> kernel git commit 2bb876b58d593d7f2522ec0f41f20a74fde76822.
>
> The following URL show where add_to_page_cache_lru is used in 6.2.16
> kernels nfs and can provide some method of seeing how the nfs related
> functions get called:
>
> https://elixir.bootlin.com/linux/v6.2.16/A/ident/add_to_page_cache_lru

Thanks for the feedback and pointers, that helps me understand where
the changes came from at least. It was still working on my last
production kernel - v5.16.

So if I recall, I used vfs.add_to_page cache because at the time it
was the only (or easiest) way to work out total reads for mmap files
from an NFS filesystem.

I also would have thought it should work for any filesystem not just
NFS - but I don't get any hits at all for an entire busy system.

> As far as specifically what has changed to cause vfs.add_to_page_cache
> not to trigger for NFS operations I am not sure.  For the 6.2 kernel
> it might be good to get a backtrace of the triggering of it and then
> use that information to see what has changed in the functions on the
> backtrace.
>
> stap -ldd -e 'probe vfs.add_to_page_cache { print_backtrace(); printf("Works.\n"); exit() }'

I just get the error "Cannot specify a script with -l/-L/--dump-*
switches" using systemtap v4.8.

Thanks for the response. It sounds like I need to find a different way
to work out total NFS reads for each filename path in modern kernels.

Daire

BTW, this is the code I had for tracking per process and file path read IO:

probe nfs.fop.open {
  pid = pid()
  filename = sprintf("%s", d_path(&$filp->f_path))
  if (filename =~ "/hosts/.*/user_data") {
    files[pid, ino] = filename
    if ( !([pid, ino] in procinfo))
      procinfo[pid, ino] = sprintf("%s", proc())
  }
}

probe vfs.add_to_page_cache {
  pid = pid()
  if ([pid, ino] in files ) {
    readpage[pid, ino] += 4096
    files_store[pid, ino] = sprintf("%s", files[pid, ino])
  }
}


More information about the Systemtap mailing list