-
Notifications
You must be signed in to change notification settings - Fork 73
vhost-device-gpu: Add support for GPU device path #903
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
7f60738 to
c27cb98
Compare
c27cb98 to
a9daf88
Compare
c557101 to
91bf7f3
Compare
0dd8175 to
ec80528
Compare
Change all GPU adapter new() methods to return io::Result<Self>. This allows callers to decide how to handle initialization failures. Signed-off-by: Dorinda Bassey <[email protected]>
cdf7bca to
e67887c
Compare
| if flags.render_server_fd.is_some() && !matches!(gpu_mode, GpuMode::VirglRenderer) { | ||
| return Err(GpuConfigError::GpuPathNotSupportedByMode); | ||
| } | ||
|
|
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.
I must insist on using a builder pattern, so the validation can be higher in the caller
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.
created an issue here - #910
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.
Why not fix it now?
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.
As I mentioned previously, the builder pattern refactor is out of scope for this PR. This PR adds the --gpu-device feature following the existing GpuConfig::new() pattern used throughout the codebase. Changing to a builder pattern would require refactoring how all backends instantiate GpuConfig and is a separate architectural change.
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.
Is there a rush to merge this PR though? It'd make sense to first make the builder pattern change (in another PR or in a commit in this PR), then add the device path logic. There's no need to add something that you know you will remove.
I don't think it's out of scope btw, for what it's worth.
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.
I disagree that this is in scope. The builder pattern would be a significant refactoring affecting the entire GpuConfig API and all three backends. The current implementation follows the existing pattern already in the codebase. This is a much bigger change than adding the --gpu-device feature alone. But if you feel strongly about it, I can implement the builder pattern first in another PR.
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.
Sounds good, thanks!
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.
I strongly disagree, I'm 100% with @epilys here, it doesn't make any sense to add something to be removed later.
I also don't think it will require lots of changes most places will change from GpuConfig::new(...) to something like GpuConfig::new(...).build(), and for VirglRenderer mode something like GpuConfig::new(GpuMode::VirglRenderer, ...).gpu_device(fd).build(), or something like that. Likewise, I think this PR is small enough to accommodate those changes.
As a side note, the description on issue #910 is unhelpful, adding a link to this thread is ok, but it should have more context
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.
I'm ok of doing it in another PR first, thanks
Add a new --gpu-device CLI argument that allows users to specify which GPU device to use for rendering when using the virglrenderer backend. This is useful for systems with multiple GPUs where a specific device needs to be selected. Signed-off-by: Dorinda Bassey <[email protected]>
e67887c to
912fd61
Compare
| // Open GPU device file if path was provided | ||
| #[cfg(feature = "backend-virgl")] | ||
| let render_server_fd = args | ||
| .flags | ||
| .gpu_device | ||
| .as_ref() | ||
| .map(|gpu_device| { | ||
| File::open(gpu_device) | ||
| .map(Into::into) | ||
| .map_err(|_| GpuConfigError::InvalidGpuDevice(gpu_device.clone())) | ||
| }) | ||
| .transpose()?; | ||
|
|
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 is not a suggestion to change the code, most probably it will need to be modified/moved to the builder
Is this AI generated?, starting from the comment that is basically useless, since I can see theFile::open(gpu_device). IMO comments should explain why something is not there, or the why's, but not a translation from code to natural language.
The other thing is, I have no problem of using a chain of methods, but don't try to be too "clever" (I made that sin also because is fun to write this type of code, but it really hurts legibility). In this case is not too problematic since is just opening a file.
| if flags.render_server_fd.is_some() && !matches!(gpu_mode, GpuMode::VirglRenderer) { | ||
| return Err(GpuConfigError::GpuPathNotSupportedByMode); | ||
| } | ||
|
|
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.
I strongly disagree, I'm 100% with @epilys here, it doesn't make any sense to add something to be removed later.
I also don't think it will require lots of changes most places will change from GpuConfig::new(...) to something like GpuConfig::new(...).build(), and for VirglRenderer mode something like GpuConfig::new(GpuMode::VirglRenderer, ...).gpu_device(fd).build(), or something like that. Likewise, I think this PR is small enough to accommodate those changes.
As a side note, the description on issue #910 is unhelpful, adding a link to this thread is ok, but it should have more context
|
@germag @epilys @stefano-garzarella I'm leaving this here as a final note: I've spent a considerable amount of time addressing your feedbacks etc. I clearly stated multiple times that the builder pattern refactor is out of scope for this PR |
|
Please forgive this old and former teacher, and please don't do this, your code is not "you", it doesn't define you, so don't take any critic as a personal attack or as a critic to you. Assume good intentions, we most probably not only have a language barrier (english is not my first lang, not even my second, and I'm terrible at it), but maybe also a cultural one, so something that for me is innocuous for you is offensive and vice versa. And the written language cannot express the "mood" of what the other person wants to say, that can lead to misunderstandings. Now I need to respond to this:
Sorry, but we also invested time reviewing your changes. You didn't provide an argument why it is out of scope, just "too complex", same with returning an error that turns out to be trivial to implement. With all the other feedback you follow the same pattern: first "no" and then we had to explain again why it is important, for instance with the panic, exit, double open... Why I think is in the scope, you are changing the API with an option restricted to a single mode, the restriction is checked too late in the call stack, and we think that is not ok, and adding the builder patter will not require too much work.
I don't want to talk for @epilys, but to be honest, after that comment I understood you will open a PR implementing the builder, and then modify this one, so is totally fine to mark it draft if it depends on a future PR, I see not wrong from @epilys side...
Sorry, but no, I never do any personal comments. I just asked if that code was AI generated, because those types of comments are very typical of that. But later, I assumed that it wasn't so I tried to explain why is not a good comment, having a comment that add nothing is useless. About being "clever", it's a well-known definition in the soft devel field:
I just called "clever" the code not you, and is not an insult to you, just a description of code that do some clever things instead of being simple and straightforward, making it hard to read/understand. Also, it's nothing wrong to use AI, but we as maintainers we need to know. However, it's not ok to just sent AI code putting all the burden of reviewing it on us (I'm not saying you did that, it's just a general comment)
It's fine if you don't have time to work on it. But if you don't want to continue working on something because the maintainers are stubborn (whether they are right or wrong), don't slam the door while leaving, that can erode your reputation. You can just say "I don't have time to continue working on it, If anyone else wants to continue, that's fine with me" and again take this as an honest attempt to help |
Summary of the PR
Add a new --gpu-path CLI argument that allows users to specify which GPU device to use for rendering when using the virglrenderer backend.
This is useful for systems with multiple GPUs where a specific device needs to be selected.
Requirements
Before submitting your PR, please make sure you addressed the following
requirements:
git commit -s), and the commit message has max 60 characters for thesummary and max 75 characters for each description line.
test.
Release" section of CHANGELOG.md (if no such section exists, please create one).
unsafecode is properly documented.