aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pkgs/by-name/i3/i3status-rust-patched/package.nix5
-rw-r--r--pkgs/by-name/i3/i3status-rust-patched/patches/0002-memory-Directly-convert-reported-memory-usage-into-b.patch117
-rw-r--r--pkgs/by-name/i3/i3status-rust-patched/patches/0003-memory-Avoid-estimating-available-memory-use-kernel-.patch49
3 files changed, 0 insertions, 171 deletions
diff --git a/pkgs/by-name/i3/i3status-rust-patched/package.nix b/pkgs/by-name/i3/i3status-rust-patched/package.nix
index 1d0a42bc..a103e275 100644
--- a/pkgs/by-name/i3/i3status-rust-patched/package.nix
+++ b/pkgs/by-name/i3/i3status-rust-patched/package.nix
@@ -9,7 +9,6 @@
# If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
{
i3status-rust,
- fetchpatch2,
}:
i3status-rust.overrideAttrs (final: prev: {
pname = "${prev.pname}-patched";
@@ -19,9 +18,5 @@ i3status-rust.overrideAttrs (final: prev: {
++ [
# Btrfs support for disk_space block.
./patches/0001-disk_space-Support-btrfs-backend.patch
-
- # Correctly calculate the used memory.
- ./patches/0002-memory-Directly-convert-reported-memory-usage-into-b.patch
- ./patches/0003-memory-Avoid-estimating-available-memory-use-kernel-.patch
];
})
diff --git a/pkgs/by-name/i3/i3status-rust-patched/patches/0002-memory-Directly-convert-reported-memory-usage-into-b.patch b/pkgs/by-name/i3/i3status-rust-patched/patches/0002-memory-Directly-convert-reported-memory-usage-into-b.patch
deleted file mode 100644
index 00a50e92..00000000
--- a/pkgs/by-name/i3/i3status-rust-patched/patches/0002-memory-Directly-convert-reported-memory-usage-into-b.patch
+++ /dev/null
@@ -1,117 +0,0 @@
-From fccc34618103126d9374a5361a5870ccf8030fa0 Mon Sep 17 00:00:00 2001
-From: Benedikt Peetz <benedikt.peetz@b-peetz.de>
-Date: Mon, 19 May 2025 21:26:57 +0200
-Subject: [PATCH 2/3] memory: Directly convert reported memory usage into bytes
-
-`/proc/meminfo` states that it's report values are in KB, when
-they actually are in KiB. Previously, this inconsistency leaked into the
-whole code for this block (which had to add `* 1024` after nearly every
-assignment). Now this inconsistency is contained to the `Memstate`
-structure.
----
- src/blocks/memory.rs | 53 +++++++++++++++++++++++---------------------
- 1 file changed, 28 insertions(+), 25 deletions(-)
-
-diff --git a/src/blocks/memory.rs b/src/blocks/memory.rs
-index 801e61de0..8cf32f9ba 100644
---- a/src/blocks/memory.rs
-+++ b/src/blocks/memory.rs
-@@ -112,8 +112,8 @@ pub async fn run(config: &Config, api: &CommonApi) -> Result<()> {
- loop {
- let mem_state = Memstate::new().await?;
-
-- let mem_total = mem_state.mem_total as f64 * 1024.;
-- let mem_free = mem_state.mem_free as f64 * 1024.;
-+ let mem_total = mem_state.mem_total as f64;
-+ let mem_free = mem_state.mem_free as f64;
-
- // TODO: possibly remove this as it is confusing to have `mem_total_used` and `mem_used`
- // htop and such only display equivalent of `mem_used`
-@@ -126,8 +126,7 @@ pub async fn run(config: &Config, api: &CommonApi) -> Result<()> {
- min(mem_state.mem_available, mem_state.mem_total)
- } else {
- mem_state.mem_free
-- } as f64
-- * 1024.;
-+ } as f64;
-
- // While zfs_arc_cache can be considered "available" memory,
- // it can only free a maximum of (zfs_arc_cache - zfs_arc_min) amount.
-@@ -137,14 +136,14 @@ pub async fn run(config: &Config, api: &CommonApi) -> Result<()> {
- .saturating_sub(mem_state.zfs_arc_min) as f64;
- let mem_avail = mem_avail + zfs_shrinkable_size;
-
-- let pagecache = mem_state.pagecache as f64 * 1024.;
-- let reclaimable = mem_state.s_reclaimable as f64 * 1024.;
-- let shmem = mem_state.shmem as f64 * 1024.;
-+ let pagecache = mem_state.pagecache as f64;
-+ let reclaimable = mem_state.s_reclaimable as f64;
-+ let shmem = mem_state.shmem as f64;
-
- // See https://lore.kernel.org/lkml/1455827801-13082-1-git-send-email-hannes@cmpxchg.org/
- let cached = pagecache + reclaimable - shmem + zfs_shrinkable_size;
-
-- let buffers = mem_state.buffers as f64 * 1024.;
-+ let buffers = mem_state.buffers as f64;
-
- // same logic as htop
- let used_diff = mem_free + buffers + pagecache + reclaimable;
-@@ -157,14 +156,14 @@ pub async fn run(config: &Config, api: &CommonApi) -> Result<()> {
- // account for ZFS ARC cache
- let mem_used = mem_used - zfs_shrinkable_size;
-
-- let swap_total = mem_state.swap_total as f64 * 1024.;
-- let swap_free = mem_state.swap_free as f64 * 1024.;
-- let swap_cached = mem_state.swap_cached as f64 * 1024.;
-+ let swap_total = mem_state.swap_total as f64;
-+ let swap_free = mem_state.swap_free as f64;
-+ let swap_cached = mem_state.swap_cached as f64;
- let swap_used = swap_total - swap_free - swap_cached;
-
- // Zswap usage
-- let zswap_compressed = mem_state.zswap_compressed as f64 * 1024.;
-- let zswap_decompressed = mem_state.zswap_decompressed as f64 * 1024.;
-+ let zswap_compressed = mem_state.zswap_compressed as f64;
-+ let zswap_decompressed = mem_state.zswap_decompressed as f64;
-
- let zswap_comp_ratio = if zswap_compressed != 0.0 {
- zswap_decompressed / zswap_compressed
-@@ -310,19 +309,23 @@ impl Memstate {
- .and_then(|x| u64::from_str(x).ok())
- .error("failed to parse /proc/meminfo")?;
-
-+ // These values are reported as “kB” but are actually “kiB”.
-+ // Convert them into bytes to avoid having to handle this later.
-+ // Source: https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/6/html/deployment_guide/s2-proc-meminfo#s2-proc-meminfo
-+ const KIB: u64 = 1024;
- match name {
-- "MemTotal:" => mem_state.mem_total = val,
-- "MemFree:" => mem_state.mem_free = val,
-- "MemAvailable:" => mem_state.mem_available = val,
-- "Buffers:" => mem_state.buffers = val,
-- "Cached:" => mem_state.pagecache = val,
-- "SReclaimable:" => mem_state.s_reclaimable = val,
-- "Shmem:" => mem_state.shmem = val,
-- "SwapTotal:" => mem_state.swap_total = val,
-- "SwapFree:" => mem_state.swap_free = val,
-- "SwapCached:" => mem_state.swap_cached = val,
-- "Zswap:" => mem_state.zswap_compressed = val,
-- "Zswapped:" => mem_state.zswap_decompressed = val,
-+ "MemTotal:" => mem_state.mem_total = val * KIB,
-+ "MemFree:" => mem_state.mem_free = val * KIB,
-+ "MemAvailable:" => mem_state.mem_available = val * KIB,
-+ "Buffers:" => mem_state.buffers = val * KIB,
-+ "Cached:" => mem_state.pagecache = val * KIB,
-+ "SReclaimable:" => mem_state.s_reclaimable = val * KIB,
-+ "Shmem:" => mem_state.shmem = val * KIB,
-+ "SwapTotal:" => mem_state.swap_total = val * KIB,
-+ "SwapFree:" => mem_state.swap_free = val * KIB,
-+ "SwapCached:" => mem_state.swap_cached = val * KIB,
-+ "Zswap:" => mem_state.zswap_compressed = val * KIB,
-+ "Zswapped:" => mem_state.zswap_decompressed = val * KIB,
- _ => (),
- }
-
---
-2.49.0
-
diff --git a/pkgs/by-name/i3/i3status-rust-patched/patches/0003-memory-Avoid-estimating-available-memory-use-kernel-.patch b/pkgs/by-name/i3/i3status-rust-patched/patches/0003-memory-Avoid-estimating-available-memory-use-kernel-.patch
deleted file mode 100644
index 8943796d..00000000
--- a/pkgs/by-name/i3/i3status-rust-patched/patches/0003-memory-Avoid-estimating-available-memory-use-kernel-.patch
+++ /dev/null
@@ -1,49 +0,0 @@
-From b7ae3bd9672e7e1a3fc8e75d90b5bcbe75e6febf Mon Sep 17 00:00:00 2001
-From: Benedikt Peetz <benedikt.peetz@b-peetz.de>
-Date: Mon, 19 May 2025 21:29:54 +0200
-Subject: [PATCH 3/3] memory: Avoid estimating available memory, use kernel
- estimate instead
-
-`free`, `btop` and other tools (like the `sysinfo` rust library)
-use `mem_total - mem_avail` to calculate the used memory. As explained
-in the already linked [kernel commit][1], `mem_avail` is an estimate of
-the available memory based on the current way the kernel handles
-memory.
-
-The previous logic for calculating used memory tried to estimate
-this based on `mem_free`, `buffers`, `pagecache` and
-`reclaimable`. Unfortunately, as the kernel commit message predicts,
-this user space estimate bitrots, as the kernel memory usage patterns change.
-
-Thus, we now simply use the kernel estimate `mem_avail` as we know that
-that is in-sync with the relevant kernel internals.
-
-[1]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=34e431b0ae398fc54ea69ff85ec700722c9da773
----
- src/blocks/memory.rs | 10 +++-------
- 1 file changed, 3 insertions(+), 7 deletions(-)
-
-diff --git a/src/blocks/memory.rs b/src/blocks/memory.rs
-index 8cf32f9ba..94d8a5fe3 100644
---- a/src/blocks/memory.rs
-+++ b/src/blocks/memory.rs
-@@ -145,13 +145,9 @@ pub async fn run(config: &Config, api: &CommonApi) -> Result<()> {
-
- let buffers = mem_state.buffers as f64;
-
-- // same logic as htop
-- let used_diff = mem_free + buffers + pagecache + reclaimable;
-- let mem_used = if mem_total >= used_diff {
-- mem_total - used_diff
-- } else {
-- mem_total - mem_free
-- };
-+ // Userspace should use `mem_avail` for estimating the memory that is available.
-+ // See: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=34e431b0ae398fc54ea69ff85ec700722c9da773
-+ let mem_used = mem_total - mem_avail;
-
- // account for ZFS ARC cache
- let mem_used = mem_used - zfs_shrinkable_size;
---
-2.49.0
-