Skip to content

DLPX-87579 sdb: use drgn helper for task states #341

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

Merged
merged 1 commit into from
Aug 23, 2023

Conversation

sdimitro
Copy link
Contributor

@sdimitro sdimitro commented Aug 22, 2023

= Problem

Currently having our own custom function for figuring out a task's state has two drawbacks:

1] As we saw in a2bdd57 things can
get out of date and it is up to us to fix them.

2] There are some weird edge cases that we don't handle as well
like the following crash that I have never been able to reproduce
locally but it occasionally reproduces in the Github runners
of PR #337:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/sdb-0.1.0-py3.8.egg/sdb/internal/repl.py", line 107, in eval_cmd
    for obj in invoke([], input_):
  File "/usr/local/lib/python3.8/dist-packages/sdb-0.1.0-py3.8.egg/sdb/pipeline.py", line 152, in invoke
    yield from execute_pipeline(first_input, pipeline)
  File "/usr/local/lib/python3.8/dist-packages/sdb-0.1.0-py3.8.egg/sdb/pipeline.py", line 84, in execute_pipeline
    yield from massage_input_and_call(pipeline[-1], this_input)
  File "/usr/local/lib/python3.8/dist-packages/sdb-0.1.0-py3.8.egg/sdb/pipeline.py", line 67, in massage_input_and_call
    yield from cmd.call(objs)
  File "/usr/local/lib/python3.8/dist-packages/sdb-0.1.0-py3.8.egg/sdb/command.py", line 413, in call
    yield from self.__invalid_memory_objects_check(
  File "/usr/local/lib/python3.8/dist-packages/sdb-0.1.0-py3.8.egg/sdb/command.py", line 358, in __invalid_memory_objects_check
    for obj in objs:
  File "/usr/local/lib/python3.8/dist-packages/sdb-0.1.0-py3.8.egg/sdb/command.py", line 625, in _call
    self.pretty_print(self.caller(objs))
  File "/usr/local/lib/python3.8/dist-packages/sdb-0.1.0-py3.8.egg/sdb/commands/linux/stacks.py", line 407, in pretty_print
    self.print_stacks(filter(self.match_stack, objs))
  File "/usr/local/lib/python3.8/dist-packages/sdb-0.1.0-py3.8.egg/sdb/commands/linux/stacks.py", line 382, in print_stacks
    for stack_key, tasks in KernelStacks.aggregate_stacks(objs):
  File "/usr/local/lib/python3.8/dist-packages/sdb-0.1.0-py3.8.egg/sdb/commands/linux/stacks.py", line 375, in aggregate_stacks
    stack_key = (KernelStacks.task_struct_get_state(task),
  File "/usr/local/lib/python3.8/dist-packages/sdb-0.1.0-py3.8.egg/sdb/commands/linux/stacks.py", line 221, in task_struct_get_state
    return KernelStacks.TASK_STATES[(state | exit_state) & 0x7f]
KeyError: 101

= This Patch

Uses the drgn helper whose implementation handles more edge cases and is more probable to stay up to date with the latest kernels while keeping backwards compatibility.

= Testing

The above stack trace that I was able to reproduce consistently in that PR no longer shows up with this patch. Additionally our regression dumps show no signs of regressions introduced by this commit.

@codecov-commenter
Copy link

codecov-commenter commented Aug 22, 2023

Codecov Report

Merging #341 (b5f4a2d) into develop (3a1fadc) will increase coverage by 0.03%.
The diff coverage is 100.00%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@             Coverage Diff             @@
##           develop     #341      +/-   ##
===========================================
+ Coverage    85.18%   85.21%   +0.03%     
===========================================
  Files           67       67              
  Lines         3077     3070       -7     
===========================================
- Hits          2621     2616       -5     
+ Misses         456      454       -2     
Files Changed Coverage Δ
sdb/commands/linux/threads.py 96.55% <ø> (ø)
sdb/commands/linux/stacks.py 95.42% <100.00%> (+1.04%) ⬆️

@sdimitro sdimitro marked this pull request as ready for review August 22, 2023 23:53
= Problem

Currently having our own custom function for figuring out a task's
state has two drawbacks:

1] As we saw in a2bdd57 things can
   get out of date and it is up to us to fix them.

2] There are some weird edge cases that we don't handle as well
   like the following crash that I have never been able to reproduce
   locally but it occasionally reproduces in the Github runners
   of PR delphix#337:

```
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/sdb-0.1.0-py3.8.egg/sdb/internal/repl.py", line 107, in eval_cmd
    for obj in invoke([], input_):
  File "/usr/local/lib/python3.8/dist-packages/sdb-0.1.0-py3.8.egg/sdb/pipeline.py", line 152, in invoke
    yield from execute_pipeline(first_input, pipeline)
  File "/usr/local/lib/python3.8/dist-packages/sdb-0.1.0-py3.8.egg/sdb/pipeline.py", line 84, in execute_pipeline
    yield from massage_input_and_call(pipeline[-1], this_input)
  File "/usr/local/lib/python3.8/dist-packages/sdb-0.1.0-py3.8.egg/sdb/pipeline.py", line 67, in massage_input_and_call
    yield from cmd.call(objs)
  File "/usr/local/lib/python3.8/dist-packages/sdb-0.1.0-py3.8.egg/sdb/command.py", line 413, in call
    yield from self.__invalid_memory_objects_check(
  File "/usr/local/lib/python3.8/dist-packages/sdb-0.1.0-py3.8.egg/sdb/command.py", line 358, in __invalid_memory_objects_check
    for obj in objs:
  File "/usr/local/lib/python3.8/dist-packages/sdb-0.1.0-py3.8.egg/sdb/command.py", line 625, in _call
    self.pretty_print(self.caller(objs))
  File "/usr/local/lib/python3.8/dist-packages/sdb-0.1.0-py3.8.egg/sdb/commands/linux/stacks.py", line 407, in pretty_print
    self.print_stacks(filter(self.match_stack, objs))
  File "/usr/local/lib/python3.8/dist-packages/sdb-0.1.0-py3.8.egg/sdb/commands/linux/stacks.py", line 382, in print_stacks
    for stack_key, tasks in KernelStacks.aggregate_stacks(objs):
  File "/usr/local/lib/python3.8/dist-packages/sdb-0.1.0-py3.8.egg/sdb/commands/linux/stacks.py", line 375, in aggregate_stacks
    stack_key = (KernelStacks.task_struct_get_state(task),
  File "/usr/local/lib/python3.8/dist-packages/sdb-0.1.0-py3.8.egg/sdb/commands/linux/stacks.py", line 221, in task_struct_get_state
    return KernelStacks.TASK_STATES[(state | exit_state) & 0x7f]
KeyError: 101
```

= This Patch

Uses the drgn helper whose implementation handles more edge cases
and is more probable to stay up to date with the latest kernels
while keeping backwards compatibility.

= Testing

The above stack trace that I was able to reproduce consistently
in that PR no longer shows up with this patch.
@sdimitro sdimitro merged commit 16267f9 into delphix:develop Aug 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants