diff options
Diffstat (limited to 'procps/mpstat.c')
-rw-r--r-- | procps/mpstat.c | 40 |
1 files changed, 1 insertions, 39 deletions
diff --git a/procps/mpstat.c b/procps/mpstat.c index 85cbb45db..b4520cb55 100644 --- a/procps/mpstat.c +++ b/procps/mpstat.c | |||
@@ -119,12 +119,6 @@ enum { | |||
119 | }; | 119 | }; |
120 | 120 | ||
121 | 121 | ||
122 | /* Does str start with "cpu"? */ | ||
123 | static int starts_with_cpu(const char *str) | ||
124 | { | ||
125 | return !((str[0] - 'c') | (str[1] - 'p') | (str[2] - 'u')); | ||
126 | } | ||
127 | |||
128 | /* Is option on? */ | 122 | /* Is option on? */ |
129 | static ALWAYS_INLINE int display_opt(int opt) | 123 | static ALWAYS_INLINE int display_opt(int opt) |
130 | { | 124 | { |
@@ -816,38 +810,6 @@ static void print_header(struct tm *t) | |||
816 | } | 810 | } |
817 | 811 | ||
818 | /* | 812 | /* |
819 | * Get number of processors in /proc/stat | ||
820 | * Return value '0' means one CPU and non SMP kernel. | ||
821 | * Otherwise N means N processor(s) and SMP kernel. | ||
822 | */ | ||
823 | static int get_cpu_nr(void) | ||
824 | { | ||
825 | FILE *fp; | ||
826 | char line[256]; | ||
827 | int proc_nr = -1; | ||
828 | |||
829 | fp = xfopen_for_read(PROCFS_STAT); | ||
830 | while (fgets(line, sizeof(line), fp)) { | ||
831 | if (!starts_with_cpu(line)) { | ||
832 | if (proc_nr >= 0) | ||
833 | break; /* we are past "cpuN..." lines */ | ||
834 | continue; | ||
835 | } | ||
836 | if (line[3] != ' ') { /* "cpuN" */ | ||
837 | int num_proc; | ||
838 | if (sscanf(line + 3, "%u", &num_proc) == 1 | ||
839 | && num_proc > proc_nr | ||
840 | ) { | ||
841 | proc_nr = num_proc; | ||
842 | } | ||
843 | } | ||
844 | } | ||
845 | |||
846 | fclose(fp); | ||
847 | return proc_nr + 1; | ||
848 | } | ||
849 | |||
850 | /* | ||
851 | * Get number of interrupts available per processor | 813 | * Get number of interrupts available per processor |
852 | */ | 814 | */ |
853 | static int get_irqcpu_nr(const char *f, int max_irqs) | 815 | static int get_irqcpu_nr(const char *f, int max_irqs) |
@@ -910,7 +872,7 @@ int mpstat_main(int UNUSED_PARAM argc, char **argv) | |||
910 | G.interval = -1; | 872 | G.interval = -1; |
911 | 873 | ||
912 | /* Get number of processors */ | 874 | /* Get number of processors */ |
913 | G.cpu_nr = get_cpu_nr(); | 875 | G.cpu_nr = get_cpu_count(); |
914 | 876 | ||
915 | /* Get number of clock ticks per sec */ | 877 | /* Get number of clock ticks per sec */ |
916 | G.hz = get_hz(); | 878 | G.hz = get_hz(); |