Skip to content

Commit

Permalink
Added CPU average clock frequency statistics to sar and sadc.
Browse files Browse the repository at this point in the history
This patch adds a new option to sar (-m FREQ) that displays
the following field: wghMHz.
For this option to work, the cpufreq-stats driver must be compiled
in the kernel, as we need to read the "time-in-state" file in /sys.
sadc and sadf have also been updated to take into account this new field.
DTD and XSD documents have been updated.
The sar manual page has been updated.

Mail from Zhen Zhang (08/09/2010) <[email protected]>
Hi ,

The current stable and development systat collect cpu frequency data
from /proc/cpuinfo, but currently cpuinfo "cpu Mhz" field report the
instant cpu frequency . From a system administrator point of view
however ,the preferred metric is  the average cpu frequency at
reporting interval . The average frequency can be obtain from
/sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state.

Will  the sysstat switch to average cpu frequency at next development version?

Thanks

Mail from Zhen Zhang (11/09/2010) <[email protected]>
I want to measure the average cpu frequency of a machine which
probably is capable of dynamic adjusting frequency (DVFS). The average
of cpu frequency is an important metric to evaluate the power
consumption of a machine, and how hard the machine is working to serve
the requests. DVFS capability is starting to get wide adoption in the
server domain e.g. in recent Xeon.

The /proc/cpuinfo interface only record the instant cpu frequency
,however linux kernel or user frequncy governor can adjust cpu
frequency frequently , e.g. for default ondemand governor the
frequency is 10ms . Such interval is way to small comparing to usual
sysstat interval e.g 5min. So an accumulated value is needed .

cpufreq-stats  is a driver ( It seems had entered into kernel 2.6.11,
and its document is available at kernel 2.6.12,
http:https://lxr.linux.no/#linux+v2.6.12/Documentation/cpu-freq/cpufreq-stats.txt).
For recent ubuntu , cpufreq-stats and cpufreq driver is built into
kernel. The average frequency can be fetch as follow

:/sys/devices/system/cpu/cpu0/cpufreq/stats$ cat time_in_state
2001000 60803
2000000 5734
1600000 5996
1200000 8819
800000 205211

each line define a pair of frequency and its accumulated ticks since
reboot. sysstat can sample it and take the difference as the
accumulated ticks at the sampling interval , and calculated weighted
average cpu frequency.

The  cpufreq-stats do have some pitfall  which is addressed in patch
https://patchwork.kernel.org/patch/72488/).

Nevertheless its current form is already quite useful, I suggest
sysstat to utilize if available , and fall back to /proc/cpuinfo if
not.

Hopes to hear good news:)

thanks
  • Loading branch information
sysstat committed Oct 24, 2010
1 parent 892b1cd commit 5b74795
Show file tree
Hide file tree
Showing 19 changed files with 932 additions and 454 deletions.
4 changes: 3 additions & 1 deletion CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ xxxx/xx/xx: Version 9.1.6 - Sebastien Godard (sysstat <at> orange.fr)
* Added a new magical value for each activity in file.
A format change can now hit only one activity instead of
the whole file.
* Added hugepages utilization statistics to sar.
* Added CPU average clock frequency statistics to sar and sadc.
* Added hugepages utilization statistics to sar and sadc.
* [Ivana Varekova]: Moved manual pages to $prefix/share/man
instead of $prefix/man.
* [Ivana Varekova]: Fixed configure's --disable-man-group option.
Expand All @@ -15,6 +16,7 @@ xxxx/xx/xx: Version 9.1.6 - Sebastien Godard (sysstat <at> orange.fr)
* sar manual page updated.
* DTD and XSD documents updated.
* Made sysstat git aware.
* CREDITS file updated.

2010/09/12: Version 9.1.5 - Sebastien Godard (sysstat <at> orange.fr)
* Added voltage inputs statistics to sar and sadc.
Expand Down
1 change: 1 addition & 0 deletions CREDITS
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ I would also thank the following people for their hints or bug reports
Urban Widmark <urban@sve[...].se>
Yu Yongcong <yuyc@cn.[...].com>
Peter Zaitsev <pz@spy[...].ru>
Zhen Zhang <furykerry@gma[...].com>

