Skip to content

linux/GPU: add per-process GPU memory column (GPU_MEMORY) - #2121

Open
rajasekharponakala wants to merge 2 commits into
htop-dev:mainfrom
rajasekharponakala:main
Open

rajasekharponakala wants to merge 2 commits into
htop-dev:mainfrom
rajasekharponakala:main

Conversation

@rajasekharponakala

Copy link
Copy Markdown

btop shows per-process GPU memory usage, which htop lacked. htop already
tracks per-process GPU engine time/utilization (GPU_TIME, GPU_PERCENT) by
parsing the generic DRM fdinfo stats (drm-engine-*), so extend the same
fdinfo parser to also sum drm-resident-/drm-memory- (the
deprecated amdgpu-only alias for resident) values, deduplicated per client
the same way engine time already is, and expose the result as a new
GPU_MEMORY column.

btop shows per-process GPU memory usage, which htop lacked. htop already
tracks per-process GPU engine time/utilization (GPU_TIME, GPU_PERCENT) by
parsing the generic DRM fdinfo stats (drm-engine-*), so extend the same
fdinfo parser to also sum drm-resident-<region>/drm-memory-<region> (the
deprecated amdgpu-only alias for resident) values, deduplicated per client
the same way engine time already is, and expose the result as a new
GPU_MEMORY column.

Assisted-by: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016Tgh778fwKS3MFYmr7wd3M
@coderabbitai

coderabbitai Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

📝 Walkthrough

Walkthrough

GPU_readProcessData now parses DRM memory statistics for each process. It accepts valid KiB and MiB values, ignores duplicates and invalid entries, converts values to bytes, and stores the total in LinuxProcess.gpu_memory. The Linux process view adds the GPU_MEMORY field, displays the value, and sorts processes by GPU memory.

Priority: ➖ Normal

Change: Feature

Merge Risk: 🟡 Moderate · up to 7825c

GPU memory can be reported too high for amdgpu processes, affecting the new column and its sort order. Deduplicate the aliases before merging.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

DRM numbers gather in flight
KiB and MiB become bytes bright
Duplicate entries fade away
GPU memory joins the display
Sorted processes line the way

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 34176738-a2ee-463c-a24b-f7fa025c7729

📥 Commits

Reviewing files that changed from the base of the PR and between 1daf6d9 and cb61770.

📒 Files selected for processing (4)
  • linux/GPU.c
  • linux/LinuxProcess.c
  • linux/LinuxProcess.h
  • linux/ProcessField.h

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Comment thread linux/GPU.c Outdated
Comment on lines +216 to +228

unsigned long long int bytesValue;
if (errno != 0)
continue;
else if (String_startsWith(endptr, "KiB"))
bytesValue = value * 1024ULL;
else if (String_startsWith(endptr, "MiB"))
bytesValue = value * 1024ULL * 1024ULL;
else
continue;

