-
Notifications
You must be signed in to change notification settings - Fork 21
Lint Errors and spl_kmem_caches regression #236
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
Conversation
Context: Issue: pytest-dev/pytest#7473 PR that was just merged: pytest-dev/pytest#7476 Opened issue to get rid of this once `pytest` is updated: delphix#235
Codecov Report
@@ Coverage Diff @@
## master #236 +/- ##
==========================================
+ Coverage 87.35% 87.38% +0.03%
==========================================
Files 60 60
Lines 2467 2473 +6
==========================================
+ Hits 2155 2161 +6
Misses 312 312
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice handling of both old and new ways of getting the allocation count!
# Fall back to the old-mechanism if that percpu_counter member | ||
# doesn't exist (an AttributeError will be thrown). | ||
# | ||
return int(cache.skc_obj_alloc.value_()) | ||
return int(cache.skc_obj_alloc.value_()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is equivalent to what we run in the except AttributeError
case, so rather than duplicating the two, would it be better to use:
except AttributeError:
pass
and let the code reach this line in that case?
Or perhaps we should more simply remove this line, since I think it's dead code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually thanks for pointing this out... this pointed out a bug in my code. We don't want to look at the percpu counter if this is not a linux_slub backed cache. I changed the code and retesting now.
return int(cache.skc_obj_total.value_()) | ||
|
||
|
||
def obj_alloc(cache: drgn.Object) -> int: | ||
assert sdb.type_canonical_name(cache.type_) == 'struct spl_kmem_cache *' | ||
try: | ||
return int(drgn_percpu.percpu_counter_sum(cache.skc_linux_alloc)) | ||
except AttributeError: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
out of curiosity, is there no way to ask if the structure contains a given member? e.g. something like:
if 'skc_linux_alloc' in cache:
return int(drgn_percpu.percpu_counter_sum(cache.skc_linux_alloc))
else:
return int(cache.skc_obj_alloc.value_())
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately I did look at drgn.Type API for that and there wasn't such a thing. The way to do this would be something like if 'skc_linux_alloc
in [ x.name for x in type.members]`. I thought that the code for the loop was probably not worth it. Does this make sense? Do you think a variant of this alternative would be preferable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, got it. I'm good with what you have.
The following commit from ZoL introduced this counter: openzfs/zfs@ec1fea4
Updated the PR applying @prakashsurya 's suggestion and fixing a bug uncovered by it. |
First Commit: Disable pylint false-positives for pytest
Context:
Issue: pytest-dev/pytest#7473
PR that was just merged: pytest-dev/pytest#7476
Opened issue to get rid of this once
pytest
is updated:#235
Second Commit: Update spl_kmem_caches command to be aware of new percpu counter
The following commit from ZoL introduced this new counter to be used instead of what sdb was looking at before
openzfs/zfs@ec1fea4
Note that since our test crash dump was generated with old bits, we'd need a new crash dump to test that new condition. Until that happens I decided that the following manual testing should suffice.
= Manual testing
Before:
After:
Prakash pointed out a bug that was missed by my manual testing above where SPL-based caches would use the percpu counter. This was missed because I was only looking at SLUB-based caches in the above out. After re-iterating now both work as before.