From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id A428E1FF141 for ; Mon, 16 Mar 2026 14:25:07 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id EB4FD1A8D9; Mon, 16 Mar 2026 14:25:18 +0100 (CET) Date: Mon, 16 Mar 2026 14:25:12 +0100 From: Arthur Bied-Charreton To: Lukas Wagner Subject: Re: [PATCH proxmox 11/26] procfs: add helpers for querying pressure stall information Message-ID: References: <20260312135229.420729-1-l.wagner@proxmox.com> <20260312135229.420729-12-l.wagner@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260312135229.420729-12-l.wagner@proxmox.com> X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1773667473293 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.259 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_MSPIKE_H2 0.001 Average reputation (+2) RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.408 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.819 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.903 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: BWRRSXVWOK7DRJ4JJM4DJQHRKJ33CPFY X-Message-ID-Hash: BWRRSXVWOK7DRJ4JJM4DJQHRKJ33CPFY X-MailFrom: a.bied-charreton@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: pdm-devel@lists.proxmox.com X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Thu, Mar 12, 2026 at 02:52:12PM +0100, Lukas Wagner wrote: > This is put into a new crate, proxmox-procfs, since proxmox-sys is > already quite large and should be split in the future. The general idea > is that the contents of proxmox_sys::linux::procfs should be moved into > this new crate (potentially after some API cleanup) at some point. > > Signed-off-by: Lukas Wagner I really like how you designed this, it reads very nicely! 2 comments inline > --- > Cargo.toml | 2 + > proxmox-procfs/Cargo.toml | 18 ++ > proxmox-procfs/debian/changelog | 5 + > proxmox-procfs/debian/control | 50 +++++ > proxmox-procfs/debian/copyright | 18 ++ > proxmox-procfs/debian/debcargo.toml | 7 + > proxmox-procfs/src/lib.rs | 1 + > proxmox-procfs/src/pressure.rs | 334 ++++++++++++++++++++++++++++ > 8 files changed, 435 insertions(+) > create mode 100644 proxmox-procfs/Cargo.toml > create mode 100644 proxmox-procfs/debian/changelog > create mode 100644 proxmox-procfs/debian/control > create mode 100644 proxmox-procfs/debian/copyright > create mode 100644 proxmox-procfs/debian/debcargo.toml > create mode 100644 proxmox-procfs/src/lib.rs > create mode 100644 proxmox-procfs/src/pressure.rs > + [...] > + fn read_pressure_line( > + reader: &mut R, > + buf: &mut Vec, > + ) -> Result<(PressureRecordKind, PressureRecord), Error> { > + // The buffer should be empty. It is only passed by the caller as a performance > + // optimization > + debug_assert!(buf.is_empty()); > + > + reader.read_until(b'\n', buf)?; > + // SAFETY: In production, `reader` is expected to read from > + // procfs/sysfs pressure files, which only ever should return ASCII strings. > + let line = unsafe { std::str::from_utf8_unchecked(buf) }; Major nit, but I wonder if using unsafe here is justified, given that this assumption is not enforced at the type level (BufRead could return anything), and this is not really a hot code path > + > + Self::read_record(line) > + } > + > + [...] > +#[cfg(test)] > +mod test { > + use super::*; > + > + #[test] > + fn test_read_psi() { > + let s = "some avg10=1.42 avg60=2.09 avg300=1.42 total=40979658 > +full avg10=0.08 avg60=0.18 avg300=0.13 total=22865313 > +"; > + > + let mut reader = std::io::Cursor::new(s); > + let stats = PressureData::read(&mut reader).unwrap(); > + > + assert_eq!(stats.some.total, 40979658); > + assert!((stats.some.average_10 - 1.82).abs() < f64::EPSILON); This test is failing, looks like this was supposed to be 1.42 > + assert!((stats.some.average_60 - 2.09).abs() < f64::EPSILON); > + assert!((stats.some.average_300 - 1.42).abs() < f64::EPSILON); > + [...]