if (sstate == SECST_UNKNOWN) {
if (client_id != INVALID_CLIENT_ID && !is_duplicate_client(parsed_ids, client_id, pdev))

@coderabbitai coderabbitai Bot Sep 22, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

sed -n '185,240p' linux/GPU.c
rg -n 'strtoull|UINT64_MAX|ULLONG_MAX|bytesValue|new_gpu_memory' linux/GPU.c linux tests | head -240

Repository: htop-dev/htop

Length of output: 6673


🏁 Script executed:

#!/bin/bash
set -o pipefail
printf '%s\n' '--- repository guidance ---'
if command -v get_repo_knowledge >/dev/null 2>&1; then
  get_repo_knowledge </dev/null
else
  printf '%s\n' 'get_repo_knowledge utility unavailable in shell'
fi
printf '%s\n' '--- GPU.c function and callers ---'
sed -n '1,310p' linux/GPU.c
printf '%s\n' '--- GPU.c symbols and call sites ---'
rg -n -C 3 'GPU_readProcessData|gpu_memory|/proc/.*/fdinfo|fdinfo' --glob '*.{c,h}' .

Repository: htop-dev/htop

Length of output: 14693


🤖 get_repo_knowledge executed:

get_repo_knowledge htop-dev/htop /tmp/coderabbit-repo-knowledge/htop-dev-htop-29b6682e

Length of output: 2126


🏁 Script executed:

#!/bin/bash
set -o pipefail
printf '%s\n' '--- GPU.c focused source ---'
sed -n '1,310p' linux/GPU.c
printf '%s\n' '--- GPU symbols and call sites ---'
rg -n -C 3 'GPU_readProcessData|gpu_memory|/proc/.*/fdinfo|fdinfo' --glob '*.{c,h}' .

Repository: htop-dev/htop

Length of output: 14609


🏁 Script executed:

#!/bin/bash
set -o pipefail
printf '%s\n' '--- caller context ---'
sed -n '1725,1790p' linux/LinuxProcessTable.c
printf '%s\n' '--- numeric limits and relevant includes ---'
rg -n -C 2 '`#include` <limits.h>|ULLONG_MAX|UINT64_MAX|GPU_readProcessData' --glob '*.{c,h}' .
printf '%s\n' '--- local DRM references ---'
rg -n -C 3 'drm-memory|drm-resident|drm-usage-stats|KiB|MiB' --glob '*' . | head -240

Repository: htop-dev/htop

Length of output: 17496


🌐 Web query:

official Linux DRM usage stats fdinfo drm-memory drm-resident units value contract

💡 Result:

<source_evidence>

<title>DRM client usage stats — The Linux Kernel documentation</title> https://kernel.org/doc/html/latest/gpu/drm-usage-stats.html client usage stats — ... DRM drivers can choose to export partly standardised text output via the fops->`show_fdinfo()` as part of the driver specific file operations registered in the `struct drm_driver` object registered with the DRM core. ... #### Memory¶ ... Each possible memory type which can be used to store buffer objects by the GPU in question shall be given a stable and unique name to be used as the “ ” string. ... The value shall reflect the amount of storage currently consumed by the buffer objects belong to this client, in the respective memory region. ... Default unit shall be bytes with optional unit ... ifiers of ‘KiB’ or ‘MiB’ indicating kibi- or mebi-bytes. ... - drm-total-: [KiB|MiB] ... size of all requested ... , including both ... does not need to be currently ... under this category. ... avoid double- ... it can be ... should consistently select a single region for accounting purposes ... - drm-shared ... - drm-resident-: [KiB|MiB] ... The total size of buffers that are resident (i.e., have their backing store present or instantiated) in the specified region. ... - drm-memory-: [KiB|MiB] ... This key is deprecated and is only printed by amdgpu; it is an alias for drm-resident-. ... Drivers should use `drm_show_fdinfo()` in their `struct file_operations`, and implement &drm_driver.show_fdinfo if they wish to provide any stats which are not provided by `drm_show_fdinfo()`. But even driver specific stats should be documented above and where possible, aligned with other drivers. <title>DRM client usage stats — The Linux Kernel documentation</title> https://docs.kernel.org/gpu/drm-usage-stats.html client usage stats — ... DRM drivers can choose to export partly standardised text output via the fops->`show_fdinfo()` as part of the driver specific file operations registered in the `struct drm_driver` object registered with the DRM core. ... #### Memory¶ ... Each possible memory type which can be used to store buffer objects by the GPU in question shall be given a stable and unique name to be used as the “ ” string. ... The value shall reflect the amount of storage currently consumed by the buffer objects belong to this client, in the respective memory region. ... Default unit shall be bytes with optional unit ... ifiers of ‘KiB’ or ‘MiB’ indicating kibi- or mebi-bytes. ... - drm-total-: [KiB|MiB] ... size of all requested ... , including both ... does not need to be currently ... under this category. ... avoid double- ... it can be ... should consistently select a single region for accounting purposes ... - drm-shared ... - drm-resident-: [KiB|MiB] ... The total size of buffers that are resident (i.e., have their backing store present or instantiated) in the specified region. ... - drm-memory-: [KiB|MiB] ... This key is deprecated and is only printed by amdgpu; it is an alias for drm-resident-. ... Drivers should use `drm_show_fdinfo()` in their `struct file_operations`, and implement &drm_driver.show_fdinfo if they wish to provide any stats which are not provided by `drm_show_fdinfo()`. But even driver specific stats should be documented above and where possible, aligned with other drivers. <title>DRM client usage stats — The Linux Kernel documentation</title> https://docs.kernel.org/6.7/gpu/drm-usage-stats.html DRM client usage stats — The Linux Kernel documentation - A guide to the Kernel Development Process - Submitting patches: the essential guide to getting your code into the kernel - Code of conduct - Kernel Maintainer Handbook - All development-process docs # DRM client usage stats¶ DRM drivers can choose to export partly standardised text output via the fops->show_fdinfo() as part of the driver specific file operations registered in the `struct drm_driver` object registered with the DRM core. One purpose of this output is to enable writing as generic as practically feasible top(1) like userspace monitoring tools. Given the differences between various DRM drivers the specification of the output is split between common and driver specific parts. Having said that, wherever possible effort should still be made to standardise as much as possible. ## File format specification¶ - File shall contain one key value pair per one line of text. - Colon character (:) must be used to delimit keys and values. - All keys shall be prefixed with drm-. - Whitespace between the delimiter and first non-whitespace character shall be ignored when parsing. - Keys are not allowed to contain whitespace characters. - Numerical key value pairs can end with optional unit string. - Data type of the value is fixed as defined in the specification. ### Key types¶ 1. Mandatory, fully standardised. 2. Optional, fully standardised. 3. Driver specific. ### Data types¶ - - Unsigned integer without defining the maximum value. - - String excluding any above defined reserved characters or whitespace. - - String. ### Mandatory fully standardised keys¶ - drm-driver: String shall contain the name this driver registered as via the respective `struct drm_driver` data structure. #### Identification¶ - drm-pdev: <aaaa:bb.cc.d> For PCI devices this should contain the PCI slot address of the device in question. - drm-client-id: Unique value relating to the open DRM file descriptor used to distinguish duplicated and shared file descriptors. Conceptually the value should map 1:1 to the in kernel representation of `struct drm_file` instances. Uniqueness of the value shall be either globally unique, or unique within the scope of each device, in which case drm-pdev shall be present as well. Userspace should make sure to not double account any usage statistics by using the above described criteria in order to associate data to individual clients. #### Utilization¶ - drm-engine-: ns GPUs usually contain multiple execution engines. Each shall be given a stable and unique name (keystr), with possible values documented in the driver specific documentation. Value shall be in specified time units which the respective GPU engine spent busy executing workloads belonging to this client. Values are not required to be constantly monotonic if it makes the driver implementation easier, but are required to catch up with the previously reported larger value within a reasonable period. Upon observing a value lower than what was previously read, userspace is expected to stay with that larger previous value until a monotonic update is seen. - drm-engine-capacity-: Engine identifier string must be the same as the one specified in the drm-engine- tag and shall contain a greater than zero number in case the exported engine corresponds to a group of identical hardware engines. In the absence of this tag parser shall assume capacity of one. Zero capacity is not allowed. - drm-cycles-: Engine identifier string must be the same as the one specified in the drm-engine- tag and shall contain the number of busy cycles for the given engine. Values are not required to be constantly monotonic if it makes the driver implementation easier, but are required to catch up with the previously reported larger value within a reasonable period. Upon observing a value lower than what was previously read, userspace is expected to stay with that larger previous value until a monotonic update is seen. - drm…[truncated] <title>[PATCH v8 3/5] Documentation/gpu: Clarify drm memory stats definition</title> https://lists.freedesktop.org/archives/dri-devel/2024-November/478070.html [PATCH v8 3/5] Documentation/gpu: Clarify drm memory stats definition # [PATCH v8 3/5] Documentation/gpu: Clarify drm memory stats definition Tvrtko Ursulin tvrtko.ursulin at igalia.com (dri-devel%40lists.freedesktop.org) Mon Nov 18 14:47:30 UTC 2024 ``` On 18/11/2024 14:03, Christian König wrote: > Am 16.11.24 um 05:44 schrieb Yunxiang Li: >> Define how to handle buffers with multiple possible placement so we >> don&`#39`;t get incompatible implementations. Callout the resident requirement >> for drm-purgeable- explicitly. Remove the requirement for there to be >> only drm-memory- or only drm-resident-, it&`#39`;s not what&`#39`;s implemented and >> having both is better for back-compat. Also re-order the paragraphs to >> flow better. >> >> Signed-off-by: Yunxiang Li <Yunxiang.Li at amd.com> >> CC: dri-devel at lists.freedesktop.org >> --- >> Documentation/gpu/drm-usage-stats.rst | 36 ++++++++++++--------------- >> 1 file changed, 16 insertions(+), 20 deletions(-) >> >> diff --git a/Documentation/gpu/drm-usage-stats.rst >> b/Documentation/gpu/drm-usage-stats.rst >> index ff964c707754a..973663f91a292 100644 >> --- a/Documentation/gpu/drm-usage-stats.rst >> +++ b/Documentation/gpu/drm-usage-stats.rst >> @@ -140,13 +140,9 @@ both. >> Memory >> ^^^^^^ >> -- drm-memory-<region>: <uint> [KiB|MiB] >> - >> -Each possible memory type which can be used to store buffer objects >> by the >> -GPU in question shall be given a stable and unique name to be >> returned as the >> -string here. >> - >> -The region name "memory" is reserved to refer to normal system memory. >> +Each possible memory type which can be used to store buffer objects >> by the GPU >> +in question shall be given a stable and unique name to be used as the >> "<region>" >> +string. The region name "memory" is reserved to refer to normal >> system memory. > > That looks like you squashed the "The region name..." sentence at the > end. Is that really helpful and intended? > >> Value shall reflect the amount of storage currently consumed by the >> buffer >> objects belong to this client, in the respective memory region. >> @@ -154,31 +150,27 @@ objects belong to this client, in the respective >> memory region. >> Default unit shall be bytes with optional unit specifiers of &`#39`;KiB&`#39`; >> or &`#39`;MiB&`#39`; >> indicating kibi- or mebi-bytes. >> -This key is deprecated and is an alias for drm-resident-<region>. >> Only one of >> -the two should be present in the output. >> +- drm-total-<region>: <uint> [KiB|MiB] >> + >> +The total size of all created buffers including shared and private >> memory. The > > Maybe write "requested" instead of "created" since without a backing > store it is questionable if the BO is really "created". Hmm is the term "requested" in colloquial use either by end users or user space developers in the context of buffer objects? If we think the sentence needs to be improved upon, maybe something like: "The total size of all buffers, either created by user space APIs, or internally by the driver, including both shared and private buffers." ? Regards, Tvrtko > > Apart from those two nit picks it looks good to me, > Christian. > >> +backing store for the buffers does not have to be currently >> instantiated to >> +count under this category. To avoid double counting, if a buffer >> falls under >> +multiple regions, the implementation should pick only one of the >> regions, and do >> +so in a consistent manner. >> - drm-shared-<region…[truncated] <title>linux-kernel - [PATCH v4 4/4] proc_pid_fdinfo.5: Add DRM subsection</title> https://lists.openwall.net/linux-kernel/2024/11/01/1500 linux-kernel - [PATCH v4 4/4] proc_pid_fdinfo.5: Add DRM subsection ``` Message-Id: <20241101211830.1298073-4-irogers@google.com> Date: Fri, 1 Nov 2024 14:18:30 -0700 From: Ian Rogers <irogers@...gle.com> To: Alejandro Colomar <alx@...nel.org>, "G . Branden Robinson" <g.branden.robinson@...il.com> Cc: David Airlie <airlied@...il.com>, Simona Vetter <simona@...ll.ch>, Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>, Maxime Ripard <mripard@...nel.org>, Thomas Zimmermann <tzimmermann@...e.de>, Jonathan Corbet <corbet@....net>, dri-devel@...ts.freedesktop.org, linux-doc@...r.kernel.org, linux-kernel@...r.kernel.org, linux-man@...r.kernel.org, Ian Rogers <irogers@...gle.com> Subject: [PATCH v4 4/4] proc_pid_fdinfo.5: Add DRM subsection Add description of DRM fdinfo information based on the Linux kernel&`#39`;s `Documentation/gpu/drm-usage-stats.rst`: https://docs.kernel.org/gpu/drm-usage-stats.html Signed-off-by: Ian Rogers <irogers@...gle.com> --- man/man5/proc_pid_fdinfo.5 | 94 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) diff --git a/man/man5/proc_pid_fdinfo.5 b/man/man5/proc_pid_fdinfo.5 index b7efde8f4..bcaf33817 100644 --- a/man/man5/proc_pid_fdinfo.5 +++ b/man/man5/proc_pid_fdinfo.5 @@ -300,6 +300,100 @@ fields contain the values that .BR timerfd_gettime (2) on this file descriptor would return.) .RE +.SS Direct Rendering Manager +.P +DRM drivers can optionally choose to expose usage stats through +/proc/pid/fdinfo/. For example: +.P +.in +4n +.EX +pos: 0 +flags: 02100002 +mnt_id: 26 +ino: 284 +drm-driver: i915 +drm-client-id: 39 +drm-pdev: 0000:00:02.0 +drm-total-system0: 6044 KiB +drm-shared-system0: 0 +drm-active-system0: 0 +drm-resident-system0: 6044 KiB +drm-purgeable-system0: 1688 KiB +drm-total-stolen-system0: 0 +drm-shared-stolen-system0: 0 +drm-active-stolen-system0: 0 +drm-resident-stolen-system0: 0 +drm-purgeable-stolen-system0: 0 +drm-engine-render: 346249 ns +drm-engine-copy: 0 ns +drm-engine-video: 0 ns +drm-engine-capacity-video: 2 +drm-engine-video-enhance: 0 ns +.EE +.TP +.IR drm-driver: " .+ (mandatory)" +The name this driver registered. +.TP +.IR drm-pdev: " <aaaa:bb:cc.d>" +For PCI devices this should contain the PCI slot address of the device +in question. +.TP +.IR drm-client-id: " [0-9]+" +Unique value relating to the open DRM file descriptor used to +distinguish duplicated and shared file descriptors. +.P +GPUs usually contain multiple execution engines. Each shall be given a +stable and unique name (<engine_name>), with possible values +documented in the driver specific documentation. +.TP +.IR drm-engine-<engine_name>: " [0-9]+ ns" +GPU engine utilization, time spent busy executing workloads for this client. +.TP +.IR drm-engine-capacity-<engine_name>: " [0-9]+" +Capacity of the engine if not 1, cannot be 0. +.TP +.IR drm-cycles-<engine_name>: " [0-9]+" +Contains the number of busy cycles for the given engine. Values are +not required to be constantly monotonic, but are required to catch up +with the previously reported larger value within a reasonable +period. Upon observing a value lower than what was previously read, +userspace is expected to stay with that larger previous value until a +monotonic update is seen. +.TP +.IR drm-total-cycles-<engine_name>: " [0-9]+" +Contains the total number cycles for the given engine. This is a +timestamp in GPU unspecified unit that matches the update rate of +drm-cycles-<engine_name>. For drivers that implement this interface, +the engine utilization can be calculated entirely on the GPU clock +domain, without considering the CPU sleep time between 2 samples. +.P +Each possible memory type which can be used to store buffer objects by +the GPU in question shall be given a stable and unique name <region>. +The name "me…[truncated]

Citations:


Reject values that overflow the byte conversion.

When GPU monitoring is active, GPU_readProcessData() can parse a valid DRM fdinfo memory entry. The parser accepts any in-range unsigned integer, but it does not check the unit multiplication. A value above ULLONG_MAX / 1024 for KiB, or above ULLONG_MAX / 1048576 for MiB, can wrap bytesValue. The wrapped value is added to new_gpu_memory and stored in lp->gpu_memory.

Suggested fix
 `#include` <errno.h>
+#include <limits.h>
 `#include` <sys/types.h>
@@
             unsigned long long int bytesValue;
+            unsigned long long int multiplier;
             if (errno != 0)
                continue;
             else if (String_startsWith(endptr, "KiB"))
-               bytesValue = value * 1024ULL;
+               multiplier = 1024ULL;
             else if (String_startsWith(endptr, "MiB"))
-               bytesValue = value * 1024ULL * 1024ULL;
+               multiplier = 1024ULL * 1024ULL;
             else
                continue;
 
+            if (value > ULLONG_MAX / multiplier)
+               continue;
+            bytesValue = value * multiplier;
+

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also take a look at the style guide regarding braces in if/elseif chains …

Also, this fails for values given in GiB or larger units.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Use this command on a human-authored review finding. CodeRabbit findings already use the standard resolution workflow.

Comment thread linux/GPU.c Outdated
unsigned long long int bytesValue;
if (errno != 0)
continue;
else if (String_startsWith(endptr, "KiB"))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

sed -n '170,245p' linux/GPU.c
rg -n 'String_startsWith|drm-resident|drm-memory|fdinfo' linux tests . | head -240

Repository: htop-dev/htop

Length of output: 21777


Require an exact unit suffix.

String_startsWith(endptr, "KiB") and the equivalent MiB branch accept values such as 1 KiBjunk. When the entry is otherwise associated with a new client, GPU_readProcessData converts and adds that value to new_gpu_memory. Reject trailing data so malformed fdinfo entries cannot affect gpu_memory.

Proposed fix
-            else if (String_startsWith(endptr, "KiB"))
+            else if (String_eq(endptr, "KiB"))
                 bytesValue = value * 1024ULL;
-            else if (String_startsWith(endptr, "MiB"))
+            else if (String_eq(endptr, "MiB"))
                 bytesValue = value * 1024ULL * 1024ULL;

@fasterit

Copy link
Copy Markdown
Member

Please clean up the commits (no merge commits)

@BenBE BenBE added Linux 🐧 Linux related issues feature request Completely new feature requested labels Sep 22, 2026
Address upstream review feedback on the GPU_MEMORY column (PR htop-dev#2121):

- CodeRabbit: a value above ULLONG_MAX / 1024 (KiB) or ULLONG_MAX / 1048576
  (MiB) could wrap bytesValue during multiplication; check for overflow
  before multiplying instead.
- CodeRabbit: String_startsWith(endptr, "KiB") accepted malformed suffixes
  like "KiBjunk"; require an exact unit match via String_eq() instead.
- BenBE: the parser only recognized KiB/MiB and failed for GiB/TiB values,
  which drivers reporting large VRAM sizes can emit; add those units.

The unit dispatch is pulled out into parse_drm_memory_value() so the
overflow check and exact-match comparisons don't turn the call site into
a multi-statement if/else-if chain.

Assisted-by: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016Tgh778fwKS3MFYmr7wd3M

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 90f50246-35ca-4101-be2a-c51facd717c9

📥 Commits

Reviewing files that changed from the base of the PR and between cb61770 and 7825cd5.

📒 Files selected for processing (1)
  • linux/GPU.c

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Comment thread linux/GPU.c
/*
* "drm-resident-<region>" is the current key for backing-store size;
* "drm-memory-<region>" is its deprecated alias (amdgpu only). A given
* driver emits only one of the two per region, so summing both is safe.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Deduplicate the deprecated alias by region.

When amdgpu emits drm-resident-vram and drm-memory-vram in one fdinfo entry, this branch adds both values. The kernel emits both keys from the same resident statistic. Client-ID deduplication does not apply within one entry, so GPU_MEMORY can report twice the actual value. Prefer drm-resident-<region> and use drm-memory-<region> only when that region has no resident key. (github.com)

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

Labels

feature request Completely new feature requested Linux 🐧 Linux related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants