Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 21 Nov 2020 11:35:51 +0000 (UTC)
From:      Jesper Schmitz Mouridsen <jsm@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r555950 - in head/sysutils/libsysstat: . files
Message-ID:  <202011211135.0ALBZpwl096091@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jsm
Date: Sat Nov 21 11:35:51 2020
New Revision: 555950
URL: https://svnweb.freebsd.org/changeset/ports/555950

Log:
  sysutils/libsysstat Update to 0.4.4
  
    No upstream changes.
    Patch improvements:
    Report cpu freq also on small load.
    Never report more than 100% freq use.

Modified:
  head/sysutils/libsysstat/Makefile
  head/sysutils/libsysstat/distinfo
  head/sysutils/libsysstat/files/patch-cpustat.cpp
  head/sysutils/libsysstat/files/patch-cpustat.h
  head/sysutils/libsysstat/files/patch-cpustat__p.h

Modified: head/sysutils/libsysstat/Makefile
==============================================================================
--- head/sysutils/libsysstat/Makefile	Sat Nov 21 11:29:40 2020	(r555949)
+++ head/sysutils/libsysstat/Makefile	Sat Nov 21 11:35:51 2020	(r555950)
@@ -2,7 +2,7 @@
 # $FreeBSD$
 
 PORTNAME=	libsysstat
-PORTVERSION=	0.4.3
+PORTVERSION=	0.4.4
 CATEGORIES=	sysutils
 MASTER_SITES=	LXQT/${PORTNAME}
 

Modified: head/sysutils/libsysstat/distinfo
==============================================================================
--- head/sysutils/libsysstat/distinfo	Sat Nov 21 11:29:40 2020	(r555949)
+++ head/sysutils/libsysstat/distinfo	Sat Nov 21 11:35:51 2020	(r555950)
@@ -1,3 +1,3 @@
-TIMESTAMP = 1588434445
-SHA256 (lxqt/libsysstat-0.4.3.tar.xz) = 67dc786a4aca4b6ce142a2355ac6dd4c873c1e03f978676926500fffa73ebae8
-SIZE (lxqt/libsysstat-0.4.3.tar.xz) = 17520
+TIMESTAMP = 1605119504
+SHA256 (lxqt/libsysstat-0.4.4.tar.xz) = 3997d17692d2ea467d384517aedb8fcc4050f2f66114a1405d42cef0adaafa6b
+SIZE (lxqt/libsysstat-0.4.4.tar.xz) = 17532

Modified: head/sysutils/libsysstat/files/patch-cpustat.cpp
==============================================================================
--- head/sysutils/libsysstat/files/patch-cpustat.cpp	Sat Nov 21 11:29:40 2020	(r555949)
+++ head/sysutils/libsysstat/files/patch-cpustat.cpp	Sat Nov 21 11:35:51 2020	(r555950)
@@ -1,6 +1,6 @@
---- cpustat.cpp.orig	2019-01-24 21:43:32 UTC
+--- cpustat.cpp.orig	2020-11-03 14:45:02 UTC
 +++ cpustat.cpp
-@@ -27,11 +27,62 @@
+@@ -27,11 +27,64 @@
  #include <unistd.h>
  
  #include "cpustat.h"
@@ -48,13 +48,15 @@
 +}
 +
 +/* Frequence is in MHz */
-+ulong CurrentFreq(void)
++ulong CpuStatPrivate::CurrentFreq(void)
 +{
 +    ulong freq=0;
 +    size_t len = sizeof(freq);
 +
-+    if (sysctlbyname("dev.cpu.0.freq", &freq, &len, NULL, 0) < 0) // man cpufreq BUGS section all cores have the same frequency.
++    if (sysctl(mib2,4,&freq, &len, NULL, 0) < 0) { // man cpufreq BUGS section all cores have the same frequency.
++	perror("sysctl");
 +        return 0;
++}
 +    else
 +        return freq;
 +
@@ -63,20 +65,22 @@
  CpuStatPrivate::CpuStatPrivate(CpuStat *parent)
      : BaseStatPrivate(parent)
      , mMonitoring(CpuStat::LoadAndFrequency)
-@@ -39,7 +90,11 @@ CpuStatPrivate::CpuStatPrivate(CpuStat *parent)
+@@ -39,7 +92,13 @@ CpuStatPrivate::CpuStatPrivate(CpuStat *parent)
      mSource = defaultSource();
  
      connect(mTimer, SIGNAL(timeout()), SLOT(timeout()));
 -
 +#ifdef HAVE_SYSCTL_H
 +    size_t flen=2;
++    size_t alen=4;
 +    sysctlnametomib("kern.cp_times",mib0,&flen);
 +    sysctlnametomib("kern.cp_time",mib1,&flen);
++    sysctlnametomib("dev.cpu.0.freq",mib2,&alen);
 +#endif
      mUserHz = sysconf(_SC_CLK_TCK);
  
      updateSources();
-@@ -47,6 +102,49 @@ CpuStatPrivate::CpuStatPrivate(CpuStat *parent)
+@@ -47,6 +106,51 @@ CpuStatPrivate::CpuStatPrivate(CpuStat *parent)
  
  void CpuStatPrivate::addSource(const QString &source)
  {
@@ -98,7 +102,6 @@
 +                free(t);
 +                return;
 +            }
-+
 +            while ((tokens = strsep(&t, " ")) != NULL)
 +            {
 +                char *freq;
@@ -117,7 +120,10 @@
 +                        if ((min == 0) || (res < min))
 +                            min = res;
 +                    }
-+                }
++               	if (res + 1 == max)
++			max--;
++		}
++
 +            }
 +
 +            free(t);
@@ -126,7 +132,7 @@
      bool ok;
  
      uint min = readAllFile(qPrintable(QString::fromLatin1("/sys/devices/system/cpu/%1/cpufreq/scaling_min_freq").arg(source))).toUInt(&ok);
-@@ -56,12 +154,27 @@ void CpuStatPrivate::addSource(const QString &source)
+@@ -56,12 +160,27 @@ void CpuStatPrivate::addSource(const QString &source)
          if (ok)
              mBounds[source] = qMakePair(min, max);
      }
@@ -154,7 +160,7 @@
      const QStringList rows = readAllFile("/proc/stat").split(QLatin1Char('\n'), QString::SkipEmptyParts);
      for (const QString &row : rows)
      {
-@@ -99,6 +212,7 @@ void CpuStatPrivate::updateSources()
+@@ -99,6 +218,7 @@ void CpuStatPrivate::updateSources()
                  addSource(QString::fromLatin1("cpu%1").arg(number));
          }
      }
@@ -162,7 +168,7 @@
  }
  
  CpuStatPrivate::~CpuStatPrivate()
-@@ -127,6 +241,88 @@ void CpuStatPrivate::recalculateMinMax()
+@@ -127,6 +247,107 @@ void CpuStatPrivate::recalculateMinMax()
  
  void CpuStatPrivate::timeout()
  {
@@ -193,28 +199,47 @@
 +                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)
-+                        emit update(0.0, 0.0, 0.0, 0.0, 0.0, 0);
-+                    else
++                    if (mMonitoring == CpuStat::LoadAndFrequency) 
++		    {
++                        float freqRate = 1.0;
++                        ulong freq = CurrentFreq();
++				
++                        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 {
 +                        emit update(0.0, 0.0, 0.0, 0.0);
-+
++			 }
 +                    mPrevious.clear();
 +                }
 +                else
++
 +                {
 +                    if (mMonitoring == CpuStat::LoadAndFrequency)
 +                    {
 +                        float freqRate = 1.0;
 +                        ulong freq = CurrentFreq();
++				
 +                        if (freq > 0)
 +                        {
-+                            if(mSource==QLatin1String("cpu"))
-+                                freqRate = static_cast<float>(freq) / static_cast<float>(mBounds[QStringLiteral("cpu0")].second);// use max cpu0 for this case
-+                            else
-+                                freqRate = static_cast<float>(freq) / static_cast<float>(mBounds[mSource].second);
++			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(
 +                               static_cast<float>(current.user   - mPrevious.user  ) / sumDelta,
 +                               static_cast<float>(current.nice   - mPrevious.nice  ) / sumDelta,
@@ -251,7 +276,16 @@
      if ( (mMonitoring == CpuStat::LoadOnly)
        || (mMonitoring == CpuStat::LoadAndFrequency) )
      {
-@@ -261,6 +457,7 @@ void CpuStatPrivate::timeout()
+@@ -229,7 +450,7 @@ void CpuStatPrivate::timeout()
+                     mPrevious = current;
+                 }
+             }
+-        }
++        //}
+     }
+     else
+     {
+@@ -261,6 +482,7 @@ void CpuStatPrivate::timeout()
          }
          emit update(freq);
      }

