Re: [fuse-devel] [fuse] Getting visibility into reads from page cache

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Apr 27 2020, Miklos Szeredi <miklos@xxxxxxxxxx> wrote:
> On Sat, Apr 25, 2020 at 7:07 PM Nikolaus Rath <Nikolaus@xxxxxxxx> wrote:
>>
>> Hello,
>>
>> For debugging purposes, I would like to get information about read
>> requests for FUSE filesystems that are answered from the page cache
>> (i.e., that never make it to the FUSE userspace daemon).
>>
>> What would be the easiest way to accomplish that?
>>
>> For now I'd be happy with seeing regular reads and knowing when an
>> application uses mmap (so that I know that I might be missing reads).
>>
>>
>> Not having done any real kernel-level work, I would start by looking
>> into using some tracing framework to hook into the relevant kernel
>> function. However, I thought I'd ask here first to make sure that I'm
>> not heading into the completely wrong direction.
>
> Bpftrace is a nice high level tracing tool.
>
> E.g.
>
>   sudo bpftrace -e 'kretprobe:fuse_file_read_iter { printf ("fuse
> read: %d\n", retval); }'

Thanks, this looks great! I had to do some reading about bpftrace first,
but I think this is exacly what I'm looking for. A few more questions:


- If I attach a probe to fuse_file_mmap, will this tell me whenever an
  application attempts to mmap() a FUSE file?

- I believe that (struct kiocb*)arg0)->ki_pos will give me the offset
  within the file, but where can I see how much data is being read?

- What is the best way to connect read requests to a specific FUSE
  filesystems (if more than one is mounted)? I found the superblock in
  (struct kiocb*)arg0)->ki_filp->f_mapping->host->i_sb->s_fs_info, but I
  do not see anything in this structure that I could map to a similar
  value that FUSE userspace has access to...

- I assume fuse_file_read_iter is called for every read request for FUSE
  filesystems unless it's an mmap'ed access. Is that right?

- Is there any similar way to catch access to an mmap'ed file? I think
  there is probably a way to make sure that every memory read triggers a
  page fault and then hook into the fault handler, but I am not sure how
  difficult this is to do and how much performance this would cost....

- If my BPF program contains e.g. a printf statement, will execution of
  the kernel function block until the printf has completed, or is there
  some queuing mechanism?

Thanks for your help!


Best,
-Nikolaus

-- 
GPG Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F

             »Time flies like an arrow, fruit flies like a Banana.«




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux