prevent the read ahead of /proc/slabinfo in ss
Signed-off-by: Bryton Lee <brytonlee01@gmail.com>
This commit is contained in:
parent
11ba90fcbd
commit
a221d621bb
14
misc/ss.c
14
misc/ss.c
|
|
@ -618,7 +618,7 @@ struct slabstat
|
||||||
int skbs;
|
int skbs;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct slabstat slabstat;
|
static struct slabstat slabstat;
|
||||||
|
|
||||||
static const char *slabstat_ids[] =
|
static const char *slabstat_ids[] =
|
||||||
{
|
{
|
||||||
|
|
@ -634,6 +634,10 @@ static int get_slabstat(struct slabstat *s)
|
||||||
char buf[256];
|
char buf[256];
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
int cnt;
|
int cnt;
|
||||||
|
static int slabstat_valid;
|
||||||
|
|
||||||
|
if (slabstat_valid)
|
||||||
|
return 0;
|
||||||
|
|
||||||
memset(s, 0, sizeof(*s));
|
memset(s, 0, sizeof(*s));
|
||||||
|
|
||||||
|
|
@ -657,6 +661,8 @@ static int get_slabstat(struct slabstat *s)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
slabstat_valid = 1;
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -2297,6 +2303,8 @@ static int tcp_show(struct filter *f, int socktype)
|
||||||
* it is able to give us some memory for snapshot.
|
* it is able to give us some memory for snapshot.
|
||||||
*/
|
*/
|
||||||
if (1) {
|
if (1) {
|
||||||
|
get_slabstat(&slabstat);
|
||||||
|
|
||||||
int guess = slabstat.socks+slabstat.tcp_syns;
|
int guess = slabstat.socks+slabstat.tcp_syns;
|
||||||
if (f->states&(1<<SS_TIME_WAIT))
|
if (f->states&(1<<SS_TIME_WAIT))
|
||||||
guess += slabstat.tcp_tws;
|
guess += slabstat.tcp_tws;
|
||||||
|
|
@ -3234,6 +3242,8 @@ static int print_summary(void)
|
||||||
if (get_snmp_int("Tcp:", "CurrEstab", &sn.tcp_estab) < 0)
|
if (get_snmp_int("Tcp:", "CurrEstab", &sn.tcp_estab) < 0)
|
||||||
perror("ss: get_snmpstat");
|
perror("ss: get_snmpstat");
|
||||||
|
|
||||||
|
get_slabstat(&slabstat);
|
||||||
|
|
||||||
printf("Total: %d (kernel %d)\n", s.socks, slabstat.socks);
|
printf("Total: %d (kernel %d)\n", s.socks, slabstat.socks);
|
||||||
|
|
||||||
printf("TCP: %d (estab %d, closed %d, orphaned %d, synrecv %d, timewait %d/%d), ports %d\n",
|
printf("TCP: %d (estab %d, closed %d, orphaned %d, synrecv %d, timewait %d/%d), ports %d\n",
|
||||||
|
|
@ -3587,8 +3597,6 @@ int main(int argc, char *argv[])
|
||||||
argc -= optind;
|
argc -= optind;
|
||||||
argv += optind;
|
argv += optind;
|
||||||
|
|
||||||
get_slabstat(&slabstat);
|
|
||||||
|
|
||||||
if (do_summary) {
|
if (do_summary) {
|
||||||
print_summary();
|
print_summary();
|
||||||
if (do_default && argc == 0)
|
if (do_default && argc == 0)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue