Page MenuHomeFreeBSD

vfs_cache: Fix the SDT definition of vfs:fplookup:lookup:done
ClosedPublic

Authored by 0mp on Mon, Jul 14, 11:14 PM.
Tags
Referenced Files
Unknown Object (File)
Sun, Aug 10, 8:35 AM
Unknown Object (File)
Tue, Jul 29, 4:10 AM
Unknown Object (File)
Tue, Jul 29, 2:32 AM
Unknown Object (File)
Tue, Jul 29, 12:21 AM
Unknown Object (File)
Mon, Jul 28, 11:58 PM
Unknown Object (File)
Mon, Jul 28, 10:46 PM
Unknown Object (File)
Mon, Jul 28, 5:57 PM
Unknown Object (File)
Mon, Jul 28, 5:21 PM
Subscribers

Details

Summary

The definition lists struct nameidata as the type
of the first argument. However, the actual probes always pass
a variable of type struct nameidata* to SDT_PROBE3.

Fixes: 07d2145a1717 vfs: add the infrastructure for lockless lookup
MFC after: 1 week

Test Plan

I've build the kernel with the change and tested that args[0] in vfs:fplookup:lookup:done no longer needs to be cast to struct nameidata * to access its members such as ni_dirp.

Here's a sample script:

vfs:fplookup:lookup:done /(int64_t)args[0]->ni_dirp < 0 && arg2 == 3/ {
        trace(stringof(args[0]->ni_dirp));
}

Side note: I could not figure out the right predicates that look sensible to only show successful lookups with actual path names available in ni_dirp. arg2 == 3 seems to help, but it was not enough. (int64_t)args[0]->ni_dirp < 0 did the trick as printable ni_dirp turn out to always be <0 when cast to int64_t, but I don't understand why.

Another side note: wouldn't it be nice to create a vfs.d in /usr/lib/dtrace so that we could use the actual enum for arg2 instead of integers? The enum would be:

enum cache_fpl_status { CACHE_FPL_STATUS_DESTROYED, CACHE_FPL_STATUS_ABORTED,
    CACHE_FPL_STATUS_PARTIAL, CACHE_FPL_STATUS_HANDLED, CACHE_FPL_STATUS_UNSET };

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

0mp requested review of this revision.Mon, Jul 14, 11:14 PM
0mp added reviewers: bnovkov, markj, chris_cretaforce.gr.
0mp added a project: DTrace.
0mp edited reviewers, added: christos; removed: chris_cretaforce.gr.

Another side note: wouldn't it be nice to create a vfs.d in /usr/lib/dtrace so that we could use the actual enum for arg2 instead of integers? The enum would be:

Just change the type from int to enum cache_fpl_status in the probe definition, and it'll work. dtrace knows about enum names since they're encoded in CTF info.

This revision is now accepted and ready to land.Tue, Jul 15, 3:09 PM

Another side note: wouldn't it be nice to create a vfs.d in /usr/lib/dtrace so that we could use the actual enum for arg2 instead of integers? The enum would be:

Just change the type from int to enum cache_fpl_status in the probe definition, and it'll work. dtrace knows about enum names since they're encoded in CTF info.

ah, so the actual fix should be:

SDT_PROBE_DEFINE3(vfs, fplookup, lookup, done, "struct nameidata *", "enum cache_fpl_status", "bool");

do I understand correctly?

I'm not sure if that would work. DTrace seems to not know about the the constants like CACHE_FPL_STATUS_DESTROYED at all. How would the type change fix that? I'll try that later. Maybe DTrace does some magic that makes it work.

Alternatively, I've opened another revision that adds the enum to libdtrace/vfs.d, but I suspect that this is not the right fix based on Mark's last comment.

https://reviews.freebsd.org/D51328

In D51315#1172217, @0mp wrote:

Another side note: wouldn't it be nice to create a vfs.d in /usr/lib/dtrace so that we could use the actual enum for arg2 instead of integers? The enum would be:

Just change the type from int to enum cache_fpl_status in the probe definition, and it'll work. dtrace knows about enum names since they're encoded in CTF info.

ah, so the actual fix should be:

SDT_PROBE_DEFINE3(vfs, fplookup, lookup, done, "struct nameidata *", "enum cache_fpl_status", "bool");

do I understand correctly?

I'm not sure if that would work. DTrace seems to not know about the the constants like CACHE_FPL_STATUS_DESTROYED at all. How would the type change fix that? I'll try that later. Maybe DTrace does some magic that makes it work.

After changing the type:

root@freebsd:~ # dtrace -n 'vfs:fplookup:lookup:done /args[1] != CACHE_FPL_STATUS_DESTROYED/{stack(); exit(0);}'
dtrace: description 'vfs:fplookup:lookup:done ' matched 1 probe
CPU     ID                    FUNCTION:NAME
  0  69081                      lookup:done 
              kernel`cache_fplookup+0xcb4
              kernel`namei+0x194
              kernel`vn_open_cred+0x592
              kernel`openatfp+0x2b3
              kernel`sys_open+0x28
              kernel`amd64_syscall+0x169
              kernel`0xffffffff81094b8b


root@freebsd:~ # dtrace -lv -n vfs:fplookup:lookup:done
   ID   PROVIDER            MODULE                          FUNCTION NAME
69081        vfs          fplookup                            lookup done

        Probe Description Attributes
                Identifier Names: Private
                Data Semantics:   Private
                Dependency Class: Unknown

        Argument Attributes
                Identifier Names: Private
                Data Semantics:   Private
                Dependency Class: ISA

        Argument Types
                args[0]: struct nameidata *
                args[1]: enum cache_fpl_status
                args[2]: bool
  • Add the enum to the definition
This revision now requires review to proceed.Tue, Jul 15, 8:23 PM
This revision is now accepted and ready to land.Tue, Jul 15, 8:31 PM