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 the list_lru interator helper #74

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

marktinguely
Copy link

list_lru iterators for UEK5, UEK6, UEK7 and UEK8.

The list_lru iteration can iterate all memcg and NUMA nodes or one memcg index and one NUMA node.

list_lru_kmem_to_memcgidx() is provided to calculate the memcg index for a list_lru kvm address. This routine is written for list_lru address and assumes slab allocated addresses.

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Feb 22, 2024
@marktinguely
Copy link
Author

No hurry with this helper.

I am writing a test that walks through a memcg aware lru (any filesystem's dentry lru) and a memcg unaware lru (the xfs_buf lru if the filesystem type is xfs).

:return: Iterator of ``type *`` objects.
"""
if ((has_member(lru, "memcg_aware") and lru.memcg_aware) or
(has_member(lru.node, "memcg_lrus") and lru.node[0].memcg_lrus)) :
Copy link
Author

Choose a reason for hiding this comment

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

sorry this has to be made smarter for uek7 memcg unaware lrus.
I will respin, test everywhere and make a new pull request

Copy link
Member

@brenns10 brenns10 left a comment

Choose a reason for hiding this comment

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

Since you're already doing a respin, I wanted to give a little bit of feedback that should reduce the round trips on this review. The code logically is looking great, but stylistically, there's some things that don't fit with the project's existing code style. I don't want to waste developer's time or mental effort on code style though, so we use some automatic code formatters & linters to help catch these things at commit time.

It's documented here, the checks happen via a pre-commit hook. You can set it up via:

# OL9
dnf install -y pre-commit

# OL8
dnf install python39-pip
python3.9 -m pip install --user pre-commit

# Then, for both:
cd path/to/drgn-tools
pre-commit install --install-hooks

Next time you commit (including amending a commit), the hook will check code. Some checks (e.g. code style) automatically make the changes to your code, so you'll just need to git add those changes. Other checks are just linters, so they may surface an issue you'll need to manually address.

The uek7 list_lru does not have a node entry. The test for memcg aware
is not smart enough to handle the memcg unaware case correctly for uek7.

Add a test for the list_lru helper. It works by walking the dentry list_lru
for one or more fileystems and then looks up the memcg index, and then
verifies the entry can be found by the memcg index. If the filesystem type
in xfs, then walk the xfs_buf list_lru and verify the memcg unaware case.
One can specify verbose output or use the default summary results.

Signed-off-by: Mark Tinguely <[email protected]>
Signed-off-by: Mark Tinguely <[email protected]>
Print the XFS memcg unaware summary only if the test was run.

Signed-off-by: Mark Tinguely <[email protected]>
yield entry


def list_lru_kmem_to_memcgidx(prog: Program, kvm: IntegerLike) -> IntegerLike:
Copy link
Author

Choose a reason for hiding this comment

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

In theory, we could get the numa node id from the page ptr, BUT there are multiple ways that is can be encoded.

Option 1: it is encoded in the vm_page.flags with the offset determined by what else is embedded in the vm_page.flags (section, zone, last cupid)
Option 2: it is in a special section_to_node_table[] array where the section is encoded in the the vm_page.flags

A check for the section_to_node_table[] is easy enough but the vm_page.flags offsets/width are CONFIG dependent and is less obvious for Drgn find automatically. From disassembling the code, the hosts that I have, the numa node is:
(page.flags >> 0x36)

@brenns10 brenns10 added this to the drgn-tools next milestone Jul 22, 2024
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