29
29
***************************************************************************
30
* Count number of interrupts that are in /proc/stat file.
31
* Truncate the number of different individual interrupts to NR_IRQS.
34
* @a Activity structure.
37
* Number of interrupts, including total number of interrupts.
38
* Value in [0, NR_IRQS + 1].
39
***************************************************************************
41
__nr_t wrap_get_irq_nr(struct activity *a)
45
if ((n = get_irq_nr()) > (a->bitmap->b_size + 1)) {
46
n = a->bitmap->b_size + 1;
53
***************************************************************************
54
* Find number of serial lines that support tx/rx accounting
55
* in /proc/tty/driver/serial file.
58
* @a Activity structure.
61
* Number of serial lines supporting tx/rx accouting + a pre-allocation
63
***************************************************************************
65
__nr_t wrap_get_serial_nr(struct activity *a)
69
if ((n = get_serial_nr()) > 0)
70
return n + NR_SERIAL_PREALLOC;
76
***************************************************************************
77
* Find number of interfaces (network devices) that are in /proc/net/dev
81
* @a Activity structure.
84
* Number of network interfaces + a pre-allocation constant.
85
***************************************************************************
87
__nr_t wrap_get_iface_nr(struct activity *a)
91
if ((n = get_iface_nr()) > 0)
92
return n + NR_IFACE_PREALLOC;
98
***************************************************************************
99
* Compute number of CPU structures to allocate.
102
* @a Activity structure.
105
* Number of structures (value in [1, NR_CPUS + 1]).
106
* 1 means that there is only one proc and non SMP kernel.
107
* 2 means one proc and SMP kernel.
109
***************************************************************************
111
__nr_t wrap_get_cpu_nr(struct activity *a)
113
return (get_cpu_nr(a->bitmap->b_size) + 1);
117
***************************************************************************
118
* Get number of devices in /proc/{diskstats,partitions}
119
* or number of disk_io entries in /proc/stat.
120
* Always done, since disk stats must be read at least for sar -b
124
* @a Activity structure.
127
* Number of devices + a pre-allocation constant.
128
***************************************************************************
130
__nr_t wrap_get_disk_nr(struct activity *a)
133
unsigned int f = COLLECT_PARTITIONS(a->opt_flags);
137
if (f == READ_DISKSTATS) {
138
flags |= S_F_HAS_DISKSTATS;
140
else if (f == READ_PPARTITIONS) {
141
flags |= S_F_HAS_PPARTITIONS;
145
return n + NR_DISK_PREALLOC;
151
***************************************************************************
152
30
* Read CPU statistics.
689
***************************************************************************
690
* Read fan statistics.
693
* @a Activity structure.
696
* @a Activity structure with statistics.
697
***************************************************************************
699
__read_funct_t wrap_read_fan(struct activity *a)
701
struct stats_pwr_fan *st_pwr_fan
702
= (struct stats_pwr_fan *) a->_buf0;
705
read_fan(st_pwr_fan, a->nr);
711
***************************************************************************
712
* Read temperature statistics.
715
* @a Activity structure.
718
* @a Activity structure with statistics.
719
***************************************************************************
721
__read_funct_t wrap_read_temp(struct activity *a)
723
struct stats_pwr_temp *st_pwr_temp
724
= (struct stats_pwr_temp *) a->_buf0;
726
/* Read temperature stats */
727
read_temp(st_pwr_temp, a->nr);
733
***************************************************************************
734
* Read voltage input statistics.
737
* @a Activity structure.
740
* @a Activity structure with statistics.
741
***************************************************************************
743
__read_funct_t wrap_read_in(struct activity *a)
745
struct stats_pwr_in *st_pwr_in
746
= (struct stats_pwr_in *) a->_buf0;
748
/* Read voltage input stats */
749
read_in(st_pwr_in, a->nr);
755
***************************************************************************
756
* Read hugepages statistics.
759
* @a Activity structure.
762
* @a Activity structure with statistics.
763
***************************************************************************
765
__read_funct_t wrap_read_meminfo_huge(struct activity *a)
767
struct stats_huge *st_huge
768
= (struct stats_huge *) a->_buf0;
770
/* Read hugepages stats */
771
read_meminfo_huge(st_huge);
777
***************************************************************************
778
* Read weighted CPU frequency statistics.
781
* @a Activity structure.
784
* @a Activity structure with statistics.
785
***************************************************************************
787
__read_funct_t wrap_read_time_in_state(struct activity *a)
791
struct stats_pwr_wghfreq *st_pwr_wghfreq
792
= (struct stats_pwr_wghfreq *) a->_buf0;
793
struct stats_pwr_wghfreq *st_pwr_wghfreq_i, *st_pwr_wghfreq_j, *st_pwr_wghfreq_all_j;
795
while (cpu < (a->nr - 1)) {
796
/* Read current CPU time-in-state data */
797
st_pwr_wghfreq_i = st_pwr_wghfreq + (cpu + 1) * a->nr2;
798
read_time_in_state(st_pwr_wghfreq_i, cpu, a->nr2);
800
/* Also save data for CPU 'all' */
801
for (j = 0; j < a->nr2; j++) {
802
st_pwr_wghfreq_j = st_pwr_wghfreq_i + j; /* CPU #cpu, state #j */
803
st_pwr_wghfreq_all_j = st_pwr_wghfreq + j; /* CPU #all, state #j */
805
/* Assume that possible frequencies are the same for all CPUs */
806
st_pwr_wghfreq_all_j->freq = st_pwr_wghfreq_j->freq;
808
st_pwr_wghfreq_all_j->time_in_state += st_pwr_wghfreq_j->time_in_state;
813
/* Special processing for non SMP kernels: Only CPU 'all' is available */
815
read_time_in_state(st_pwr_wghfreq, 0, a->nr2);
818
for (j = 0; j < a->nr2; j++) {
819
st_pwr_wghfreq_all_j = st_pwr_wghfreq + j; /* CPU #all, state #j */
820
st_pwr_wghfreq_all_j->time_in_state /= (a->nr - 1);
828
***************************************************************************
829
* Count number of interrupts that are in /proc/stat file.
830
* Truncate the number of different individual interrupts to NR_IRQS.
833
* @a Activity structure.
836
* Number of interrupts, including total number of interrupts.
837
* Value in [0, NR_IRQS + 1].
838
***************************************************************************
840
__nr_t wrap_get_irq_nr(struct activity *a)
844
if ((n = get_irq_nr()) > (a->bitmap->b_size + 1)) {
845
n = a->bitmap->b_size + 1;
852
***************************************************************************
853
* Find number of serial lines that support tx/rx accounting
854
* in /proc/tty/driver/serial file.
857
* @a Activity structure.
860
* Number of serial lines supporting tx/rx accouting + a pre-allocation
862
***************************************************************************
864
__nr_t wrap_get_serial_nr(struct activity *a)
868
if ((n = get_serial_nr()) > 0)
869
return n + NR_SERIAL_PREALLOC;
875
***************************************************************************
876
* Find number of interfaces (network devices) that are in /proc/net/dev
880
* @a Activity structure.
883
* Number of network interfaces + a pre-allocation constant.
884
***************************************************************************
886
__nr_t wrap_get_iface_nr(struct activity *a)
890
if ((n = get_iface_nr()) > 0)
891
return n + NR_IFACE_PREALLOC;
897
***************************************************************************
898
* Compute number of CPU structures to allocate.
901
* @a Activity structure.
904
* Number of structures (value in [1, NR_CPUS + 1]).
905
* 1 means that there is only one proc and non SMP kernel.
906
* 2 means one proc and SMP kernel.
908
***************************************************************************
910
__nr_t wrap_get_cpu_nr(struct activity *a)
912
return (get_cpu_nr(a->bitmap->b_size) + 1);
916
***************************************************************************
917
* Get number of devices in /proc/diskstats.
918
* Always done, since disk stats must be read at least for sar -b
922
* @a Activity structure.
925
* Number of devices + a pre-allocation constant.
926
***************************************************************************
928
__nr_t wrap_get_disk_nr(struct activity *a)
931
unsigned int f = COLLECT_PARTITIONS(a->opt_flags);
933
if ((n = get_disk_nr(f)) > 0)
934
return n + NR_DISK_PREALLOC;
940
***************************************************************************
941
* Get number of fan structures to allocate.
944
* @a Activity structure.
947
* Number of structures.
948
***************************************************************************
950
__nr_t wrap_get_fan_nr(struct activity *a)
952
return (get_fan_nr());
956
***************************************************************************
957
* Get number of temp structures to allocate.
960
* @a Activity structure.
963
* Number of structures.
964
***************************************************************************
966
__nr_t wrap_get_temp_nr(struct activity *a)
968
return (get_temp_nr());
972
***************************************************************************
973
* Get number of voltage input structures to allocate.
976
* @a Activity structure.
979
* Number of structures.
980
***************************************************************************
982
__nr_t wrap_get_in_nr(struct activity *a)
984
return (get_in_nr());
988
***************************************************************************
989
* Count number of possible frequencies for CPU#0.
992
* @a Activity structure.
995
* Number of CPU frequencies + a pre-allocation constant.
996
***************************************************************************
998
__nr_t wrap_get_freq_nr(struct activity *a)
1002
if ((n = get_freq_nr()) > 0)
1003
return n + NR_FREQ_PREALLOC;