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

Corelens module: dentrycache #26

Merged
merged 7 commits into from
Nov 18, 2023

Conversation

brenns10
Copy link
Member

@brenns10 brenns10 commented Nov 9, 2023

We already have some excellent dentry helpers, but no actual corelens module. This PR adds the corelens module, and it adds a bit of optimization so that the runtime is pretty decent.

  1. Add the corelens module.
  2. Create a dentry_path_any_mount() helper to ensure we get a full path to the root for each dentry.
  3. Stop loading dentries into memory when we're printing them out, this ensures we can scale to millions of dentries without any issue.
  4. Try to match the oled dentrycache output by default.
  5. Improve performance by iterating over the dentry hash table in chunks, rather than one entry at a time.

The command line interface is similar to "oled dentrycache".

Signed-off-by: Stephen Brennan <[email protected]>
For the corelens report, we want to see a full filepath from the root,
not just the path within a single filesystem. But we don't have any
information about the mount that was used to reach a dentry, since it
came straight from the hash table. Introduce dentry_path_any_mount()
which is like dentry_path(), except that it simply uses the first mount
point of each superblock until it reaches the root. This matches the
behavior of oled dentrycache, but it's also quite useful.

Signed-off-by: Stephen Brennan <[email protected]>
When printing a table of just 100 or so dentries, it's ok to load
everything into memory. But as the number increases, it becomes a major
waste. Introduce a print_row() helper for cases where you can compute
column widths ahead of time, and print each row as we build it.

Signed-off-by: Stephen Brennan <[email protected]>
While it is nice to see the the detailed output including inodes, super
blocks, refcounts, etc, this is probably unnecessary for the use cases
that oled dentrycache is used for. Hide that ability behind the "-d"
flag, and have a simpler output method for compatibility with oled.

Signed-off-by: Stephen Brennan <[email protected]>
The dentry hash table is large, and reading each individual element via
/proc/kcore is expensive. Instead, read the table in chunks and then
access elements from the chunk. This reduces the number of /proc/kcore
reads which generally improves performance.

In cursory tests on my laptop, with a dentry cache of roughly 580k
entries, this improved runtime of count_dentries_in_hashtable() from
5.15 seconds, to 2.33 seconds (10 trials each).

Signed-off-by: Stephen Brennan <[email protected]>
@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Nov 9, 2023
This is unfortunate, but it has become necessary to do some version
comparisons in order to maintain helper compatibility. This evil should
be kept to a minimum, but if it must exist, let's implement it with a
standard shared helper.

Signed-off-by: Stephen Brennan <[email protected]>
@brenns10 brenns10 requested a review from biger410 November 17, 2023 21:48
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.

LGTM

@brenns10 brenns10 merged commit 46a4501 into oracle-samples:main Nov 18, 2023
@brenns10 brenns10 deleted the dentrycache-optimization branch February 1, 2024 17:56
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