Implement glibtop_map_entry Pss and Swap.

Regenerate hash function for fast parsing.
This commit is contained in:
Benoit Dejean
2015-07-20 23:54:55 +02:00
committed by Benoît Dejean
parent 56f03d0987
commit 4c455ac8a0
3 changed files with 32 additions and 35 deletions

View File

@@ -52,6 +52,7 @@ static const unsigned long _glibtop_sysdeps_map_entry =
static const unsigned long _glibtop_sysdeps_map_entry_smaps = static const unsigned long _glibtop_sysdeps_map_entry_smaps =
(1UL << GLIBTOP_MAP_ENTRY_SIZE) + (1UL << GLIBTOP_MAP_ENTRY_RSS) + (1UL << GLIBTOP_MAP_ENTRY_SIZE) + (1UL << GLIBTOP_MAP_ENTRY_RSS) +
(1UL << GLIBTOP_MAP_ENTRY_PSS) + (1UL << GLIBTOP_MAP_ENTRY_SWAP) +
(1UL << GLIBTOP_MAP_ENTRY_SHARED_DIRTY) + (1UL << GLIBTOP_MAP_ENTRY_SHARED_CLEAN) + (1UL << GLIBTOP_MAP_ENTRY_SHARED_DIRTY) + (1UL << GLIBTOP_MAP_ENTRY_SHARED_CLEAN) +
(1UL << GLIBTOP_MAP_ENTRY_PRIVATE_DIRTY) + (1UL << GLIBTOP_MAP_ENTRY_PRIVATE_CLEAN); (1UL << GLIBTOP_MAP_ENTRY_PRIVATE_DIRTY) + (1UL << GLIBTOP_MAP_ENTRY_PRIVATE_CLEAN);

View File

@@ -1,6 +1,6 @@
/* ANSI-C code produced by gperf version 3.0.3 */ /* ANSI-C code produced by gperf version 3.0.3 */
/* Command-line: gperf sysdeps/linux/procmap_smaps.gperf */ /* Command-line: gperf sysdeps/linux/procmap_smaps.gperf */
/* Computed positions: -k'9' */ /* Computed positions: -k'1,$' */
#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ #if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
&& ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \ && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
@@ -40,7 +40,7 @@ struct smap_value { int name; ptrdiff_t offset; };
#include <string.h> #include <string.h>
#include <stddef.h> #include <stddef.h>
#define TOTAL_KEYWORDS 6 #define TOTAL_KEYWORDS 8
#define MIN_WORD_LENGTH 3 #define MIN_WORD_LENGTH 3
#define MAX_WORD_LENGTH 13 #define MAX_WORD_LENGTH 13
#define MIN_HASH_VALUE 3 #define MIN_HASH_VALUE 3
@@ -65,13 +65,13 @@ hash (register const char *str, register unsigned int len)
19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 5, 0, 19,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
0, 19, 5, 0, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 5, 19, 19, 0, 19, 19, 5, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 5, 19, 0, 19, 19, 0, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 0, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
@@ -86,40 +86,29 @@ hash (register const char *str, register unsigned int len)
19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19 19, 19, 19, 19, 19, 19
}; };
register int hval = len; return len + asso_values[(unsigned char)str[len - 1]] + asso_values[(unsigned char)str[0]];
switch (hval)
{
default:
hval += asso_values[(unsigned char)str[8]];
/*FALLTHROUGH*/
case 8:
case 7:
case 6:
case 5:
case 4:
case 3:
break;
}
return hval;
} }
struct stringpool_t struct stringpool_t
{ {
char stringpool_str3[sizeof("Rss")]; char stringpool_str3[sizeof("Pss")];
char stringpool_str4[sizeof("Size")]; char stringpool_str4[sizeof("Swap")];
char stringpool_str12[sizeof("Shared_Clean")]; char stringpool_str8[sizeof("Rss")];
char stringpool_str9[sizeof("Size")];
char stringpool_str12[sizeof("Shared_Dirty")];
char stringpool_str13[sizeof("Private_Dirty")]; char stringpool_str13[sizeof("Private_Dirty")];
char stringpool_str17[sizeof("Shared_Dirty")]; char stringpool_str17[sizeof("Shared_Clean")];
char stringpool_str18[sizeof("Private_Clean")]; char stringpool_str18[sizeof("Private_Clean")];
}; };
static const struct stringpool_t stringpool_contents = static const struct stringpool_t stringpool_contents =
{ {
"Pss",
"Swap",
"Rss", "Rss",
"Size", "Size",
"Shared_Clean",
"Private_Dirty",
"Shared_Dirty", "Shared_Dirty",
"Private_Dirty",
"Shared_Clean",
"Private_Clean" "Private_Clean"
}; };
#define stringpool ((const char *) &stringpool_contents) #define stringpool ((const char *) &stringpool_contents)
@@ -135,24 +124,29 @@ _glibtop_find_smap (register const char *str, register unsigned int len)
{ {
static const unsigned char lengthtable[] = static const unsigned char lengthtable[] =
{ {
0, 0, 0, 3, 4, 0, 0, 0, 0, 0, 0, 0, 12, 13, 0, 0, 0, 3, 4, 0, 0, 0, 3, 4, 0, 0, 12, 13,
0, 0, 0, 12, 13 0, 0, 0, 12, 13
}; };
static const struct smap_value wordlist[] = static const struct smap_value wordlist[] =
{ {
{-1}, {-1}, {-1}, {-1}, {-1}, {-1},
#line 18 "sysdeps/linux/procmap_smaps.gperf" #line 18 "sysdeps/linux/procmap_smaps.gperf"
{offsetof(struct stringpool_t, stringpool_str3), SMAP_OFFSET(rss)}, {offsetof(struct stringpool_t, stringpool_str3), SMAP_OFFSET(pss)},
#line 21 "sysdeps/linux/procmap_smaps.gperf" #line 23 "sysdeps/linux/procmap_smaps.gperf"
{offsetof(struct stringpool_t, stringpool_str4), SMAP_OFFSET(size)}, {offsetof(struct stringpool_t, stringpool_str4), SMAP_OFFSET(swap),},
{-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
#line 19 "sysdeps/linux/procmap_smaps.gperf" #line 19 "sysdeps/linux/procmap_smaps.gperf"
{offsetof(struct stringpool_t, stringpool_str12), SMAP_OFFSET(shared_clean)}, {offsetof(struct stringpool_t, stringpool_str8), SMAP_OFFSET(rss)},
#line 22 "sysdeps/linux/procmap_smaps.gperf"
{offsetof(struct stringpool_t, stringpool_str9), SMAP_OFFSET(size)},
{-1}, {-1},
#line 21 "sysdeps/linux/procmap_smaps.gperf"
{offsetof(struct stringpool_t, stringpool_str12), SMAP_OFFSET(shared_dirty)},
#line 17 "sysdeps/linux/procmap_smaps.gperf" #line 17 "sysdeps/linux/procmap_smaps.gperf"
{offsetof(struct stringpool_t, stringpool_str13), SMAP_OFFSET(private_dirty)}, {offsetof(struct stringpool_t, stringpool_str13), SMAP_OFFSET(private_dirty)},
{-1}, {-1}, {-1}, {-1}, {-1}, {-1},
#line 20 "sysdeps/linux/procmap_smaps.gperf" #line 20 "sysdeps/linux/procmap_smaps.gperf"
{offsetof(struct stringpool_t, stringpool_str17), SMAP_OFFSET(shared_dirty)}, {offsetof(struct stringpool_t, stringpool_str17), SMAP_OFFSET(shared_clean)},
#line 16 "sysdeps/linux/procmap_smaps.gperf" #line 16 "sysdeps/linux/procmap_smaps.gperf"
{offsetof(struct stringpool_t, stringpool_str18), SMAP_OFFSET(private_clean)} {offsetof(struct stringpool_t, stringpool_str18), SMAP_OFFSET(private_clean)}
}; };

View File

@@ -15,7 +15,9 @@ struct smap_value { int name; ptrdiff_t offset; };
%% %%
Private_Clean, SMAP_OFFSET(private_clean) Private_Clean, SMAP_OFFSET(private_clean)
Private_Dirty, SMAP_OFFSET(private_dirty) Private_Dirty, SMAP_OFFSET(private_dirty)
Pss, SMAP_OFFSET(pss)
Rss, SMAP_OFFSET(rss) Rss, SMAP_OFFSET(rss)
Shared_Clean, SMAP_OFFSET(shared_clean) Shared_Clean, SMAP_OFFSET(shared_clean)
Shared_Dirty, SMAP_OFFSET(shared_dirty) Shared_Dirty, SMAP_OFFSET(shared_dirty)
Size, SMAP_OFFSET(size) Size, SMAP_OFFSET(size)
Swap, SMAP_OFFSET(swap),