From: Sami Kerola <kerolasa@iki.fi>
To: util-linux@vger.kernel.org
Cc: kerolasa@iki.fi
Subject: [PATCH 02/19] lscpu: add max MHz value to make cpu governor effects more visible
Date: Sun, 2 Jun 2013 18:51:08 +0100 [thread overview]
Message-ID: <1370195485-27907-3-git-send-email-kerolasa@iki.fi> (raw)
In-Reply-To: <1370195485-27907-1-git-send-email-kerolasa@iki.fi>
The existing 'CPU MHz' is usually dynamic value, which CPU governor
changes up on needs of CPU demand. Assuming lscpu is used to gather
information to a hardware inventory the dynamic value is misleading. For
inventing the maximum MHz value is more sensible.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
sys-utils/lscpu.c | 26 +++++++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)
diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c
index dde227b..fbaaa31 100644
--- a/sys-utils/lscpu.c
+++ b/sys-utils/lscpu.c
@@ -148,6 +148,7 @@ struct lscpu_desc {
int hyper; /* hypervisor vendor ID */
int virtype; /* VIRT_PARA|FULL|NONE ? */
char *mhz;
+ char **mmhz; /* maximum mega hertz */
char *stepping;
char *bogomips;
char *flags;
@@ -230,6 +231,7 @@ enum {
COL_ADDRESS,
COL_CONFIGURED,
COL_ONLINE,
+ COL_MMHZ,
};
/* column description
@@ -252,7 +254,8 @@ static struct lscpu_coldesc coldescs[] =
[COL_POLARIZATION] = { "POLARIZATION", N_("CPU dispatching mode on virtual hardware") },
[COL_ADDRESS] = { "ADDRESS", N_("physical address of a CPU") },
[COL_CONFIGURED] = { "CONFIGURED", N_("shows if the hypervisor has allocated the CPU") },
- [COL_ONLINE] = { "ONLINE", N_("shows if Linux currently makes use of the CPU") }
+ [COL_ONLINE] = { "ONLINE", N_("shows if Linux currently makes use of the CPU") },
+ [COL_MMHZ] = { "MMHZ", N_("shows the maximum mhz of the CPU") }
};
static int
@@ -777,6 +780,18 @@ read_configured(struct lscpu_desc *desc, int num)
desc->configured[num] = path_read_s32(_PATH_SYS_CPU "/cpu%d/configure", num);
}
+static void
+read_max_mhz(struct lscpu_desc *desc, int num)
+{
+ if (!path_exist(_PATH_SYS_CPU "/cpu%d/cpufreq/cpuinfo_max_freq", num))
+ return;
+ if (!desc->mmhz)
+ desc->mmhz = xcalloc(desc->ncpuspos, sizeof(char *));
+ xasprintf(&(desc->mmhz[num]), "%.4f",
+ (float)path_read_s32(_PATH_SYS_CPU
+ "/cpu%d/cpufreq/cpuinfo_max_freq", num) / 1000);
+}
+
static int
cachecmp(const void *a, const void *b)
{
@@ -965,6 +980,10 @@ get_cell_data(struct lscpu_desc *desc, int cpu, int col,
snprintf(buf, bufsz,
is_cpu_online(desc, cpu) ? _("yes") : _("no"));
break;
+ case COL_MMHZ:
+ if (desc->mmhz)
+ xstrncpy(buf, desc->mmhz[cpu], bufsz);
+ break;
}
return buf;
}
@@ -1272,6 +1291,8 @@ print_summary(struct lscpu_desc *desc, struct lscpu_modifier *mod)
print_s(_("Stepping:"), desc->stepping);
if (desc->mhz)
print_s(_("CPU MHz:"), desc->mhz);
+ if (desc->mmhz)
+ print_s(_("CPU max MHz:"), desc->mmhz[0]);
if (desc->bogomips)
print_s(_("BogoMIPS:"), desc->bogomips);
if (desc->virtflag) {
@@ -1439,6 +1460,7 @@ int main(int argc, char *argv[])
read_polarization(desc, i);
read_address(desc, i);
read_configured(desc, i);
+ read_max_mhz(desc, i);
}
if (desc->caches)
@@ -1485,6 +1507,8 @@ int main(int argc, char *argv[])
columns[ncolumns++] = COL_POLARIZATION;
if (desc->addresses)
columns[ncolumns++] = COL_ADDRESS;
+ if (desc->mmhz)
+ columns[ncolumns++] = COL_MMHZ;
}
print_readable(desc, columns, ncolumns, mod);
break;
--
1.8.3
next prev parent reply other threads:[~2013-06-02 17:51 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-02 17:51 [PATCH 00/19] pull: various clean ups and couple bug fixes Sami Kerola
2013-06-02 17:51 ` [PATCH 01/19] lib: remove unused code Sami Kerola
2013-06-02 17:51 ` Sami Kerola [this message]
2013-06-02 17:51 ` [PATCH 03/19] docs: add lscpu max mhz to manual and bash completion Sami Kerola
2013-06-02 17:51 ` [PATCH 04/19] sfdisk: use libc error printing function, and symbolic exit values Sami Kerola
2013-06-07 10:20 ` Karel Zak
2013-06-02 17:51 ` [PATCH 05/19] sfdisk: clean up usage() functions Sami Kerola
2013-06-02 17:51 ` [PATCH 06/19] sfdisk: use program_invocation_short_name to determine program name Sami Kerola
2013-06-02 17:51 ` [PATCH 07/19] docs: correct sfdisk --activate instructions Sami Kerola
2013-06-02 17:51 ` [PATCH 08/19] sfdisk: remove --unhide and related functions Sami Kerola
2013-06-02 17:51 ` [PATCH 09/19] sfdisk: replace my_warn() with warnx() Sami Kerola
2013-06-02 17:51 ` [PATCH 10/19] rev: stop adding new line at the end when input does not have it Sami Kerola
2013-06-02 17:51 ` [PATCH 11/19] rev: simplify new line detection and impossible test Sami Kerola
2013-06-02 17:51 ` [PATCH 12/19] rev: reduce stream checking when closing read-only file descriptor Sami Kerola
2013-06-02 17:51 ` [PATCH 13/19] dmesg: make time format parsing to use enum bit field Sami Kerola
2013-06-03 8:45 ` Karel Zak
2013-06-02 17:51 ` [PATCH 14/19] dmesg: add --time-format option Sami Kerola
2013-06-02 17:51 ` [PATCH 15/19] dmesg: add iso-8601 time format Sami Kerola
2013-06-02 17:51 ` [PATCH 16/19] docs: add --time-format option and ISO-8601 format to manual Sami Kerola
2013-06-02 17:51 ` [PATCH 17/19] dmesg: make usage() a little bit shorter Sami Kerola
2013-06-03 8:56 ` Karel Zak
2013-06-02 17:51 ` [PATCH 18/19] dmesg: more deterministic boot time detection Sami Kerola
2013-06-03 9:35 ` Karel Zak
2013-06-02 17:51 ` [PATCH 19/19] cal: fix few type mismatches Sami Kerola
2013-06-07 10:28 ` [PATCH 00/19] pull: various clean ups and couple bug fixes Karel Zak
2013-06-07 15:45 ` Sami Kerola
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1370195485-27907-3-git-send-email-kerolasa@iki.fi \
--to=kerolasa@iki.fi \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox