8000 basic resume support by eaceaser · Pull Request #49 · anatol/booster · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

basic resume support #49

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

Closed
wants to merge 3 commits into from
Closed

basic resume support #49

wants to merge 3 commits into from

Conversation

eaceaser
Copy link
Contributor

This adds basic support for parsing the resume kernel parameter and setting /sys/power/resume appropriately. It works for me, but I haven't tested all combinations of argument formats yet (e.g. a LABEL device selector) -- I wanted to get this PR in front of people early because it kinda feels like a general refactor of devAdd might be in order if this approach I'm taking is what we want.

Couple notes;

  • I chose to add the resume handling to the devAdd handler, because that's also where luks handling that similarly needs to lookup devices lives. I'm not sure if this is the best approach -- seems like we could maybe do the resume handling after we've mounted the root volume, and just no-op if the device hasn't been added by that point?
  • If doing this logic in the devAdd handler makes sense, it's currently a bit unwieldy because there are a few return points from the function, and currently it seems like we'd have to call the resume handler at each point. I'd love to discuss ways to refactor the function if necessary.

}

return nil
resume:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

i dont love this but if there's a larger refactor in the cards I'll address whether or not a goto makes sense here later

Copy link
Owner

Choose a reason for hiding this comment

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

Yeah, this device matching logic needs to be simplified and made consistent. I want to review/refactor it in the short term.

Either adding the goto here (and I'll change it later) or wait for the refactoring works for me.

Copy link
Owner
@anatol anatol left a comment

Choose a reason for hiding this comment

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

Thank you for your change @eaceaser

I never used the resume functionality. I do not know anything about it but I eager to learn more. A couple of questions below.

}

return nil
resume:
Copy link
Owner

Choose a reason for hiding this comment

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

Yeah, this device matching logic needs to be simplified and made consistent. I want to review/refactor it in the short term.

Either adding the goto here (and I'll change it later) or wait for the refactoring works for me.

return false
}

func resume(devpath string) error {
Copy link
Owner

Choose a reason for hiding this comment

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

does this patch handles suspend-on-disk only? is there anything special need to be to handle suspend-to-ram functionality?

Copy link
Contributor Author
@eaceaser eaceaser Mar 20, 2021

Choose a reason for hiding this comment

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

This is purely for suspend-to-disk. Suspend-to-ram doesn't go through a reboot, so it's handled by the running kernel.


rd := fmt.Sprintf("%d:%d", major, minor)
debug("resume matched: %s=%s, writing %s", resume, resumeDevice, rd)
if err := os.WriteFile("/sys/power/resume", []byte(rd), 0644); err != nil {
Copy link
Owner

Choose a reason for hiding this comment

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

where I can find more information about this "echo $diskno > /sys/power/resume" operation. What exactly kernel does here? How does suspend-to-XXX implemented in Linux?

Copy link
Contributor Author
@eaceaser eaceaser Mar 20, 2021

Choose a reason for hiding this comment

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

A couple resources:

One thing that I noticed when implementing this is that it appears that we don't need to handle the resume_offset kernel parameter in the initrd, just the resume parameter - the kernel seems to parse that from its commandline itself when resuming, but it needs /sys/power/resume to have the major/minor of the block device set already for the resume to occur. Neither dracut nor mkinitcpio handle the resume_offset parameter either.

return false
}

func resume(devpath string) error {
Copy link
Owner

Choose a reason for hiding this comment

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

Is there anything need to be done by booster at suspend time? Or it is assumed that the host software (e.g. systemd) handles it without involving booster.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nope, as long as /sys/power/resume and /sys/power/resume_offset are set correctly, when suspend-to-disk happens the kernel handles everything

@eaceaser eaceaser changed the title wip: basic resume support basic resume support Mar 20, 2021
anatol added a commit that referenced this pull request Mar 22, 2021
If user can specified 'resume' boot flag and it matches a block device
then booster resumes this device using '/sys/power/resume' sys
interface.

Closes #49
@anatol
Copy link
Owner
anatol commented Mar 22, 2021

Thank you for your work.

I just finished the init code refactoring that among other things should address duplication in the 'match block device' code.

I rebased your change on top of it and pushed both your changes and my refactoring to resume branch. Could you please check if it works as expected?

@anatol
Copy link
Owner
anatol commented Mar 23, 2021

Also it would be really great to have an integration test for resume functionality. Is there a way to create a disk with "suspended" state and then boot using it?

anatol added a commit that referenced this pull request Mar 23, 2021
If user can specified 'resume' boot flag and it matches a block device
then booster resumes this device using '/sys/power/resume' sys
interface.

Closes #49
@anatol
Copy link
Owner
anatol commented Mar 25, 2021

D'oh messed up with git commit author. I am going to fix it really quick.

anatol pushed a commit that referenced this pull request Mar 25, 2021
If user can specified 'resume' boot flag and it matches a block device
then booster resumes this device using '/sys/power/resume' sysfs
interface.

Closes #49
anatol pushed a commit that referenced this pull request Mar 25, 2021
If user can specified 'resume' boot flag and it matches a block device
then booster resumes this device using '/sys/power/resume' sysfs
interface.

Closes #49
@anatol
Copy link
Owner
anatol commented Mar 27, 2021

Hi Ed, I would like to move with this change forward. Had you chance to review/verify the rebased commit?

@eaceaser
Copy link
Contributor Author
eaceaser commented Mar 27, 2021

@anatol Hey, sorry, I've been dealing with some life stuff over the past week or so. I haven't forgotten about this, I'll find some time to rebase and test.

@eaceaser
Copy link
Contributor Author

@anatol Just tested 8175bbe -- it appears to work perfectly. Sorry again that i haven't had a ton of time these past few weeks to shepherd this so I appreciate your efforts.

@anatol
Copy link
Owner
anatol commented Mar 29, 2021

No worries, you did a great work. Thank you very much for your contribution.

@anatol anatol closed this in 8175bbe Mar 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0