Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 8 May 2021 16:58:57 GMT
From:      Jesper Schmitz Mouridsen <jsm@FreeBSD.org>
To:        ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org
Subject:   git: 8d9632ac336b - main - sysutils/libsysstat: Update to 0.4.5 - Improve patches for per cpu freq levels.
Message-ID:  <202105081658.148GwvIu060022@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by jsm:

URL: https://cgit.FreeBSD.org/ports/commit/?id=8d9632ac336b47ca89064b79d575c05b37982c31

commit 8d9632ac336b47ca89064b79d575c05b37982c31
Author:     Jesper Schmitz Mouridsen <jsm@FreeBSD.org>
AuthorDate: 2021-05-08 15:41:56 +0000
Commit:     Jesper Schmitz Mouridsen <jsm@FreeBSD.org>
CommitDate: 2021-05-08 16:51:58 +0000

    sysutils/libsysstat: Update to 0.4.5
     - Improve patches for per cpu freq levels.
---
 sysutils/libsysstat/Makefile                 |   2 +-
 sysutils/libsysstat/distinfo                 |   6 +-
 sysutils/libsysstat/files/patch-cpustat.cpp  | 148 +++++++++++++++------------
 sysutils/libsysstat/files/patch-cpustat__p.h |   6 +-
 sysutils/libsysstat/files/patch-memstat.cpp  |  14 +--
 sysutils/libsysstat/files/patch-netstat.cpp  |  23 ++---
 6 files changed, 109 insertions(+), 90 deletions(-)

diff --git a/sysutils/libsysstat/Makefile b/sysutils/libsysstat/Makefile
index d29e183d7935..3a4454f845ed 100644
--- a/sysutils/libsysstat/Makefile
+++ b/sysutils/libsysstat/Makefile
@@ -1,7 +1,7 @@
 # Created by: Olivier Duchateau
 
 PORTNAME=	libsysstat
-PORTVERSION=	0.4.4
+PORTVERSION=	0.4.5
 CATEGORIES=	sysutils
 MASTER_SITES=	LXQT/${PORTNAME}
 
diff --git a/sysutils/libsysstat/distinfo b/sysutils/libsysstat/distinfo
index b4518185c58a..8aaec17c51de 100644
--- a/sysutils/libsysstat/distinfo
+++ b/sysutils/libsysstat/distinfo
@@ -1,3 +1,3 @@
-TIMESTAMP = 1605119504
-SHA256 (lxqt/libsysstat-0.4.4.tar.xz) = 3997d17692d2ea467d384517aedb8fcc4050f2f66114a1405d42cef0adaafa6b
-SIZE (lxqt/libsysstat-0.4.4.tar.xz) = 17532
+TIMESTAMP = 1618772764
+SHA256 (lxqt/libsysstat-0.4.5.tar.xz) = f19b6550d78939cc1ad11c5788e2a7293f7f886d037837cd1cf56ebcdf2b5ed2
+SIZE (lxqt/libsysstat-0.4.5.tar.xz) = 17744
diff --git a/sysutils/libsysstat/files/patch-cpustat.cpp b/sysutils/libsysstat/files/patch-cpustat.cpp
index 59df2dc3b1dc..0ede73fd5524 100644
--- a/sysutils/libsysstat/files/patch-cpustat.cpp
+++ b/sysutils/libsysstat/files/patch-cpustat.cpp
@@ -1,8 +1,13 @@
---- cpustat.cpp.orig	2020-11-03 14:45:02 UTC
+--- cpustat.cpp.orig	2021-04-07 06:58:34 UTC
 +++ cpustat.cpp
-@@ -27,11 +27,64 @@
+@@ -22,16 +22,65 @@
+ **  51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ **
+ ** END_COMMON_COPYRIGHT_HEADER */
+-
+-
  #include <unistd.h>
- 
+-
  #include "cpustat.h"
 +#ifdef HAVE_SYSCTL_H
 +extern "C"
@@ -48,24 +53,23 @@
 +}
 +
 +/* Frequence is in MHz */
