.f_xml_print = xml_print_memory_stats,
.hdr_line = "frmpg/s;bufpg/s;campg/s|"
"kbmemfree;kbmemused;%memused;kbbuffers;kbcached;kbcommit;%commit|"
- "kbswpfree;kbswpused;%swpused;kbswpcad;%swpcad|"
- "kbhugfree;kbhugused;%hugused",
+ "kbswpfree;kbswpused;%swpused;kbswpcad;%swpcad",
.name = "A_MEMORY",
#endif
.nr = 1,
.bitmap = NULL
};
+/* Hugepages activity */
+struct activity huge_act = {
+ .id = A_HUGE,
+ .options = AO_COLLECTED,
+#ifdef SOURCE_SADC
+ .f_count = NULL,
+ .f_read = wrap_read_meminfo_huge,
+#endif
+#ifdef SOURCE_SAR
+ .f_print = print_huge_stats,
+ .f_print_avg = print_avg_huge_stats,
+#endif
+#ifdef SOURCE_SADF
+ .f_render = render_huge_stats,
+ .f_xml_print = xml_print_huge_stats,
+ .hdr_line = "kbhugfree;kbhugused;%hugused",
+ .name = "A_HUGE",
+#endif
+ .nr = 1,
+ .fsize = STATS_HUGE_SIZE,
+ .msize = STATS_HUGE_SIZE,
+ .opt_flags = 0,
+ .buf = {NULL, NULL, NULL},
+ .bitmap = NULL
+};
/*
* Array of activities.
&pwr_cpufreq_act,
&pwr_fan_act,
&pwr_temp_act,
- &pwr_in_act
+ &pwr_in_act,
+ &huge_act
};
/*
***************************************************************************
- * Display memory, swap and huge pages statistics. This function is used to
+ * Display memory and swap statistics. This function is used to
* display instantaneous and average statistics.
*
* IN:
avg_frskb = 0,
avg_tlskb = 0,
avg_caskb = 0;
- static unsigned long long
- avg_frhkb = 0,
- avg_tlhkb = 0;
if (DISPLAY_MEMORY(a->opt_flags)) {
if (dis) {
avg_frskb = avg_tlskb = avg_caskb = 0;
}
}
-
- if (DISPLAY_HUGE(a->opt_flags)) {
- if (dis) {
- printf("\n%-11s kbhugfree kbhugused %%hugused\n",
- timestamp[!curr]);
- }
-
- if (!dispavg) {
- /* Display instantaneous values */
- printf("%-11s %9lu %9lu %6.2f\n",
- timestamp[curr],
- smc->frhkb,
- smc->tlhkb - smc->frhkb,
- smc->tlhkb ?
- SP_VALUE(smc->frhkb, smc->tlhkb, smc->tlhkb) : 0.0);
-
- /* Will be used to compute the average */
- avg_frhkb += smc->frhkb;
- avg_tlhkb += smc->tlhkb;
- }
- else {
- /* Display average values */
- printf("%-11s %9.0f %9.0f %6.2f\n",
- timestamp[curr],
- (double) avg_frhkb / avg_count,
- ((double) avg_tlhkb / avg_count) -
- ((double) avg_frhkb / avg_count),
- ((double) (avg_tlhkb / avg_count)) ?
- SP_VALUE((double) (avg_frhkb / avg_count),
- (double) (avg_tlhkb / avg_count),
- (double) (avg_tlhkb / avg_count)) :
- 0.0);
-
- /* Reset average counters */
- avg_frhkb = avg_tlhkb = 0;
- }
- }
}
/*
{
stub_print_pwr_in_stats(a, prev, curr, TRUE);
}
+
+/*
+ ***************************************************************************
+ * Display huge pages statistics. This function is used to
+ * display instantaneous and average statistics.
+ *
+ * IN:
+ * @a Activity structure with statistics.
+ * @prev Index in array where stats used as reference are.
+ * @curr Index in array for current sample statistics.
+ * @itv Interval of time in jiffies.
+ * @dispavg TRUE if displaying average statistics.
+ ***************************************************************************
+ */
+void stub_print_huge_stats(struct activity *a, int prev, int curr,
+ unsigned long long itv, int dispavg)
+{
+ struct stats_huge
+ *smc = (struct stats_huge *) a->buf[curr];
+ static unsigned long long
+ avg_frhkb = 0,
+ avg_tlhkb = 0;
+
+ if (dis) {
+ printf("\n%-11s kbhugfree kbhugused %%hugused\n",
+ timestamp[!curr]);
+ }
+
+ if (!dispavg) {
+ /* Display instantaneous values */
+ printf("%-11s %9lu %9lu %6.2f\n",
+ timestamp[curr],
+ smc->frhkb,
+ smc->tlhkb - smc->frhkb,
+ smc->tlhkb ?
+ SP_VALUE(smc->frhkb, smc->tlhkb, smc->tlhkb) : 0.0);
+
+ /* Will be used to compute the average */
+ avg_frhkb += smc->frhkb;
+ avg_tlhkb += smc->tlhkb;
+ }
+ else {
+ /* Display average values */
+ printf("%-11s %9.0f %9.0f %6.2f\n",
+ timestamp[curr],
+ (double) avg_frhkb / avg_count,
+ ((double) avg_tlhkb / avg_count) -
+ ((double) avg_frhkb / avg_count),
+ ((double) (avg_tlhkb / avg_count)) ?
+ SP_VALUE((double) (avg_frhkb / avg_count),
+ (double) (avg_tlhkb / avg_count),
+ (double) (avg_tlhkb / avg_count)) :
+ 0.0);
+
+ /* Reset average counters */
+ avg_frhkb = avg_tlhkb = 0;
+ }
+}
+
+/*
+ ***************************************************************************
+ * Display huge pages statistics.
+ *
+ * IN:
+ * @a Activity structure with statistics.
+ * @prev Index in array where stats used as reference are.
+ * @curr Index in array for current sample statistics.
+ * @itv Interval of time in jiffies.
+ ***************************************************************************
+ */
+__print_funct_t print_huge_stats(struct activity *a, int prev, int curr,
+ unsigned long long itv)
+{
+ stub_print_huge_stats(a, prev, curr, itv, FALSE);
+}
+
+/*
+ ***************************************************************************
+ * Display huge pages statistics.
+ *
+ * IN:
+ * @a Activity structure with statistics.
+ * @prev Index in array where stats used as reference are.
+ * @curr Index in array for current sample statistics.
+ * @itv Interval of time in jiffies.
+ ***************************************************************************
+ */
+__print_funct_t print_avg_huge_stats(struct activity *a, int prev, int curr,
+ unsigned long long itv)
+{
+ stub_print_huge_stats(a, prev, curr, itv, TRUE);
+}
(struct activity *, int, int, unsigned long long);
extern __print_funct_t print_pwr_in_stats
(struct activity *, int, int, unsigned long long);
+extern __print_funct_t print_huge_stats
+ (struct activity *, int, int, unsigned long long);
/* Functions used to display average statistics */
extern __print_funct_t print_avg_memory_stats
(struct activity *, int, int, unsigned long long);
extern __print_funct_t print_avg_pwr_in_stats
(struct activity *, int, int, unsigned long long);
+extern __print_funct_t print_avg_huge_stats
+ (struct activity *, int, int, unsigned long long);
#endif /* _PR_STATS_H */
/*
***************************************************************************
- * Display memory, swap and huge pages statistics in selected format.
+ * Display memory and swap statistics in selected format.
*
* IN:
* @a Activity structure with statistics.
SP_VALUE(0, smc->caskb, smc->tlskb - smc->frskb) :
0.0);
}
-
- if (DISPLAY_HUGE(a->opt_flags)) {
-
- render(isdb, pre, PT_USEINT,
- "-\tkbhugfree", NULL, NULL,
- smc->frhkb, DNOVAL);
-
- render(isdb, pre, PT_USEINT,
- "-\tkbhugused", NULL, NULL,
- smc->tlhkb - smc->frhkb, DNOVAL);
-
- render(isdb, pre, pt_newlin,
- "-\t%%hugused", NULL, NULL, NOVAL,
- smc->tlhkb ?
- SP_VALUE(smc->frhkb, smc->tlhkb, smc->tlhkb) :
- 0.0);
- }
}
/*
}
}
+/*
+ ***************************************************************************
+ * Display huge pages statistics in selected format.
+ *
+ * IN:
+ * @a Activity structure with statistics.
+ * @isdb Flag, true if db printing, false if ppc printing.
+ * @pre Prefix string for output entries
+ * @curr Index in array for current sample statistics.
+ * @itv Interval of time in jiffies.
+ ***************************************************************************
+ */
+__print_funct_t render_huge_stats(struct activity *a, int isdb, char *pre,
+ int curr, unsigned long long itv)
+{
+ struct stats_huge
+ *smc = (struct stats_huge *) a->buf[curr];
+ int pt_newlin
+ = (DISPLAY_HORIZONTALLY(flags) ? PT_NOFLAG : PT_NEWLIN);
+
+ render(isdb, pre, PT_USEINT,
+ "-\tkbhugfree", NULL, NULL,
+ smc->frhkb, DNOVAL);
+
+ render(isdb, pre, PT_USEINT,
+ "-\tkbhugused", NULL, NULL,
+ smc->tlhkb - smc->frhkb, DNOVAL);
+
+ render(isdb, pre, pt_newlin,
+ "-\t%%hugused", NULL, NULL, NOVAL,
+ smc->tlhkb ?
+ SP_VALUE(smc->frhkb, smc->tlhkb, smc->tlhkb) :
+ 0.0);
+}
+
/*
***************************************************************************
* Print tabulations
0.0);
}
- if (DISPLAY_HUGE(a->opt_flags)) {
-
- xprintf(++tab, "<hugfree>%lu</hugfree>",
- smc->frhkb);
-
- xprintf(tab, "<hugused>%lu</hugused>",
- smc->tlhkb - smc->frhkb);
-
- xprintf(tab--, "<hugused-percent>%.2f</hugused-percent>",
- smc->tlhkb ?
- SP_VALUE(smc->frhkb, smc->tlhkb, smc->tlhkb) :
- 0.0);
- }
-
if (DISPLAY_MEMORY(a->opt_flags)) {
xprintf(++tab, "<frmpg>%.2f</frmpg>",
xml_markup_power_management(tab, CLOSE_XML_MARKUP);
}
}
+
+/*
+ ***************************************************************************
+ * Display huge pages statistics in XML.
+ *
+ * IN:
+ * @a Activity structure with statistics.
+ * @curr Index in array for current sample statistics.
+ * @tab Indentation in XML output.
+ * @itv Interval of time in jiffies.
+ ***************************************************************************
+ */
+__print_funct_t xml_print_huge_stats(struct activity *a, int curr, int tab,
+ unsigned long long itv)
+{
+ struct stats_huge
+ *smc = (struct stats_huge *) a->buf[curr];
+
+ xprintf(tab, "<hugepages unit=\"kB\">");
+
+ xprintf(++tab, "<hugfree>%lu</hugfree>",
+ smc->frhkb);
+
+ xprintf(tab, "<hugused>%lu</hugused>",
+ smc->tlhkb - smc->frhkb);
+
+ xprintf(tab--, "<hugused-percent>%.2f</hugused-percent>",
+ smc->tlhkb ?
+ SP_VALUE(smc->frhkb, smc->tlhkb, smc->tlhkb) :
+ 0.0);
+
+ xprintf(tab, "</hugepages>");
+}
(struct activity *, int, char *, int, unsigned long long);
extern __print_funct_t render_pwr_in_stats
(struct activity *, int, char *, int, unsigned long long);
+extern __print_funct_t render_huge_stats
+ (struct activity *, int, char *, int, unsigned long long);
/* Functions used to display statistics in XML */
extern void xprintf
(struct activity *, int, int, unsigned long long);
extern __print_funct_t xml_print_pwr_in_stats
(struct activity *, int, int, unsigned long long);
+extern __print_funct_t xml_print_huge_stats
+ (struct activity *, int, int, unsigned long long);
#endif /* _PRF_STATS_H */
{
FILE *fp;
char line[128];
- unsigned long szhkb = 0;
if ((fp = fopen(MEMINFO, "r")) == NULL)
return;
/* Read the amount of commited memory in kB */
sscanf(line + 13, "%lu", &st_memory->comkb);
}
- else if (!strncmp(line, "HugePages_Total:", 16)) {
- /* Read the total number of huge pages */
- sscanf(line + 16, "%lu", &st_memory->tlhkb);
- }
- else if (!strncmp(line, "HugePages_Free:", 15)) {
- /* Read the number of free huge pages */
- sscanf(line + 15, "%lu", &st_memory->frhkb);
- }
- else if (!strncmp(line, "Hugepagesize:", 13)) {
- /* Read the default size of a huge page in kB */
- sscanf(line + 13, "%lu", &szhkb);
- }
}
fclose(fp);
-
- /* We want huge pages stats in kB and not expressed in a number of pages */
- st_memory->tlhkb *= szhkb;
- st_memory->frhkb *= szhkb;
}
/*
}
#endif /* HAVE_SENSORS */
}
+
+/*
+ ***************************************************************************
+ * Read hugepages statistics from /proc/meminfo.
+ *
+ * IN:
+ * @st_huge Structure where stats will be saved.
+ *
+ * OUT:
+ * @st_huge Structure with statistics.
+ ***************************************************************************
+ */
+void read_meminfo_huge(struct stats_huge *st_huge)
+{
+ FILE *fp;
+ char line[128];
+ unsigned long szhkb = 0;
+
+ if ((fp = fopen(MEMINFO, "r")) == NULL)
+ return;
+
+ while (fgets(line, 128, fp) != NULL) {
+
+ if (!strncmp(line, "HugePages_Total:", 16)) {
+ /* Read the total number of huge pages */
+ sscanf(line + 16, "%lu", &st_huge->tlhkb);
+ }
+ else if (!strncmp(line, "HugePages_Free:", 15)) {
+ /* Read the number of free huge pages */
+ sscanf(line + 15, "%lu", &st_huge->frhkb);
+ }
+ else if (!strncmp(line, "Hugepagesize:", 13)) {
+ /* Read the default size of a huge page in kB */
+ sscanf(line + 13, "%lu", &szhkb);
+ }
+ }
+
+ fclose(fp);
+
+ /* We want huge pages stats in kB and not expressed in a number of pages */
+ st_huge->tlhkb *= szhkb;
+ st_huge->frhkb *= szhkb;
+}
unsigned long tlskb __attribute__ ((aligned (8)));
unsigned long caskb __attribute__ ((aligned (8)));
unsigned long comkb __attribute__ ((aligned (8)));
- unsigned long frhkb __attribute__ ((aligned (8)));
- unsigned long tlhkb __attribute__ ((aligned (8)));
};
#define STATS_MEMORY_SIZE (sizeof(struct stats_memory))
char device[MAX_SENSORS_DEV_LEN] __attribute__ ((aligned (8)));
};
-#define STATS_PWR_IN_SIZE (sizeof(struct stats_pwr_in))
+#define STATS_PWR_IN_SIZE (sizeof(struct stats_pwr_in))
+
+/* Structure for hugepages statistics */
+struct stats_huge {
+ unsigned long frhkb __attribute__ ((aligned (8)));
+ unsigned long tlhkb __attribute__ ((aligned (8)));
+};
+
+#define STATS_HUGE_SIZE (sizeof(struct stats_memory))
/*
***************************************************************************
read_temp(struct stats_pwr_temp *, int);
extern void
read_in(struct stats_pwr_in *, int);
+extern void
+ read_meminfo_huge(struct stats_huge *);
/*
***************************************************************************
*/
/* Number of activities */
-#define NR_ACT 33
+#define NR_ACT 34
/* Activities */
#define A_CPU 1
#define A_PWR_FAN 31
#define A_PWR_TEMP 32
#define A_PWR_IN 33
+#define A_HUGE 34
/* Macro used to flag an activity that should be collected */
#define DISPLAY_HORIZONTALLY(m) (((m) & S_F_HORIZONTALLY) == S_F_HORIZONTALLY)
#define DISPLAY_COMMENT(m) (((m) & S_F_COMMENT) == S_F_COMMENT)
-/* Output flags for options -R / -r / -S / -H */
+/* Output flags for options -R / -r / -S */
#define AO_F_MEM_DIA 0x00000001
#define AO_F_MEM_AMT 0x00000002
#define AO_F_MEM_SWAP 0x00000004
-#define AO_F_MEM_HUGE 0x00000008
#define DISPLAY_MEMORY(m) (((m) & AO_F_MEM_DIA) == AO_F_MEM_DIA)
#define DISPLAY_MEM_AMT(m) (((m) & AO_F_MEM_AMT) == AO_F_MEM_AMT)
#define DISPLAY_SWAP(m) (((m) & AO_F_MEM_SWAP) == AO_F_MEM_SWAP)
-#define DISPLAY_HUGE(m) (((m) & AO_F_MEM_HUGE) == AO_F_MEM_HUGE)
/* Output flags for option -u [ ALL ] */
#define AO_F_CPU_DEF 0x00000001
wrap_read_temp(struct activity *);
extern __read_funct_t
wrap_read_in(struct activity *);
+extern __read_funct_t
+ wrap_read_meminfo_huge(struct activity *);
/* Other functions */
extern void
p = get_activity_position(act, A_MEMORY);
act[p]->opt_flags |= AO_F_MEM_AMT + AO_F_MEM_DIA +
- AO_F_MEM_SWAP + AO_F_MEM_HUGE;
+ AO_F_MEM_SWAP;
p = get_activity_position(act, A_IRQ);
set_bitmap(act[p]->bitmap->b_array, ~0,
break;
case 'H':
- p = get_activity_position(act, A_MEMORY);
+ p = get_activity_position(act, A_HUGE);
act[p]->options |= AO_SELECTED;
- act[p]->opt_flags |= AO_F_MEM_HUGE;
break;
case 'p':
return;
}
+/*
+ ***************************************************************************
+ * Read hugepages statistics.
+ *
+ * IN:
+ * @a Activity structure.
+ *
+ * OUT:
+ * @a Activity structure with statistics.
+ ***************************************************************************
+ */
+__read_funct_t wrap_read_meminfo_huge(struct activity *a)
+{
+ struct stats_huge *st_huge
+ = (struct stats_huge *) a->_buf0;
+
+ /* Read hugepages stats */
+ read_meminfo_huge(st_huge);
+
+ return;
+}
+
/*
***************************************************************************
* Get number of voltage input structures to allocate.
pty-nr CDATA #REQUIRED
>
<!ELEMENT memfree (#PCDATA)>
-<!ELEMENT memory (memfree, memused, memused-percent, buffers, cached, commit, commit-percent, swpfree, swpused, swpused-percent, swpcad, swpcad-percent, hugfree, hugused, hugused-percent, frmpg, bufpg, campg)>
+<!ELEMENT memory (memfree, memused, memused-percent, buffers, cached, commit, commit-percent, swpfree, swpused, swpused-percent, swpcad, swpcad-percent, frmpg, bufpg, campg)>
<!ATTLIST memory
per CDATA #REQUIRED
unit CDATA #REQUIRED
>
<!ELEMENT memused (#PCDATA)>
<!ELEMENT memused-percent (#PCDATA)>
+<!ELEMENT hugepages (hugfree, hugused, hugused-percent)>
+<!ATTLIST hugepages
+ unit CDATA #REQUIRED
+>
<!ELEMENT network (net-dev+, net-edev+, net-nfs, net-nfsd, net-sock, net-ip, net-eip, net-icmp, net-eicmp, net-tcp, net-etcp, net-udp, net-sock6, net-ip6, net-eip6, net-icmp6, net-eicmp6, net-udp6)>
<!ATTLIST network
per CDATA #REQUIRED
<!ELEMENT number-of-cpus (#PCDATA)>
<!ELEMENT file-date (#PCDATA)>
<!ELEMENT sysstat (sysdata-version, host)>
-<!ELEMENT timestamp (cpu-load, cpu-load-all, process-and-context-switch, interrupts, swap-pages, paging, io, memory, kernel, queue, serial, disk, network, power-management)>
+<!ELEMENT timestamp (cpu-load, cpu-load-all, process-and-context-switch, interrupts, swap-pages, paging, io, memory, kernel, queue, serial, disk, network, power-management, hugepages)>
<!ATTLIST timestamp
date CDATA #REQUIRED
time CDATA #REQUIRED
<xs:element name="swpused-percent" type="hundredth-type"></xs:element>
<xs:element name="swpcad" type="xs:nonNegativeInteger"></xs:element>
<xs:element name="swpcad-percent" type="hundredth-type"></xs:element>
- <xs:element name="hugfree" type="xs:nonNegativeInteger"></xs:element>
- <xs:element name="hugused" type="xs:nonNegativeInteger"></xs:element>
- <xs:element name="hugused-percent" type="hundredth-type"></xs:element>
<xs:element name="frmpg" type="hundredth-type"></xs:element>
<xs:element name="bufpg" type="hundredth-type"></xs:element>
<xs:element name="campg" type="hundredth-type"></xs:element>
<xs:attribute name="unit" type="unit-type"></xs:attribute>
</xs:complexType>
+ <xs:element name="hugepages" type="hugepages-type"></xs:element>
+
+ <xs:complexType name="hugepages-type">
+ <xs:sequence>
+ <xs:element name="hugfree" type="xs:nonNegativeInteger"></xs:element>
+ <xs:element name="hugused" type="xs:nonNegativeInteger"></xs:element>
+ <xs:element name="hugused-percent" type="hundredth-type"></xs:element>
+ </xs:sequence>
+ </xs:complexType>
+
<xs:simpleType name="unit-type">
<xs:restriction base="xs:string">
<xs:enumeration value="kB"></xs:enumeration>
<xs:element name="paging" type="paging-type"></xs:element>
<xs:element name="io" type="io-type"></xs:element>
<xs:element name="memory" type="memory-type"></xs:element>
+ <xs:element name="hugepages" type="hugepages-type"></xs:element>
<xs:element name="kernel" type="kernel-type"></xs:element>
<xs:element name="queue" type="queue-type"></xs:element>
<xs:element name="serial" type="serial-type"></xs:element>