aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Polacek <mmpolacek@gmail.com>2010-07-30 16:43:11 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2010-07-30 16:43:11 +0200
commit85a359afab4743e68977086bddac301ef0675ee1 (patch)
treeebd70751245449a64e507968dbe99a90b04a0ce3
parent3fb4a5e6d86e52014502391d8dca25befa4ff9b4 (diff)
downloadbusybox-85a359afab4743e68977086bddac301ef0675ee1.tar.gz
mpstat: do not use /sys to get number of CPUs. /proc should be ok.
function old new delta get_cpu_nr - 137 +137 mpstat_main 1140 1131 -9 get_proc_cpu_nr 137 - -137 get_sys_cpu_nr 178 - -178 ------------------------------------------------------------------------------ (add/remove: 1/2 grow/shrink: 0/1 up/down: 137/-324) Total: -187 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--procps/mpstat.c49
1 files changed, 1 insertions, 48 deletions
diff --git a/procps/mpstat.c b/procps/mpstat.c
index 1199b98dd..7610a68fb 100644
--- a/procps/mpstat.c
+++ b/procps/mpstat.c
@@ -816,45 +816,11 @@ static void print_header(struct tm *t)
}
/*
- * Get number of processors in /sys
- */
-static int get_sys_cpu_nr(void)
-{
- DIR *dir;
- struct dirent *d;
- struct stat buf;
- char line[MAX_PF_NAME];
- int proc_nr = 0;
-
- dir = opendir(SYSFS_DEVCPU);
- if (!dir)
- return 0; /* /sys not mounted */
-
- /* Get current file entry */
- while ((d = readdir(dir)) != NULL) {
- if (starts_with_cpu(d->d_name) && isdigit(d->d_name[3])) {
- snprintf(line, MAX_PF_NAME, "%s/%s", SYSFS_DEVCPU,
- d->d_name);
- line[MAX_PF_NAME - 1] = '\0';
- /* Get information about file */
- if (stat(line, &buf) < 0)
- continue;
- /* If found 'cpuN', we have one more processor */
- if (S_ISDIR(buf.st_mode))
- proc_nr++;
- }
- }
-
- closedir(dir);
- return proc_nr;
-}
-
-/*
* Get number of processors in /proc/stat
* Return value '0' means one CPU and non SMP kernel.
* Otherwise N means N processor(s) and SMP kernel.
*/
-static int get_proc_cpu_nr(void)
+static int get_cpu_nr(void)
{
FILE *fp;
char line[256];
@@ -881,19 +847,6 @@ static int get_proc_cpu_nr(void)
return proc_nr + 1;
}
-static int get_cpu_nr(void)
-{
- int n;
-
- /* Try to use /sys, if possible */
- n = get_sys_cpu_nr();
- if (n == 0)
- /* Otherwise use /proc/stat */
- n = get_proc_cpu_nr();
-
- return n;
-}
-
/*
* Get number of interrupts available per processor
*/