-+ulong CpuStatPrivate::CurrentFreq(void)
++ulong CpuStatPrivate::CurrentFreq(QString mSource)
 +{
 +    ulong freq=0;
 +    size_t len = sizeof(freq);
-+
-+    if (sysctl(mib2,4,&freq, &len, NULL, 0) < 0) { // man cpufreq BUGS section all cores have the same frequency.
-+	perror("sysctl");
++    int i = mSource.mid(3).toInt();
++    if (sysctl(mib2[i],4,&freq, &len, NULL, 0) < 0) {
++    	perror("sysctl");
 +        return 0;
-+}
++    }
 +    else
 +        return freq;
-+
 +}
 +#endif
  CpuStatPrivate::CpuStatPrivate(CpuStat *parent)
      : BaseStatPrivate(parent)
      , mMonitoring(CpuStat::LoadAndFrequency)
-@@ -39,7 +92,13 @@ CpuStatPrivate::CpuStatPrivate(CpuStat *parent)
+@@ -39,7 +88,17 @@ CpuStatPrivate::CpuStatPrivate(CpuStat *parent)
      mSource = defaultSource();
  
      connect(mTimer, SIGNAL(timeout()), SLOT(timeout()));
@@ -75,7 +79,11 @@
 +    size_t alen=4;
 +    sysctlnametomib("kern.cp_times",mib0,&flen);
 +    sysctlnametomib("kern.cp_time",mib1,&flen);
-+    sysctlnametomib("dev.cpu.0.freq",mib2,&alen);
++    int ncpu = GetCpu();
++    for (int i=0;i<ncpu;i++) {
++    QString cpu_sysctl_name = QString::fromLatin1("dev.cpu.%1.freq").arg(i);
++    sysctlnametomib(cpu_sysctl_name.toStdString().c_str(),mib2[i],&alen);
++    }
 +#endif
      mUserHz = sysconf(_SC_CLK_TCK);
  
@@ -93,9 +101,11 @@
 +            /* The string returned by the dev.cpu.0.freq_levels sysctl
 +             * is a space separated list of MHz/milliwatts.
 +             */
-+            if (sysctlbyname("dev.cpu.0.freq_levels", buf, &len, NULL, 0) < 0)
-+                return;
++            if (source != QStringLiteral("cpu") && source.midRef(3).toInt() >-1) {
 +
++                if (sysctlbyname(QString::fromLatin1("dev.cpu.%1.freq_levels").arg(source.midRef(3).toInt()).toStdString().c_str(), buf, &len, NULL, 0) < 0)
++                    return;
++            }
 +            t = strndup(buf, len);
 +            if (t == NULL)
 +            {
@@ -120,19 +130,17 @@
 +                        if ((min == 0) || (res < min))
 +                            min = res;
 +                    }
-+               	if (res + 1 == max)
-+			max--;
-+		}
++               	}
 +
 +            }
 +
 +            free(t);
 +            mBounds[source] = qMakePair(min, max);
-+        #else
-     bool ok;
++#else
+     bool ok = false;
  
      uint min = readAllFile(qPrintable(QString::fromLatin1("/sys/devices/system/cpu/%1/cpufreq/scaling_min_freq").arg(source))).toUInt(&ok);
-@@ -56,12 +160,27 @@ void CpuStatPrivate::addSource(const QString &source)
+@@ -56,11 +160,35 @@ void CpuStatPrivate::addSource(const QString &source)
          if (ok)
              mBounds[source] = qMakePair(min, max);
      }
@@ -145,30 +153,38 @@
 +#ifdef HAVE_SYSCTL_H
 +    mBounds.clear();
 +    int cpu;
- 
++
 +    cpu = GetCpu();
-+    mSources.append(QStringLiteral("cpu")); // Linux has cpu in /proc/stat
++    mSources.append(QString::fromLatin1("cpu"));
 +    for (int i =0;i<cpu;i++)
 +    {
 +        mSources.append(QString::fromLatin1("cpu%1").arg(i));
-+
-+
-+
 +        addSource(QString::fromLatin1("cpu%1").arg(i));
 +    }
++    long max=0;
++    long min=0;
++    for (Bounds::ConstIterator I = mBounds.constBegin(); I != mBounds.constEnd(); ++I)
++    {
++        min += mBounds[I.key()].first;
++        max += mBounds[I.key()].second;
++
++    }
++
++    mBounds[QStringLiteral("cpu")] = qMakePair(min,max);
 +#else
-     const QStringList rows = readAllFile("/proc/stat").split(QLatin1Char('\n'), QString::SkipEmptyParts);
-     for (const QString &row : rows)
-     {
-@@ -99,6 +218,7 @@ void CpuStatPrivate::updateSources()
++
+ #if (QT_VERSION >= QT_VERSION_CHECK(5,15,0))
+     const QStringList rows = readAllFile("/proc/stat").split(QLatin1Char('\n'), Qt::SkipEmptyParts);
+ #else
+@@ -110,6 +238,7 @@ void CpuStatPrivate::updateSources()
                  addSource(QString::fromLatin1("cpu%1").arg(number));
          }
      }
 +#endif
  }
  
- CpuStatPrivate::~CpuStatPrivate()
-@@ -127,6 +247,107 @@ void CpuStatPrivate::recalculateMinMax()
+ CpuStatPrivate::~CpuStatPrivate() = default;
+@@ -136,6 +265,113 @@ void CpuStatPrivate::recalculateMinMax()
  
  void CpuStatPrivate::timeout()
  {
@@ -178,7 +194,9 @@
 +            {
 +                int cpuNumber=0;
 +                long *cp_times=0;
-+                if(mSource!=QLatin1String("cpu")) {
++
++                if(mSource!=QLatin1String("cpu"))
++                {
 +                    size_t cp_size = sizeof(long) * CPUSTATES * GetCpu();
 +                    cp_times = (long *)malloc(cp_size);
 +                    cpuNumber = mSource.midRef(3).toInt();
@@ -188,7 +206,10 @@
 +                    size_t cp_size = sizeof(long)*CPUSTATES;
 +                    cp_times = (long *)malloc(cp_size);
 +                    if(sysctl(mib1,2,cp_times,&cp_size,NULL,0) < 0)
++                    {
++                        perror("sysctl");
 +                        free(cp_times);
++                    }
 +                }
 +                Values current;
 +                current.user = static_cast<ulong>(cp_times[CP_USER+cpuNumber*CPUSTATES]);
@@ -197,49 +218,51 @@
 +                current.idle = static_cast<ulong>(cp_times[CP_IDLE+cpuNumber*CPUSTATES]);
 +                current.other = static_cast<ulong>(cp_times[CP_INTR+cpuNumber*CPUSTATES]);
 +                current.total = current.user + current.nice + current.system+current.idle+current.other;
-+
 +                float sumDelta = static_cast<float>(current.total - mPrevious.total);
 +                if ((mPrevious.total != 0) && ((sumDelta < mIntervalMin) || (sumDelta > mIntervalMax)))
 +                {
 +                    if (mMonitoring == CpuStat::LoadAndFrequency) 
-+		    {
++		            {
 +                        float freqRate = 1.0;
-+                        ulong freq = CurrentFreq();
++                        ulong freq = CurrentFreq(mSource);
 +				
++                        	if (mSource == QLatin1String("cpu")) {
++                                freq=0;
++                                for (Bounds::ConstIterator I = mBounds.constBegin(); I != mBounds.constEnd(); ++I) {
++                                    if (I.key() != QStringLiteral("cpu"))
++                                    {
++                                        freq += CurrentFreq(I.key());
++                                    }
++                                }
++                            }
++
 +                        if (freq > 0)
 +                       	{
-+			if (mSource == QLatin1String("cpu"))
-+				mSource = QLatin1String("cpu0");
-+			//do not report more than 100%
-+                	if (freq > mBounds[mSource].second) {
-+				freq = mBounds[mSource].second;
-+			}
 +                        freqRate = static_cast<float>(freq) / static_cast<float>(mBounds[mSource].second);
 +                        emit update(0.0, 0.0, 0.0, 0.0, static_cast<float>(freqRate), freq);
-+			}
-+	            }
-+                    else {
++                        }
++                    } else {
 +                        emit update(0.0, 0.0, 0.0, 0.0);
-+			 }
++			        }
 +                    mPrevious.clear();
-+                }
-+                else
-+
-+                {
-+                    if (mMonitoring == CpuStat::LoadAndFrequency)
++                } else {
++                        if (mMonitoring == CpuStat::LoadAndFrequency)
 +                    {
 +                        float freqRate = 1.0;
-+                        ulong freq = CurrentFreq();
++                        ulong freq = CurrentFreq(mSource);
 +				
 +                        if (freq > 0)
 +                        {
-+			if (mSource == QLatin1String("cpu"))
-+				mSource = QLatin1String("cpu0");
-+			//do not report more than 100%
-+                	if (freq > mBounds[mSource].second) {
-+				freq = mBounds[mSource].second;
-+			}
-+                        freqRate = static_cast<float>(freq) / static_cast<float>(mBounds[mSource].second);
++					        if (mSource == QLatin1String("cpu")) {
++                                freq=0;
++                                for (Bounds::ConstIterator I = mBounds.constBegin(); I != mBounds.constEnd(); ++I) {
++                                    if (I.key() != QStringLiteral("cpu"))
++                                    {
++                                        freq += CurrentFreq(I.key());
++                                    }
++                        }
++                        }
++		                freqRate = static_cast<float>(freq) / static_cast<float>(mBounds[mSource].second);
 +                           emit update(
 +                               static_cast<float>(current.user   - mPrevious.user  ) / sumDelta,
 +                               static_cast<float>(current.nice   - mPrevious.nice  ) / sumDelta,
@@ -247,8 +270,9 @@
 +                               static_cast<float>(current.other  - mPrevious.other ) / sumDelta,
 +                               static_cast<float>(freqRate),
 +                               freq);
-+                            }
++
 +                        }
++                    }
 +                        else
 +                        {
 +                            emit update(
@@ -258,17 +282,15 @@
 +                                static_cast<float>(current.other  - mPrevious.other ) / sumDelta);
 +                        }
 +
-+
 +                    mPrevious = current;
 +                }
-+
 +                free(cp_times);
 +            }
 +            else
 +            {
 +                ulong freq = 0;
 +
-+                freq = CurrentFreq();
++                freq = CurrentFreq(mSource);
 +                if (freq > 0)
 +                    emit update(freq);
 +            }