Modified: head/sysutils/libsysstat/files/patch-cpustat.h
==============================================================================
--- head/sysutils/libsysstat/files/patch-cpustat.h	Sat Nov 21 11:29:40 2020	(r555949)
+++ head/sysutils/libsysstat/files/patch-cpustat.h	Sat Nov 21 11:35:51 2020	(r555950)
@@ -1,6 +1,6 @@
---- cpustat.h.orig	2019-01-30 19:27:42 UTC
+--- cpustat.h.orig	2020-11-03 14:45:02 UTC
 +++ cpustat.h
-@@ -27,14 +27,20 @@
+@@ -27,14 +27,19 @@
  #ifndef LIBSYSSTAT__CPU_STAT__INCLUDED
  #define LIBSYSSTAT__CPU_STAT__INCLUDED
  
@@ -18,8 +18,15 @@
 +#ifdef HAVE_SYSCTL_H
 +    char *GetFirstFragment(char *string, const char *delim);
 +    int GetCpu(void);
-+    ulong CurrentFreq(void);
 +#endif
  class CpuStatPrivate;
  
  class SYSSTATSHARED_EXPORT CpuStat : public BaseStat
+@@ -54,7 +59,6 @@ class SYSSTATSHARED_EXPORT CpuStat : public BaseStat (
+ 
+     uint minFreq(const QString &source) const;
+     uint maxFreq(const QString &source) const;
+-
+ signals:
+     void update(float user, float nice, float system, float other, float frequencyRate, uint frequency);
+     void update(float user, float nice, float system, float other);

Modified: head/sysutils/libsysstat/files/patch-cpustat__p.h
==============================================================================
--- head/sysutils/libsysstat/files/patch-cpustat__p.h	Sat Nov 21 11:29:40 2020	(r555949)
+++ head/sysutils/libsysstat/files/patch-cpustat__p.h	Sat Nov 21 11:35:51 2020	(r555950)
@@ -1,4 +1,4 @@
---- cpustat_p.h.orig	2019-01-30 19:24:29 UTC
+--- cpustat_p.h.orig	2020-11-03 14:45:02 UTC
 +++ cpustat_p.h
 @@ -27,6 +27,9 @@
  #ifndef LIBSYSSTAT__CPU_STAT__PRIVATE__INCLUDED
@@ -10,13 +10,15 @@
  
  #include <QtCore/QObject>
  #include <QtCore/QtGlobal>
-@@ -52,8 +55,13 @@ class CpuStatPrivate : public BaseStatPrivate (public)
+@@ -52,8 +55,15 @@ class CpuStatPrivate : public BaseStatPrivate (public)
      CpuStat::Monitoring monitoring() const;
      void setMonitoring(CpuStat::Monitoring value);
  
 +#ifdef HAVE_SYSCTL_H
 +    ulong minFreq(const QString &source) const;
 +    ulong maxFreq(const QString &source) const;
++    ulong CurrentFreq(void);
++
 +#else
      uint minFreq(const QString &source) const;
      uint maxFreq(const QString &source) const;
@@ -24,7 +26,7 @@
  
  signals:
      void update(float user, float nice, float system, float other);
-@@ -74,12 +82,21 @@ private slots: (private)
+@@ -74,12 +84,21 @@ private slots: (private)
      {
          Values();
  
@@ -46,7 +48,7 @@
  
          void sum();
  
-@@ -89,7 +106,13 @@ private slots: (private)
+@@ -89,7 +108,14 @@ private slots: (private)
  
      CpuStat::Monitoring mMonitoring;
  
@@ -54,6 +56,7 @@
 +    typedef QMap<QString, QPair<ulong, ulong> > Bounds;
 +    int mib0[2];
 +    int mib1[2];
++    int mib2[4];
 +#else
      typedef QMap<QString, QPair<uint, uint> > Bounds;
 +#endif



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