--
Sebastien Godard (sysstat <at> orange.fr) is the author and the current
Expand Down
35 changes: 33 additions & 2 deletions activity.c
Original file line number Diff line number Diff line change
Expand Up @@ -1006,7 +1006,7 @@ struct activity pwr_temp_act = {
/* Voltage inputs */
struct activity pwr_in_act = {
.id = A_PWR_IN,
.options = AO_CLOSE_MARKUP,
.options = AO_NULL,
.magic = ACTIVITY_MAGIC_BASE,
#ifdef SOURCE_SADC
.f_count = wrap_get_in_nr,
Expand Down Expand Up @@ -1061,6 +1061,36 @@ struct activity huge_act = {
.bitmap = NULL
};

/* CPU weighted frequency */
struct activity pwr_wghfreq_act = {
.id = A_PWR_WGHFREQ,
.options = AO_CLOSE_MARKUP,
.magic = ACTIVITY_MAGIC_BASE,
#ifdef SOURCE_SADC
.f_count = wrap_get_cpu_nr,
.f_count2 = wrap_get_freq_nr,
.f_read = wrap_read_time_in_state,
#endif
#ifdef SOURCE_SAR
.f_print = print_pwr_wghfreq_stats,
.f_print_avg = print_pwr_wghfreq_stats,
#endif
#ifdef SOURCE_SADF
.f_render = render_pwr_wghfreq_stats,
.f_xml_print = xml_print_pwr_wghfreq_stats,
.hdr_line = "CPU;wghMHz",
.name = "A_PWR_WGHFREQ",
#endif
.nr = -1,
.nr2 = 1,
.fsize = STATS_PWR_WGHFREQ_SIZE,
.msize = STATS_PWR_WGHFREQ_SIZE,
.opt_flags = 0,
.buf = {NULL, NULL, NULL},
.bitmap = &cpu_bitmap
};


/*
* Array of activities.
*/
Expand Down Expand Up @@ -1098,5 +1128,6 @@ struct activity *act[NR_ACT] = {
&pwr_fan_act,
&pwr_temp_act,
&pwr_in_act,
&huge_act
&huge_act,
&pwr_wghfreq_act
};
21 changes: 11 additions & 10 deletions common.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,17 @@
#define K_UTC "UTC"

/* Files */
#define STAT "/proc/stat"
#define UPTIME "/proc/uptime"
#define PPARTITIONS "/proc/partitions"
#define DISKSTATS "/proc/diskstats"
#define INTERRUPTS "/proc/interrupts"
#define MEMINFO "/proc/meminfo"
#define SYSFS_BLOCK "/sys/block"
#define SYSFS_DEVCPU "/sys/devices/system/cpu"
#define S_STAT "stat"
#define DEVMAP_DIR "/dev/mapper"
#define STAT "/proc/stat"
#define UPTIME "/proc/uptime"
#define PPARTITIONS "/proc/partitions"
#define DISKSTATS "/proc/diskstats"
#define INTERRUPTS "/proc/interrupts"
#define MEMINFO "/proc/meminfo"
#define SYSFS_BLOCK "/sys/block"
#define SYSFS_DEVCPU "/sys/devices/system/cpu"
#define SYSFS_TIME_IN_STATE "cpufreq/stats/time_in_state"
#define S_STAT "stat"
#define DEVMAP_DIR "/dev/mapper"

#define MAX_FILE_LEN 256
#define MAX_PF_NAME 1024
Expand Down
19 changes: 16 additions & 3 deletions man/sar.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH SAR 1 "SEPTEMBER 2010" Linux "Linux User's Manual" -*- nroff -*-
.TH SAR 1 "OCTOBER 2010" Linux "Linux User's Manual" -*- nroff -*-
.SH NAME
sar \- Collect, report, or save system activity information.
.SH SYNOPSIS
Expand Down Expand Up @@ -374,19 +374,20 @@ Note that these statistics depend on sadc option "-S POWER" to be collected.
Possible keywords are
.BR CPU ,
.BR FAN ,
.BR FREQ ,
.BR IN
and
.BR TEMP .

With the
.B CPU
keyword, statistics about CPU clock frequency are reported.
keyword, statistics about CPU are reported.
The following value is displayed:

.B MHz
.RS
.RS
CPU clock frequency in MHz.
Instantaneous CPU clock frequency in MHz.
.RE

With the
Expand All @@ -410,6 +411,18 @@ and its low limit (fan_min).
Sensor device name.
.RE

With the
.B FREQ
keyword, statistics about CPU clock frequency are reported.
The following value is displayed:

.B wghMHz
.RS
Weighted average CPU clock frequency in MHz.
Note that the cpufreq-stats driver must be compiled in the
kernel for this option to work.
.RE

With the
.B IN
keyword, statistics about voltage inputs are reported.
Expand Down
62 changes: 34 additions & 28 deletions nls/sysstat.pot
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: sysstat <at> orange.fr\n"
"POT-Creation-Date: 2010-09-18 15:03+0200\n"
"POT-Creation-Date: 2010-10-23 15:32+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand All @@ -34,8 +34,8 @@ msgstr ""
msgid "sysstat version %s\n"
msgstr ""

#: ioconf.c:490 rd_stats.c:72 rd_stats.c:1848 sa_common.c:1052 sadc.c:593
#: sadc.c:602 sadc.c:662
#: ioconf.c:490 rd_stats.c:72 rd_stats.c:2145 sa_common.c:1057 sadc.c:607
#: sadc.c:616 sadc.c:676
#, c-format
msgid "Cannot open %s: %s\n"
msgstr ""
Expand Down Expand Up @@ -69,7 +69,7 @@ msgid ""
"ALL } ] [ -V ]\n"
msgstr ""

#: mpstat.c:530 pidstat.c:1806 sar.c:361
#: mpstat.c:530 pidstat.c:1806 sar.c:362
msgid "Average:"
msgstr ""

Expand All @@ -87,12 +87,12 @@ msgid ""
"[ -p { <pid> [,...] | SELF | ALL } ] [ -T { TASK | CHILD | ALL } ]\n"
msgstr ""

#: pidstat.c:199 sar.c:979
#: pidstat.c:199 sar.c:989
#, c-format
msgid "Requested activities not available\n"
msgstr ""

#: rd_stats.c:1894
#: rd_stats.c:2191
#, c-format
msgid "Cannot handle so many processors!\n"
msgstr ""
Expand Down Expand Up @@ -123,7 +123,7 @@ msgid ""
"Current sysstat version can no longer read the format of this file (%#x)\n"
msgstr ""

#: sa_common.c:1135
#: sa_common.c:1164
#, c-format
msgid "Requested activities not available in file %s\n"
msgstr ""
Expand All @@ -141,17 +141,17 @@ msgid ""
"[ -S { INT | DISK | IPV6 | POWER | SNMP | XDISK | ALL | XALL } ]\n"
msgstr ""

#: sadc.c:206
#: sadc.c:207
#, c-format
msgid "Cannot write data to system activity file: %s\n"
msgstr ""

#: sadc.c:480
#: sadc.c:494
#, c-format
msgid "Cannot write system activity file header: %s\n"
msgstr ""

#: sadc.c:756
#: sadc.c:775
#, c-format
msgid "Cannot append data to that file (%s)\n"
msgstr ""
Expand Down Expand Up @@ -190,6 +190,11 @@ msgstr ""
msgid "List of activities:\n"
msgstr ""

#: sadf.c:638
#, c-format
msgid "\t[Unknown activity format]"
msgstr ""

#: sar.c:104
#, c-format
msgid ""
Expand Down Expand Up @@ -240,13 +245,14 @@ msgid ""
"\t-m { <keyword> [,...] | ALL }\n"
"\t\tPower management statistics\n"
"\t\tKeywords are:\n"
"\t\tCPU\tCPU clock frequency\n"
"\t\tCPU\tCPU instantaneous clock frequency\n"
"\t\tFAN\tFans speed\n"
"\t\tFREQ\tCPU average clock frequency\n"
"\t\tIN\tVoltage inputs\n"
"\t\tTEMP\tDevices temperature\n"
msgstr ""

#: sar.c:140
#: sar.c:141
#, c-format
msgid ""
"\t-n { <keyword> [,...] | ALL }\n"
Expand All @@ -272,84 +278,84 @@ msgid ""
"\t\tUDP6\tUDP traffic\t(v6)\n"
msgstr ""

#: sar.c:161
#: sar.c:162
#, c-format
msgid "\t-q\tQueue length and load average statistics\n"
msgstr ""

#: sar.c:162
#: sar.c:163
#, c-format
msgid "\t-r\tMemory utilization statistics\n"
msgstr ""

#: sar.c:163
#: sar.c:164
#, c-format
msgid "\t-R\tMemory statistics\n"
msgstr ""

#: sar.c:164
#: sar.c:165
#, c-format
msgid "\t-S\tSwap space utilization statistics\n"
msgstr ""

#: sar.c:165
#: sar.c:166
#, c-format
msgid ""
"\t-u [ ALL ]\n"
"\t\tCPU utilization statistics\n"
msgstr ""

#: sar.c:167
#: sar.c:168
#, c-format
msgid "\t-v\tKernel table statistics\n"
msgstr ""

#: sar.c:168
#: sar.c:169
#, c-format
msgid "\t-w\tTask creation and system switching statistics\n"
msgstr ""

#: sar.c:169
#: sar.c:170
#, c-format
msgid "\t-W\tSwapping statistics\n"
msgstr ""

#: sar.c:170
#: sar.c:171
#, c-format
msgid "\t-y\tTTY device statistics\n"
msgstr ""

#: sar.c:213
#: sar.c:214
#, c-format
msgid "End of data collecting unexpected\n"
msgstr ""

#: sar.c:781
#: sar.c:783
#, c-format
msgid "Invalid data format\n"
msgstr ""

#: sar.c:785
#: sar.c:787
#, c-format
msgid "Using a wrong data collector from a different sysstat version\n"
msgstr ""

#: sar.c:805
#: sar.c:811
#, c-format
msgid "Inconsistent input data\n"
msgstr ""

#: sar.c:1226
#: sar.c:1236
#, c-format
msgid "-f and -o options are mutually exclusive\n"
msgstr ""

#: sar.c:1232
#: sar.c:1242
#, c-format
msgid "Not reading from a system activity file (use -f option)\n"
msgstr ""

#: sar.c:1333
#: sar.c:1343
#, c-format
msgid "Cannot find the data collector (%s)\n"
msgstr ""

0 comments on commit 5b74795

Please sign in to comment.