Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some VFS helpers #90

Merged
merged 7 commits into from
Jun 28, 2024
Merged

Add some VFS helpers #90

merged 7 commits into from
Jun 28, 2024

Conversation

brenns10
Copy link
Member

  • A corelens module "ls" for listing dentry children.
  • A corelens module "fsnotify" for printing fsnotify info about every fanotify, inotify, and dnotify group.
  • Some minor improvements to bt() in order to improve the fsnotify helper.

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Jun 21, 2024
@brenns10
Copy link
Member Author

Sample inotify and dnotify output from my laptop:

[PID 4071095 COMM: gvfsd-trash inotify FD 10]
FSNOTIFY GROUP: ffff8bf0b8574000
  MARK: inode ffff8bee62d7b408 /run/mount/utab.event
    CNT:2 MASK:CLOSE_WRITE|UNMOUNT IGN:0
OBJECT SUMMARY: inode: 1
0 notifications are pending.
Tasks waiting for notification:
  [EVENTPOLL: ffff8bee40280b40]
  Waiting in file->poll():
    [PID: 4071095 COMM: gvfsd-trash WAIT: select]

[SYSTEM DNOTIFY GROUP]
FSNOTIFY GROUP: ffff8bee427b5000
OBJECT SUMMARY:
0 notifications are pending.
Tasks waiting for notification:
  <no waiters>

Sample fanotify output:

[PID 3756 COMM: ds_am fanotify FD 7]
FSNOTIFY GROUP: ffff9bbd820b9d00
  MARK: inode ffff9bc1228d9640 /var/cache/uptrack/Linux/x86_64/5.15.0-206.153.7.el8uek.x86_64/#2 SMP Thu May 9 15:52:29 PDT 2024/results.server-stamp
    CNT:1 MASK:0 IGN:0
  MARK: vfsmount ffff9bbd8b244a00 FS:xfs MOUNT:/
    CNT:76 MASK:CLOSE_WRITE|OPEN_PERM|OPEN_EXEC_PERM IGN:0
   ... note: several lines removed here for brevity ...
OBJECT SUMMARY: inode: 131221, vfsmount: 32
84 notifications are pending.
Tasks waiting for notification:
  <no waiters>
0 pending permission responses
Tasks waiting for permission response from userspace:
  [PID: 1828676 COMM: sshd WAIT: direct]
  ... several lines removed ...

With higher levels of verbosity, at level 3, all of the ~80 tasks which were waiting for a permission response would have gotten printed with a stack trace. At level 4, all 131k inode marks would hav ebeen printed (by default, we only print the first 10 inodes, but we print all super blocks and vfsmounts).

Of course, for the "ls" module it's a bit less interesting.

>>> cl("ls /")
00000 /__init__.py
00001 /conftest.py
00002 /pytest.ini
00003 /tox.ini
[...]
00439 /sys
00440 /usr
00441 /etc
23 positive, 419 negative dentries
>>> cl("ls -c /")
23 positive, 419 negative dentries

The ls module can be quite slow at times due to the implementation of path_lookup() which iterates over child lists rather than using the hash table. I'll try to upstream a helper that can use the hash table as well.

@brenns10 brenns10 requested review from biger410 and imran-kn June 21, 2024 21:19
@brenns10
Copy link
Member Author

There's a bit of overlap in one of my waitqueue functions and the epoll code that @imran-kn has in #83, I'll see if there is anything that can be shared between these branches.

brenns10 added 5 commits June 25, 2024 13:20
This simple module just lists the children of a dentry, much like ls
would list the contents of a directory. Of course, not all children of a
dentry are real files (as they may be negative), and not all real
contents of a directory are necessarily cached as a child dentry. So
it's not an exact comparison. But it's close enough.

Signed-off-by: Stephen Brennan <[email protected]>
This allows the bt() function to be used within other helpers without
breaking up the indentation of the output.

Signed-off-by: Stephen Brennan <[email protected]>
This just makes sense, idle tasks aren't terribly interesting. That
said, make this a kwarg just so users can still look at them if they
want.

Signed-off-by: Stephen Brennan <[email protected]>
This module aids in understanding the state of the fsnotify subsystem:
what inodes / superblocks / vfsmounts are being watched, who is waiting
for events, and in the case of fanotify, who is waiting on an access
response from userspace.

Signed-off-by: Stephen Brennan <[email protected]>
Hopefully we will never need this, but it allows the UEK4 live and
vmcore tests to pass.

Signed-off-by: Stephen Brennan <[email protected]>
Copy link
Member

@biger410 biger410 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One comment, other looks good.

drgn_tools/bt.py Outdated Show resolved Hide resolved
Also include the native_safe_halt() when a swapper task is halted.

Signed-off-by: Stephen Brennan <[email protected]>
@brenns10
Copy link
Member Author

Gitlab vmcore & VM tests pass!

Copy link
Member

@biger410 biger410 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@brenns10 brenns10 merged commit a457ffb into oracle-samples:main Jun 28, 2024
5 checks passed
@brenns10 brenns10 deleted the fs branch June 28, 2024 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCA Verified All contributors have signed the Oracle Contributor Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants