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

Remove libdrm_amdgpu and other unnecessary code #703

Merged
merged 14 commits into from
Mar 15, 2022

Conversation

evelikov
Copy link
Contributor

@evelikov evelikov commented Mar 6, 2022

This series removes the a bunch of dead or no longer needed code. In particular:

  • libdrm_amdgpu has two better alternatives in-tree - individual and the gpu_metrics sysfs nodes
    • bonus now we properly track/open only the required ones
  • ifdef spaghetty in keybinds code
  • the find_folder() API - we can use ls() instead
  • excessive pipelines when fetching basic data

The vendor/device handling is still a bit iffy - I might be sorting that out next.

Note: this has been only lightly tested, so please give it a spin on your end and report issues.

There is no such file in-tree and never was.

Signed-off-by: Emil Velikov <[email protected]>
Drop the ifdef and simplify the .cpp file.

Signed-off-by: Emil Velikov <[email protected]>
Currently we pipeline a bunch of commands alike cat | grep | sed, there
we can do all that job with a single sed invocation - use that.

Signed-off-by: Emil Velikov <[email protected]>
The code was added back in 2020 and seemingly never built. Just drop it
- if needed it can be git reverted at some point.

Signed-off-by: Emil Velikov <[email protected]>
There are two alternatives - hwmon entries and gpu_metrics sysfs file.

Signed-off-by: Emil Velikov <[email protected]>
Currently it can give you a regular file, block/char device, fifo or a
socket.

Signed-off-by: Emil Velikov <[email protected]>
Makes the code much easier to read.

Signed-off-by: Emil Velikov <[email protected]>
@evelikov
Copy link
Contributor Author

Been using this for a few days without issues. Just some 600+ loc removed

@flightlessmango @jackun any takers?

@Faalagorn
Copy link
Contributor

I gave it a quick try on my RX 580, so far no issues at the first glance, I'll keep on running with that to see if I encounter any issues down the road.

@flightlessmango
Copy link
Owner

It looks good to me, I would just like @jackun to sign off as well

src/overlay.cpp Outdated Show resolved Hide resolved
@jackun
Copy link
Collaborator

jackun commented Mar 12, 2022

Do Vega APUs support gpu_metrics (a.k.a why libdrm etc used in first place)? At least Vega64 dgpu doesn't seem to.
e: vega12, vega20, renoir, vangogh, navi10, navi21(?), MI cards, maybe more... so only APUs since 2020?

@evelikov
Copy link
Contributor Author

Do Vega APUs support gpu_metrics (a.k.a why libdrm etc used in first place)? At least Vega64 dgpu doesn't seem to. e: vega12, vega20, renoir, vangogh, navi10, navi21(?), MI cards, maybe more... so only APUs since 2020?

AFAICT the standalone nodes - gpu_busy_percent, temp1_input and others, are present on all GPUs. So even if the composite gpu_metrics node is missing, all GPU will still have basic data.

That said, looks like I've forgot a check - currently the gpu_metrics node will be omitted if gpu_busy_percent is missing. It seems very unlikely to happen, but still not the right thing to do. Will add extra patch on top.

Can be trivially replaced with ls()

v2: Move break where it's supposed to.

Signed-off-by: Emil Velikov <[email protected]>
We have already enforced that a few lines above just after parsing the
vendor node.

Signed-off-by: Emil Velikov <[email protected]>
Currently we can get the load and temp stats either from the standalone
nodes or from the gpu_metrics (binary) sysfs node.

Fix the next to handle that.

Signed-off-by: Emil Velikov <[email protected]>
Currently we open the standalone busy, temp, gpu/memory clock and
power_usage nodes, even if gpu_metrics is present.

At the same time, we correctly ignore them when doing the read-only.
So just avoid opening them all together.

Signed-off-by: Emil Velikov <[email protected]>
No longer applicable, since the libdrm path is gone and hwmon is
required - either partially or in full.

Signed-off-by: Emil Velikov <[email protected]>
@jackun
Copy link
Collaborator

jackun commented Mar 12, 2022

IIRC gpu_busy_percent gave "Invalid Argument" on Vega 3 etc. unless patched since #53

@evelikov
Copy link
Contributor Author

Sounds like something which should be reported and fixed in the amdgpu driver. Adding/maintaining a complete code-path for such a bug that does not sound palatable IMHO.

@evelikov evelikov marked this pull request as draft March 12, 2022 19:54
@evelikov
Copy link
Contributor Author

evelikov commented Mar 12, 2022

Doing a quick test shows that something has gone off.
Quickly flipping to draft - so this doesn't go in and break the world

Fixed, see below

Above all, we really don't need the gpu_busy_percent node, if the GPU
exposes a gpu_metrics node,

Although looking closer, the gpu_busy_percent check is meant for
something else - to distinguish between the card node (cardX) and the
card output node (cardX-output-foo).

To top it all up, the check at the very end implies that we can get a
case where gpu_metrics and gpu_busy_perfect is missing ... that's not
possible.

So instead, drop the early gpu_busy_perfect check and properly mandate
it later on.

Signed-off-by: Emil Velikov <[email protected]>
@evelikov evelikov marked this pull request as ready for review March 12, 2022 20:31
@evelikov
Copy link
Contributor Author

The gpu_busy_percent check that the last commit removed had a very misleading meaning - it was used to distinguish between card0 and card0-DP-1 nodes. See the commit description (and inline comment) for details.

@jackun
Copy link
Collaborator

jackun commented Mar 12, 2022

to distinguish between the card node (cardX) and the
card output node (cardX-output-foo).

More of a is using amdgpu check but filters those (cardX-output-foo) out too :P

@evelikov
Copy link
Contributor Author

Fwiw there's another dozen or so patches series sitting on top of this work - #707

@jackun jackun merged commit 11142b5 into flightlessmango:master Mar 15, 2022
@evelikov evelikov deleted the misc-mixes branch March 27, 2022 11:34
@jackun
Copy link
Collaborator

jackun commented Mar 30, 2022

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.

4 participants