From: Sebastien Godard Date: Sat, 18 Sep 2010 13:14:13 +0000 (+0200) Subject: Added hugepages utilization statistics. X-Git-Tag: v9.1.6~17 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d7ed8d382140e2d709a6753fa44a0acfcba91a7e;p=sysstat Added hugepages utilization statistics. Added option -H to sar to display hugepages utilization statistics. Sar manual page updated. DTD and XSD documents updated (v2.9) --- diff --git a/CHANGES b/CHANGES index 2035706..c735411 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,9 @@ Changes: xxxx/xx/xx: Version 9.1.6 - Sebastien Godard (sysstat orange.fr) + * Added hugepages utilization statistics to sar. + * sar manual page updated. + * DTD and XSD documents updated. * Made sysstat git aware. 2010/09/12: Version 9.1.5 - Sebastien Godard (sysstat orange.fr) diff --git a/activity.c b/activity.c index a1ee28e..0f8644c 100644 --- a/activity.c +++ b/activity.c @@ -237,7 +237,8 @@ struct activity memory_act = { .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", + "kbswpfree;kbswpused;%swpused;kbswpcad;%swpcad|" + "kbhugfree;kbhugused;%hugused", .name = "A_MEMORY", #endif .nr = 1, diff --git a/man/sar.in b/man/sar.in index 16ee09f..810d2a5 100644 --- a/man/sar.in +++ b/man/sar.in @@ -1,8 +1,8 @@ -.TH SAR 1 "AUGUST 2010" Linux "Linux User's Manual" -*- nroff -*- +.TH SAR 1 "SEPTEMBER 2010" Linux "Linux User's Manual" -*- nroff -*- .SH NAME sar \- Collect, report, or save system activity information. .SH SYNOPSIS -.B sar [ -A ] [ -b ] [ -B ] [ -C ] [ -d ] [ -h ] [ -i +.B sar [ -A ] [ -b ] [ -B ] [ -C ] [ -d ] [ -h ] [ -H ] [ -i .I interval .B ] [ -p ] [ -q ] [ -r ] [ -R ] [ -S ] [ -t ] [ -u [ ALL ] ] [ -v ] [ -V ] [ -w ] [ -W ] [ -y ] @@ -139,7 +139,7 @@ command only reports on local activities. .SH OPTIONS .IP -A This is equivalent to specifying -.BR "-bBdqrRSuvwWy -I SUM -I XALL -n ALL -u ALL -P ALL". +.BR "-bBdHqrRSuvwWy -I SUM -I XALL -n ALL -u ALL -P ALL". .IP -b Report I/O and transfer rate statistics. The following values are displayed: @@ -325,6 +325,26 @@ parameter is the current daily data file, the file. The -f option is exclusive of the -o option. .IP -h Display a short help message then exit. +.IP -H +Report hugepages utilization statistics. +The following values are displayed: + +.B kbhugfree +.RS +.RS +Amount of hugepages memory in kilobytes that is not yet allocated. +.RE + +.B kbhugused +.RS +Amount of hugepages memory in kilobytes that has been allocated. +.RE + +.B %hugused +.RS +Percentage of total hugepages memory that has been allocated. +.RE +.RE .IP "-i interval" Select data records at seconds as close as possible to the number specified by the diff --git a/nls/sysstat.pot b/nls/sysstat.pot index 59ec887..0693f33 100644 --- a/nls/sysstat.pot +++ b/nls/sysstat.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: sysstat orange.fr\n" -"POT-Creation-Date: 2010-09-04 08:21+0200\n" +"POT-Creation-Date: 2010-09-18 15:03+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -34,7 +34,7 @@ msgstr "" msgid "sysstat version %s\n" msgstr "" -#: ioconf.c:490 rd_stats.c:72 rd_stats.c:1831 sa_common.c:1052 sadc.c:593 +#: ioconf.c:490 rd_stats.c:72 rd_stats.c:1848 sa_common.c:1052 sadc.c:593 #: sadc.c:602 sadc.c:662 #, c-format msgid "Cannot open %s: %s\n" @@ -69,7 +69,7 @@ msgid "" "ALL } ] [ -V ]\n" msgstr "" -#: mpstat.c:530 pidstat.c:1806 sar.c:360 +#: mpstat.c:530 pidstat.c:1806 sar.c:361 msgid "Average:" msgstr "" @@ -87,12 +87,12 @@ msgid "" "[ -p { [,...] | SELF | ALL } ] [ -T { TASK | CHILD | ALL } ]\n" msgstr "" -#: pidstat.c:199 sar.c:978 +#: pidstat.c:199 sar.c:979 #, c-format msgid "Requested activities not available\n" msgstr "" -#: rd_stats.c:1877 +#: rd_stats.c:1894 #, c-format msgid "Cannot handle so many processors!\n" msgstr "" @@ -194,7 +194,7 @@ msgstr "" #, c-format msgid "" "Options are:\n" -"[ -A ] [ -b ] [ -B ] [ -C ] [ -d ] [ -h ] [ -p ] [ -q ] [ -r ]\n" +"[ -A ] [ -b ] [ -B ] [ -C ] [ -d ] [ -h ] [ -H ] [ -p ] [ -q ] [ -r ]\n" "[ -R ] [ -S ] [ -t ] [ -u [ ALL ] ] [ -v ] [ -V ] [ -w ] [ -W ] [ -y ]\n" "[ -I { [,...] | SUM | ALL | XALL } ] [ -P { [,...] | ALL } ]\n" "[ -m { [,...] | ALL } ] [ -n { [,...] | ALL } ]\n" @@ -224,12 +224,17 @@ msgstr "" #: sar.c:130 #, c-format +msgid "\t-H\tHugepages utilization statistics\n" +msgstr "" + +#: sar.c:131 +#, c-format msgid "" "\t-I { | SUM | ALL | XALL }\n" "\t\tInterrupts statistics\n" msgstr "" -#: sar.c:132 +#: sar.c:133 #, c-format msgid "" "\t-m { [,...] | ALL }\n" @@ -241,7 +246,7 @@ msgid "" "\t\tTEMP\tDevices temperature\n" msgstr "" -#: sar.c:139 +#: sar.c:140 #, c-format msgid "" "\t-n { [,...] | ALL }\n" @@ -267,84 +272,84 @@ msgid "" "\t\tUDP6\tUDP traffic\t(v6)\n" msgstr "" -#: sar.c:160 +#: sar.c:161 #, c-format msgid "\t-q\tQueue length and load average statistics\n" msgstr "" -#: sar.c:161 +#: sar.c:162 #, c-format msgid "\t-r\tMemory utilization statistics\n" msgstr "" -#: sar.c:162 +#: sar.c:163 #, c-format msgid "\t-R\tMemory statistics\n" msgstr "" -#: sar.c:163 +#: sar.c:164 #, c-format msgid "\t-S\tSwap space utilization statistics\n" msgstr "" -#: sar.c:164 +#: sar.c:165 #, c-format msgid "" "\t-u [ ALL ]\n" "\t\tCPU utilization statistics\n" msgstr "" -#: sar.c:166 +#: sar.c:167 #, c-format msgid "\t-v\tKernel table statistics\n" msgstr "" -#: sar.c:167 +#: sar.c:168 #, c-format msgid "\t-w\tTask creation and system switching statistics\n" msgstr "" -#: sar.c:168 +#: sar.c:169 #, c-format msgid "\t-W\tSwapping statistics\n" msgstr "" -#: sar.c:169 +#: sar.c:170 #, c-format msgid "\t-y\tTTY device statistics\n" msgstr "" -#: sar.c:212 +#: sar.c:213 #, c-format msgid "End of data collecting unexpected\n" msgstr "" -#: sar.c:780 +#: sar.c:781 #, c-format msgid "Invalid data format\n" msgstr "" -#: sar.c:784 +#: sar.c:785 #, c-format msgid "Using a wrong data collector from a different sysstat version\n" msgstr "" -#: sar.c:804 +#: sar.c:805 #, c-format msgid "Inconsistent input data\n" msgstr "" -#: sar.c:1225 +#: sar.c:1226 #, c-format msgid "-f and -o options are mutually exclusive\n" msgstr "" -#: sar.c:1231 +#: sar.c:1232 #, c-format msgid "Not reading from a system activity file (use -f option)\n" msgstr "" -#: sar.c:1332 +#: sar.c:1333 #, c-format msgid "Cannot find the data collector (%s)\n" msgstr "" diff --git a/pr_stats.c b/pr_stats.c index 5e7f092..6109bf5 100644 --- a/pr_stats.c +++ b/pr_stats.c @@ -369,8 +369,8 @@ __print_funct_t print_io_stats(struct activity *a, int prev, int curr, /* *************************************************************************** - * Display memory and swap statistics. This function is used to display - * instantaneous and average statistics. + * Display memory, swap and huge pages statistics. This function is used to + * display instantaneous and average statistics. * * IN: * @a Activity structure with statistics. @@ -395,6 +395,9 @@ void stub_print_memory_stats(struct activity *a, int prev, int curr, 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) { @@ -511,6 +514,43 @@ void stub_print_memory_stats(struct activity *a, int prev, int curr, 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; + } + } } /* diff --git a/prf_stats.c b/prf_stats.c index f44f93f..2964c30 100644 --- a/prf_stats.c +++ b/prf_stats.c @@ -616,7 +616,7 @@ __print_funct_t render_io_stats(struct activity *a, int isdb, char *pre, /* *************************************************************************** - * Display memory and swap statistics in selected format. + * Display memory, swap and huge pages statistics in selected format. * * IN: * @a Activity structure with statistics. @@ -717,6 +717,23 @@ __print_funct_t render_memory_stats(struct activity *a, int isdb, char *pre, 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); + } } /* @@ -2833,7 +2850,7 @@ __print_funct_t xml_print_memory_stats(struct activity *a, int curr, int tab, SP_VALUE(0, smc->comkb, smc->tlmkb + smc->tlskb) : 0.0); } - + if (DISPLAY_SWAP(a->opt_flags)) { xprintf(++tab, "%lu", @@ -2856,6 +2873,20 @@ __print_funct_t xml_print_memory_stats(struct activity *a, int curr, int tab, 0.0); } + if (DISPLAY_HUGE(a->opt_flags)) { + + xprintf(++tab, "%lu", + smc->frhkb); + + xprintf(tab, "%lu", + smc->tlhkb - smc->frhkb); + + xprintf(tab, "%.2f", + smc->tlhkb ? + SP_VALUE(smc->frhkb, smc->tlhkb, smc->tlhkb) : + 0.0); + } + if (DISPLAY_MEMORY(a->opt_flags)) { xprintf(++tab, "%.2f", diff --git a/rd_stats.c b/rd_stats.c index f84c14d..ed9ba26 100644 --- a/rd_stats.c +++ b/rd_stats.c @@ -293,6 +293,7 @@ void read_meminfo(struct stats_memory *st_memory) { FILE *fp; char line[128]; + unsigned long szhkb = 0; if ((fp = fopen(MEMINFO, "r")) == NULL) return; @@ -331,9 +332,25 @@ void read_meminfo(struct stats_memory *st_memory) /* 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; } /* diff --git a/rd_stats.h b/rd_stats.h index bbb1124..db1aaa0 100644 --- a/rd_stats.h +++ b/rd_stats.h @@ -152,6 +152,8 @@ struct stats_memory { 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)) diff --git a/sa.h b/sa.h index ac5cc40..91439da 100644 --- a/sa.h +++ b/sa.h @@ -94,14 +94,16 @@ #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 */ +/* Output flags for options -R / -r / -S / -H */ #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 diff --git a/sa_common.c b/sa_common.c index 7d1bea6..2e14d50 100644 --- a/sa_common.c +++ b/sa_common.c @@ -1172,7 +1172,8 @@ int parse_sar_opt(char *argv[], int *opt, struct activity *act[], *flags |= S_F_PER_PROC; p = get_activity_position(act, A_MEMORY); - act[p]->opt_flags |= AO_F_MEM_AMT + AO_F_MEM_DIA + AO_F_MEM_SWAP; + act[p]->opt_flags |= AO_F_MEM_AMT + AO_F_MEM_DIA + + AO_F_MEM_SWAP + AO_F_MEM_HUGE; p = get_activity_position(act, A_IRQ); set_bitmap(act[p]->bitmap->b_array, ~0, @@ -1200,6 +1201,12 @@ int parse_sar_opt(char *argv[], int *opt, struct activity *act[], SELECT_ACTIVITY(A_DISK); break; + case 'H': + p = get_activity_position(act, A_MEMORY); + act[p]->options |= AO_SELECTED; + act[p]->opt_flags |= AO_F_MEM_HUGE; + break; + case 'p': *flags |= S_F_DEV_PRETTY; break; diff --git a/sadf.h b/sadf.h index 3b6cc0b..5e1eb1e 100644 --- a/sadf.h +++ b/sadf.h @@ -14,6 +14,6 @@ #define S_O_DBD_OPTION 5 /* DTD version for XML output */ -#define XML_DTD_VERSION "2.8" +#define XML_DTD_VERSION "2.9" #endif /* _SADF_H */ diff --git a/sar.c b/sar.c index a48bb7f..aad5ea4 100644 --- a/sar.c +++ b/sar.c @@ -102,7 +102,7 @@ void usage(char *progname) print_usage_title(progname); fprintf(stderr, _("Options are:\n" - "[ -A ] [ -b ] [ -B ] [ -C ] [ -d ] [ -h ] [ -p ] [ -q ] [ -r ]\n" + "[ -A ] [ -b ] [ -B ] [ -C ] [ -d ] [ -h ] [ -H ] [ -p ] [ -q ] [ -r ]\n" "[ -R ] [ -S ] [ -t ] [ -u [ ALL ] ] [ -v ] [ -V ] [ -w ] [ -W ] [ -y ]\n" "[ -I { [,...] | SUM | ALL | XALL } ] [ -P { [,...] | ALL } ]\n" "[ -m { [,...] | ALL } ] [ -n { [,...] | ALL } ]\n" @@ -127,6 +127,7 @@ void display_help(char *progname) fprintf(stderr, _("\t-b\tI/O and transfer rate statistics\n")); fprintf(stderr, _("\t-B\tPaging statistics\n")); fprintf(stderr, _("\t-d\tBlock device statistics\n")); + fprintf(stderr, _("\t-H\tHugepages utilization statistics\n")); fprintf(stderr, _("\t-I { | SUM | ALL | XALL }\n" "\t\tInterrupts statistics\n")); fprintf(stderr, _("\t-m { [,...] | ALL }\n" diff --git a/xml/sysstat.dtd b/xml/sysstat.dtd index 16849ec..ade92ef 100644 --- a/xml/sysstat.dtd +++ b/xml/sysstat.dtd @@ -1,5 +1,5 @@ - + - + + + + diff --git a/xml/sysstat.xsd b/xml/sysstat.xsd index 9ac00fa..58af937 100644 --- a/xml/sysstat.xsd +++ b/xml/sysstat.xsd @@ -1,6 +1,6 @@ --- XML Schema v2.8 for sysstat. See sadf.h -- +-- XML Schema v2.9 for sysstat. See sadf.h -- @@ -46,6 +46,9 @@ + + +