library: eliminate distorted history 1st time switches

Upon reflection, at the point where the 'priming read'
was introduced, any possibility of history distortions
was also eliminated.  This was true because all of the
'old' (zeroed) data will have been replaced with 'new'
data whenever a user finally calls get, select & reap.

Thus, any DELTA values will automatically reflect that
interval between 'new' and subsequent retrieval calls.

[ diskstats didn't actually employ a 1st time switch ]
[ like the others so we have changed a comment only. ]
[ but that module will retain something similar used ]
[ inside node_update whenever a new node is created. ]

Reference(s):
. priming read added to slabinfo
commit 5d5a52a380
. priming read added to diskstats
commit ecd64f4445
. priming read added to meminfo, stat, vmstat
commit 1a2b62c779

Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner 2016-12-31 00:00:00 -06:00 committed by Craig Small
parent 904f4c3b35
commit e524e48138
5 changed files with 10 additions and 34 deletions

View File

@ -769,7 +769,8 @@ PROCPS_EXPORT int procps_diskstats_new (
/* do a priming read here for the following potential benefits: |
1) ensure there will be no problems with subsequent access |
2) make delta results potentially useful, even if 1st time | */
2) make delta results potentially useful, even if 1st time |
3) elimnate need for history distortions 1st time 'switch' | */
if ((rc = diskstats_read_failed(p))) {
procps_diskstats_unref(&p);
return rc;

View File

@ -109,7 +109,6 @@ struct stacks_extent {
struct meminfo_info {
int refcount;
int meminfo_fd;
int meminfo_was_read;
int dirty_stacks;
struct mem_hist hist;
int numitems;
@ -644,11 +643,6 @@ static int meminfo_read_failed (
if (mHr(SwapFree) < mHr(SwapTotal))
mHr(derived_swap_used) = mHr(SwapTotal) - mHr(SwapFree);
// let's not distort the deltas the first time thru ...
if (!info->meminfo_was_read) {
memcpy(&info->hist.old, &info->hist.new, sizeof(struct meminfo_data));
info->meminfo_was_read = 1;
}
return 0;
#undef mHr
} // end: meminfo_read_failed
@ -751,7 +745,8 @@ PROCPS_EXPORT int procps_meminfo_new (
/* do a priming read here for the following potential benefits: |
1) ensure there will be no problems with subsequent access |
2) make delta results potentially useful, even if 1st time | */
2) make delta results potentially useful, even if 1st time |
3) elimnate need for history distortions 1st time 'switch' | */
if ((rc = meminfo_read_failed(p))) {
procps_meminfo_unref(&p);
return rc;

View File

@ -121,7 +121,6 @@ struct fetch_support {
struct slabinfo_info {
int refcount;
FILE *slabinfo_fp;
int slabinfo_was_read;
int nodes_alloc; /* nodes alloc()ed */
int nodes_used; /* nodes using alloced memory */
struct slabs_node *nodes; /* first slabnode of this list */
@ -495,10 +494,6 @@ static int read_slabinfo_failed (
else
return -ERANGE;
if (!info->slabinfo_was_read) {
memcpy(&info->slabs.old, &info->slabs.new, sizeof(struct slabs_summ));
info->slabinfo_was_read = 1;
}
return retval;
} // end: read_slabinfo_failed
@ -814,7 +809,8 @@ PROCPS_EXPORT int procps_slabinfo_new (
/* do a priming read here for the following potential benefits: |
1) see if that caller's permissions were sufficient (root) |
2) make delta results potentially useful, even if 1st time | */
2) make delta results potentially useful, even if 1st time |
3) elimnate need for history distortions 1st time 'switch' | */
if ((rc = read_slabinfo_failed(p))) {
procps_slabinfo_unref(&p);
return rc;

View File

@ -118,7 +118,6 @@ struct reap_support {
struct stat_info {
int refcount;
int stat_fd;
int stat_was_read; // is stat file history valid?
struct hist_sys sys_hist; // SYS type management
struct hist_tic cpu_hist; // TIC type management for cpu summary
struct reap_support cpus; // TIC type management for real cpus
@ -617,9 +616,6 @@ static int stat_read_failed (
, &sum_ptr->new.guest, &sum_ptr->new.gnice))
return -1;
stat_derive_unique(sum_ptr);
// let's not distort the deltas the first time thru ...
if (!info->stat_was_read)
memcpy(&sum_ptr->old, &sum_ptr->new, sizeof(struct stat_jifs));
i = 0;
reap_em_again:
@ -645,9 +641,6 @@ reap_em_again:
break; // we must tolerate cpus taken offline
}
stat_derive_unique(cpu_ptr);
// let's not distort the deltas the first time thru ...
if (!info->stat_was_read)
memcpy(&cpu_ptr->old, &cpu_ptr->new, sizeof(struct stat_jifs));
++i;
++cpu_ptr;
} while (i < info->cpus.hist.n_alloc);
@ -695,11 +688,6 @@ reap_em_again:
sscanf(b, "procs_running %llu", &llnum);
info->sys_hist.new.procs_running = llnum;
// let's not distort the deltas the first time thru ...
if (!info->stat_was_read) {
memcpy(&info->sys_hist.old, &info->sys_hist.new, sizeof(struct stat_data));
info->stat_was_read = 1;
}
return 0;
} // end: stat_read_failed
@ -939,7 +927,8 @@ PROCPS_EXPORT int procps_stat_new (
/* do a priming read here for the following potential benefits: |
1) ensure there will be no problems with subsequent access |
2) make delta results potentially useful, even if 1st time | */
2) make delta results potentially useful, even if 1st time |
3) elimnate need for history distortions 1st time 'switch' | */
if ((rc = stat_read_failed(p))) {
procps_stat_unref(&p);
return rc;

View File

@ -182,7 +182,6 @@ struct stacks_extent {
struct vmstat_info {
int refcount;
int vmstat_fd;
int vmstat_was_read;
int dirty_stacks;
struct vmstat_hist hist;
int numitems;
@ -1029,11 +1028,6 @@ static int vmstat_read_failed (
head = tail + 1;
}
// let's not distort the deltas the first time thru ...
if (!info->vmstat_was_read) {
memcpy(&info->hist.old, &info->hist.new, sizeof(struct vmstat_data));
info->vmstat_was_read = 1;
}
return 0;
} // end: vmstat_read_failed
@ -1135,7 +1129,8 @@ PROCPS_EXPORT int procps_vmstat_new (
/* do a priming read here for the following potential benefits: |
1) ensure there will be no problems with subsequent access |
2) make delta results potentially useful, even if 1st time | */
2) make delta results potentially useful, even if 1st time |
3) elimnate need for history distortions 1st time 'switch' | */
if ((rc = vmstat_read_failed(p))) {
procps_vmstat_unref(&p);
return rc;