Skip to content

ksmd: add general_profit metric - #3778

Merged
SuperQ merged 1 commit into
prometheus:masterfrom
michalskrivanek:general-profit
Aug 5, 2026
Merged

SuperQ merged 1 commit into
prometheus:masterfrom
michalskrivanek:general-profit

Conversation

@michalskrivanek

Copy link
Copy Markdown
Contributor

Expose /sys/kernel/mm/ksm/general_profit as node_ksmd_general_profit_bytes.
This file (reports the net memory saved by KSM after subtracting the overhead of rmap_item tracking structures.
A negative value means KSM is consuming more memory than it saves. This is the single most useful KSM metric for operators deciding whether KSM is worthwhile on a given workload.

general_profit is available since Linux kernel 6.4 upstream, or CentOS Stream 9.
Since it may not exist on older kernels, also make the collector gracefully skip any missing sysfs file instead of failing the entire scrape.

Expose /sys/kernel/mm/ksm/general_profit as node_ksmd_general_profit_bytes.
This file (available since Linux 6.4, EL9) reports the net memory saved by KSM
after subtracting the overhead of rmap_item tracking structures.
Also gracefully skip any missing sysfs files instead of failing the entire
collector, since general_profit and potentially other files may not exist
on older kernels.

Signed-off-by: Michal Skrivanek <[email protected]>
Assisted-by: claude-4.6-opus

@rtreffer rtreffer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@SuperQ SuperQ left a comment

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.

Thanks!

I guess this is another TODO to add a parser to the procfs library.

@SuperQ
SuperQ merged commit 1771767 into prometheus:master Aug 5, 2026
17 checks passed
@michalskrivanek
michalskrivanek deleted the general-profit branch August 5, 2026 06:56
@SuperQ SuperQ mentioned this pull request Nov 18, 2026
SuperQ added a commit that referenced this pull request Nov 18, 2026
The behavior of `node_cpu_frequency_hertz` has changed. There are two different sources
of data for this metric. One from the `cpu` collector, one from the `cpufreq` collector.
Due to historical feature migrations the `cpufreq` collector shares the same subsystem
as the `cpu` collector. This caused conflicting data behavior. An attempt to fix this
was introduced in #3318. This behavior has been reverted to the previous behavior in #3795.

A new flag (`--collector.cpufreq.enable-cpufreq-prefix`) has been introduced that gives
the `cpufreq` a dedicated metric name subsystem (`node_cpufreq_...`). This will likely
be the default in v2.

* [CHANGE] netstat: Use procfs parsers for netstat, snmp and snmp6 #3796
* [CHANGE] edac: Fix no data results #3863
* [CHANGE] nvme: Deprecate metric nvme_namespace_capacity_bytes #3899
* [FEATURE] Add tainted collector for /proc/sys/kernel/tainted #3745
* [FEATURE] Add resctrl collector #3797
* [ENHANCEMENT] netstat: Add new FreeBSD metrics #3334
* [ENHANCEMENT] Add `chip` label to DRM metrics #3572
* [ENHANCEMENT] diskstats: add device-mapper backing device info metric #3676
* [ENHANCEMENT] textfile: support UTF-8 metric and label names #3729
* [ENHANCEMENT] ksmd: add general_profit metric #3778 #3894
* [BUGFIX] edac: Fix printf-style formatting in slog call #3759
* [BUGFIX] fibre_channel: fix crash when attempting to dereference invalid counters #3573
* [BUGFIX] thermal: Fix collecting Darwin temperatures without CPU power status #3767
* [BUGFIX] fibrechannel: Fix for ppc64le #3769
* [BUGFIX] cpu: Revert dup cpu frequency, add node_cpufreq flag #3795
* [BUGFIX] infiniband: skip sysfs reads for excluded devices #3824
* [BUGFIX] bcache: Fix btree_read_average_duration_seconds unit #3828

Signed-off-by: Ben Kochie <[email protected]>
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.

3 participants