@@ -276,7 +298,7 @@
      if ( (mMonitoring == CpuStat::LoadOnly)
        || (mMonitoring == CpuStat::LoadAndFrequency) )
      {
-@@ -229,7 +450,7 @@ void CpuStatPrivate::timeout()
+@@ -246,7 +482,7 @@ void CpuStatPrivate::timeout()
                      mPrevious = current;
                  }
              }
@@ -285,7 +307,7 @@
      }
      else
      {
-@@ -261,6 +482,7 @@ void CpuStatPrivate::timeout()
+@@ -278,6 +514,7 @@ void CpuStatPrivate::timeout()
          }
          emit update(freq);
      }
diff --git a/sysutils/libsysstat/files/patch-cpustat__p.h b/sysutils/libsysstat/files/patch-cpustat__p.h
index 168c6959f30f..3c56a8038991 100644
--- a/sysutils/libsysstat/files/patch-cpustat__p.h
+++ b/sysutils/libsysstat/files/patch-cpustat__p.h
@@ -1,4 +1,4 @@
---- cpustat_p.h.orig	2020-11-03 14:45:02 UTC
+--- cpustat_p.h.orig	2021-04-07 06:58:34 UTC
 +++ cpustat_p.h
 @@ -27,6 +27,9 @@
  #ifndef LIBSYSSTAT__CPU_STAT__PRIVATE__INCLUDED
@@ -17,7 +17,7 @@
 +#ifdef HAVE_SYSCTL_H
 +    ulong minFreq(const QString &source) const;
 +    ulong maxFreq(const QString &source) const;
-+    ulong CurrentFreq(void);
++    ulong CurrentFreq(const QString);
 +
 +#else
      uint minFreq(const QString &source) const;
@@ -56,7 +56,7 @@
 +    typedef QMap<QString, QPair<ulong, ulong> > Bounds;
 +    int mib0[2];
 +    int mib1[2];
-+    int mib2[4];
++    int mib2[512][4];
 +#else
      typedef QMap<QString, QPair<uint, uint> > Bounds;
 +#endif
diff --git a/sysutils/libsysstat/files/patch-memstat.cpp b/sysutils/libsysstat/files/patch-memstat.cpp
index 90fde0fa79d4..92134a8acf19 100644
--- a/sysutils/libsysstat/files/patch-memstat.cpp
+++ b/sysutils/libsysstat/files/patch-memstat.cpp
@@ -1,4 +1,4 @@
---- memstat.cpp.orig	2019-01-24 21:43:32 UTC
+--- memstat.cpp.orig	2021-04-18 21:03:41 UTC
 +++ memstat.cpp
 @@ -26,10 +26,58 @@
  
