Add per-game configuration override (for cpu pinning) - #572
Conversation
|
Cool idea! I like the implementation, it seems simple enough. I'm intending something similar in a fork, though I was gonna allow specifics within the existing configs, paired with an envar or a filter of some kind, like so: But this approach offers similar versatility without the up-front complexity, so that's cool. There's a few caveats that maybe are worth solving:
|
| if (strcmp(section, "cpu") == 0 && strcmp(name, "pin_cores") == 0) { | ||
| strncpy(ov->pin_cores, value, sizeof(ov->pin_cores) - 1); | ||
| ov->pin_cores[sizeof(ov->pin_cores) - 1] = '\0'; | ||
| ov->have_pin_cores = true; |
There was a problem hiding this comment.
have_pin_cores seems redundant, if pin_cores[0] == 0 then that's the same thing, surely? Or am I missing something.
Actually worth mentioning this - I had assumed more recent code was accounting for this in gamemode-wine.c. Is that no longer working? Worth a bug report if so. |
Elden Ring crashes when using
gamemoderunwith core pinning. I was using a script workaround to load a different config file on-the-fly, which was (at best) messy. This adds an option for per-game configuration files, living in~/.config/gamemode.d/(also ties to previous per-game use-cases, such as #388 and #570).The change lets users pass
GAMEMODE_CONFIG=xinto Steam launch options, which then dynamically loadsx.inifrom thegamemode.dfolder. Passes all tests (build, format-check, meson test). Confirmed working locally (Elden Ring now launches properly for me usingGAMEMODE_CONFIG=eldenring gamemoderun %command%). Also tested against invalid names, invalid values, with and without overrides.I originally looked at just checking the process name and using that to match to the file (so
eldenring.exewould look foreldenring.ini). This worked in testing (gamemoderun sleep 5would properly check forsleep.ini), but launching a game via Steam would look forenvevery time. This is because the game itself is a Windows process under Wine inside pressure-vessel, where the LD_PRELOAD never loads, so only the wrapper processes ever register with gamemode.Additionally, names are restricted to
[A-Za-z0-9_-]to prevent path traversal; config files can only be loaded from thegamemode.dfolder (confirmed by testing withGAMEMODE_CONFIG=../badconfigand it being rejected). Verified the override holds across the reaper's periodic re-pinning and config reloads too.This was intentionally scoped to only
pin_coresto solve my personal issue with Elden Ring, and keep it more easily reviewable. Further keys can be added using the same pattern. Happy to adjust the approach; I would love to see a per-game solution for gamemode.