Skip to content

Conversation

mdiluz
Copy link
Contributor

@mdiluz mdiluz commented May 19, 2019

This PR sets up two new ways to refresh the current configuration. For safety, if GameMode is active it tears down the current optimizations on both system and clients, swaps out to a new config, and then rebuilds the optimizations.

The changes provide two ways to do this:

  • By watching the config locations with inotify for file changes, new config files, or moved and deleted config files. Currently uses the reaper thread to check the inotify file descriptor for updates.
  • By using the new RefreshConfig dbus interface (not exposed in gamemode_client.h for now).

The dbus interface is implemented as a fallback, although perhaps an argument could be made that "supervisor" clients should be allowed to call this if ever needed, and a command line argument to gamemoded could be implemented alongside that.

@mdiluz mdiluz changed the title Add config reloading Add config hot-reloading May 19, 2019
@aejsmith
Copy link
Contributor

When reloading the config, the reaper thread will disable optimisations then re-enable them while holding a write lock. However, game_mode_context_(un)register do not hold the lock around enabling/disabling optimisations. Seems like there's a race condition there if we get a client (un)register at the same time the reaper reloads the config?

	This prevents a potential race condition for when the reaper thread reloads the config
@mdiluz
Copy link
Contributor Author

mdiluz commented May 24, 2019

Good point - I'd assumed that to be the case, but forgot that it was only the dbus single-threaded message queue that was protecting that race condition before. 4612533 should resolve that and passes the tests.

SD_BUS_VTABLE_UNPRIVILEGED),
SD_BUS_VTABLE_END
};
static const sd_bus_vtable gamemode_vtable[] =
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note this keeps getting changed by slightly differing clang-format versions. Perhaps we can do something about that eventually...

@aejsmith aejsmith merged commit 54c2d52 into FeralInteractive:master May 24, 2019
@mdiluz mdiluz deleted the add-config-hotreloading branch May 25, 2019 13:49
afayaz-feral pushed a commit that referenced this pull request May 26, 2020
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