@@ -59,7 +59,7 @@
  MemStatPrivate::MemStatPrivate(MemStat *parent)
      : BaseStatPrivate(parent)
  {
-@@ -52,7 +100,37 @@ void MemStatPrivate::timeout()
+@@ -50,7 +98,37 @@ void MemStatPrivate::timeout()
      qulonglong memCached = 0;
      qulonglong swapTotal = 0;
      qulonglong swapFree = 0;
@@ -94,10 +94,10 @@
 +        kvm_close(kd);
 +#endif
 +#ifndef HAVE_SYSCTL_H
-     const QStringList rows = readAllFile("/proc/meminfo").split(QLatin1Char('\n'), QString::SkipEmptyParts);
-     for (const QString &row : rows)
-     {
-@@ -73,7 +151,7 @@ void MemStatPrivate::timeout()
+ #if (QT_VERSION >= QT_VERSION_CHECK(5,15,0))
+     const QStringList rows = readAllFile("/proc/meminfo").split(QLatin1Char('\n'), Qt::SkipEmptyParts);
+ #else
+@@ -79,7 +157,7 @@ void MemStatPrivate::timeout()
          else if(tokens[0] == QLatin1String("SwapFree:"))
              swapFree = tokens[1].toULong();
      }
@@ -106,7 +106,7 @@
      if (mSource == QLatin1String("memory"))
      {
          if (memTotal)
-@@ -90,8 +168,11 @@ void MemStatPrivate::timeout()
+@@ -96,8 +174,11 @@ void MemStatPrivate::timeout()
      {
          if (swapTotal)
          {
diff --git a/sysutils/libsysstat/files/patch-netstat.cpp b/sysutils/libsysstat/files/patch-netstat.cpp
index c3a95336d6f9..f0f70a36fdd4 100644
--- a/sysutils/libsysstat/files/patch-netstat.cpp
+++ b/sysutils/libsysstat/files/patch-netstat.cpp
@@ -1,4 +1,4 @@
---- netstat.cpp.orig	2019-01-30 19:24:29 UTC
+--- netstat.cpp.orig	2021-04-18 21:04:00 UTC
 +++ netstat.cpp
 @@ -26,8 +26,23 @@
  
@@ -24,16 +24,15 @@
  namespace SysStat {
  
  NetStatPrivate::NetStatPrivate(NetStat *parent)
-@@ -37,7 +52,7 @@ NetStatPrivate::NetStatPrivate(NetStat *parent)
+@@ -37,6 +52,7 @@ NetStatPrivate::NetStatPrivate(NetStat *parent)
  
      connect(mTimer, SIGNAL(timeout()), SLOT(timeout()));
  
--
 +#ifndef HAVE_SYSCTL_H
-     QStringList rows(readAllFile("/proc/net/dev").split(QLatin1Char('\n'), QString::SkipEmptyParts));
  
-     rows.erase(rows.begin(), rows.begin() + 2);
-@@ -50,6 +65,29 @@ NetStatPrivate::NetStatPrivate(NetStat *parent)
+ #if (QT_VERSION >= QT_VERSION_CHECK(5,15,0))
+     QStringList rows(readAllFile("/proc/net/dev").split(QLatin1Char('\n'), Qt::SkipEmptyParts));
+@@ -58,12 +74,78 @@ NetStatPrivate::NetStatPrivate(NetStat *parent)
  
          mSources.append(tokens[0].trimmed());
      }
@@ -62,8 +61,7 @@
 +#endif
  }
  
- NetStatPrivate::~NetStatPrivate()
-@@ -58,6 +96,50 @@ NetStatPrivate::~NetStatPrivate()
+ NetStatPrivate::~NetStatPrivate() = default;
  
  void NetStatPrivate::timeout()
  {
@@ -110,11 +108,10 @@
 +
 +        }
 +    }
-+#else
-     QStringList rows(readAllFile("/proc/net/dev").split(QLatin1Char('\n'), QString::SkipEmptyParts));
- 
- 
-@@ -99,6 +181,7 @@ void NetStatPrivate::timeout()
+ #if (QT_VERSION >= QT_VERSION_CHECK(5,15,0))
+     QStringList rows(readAllFile("/proc/net/dev").split(QLatin1Char('\n'), Qt::SkipEmptyParts));
+ #else
+@@ -122,6 +204,7 @@ void NetStatPrivate::timeout()
  
          mPrevious[interfaceName] = current;
      }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202105081658.148GwvIu060022>