Skip to content

[Feature] Implement dmemcg (Device Memory Control Groups) for improved VRAM prioritization #109

Description

@Dar1usTheGr3at

Summary

I am requesting the inclusion of Natalie Vock's (Valve/pixelcluster) dmemcg kernel patches and the associated userspace utilities (dmemcg-booster and plasma-foreground-booster) into Ultramarine Linux.

These patches address a long-standing VRAM management issue in the Linux kernel where background applications (like browsers) can displace game assets from VRAM into the slower GTT region (system RAM via PCIe). This causes significant stuttering and performance degradation, especially on hardware with 8GB of VRAM or less.

The Problem

On systems with limited VRAM (e.g., Steam Deck, RX 7600, RTX 4060, or older 8GB cards), the kernel currently lacks a mechanism to prioritize which process's GPU memory allocations are protected from eviction.

  • A browser with many open tabs can cause a game to be evicted to GTT even while VRAM is partially free for lower-priority background processes.
  • This results in stuttering, lower 1% lows, and gradual performance degradation during long gaming sessions.
  • There are cases of games running on Unreal Engine 5 at higher settings, where hardware with 16GB of VRAM may also be evicted to GTT due to the natural weight of that gaming experience.

The Solution

The implementation consists of two parts:

  1. Kernel Patches: A series of patches modifying TTM (Translation Table Manager) allocation/eviction logic and adding the DRM device memory cgroup (dmemcg) controller.

  2. Userspace Utilities:

  • dmemcg-booster: A systemd service that enables and configures the memory controllers.
  • plasma-foreground-booster: An integration for KDE Plasma (Ultramarine's recommended edition) that dynamically assigns the highest VRAM priority to the focused window. (Out-of-tree utility also developed my Natalie Vock, and not yet implemented in Ultramarine KDE Plasma to my knowledge)

Measured Impact

In community testing (e.g., Cyberpunk 2077 on 8GB GPUs), these patches have shown:

  • VRAM Utilization: Increased from ~6GB to ~7.4GB (better usage of available hardware).
  • GTT Spillover: Reduced by over 50% (less reliance on slow system RAM).
  • Subjective Feel: Significantly smoother frame pacing and reduced "micro-stutter."

References / Prior Art

Post Script

My interest in this as a gamer is to see Linux pick up the slack that the rest of the industry has dropped in order for gamers using more affordable hardware options to participate with the rest of us. Ultramarine has given me a wonderful out-of-the-box gaming experience overall, and I feel that these VRAM management improvements could be extremely beneficial to the community.

Since Ultramarine already allows users to easily switch to the CachyOS kernel via umcli, if you don't want to patch the default kernel yet, you could consider packaging the userspace tools (dmemcg-booster) to complement the CachyOS kernel option already provided.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions