diff options
author | Andreas Sturmlechner <asturm@gentoo.org> | 2023-06-30 19:09:02 +0200 |
---|---|---|
committer | Andreas Sturmlechner <asturm@gentoo.org> | 2023-06-30 19:25:01 +0200 |
commit | 7c5246cdd7e13c97f2102ce44aaa2d05c8d90381 (patch) | |
tree | b63d6d27128223b27e7e987671ae96177c19de5d /kde-plasma | |
parent | dev-db/postgresql: drop 10.23 (diff) | |
download | gentoo-7c5246cdd7e13c97f2102ce44aaa2d05c8d90381.tar.gz gentoo-7c5246cdd7e13c97f2102ce44aaa2d05c8d90381.tar.bz2 gentoo-7c5246cdd7e13c97f2102ce44aaa2d05c8d90381.zip |
kde-plasma/ksystemstats: gpu/nvidia: Discover future data fields
KDE-bug: https://bugs.kde.org/show_bug.cgi?id=470474
Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
Diffstat (limited to 'kde-plasma')
-rw-r--r-- | kde-plasma/ksystemstats/files/ksystemstats-5.27.6-nvidia-data-fields.patch | 131 | ||||
-rw-r--r-- | kde-plasma/ksystemstats/ksystemstats-5.27.6-r1.ebuild | 47 |
2 files changed, 178 insertions, 0 deletions
diff --git a/kde-plasma/ksystemstats/files/ksystemstats-5.27.6-nvidia-data-fields.patch b/kde-plasma/ksystemstats/files/ksystemstats-5.27.6-nvidia-data-fields.patch new file mode 100644 index 000000000000..718bbd8c64e2 --- /dev/null +++ b/kde-plasma/ksystemstats/files/ksystemstats-5.27.6-nvidia-data-fields.patch @@ -0,0 +1,131 @@ +From 4f7213e6e742b993feeaf300181a67923e60c0f4 Mon Sep 17 00:00:00 2001 +From: David Redondo <kde@david-redondo.de> +Date: Wed, 10 May 2023 02:26:29 +0000 +Subject: [PATCH] gpu/nvidia: Discover data fields based on headers + +This guards us against the appearance of new fields or if they +ever appear in a different order. +BUG:470474 +FIXED-IN:5.27.7 + +(cherry picked from commit 7f9ead6bddfdf6f13a1ea48791f8f5d5c80c6980) +Because in Qt5 QVector<T>::indexOf only takes T's we have to provide +our own indexOf here. +--- + plugins/gpu/NvidiaSmiProcess.cpp | 56 ++++++++++++++++++++++---------- + plugins/gpu/NvidiaSmiProcess.h | 14 ++++++++ + 2 files changed, 53 insertions(+), 17 deletions(-) + +diff --git a/plugins/gpu/NvidiaSmiProcess.cpp b/plugins/gpu/NvidiaSmiProcess.cpp +index 7f8dd62..d92b396 100644 +--- a/plugins/gpu/NvidiaSmiProcess.cpp ++++ b/plugins/gpu/NvidiaSmiProcess.cpp +@@ -155,19 +155,37 @@ void NvidiaSmiProcess::unref() + void NvidiaSmiProcess::readStatisticsData() + { + while (m_process->canReadLine()) { +- const QString line = m_process->readLine(); +- if (line.startsWith(QLatin1Char('#'))) { +- continue; +- } ++ QString line = m_process->readLine(); + #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +- const QVector<QStringRef> parts = QStringRef(&line).trimmed().split(QLatin1Char(' '), Qt::SkipEmptyParts); ++ QVector<QStringRef> parts = QStringRef(&line).trimmed().split(QLatin1Char(' '), Qt::SkipEmptyParts); + #else +- const QVector<QStringView> parts = QStringView(line).trimmed().split(QLatin1Char(' '), Qt::SkipEmptyParts); ++ QVector<QStringView> parts = QStringView(line).trimmed().split(QLatin1Char(' '), Qt::SkipEmptyParts); + #endif +- +- // format at time of writing is +- // # gpu pwr gtemp mtemp sm mem enc dec mclk pclk fb bar1 +- if (parts.count() != 12) { ++ // Because in Qt5 indexOf of QVector<T> only takes T's, write our own indexOf taking arbitrary types ++ auto indexOf = [](const auto &stack, const auto& needle) { ++ auto it = std::find(stack.cbegin(), stack.cend(), needle); ++ return it != stack.cend() ? std::distance(stack.cbegin(), it) : -1; ++ }; ++ ++ // discover index of fields in the header format is something like ++ //# gpu pwr gtemp mtemp sm mem enc dec mclk pclk fb bar1 ++ // # Idx W C C % % % % MHz MHz MB MB ++ // 0 25 29 - 1 1 0 0 4006 1506 891 22 ++ if (line.startsWith(QLatin1Char('#'))) { ++ if (m_dmonIndices.gpu == -1) { ++ // Remove First part because of leading '# '; ++ parts.removeFirst(); ++ m_dmonIndices.gpu = indexOf(parts, QLatin1String("gpu")); ++ m_dmonIndices.power = indexOf(parts, QLatin1String("pwr")); ++ m_dmonIndices.gtemp = indexOf(parts, QLatin1String("gtemp")); ++ m_dmonIndices.sm = indexOf(parts, QLatin1String("sm")); ++ m_dmonIndices.enc = indexOf(parts, QLatin1String("enc")); ++ m_dmonIndices.dec = indexOf(parts, QLatin1String("dec")); ++ m_dmonIndices.fb = indexOf(parts, QLatin1String("fb")); ++ m_dmonIndices.bar1 = indexOf(parts, QLatin1String("bar1")); ++ m_dmonIndices.mclk = indexOf(parts, QLatin1String("mclk")); ++ m_dmonIndices.pclk = indexOf(parts, QLatin1String("pclk")); ++ } + continue; + } + +@@ -177,19 +195,23 @@ void NvidiaSmiProcess::readStatisticsData() + continue; + } + ++ auto readDataIfFound = [&parts, this] (int index) { ++ return index > 0 ? parts[index].toUInt() : 0; ++ }; ++ + GpuData data; +- data.index = index; +- data.power = parts[1].toUInt(); +- data.temperature = parts[2].toUInt(); ++ data.index = readDataIfFound(m_dmonIndices.gpu); ++ data.power = readDataIfFound(m_dmonIndices.power); ++ data.temperature = readDataIfFound(m_dmonIndices.gtemp); + + // GPU usage equals "SM" usage + "ENC" usage + "DEC" usage +- data.usage = parts[4].toUInt() + parts[6].toUInt() + parts[7].toUInt(); ++ data.usage = readDataIfFound(m_dmonIndices.sm) + readDataIfFound(m_dmonIndices.enc) + readDataIfFound(m_dmonIndices.dec); + + // Total memory used equals "FB" usage + "BAR1" usage +- data.memoryUsed = parts[10].toUInt() + parts[11].toUInt(); ++ data.memoryUsed = readDataIfFound(m_dmonIndices.fb) + readDataIfFound(m_dmonIndices.bar1); + +- data.memoryFrequency = parts[8].toUInt(); +- data.coreFrequency = parts[9].toUInt(); ++ data.memoryFrequency = readDataIfFound(m_dmonIndices.mclk); ++ data.coreFrequency = readDataIfFound(m_dmonIndices.pclk); + + Q_EMIT dataReceived(data); + } +diff --git a/plugins/gpu/NvidiaSmiProcess.h b/plugins/gpu/NvidiaSmiProcess.h +index f39cc9d..2cd8504 100644 +--- a/plugins/gpu/NvidiaSmiProcess.h ++++ b/plugins/gpu/NvidiaSmiProcess.h +@@ -49,8 +49,22 @@ public: + private: + void readStatisticsData(); + ++ struct dmonIndices { ++ int gpu = -1; ++ int gtemp = -1; ++ int power = -1; ++ int sm = -1; ++ int enc = -1; ++ int dec = -1; ++ int fb = -1; ++ int bar1 = -1; ++ int mclk = -1; ++ int pclk = -1; ++ }; ++ + QString m_smiPath; + std::vector<GpuQueryResult> m_queryResult; + std::unique_ptr<QProcess> m_process = nullptr; + int m_references = 0; ++ dmonIndices m_dmonIndices; + }; +-- +GitLab + diff --git a/kde-plasma/ksystemstats/ksystemstats-5.27.6-r1.ebuild b/kde-plasma/ksystemstats/ksystemstats-5.27.6-r1.ebuild new file mode 100644 index 000000000000..529d943b69ce --- /dev/null +++ b/kde-plasma/ksystemstats/ksystemstats-5.27.6-r1.ebuild @@ -0,0 +1,47 @@ +# Copyright 1999-2023 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +ECM_HANDBOOK="forceoptional" +ECM_TEST="forceoptional" +KFMIN=5.106.0 +PVCUT=$(ver_cut 1-3) +QTMIN=5.15.9 +inherit ecm plasma.kde.org + +DESCRIPTION="Plugin-based system monitoring daemon" + +LICENSE="GPL-2+" +SLOT="5" +KEYWORDS="~amd64 ~arm ~arm64 ~loong ~ppc64 ~riscv ~x86" +IUSE="networkmanager" + +DEPEND=" + dev-libs/libnl:3 + >=dev-qt/qtdbus-${QTMIN}:5 + >=dev-qt/qtnetwork-${QTMIN}:5 + >=kde-frameworks/kcoreaddons-${KFMIN}:5 + >=kde-frameworks/kdbusaddons-${KFMIN}:5 + >=kde-frameworks/ki18n-${KFMIN}:5 + >=kde-frameworks/kio-${KFMIN}:5 + >=kde-frameworks/solid-${KFMIN}:5 + >=kde-plasma/libksysguard-${PVCUT}:5 + net-libs/libpcap + sys-apps/lm-sensors:= + sys-libs/libcap + virtual/libudev:= + networkmanager? ( >=kde-frameworks/networkmanager-qt-${KFMIN}:5 ) +" +RDEPEND="${DEPEND} + !<kde-plasma/ksysguard-5.21.90:5 +" + +PATCHES=( "${FILESDIR}/${P}-nvidia-data-fields.patch" ) # KDE-bug 470474 + +src_configure() { + local mycmakeargs=( + $(cmake_use_find_package networkmanager KF5NetworkManagerQt) + ) + ecm_src_configure +} |