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 commit5d5a52a380
. priming read added to diskstats commitecd64f4445
. priming read added to meminfo, stat, vmstat commit1a2b62c779
Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
parent
904f4c3b35
commit
e524e48138
@ -769,7 +769,8 @@ PROCPS_EXPORT int procps_diskstats_new (
|
|||||||
|
|
||||||
/* do a priming read here for the following potential benefits: |
|
/* do a priming read here for the following potential benefits: |
|
||||||
1) ensure there will be no problems with subsequent access |
|
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))) {
|
if ((rc = diskstats_read_failed(p))) {
|
||||||
procps_diskstats_unref(&p);
|
procps_diskstats_unref(&p);
|
||||||
return rc;
|
return rc;
|
||||||
|
@ -109,7 +109,6 @@ struct stacks_extent {
|
|||||||
struct meminfo_info {
|
struct meminfo_info {
|
||||||
int refcount;
|
int refcount;
|
||||||
int meminfo_fd;
|
int meminfo_fd;
|
||||||
int meminfo_was_read;
|
|
||||||
int dirty_stacks;
|
int dirty_stacks;
|
||||||
struct mem_hist hist;
|
struct mem_hist hist;
|
||||||
int numitems;
|
int numitems;
|
||||||
@ -644,11 +643,6 @@ static int meminfo_read_failed (
|
|||||||
if (mHr(SwapFree) < mHr(SwapTotal))
|
if (mHr(SwapFree) < mHr(SwapTotal))
|
||||||
mHr(derived_swap_used) = mHr(SwapTotal) - mHr(SwapFree);
|
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;
|
return 0;
|
||||||
#undef mHr
|
#undef mHr
|
||||||
} // end: meminfo_read_failed
|
} // end: meminfo_read_failed
|
||||||
@ -751,7 +745,8 @@ PROCPS_EXPORT int procps_meminfo_new (
|
|||||||
|
|
||||||
/* do a priming read here for the following potential benefits: |
|
/* do a priming read here for the following potential benefits: |
|
||||||
1) ensure there will be no problems with subsequent access |
|
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))) {
|
if ((rc = meminfo_read_failed(p))) {
|
||||||
procps_meminfo_unref(&p);
|
procps_meminfo_unref(&p);
|
||||||
return rc;
|
return rc;
|
||||||
|
@ -121,7 +121,6 @@ struct fetch_support {
|
|||||||
struct slabinfo_info {
|
struct slabinfo_info {
|
||||||
int refcount;
|
int refcount;
|
||||||
FILE *slabinfo_fp;
|
FILE *slabinfo_fp;
|
||||||
int slabinfo_was_read;
|
|
||||||
int nodes_alloc; /* nodes alloc()ed */
|
int nodes_alloc; /* nodes alloc()ed */
|
||||||
int nodes_used; /* nodes using alloced memory */
|
int nodes_used; /* nodes using alloced memory */
|
||||||
struct slabs_node *nodes; /* first slabnode of this list */
|
struct slabs_node *nodes; /* first slabnode of this list */
|
||||||
@ -495,10 +494,6 @@ static int read_slabinfo_failed (
|
|||||||
else
|
else
|
||||||
return -ERANGE;
|
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;
|
return retval;
|
||||||
} // end: read_slabinfo_failed
|
} // end: read_slabinfo_failed
|
||||||
|
|
||||||
@ -814,7 +809,8 @@ PROCPS_EXPORT int procps_slabinfo_new (
|
|||||||
|
|
||||||
/* do a priming read here for the following potential benefits: |
|
/* do a priming read here for the following potential benefits: |
|
||||||
1) see if that caller's permissions were sufficient (root) |
|
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))) {
|
if ((rc = read_slabinfo_failed(p))) {
|
||||||
procps_slabinfo_unref(&p);
|
procps_slabinfo_unref(&p);
|
||||||
return rc;
|
return rc;
|
||||||
|
15
proc/stat.c
15
proc/stat.c
@ -118,7 +118,6 @@ struct reap_support {
|
|||||||
struct stat_info {
|
struct stat_info {
|
||||||
int refcount;
|
int refcount;
|
||||||
int stat_fd;
|
int stat_fd;
|
||||||
int stat_was_read; // is stat file history valid?
|
|
||||||
struct hist_sys sys_hist; // SYS type management
|
struct hist_sys sys_hist; // SYS type management
|
||||||
struct hist_tic cpu_hist; // TIC type management for cpu summary
|
struct hist_tic cpu_hist; // TIC type management for cpu summary
|
||||||
struct reap_support cpus; // TIC type management for real cpus
|
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))
|
, &sum_ptr->new.guest, &sum_ptr->new.gnice))
|
||||||
return -1;
|
return -1;
|
||||||
stat_derive_unique(sum_ptr);
|
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;
|
i = 0;
|
||||||
reap_em_again:
|
reap_em_again:
|
||||||
@ -645,9 +641,6 @@ reap_em_again:
|
|||||||
break; // we must tolerate cpus taken offline
|
break; // we must tolerate cpus taken offline
|
||||||
}
|
}
|
||||||
stat_derive_unique(cpu_ptr);
|
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;
|
++i;
|
||||||
++cpu_ptr;
|
++cpu_ptr;
|
||||||
} while (i < info->cpus.hist.n_alloc);
|
} while (i < info->cpus.hist.n_alloc);
|
||||||
@ -695,11 +688,6 @@ reap_em_again:
|
|||||||
sscanf(b, "procs_running %llu", &llnum);
|
sscanf(b, "procs_running %llu", &llnum);
|
||||||
info->sys_hist.new.procs_running = 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;
|
return 0;
|
||||||
} // end: stat_read_failed
|
} // end: stat_read_failed
|
||||||
|
|
||||||
@ -939,7 +927,8 @@ PROCPS_EXPORT int procps_stat_new (
|
|||||||
|
|
||||||
/* do a priming read here for the following potential benefits: |
|
/* do a priming read here for the following potential benefits: |
|
||||||
1) ensure there will be no problems with subsequent access |
|
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))) {
|
if ((rc = stat_read_failed(p))) {
|
||||||
procps_stat_unref(&p);
|
procps_stat_unref(&p);
|
||||||
return rc;
|
return rc;
|
||||||
|
@ -182,7 +182,6 @@ struct stacks_extent {
|
|||||||
struct vmstat_info {
|
struct vmstat_info {
|
||||||
int refcount;
|
int refcount;
|
||||||
int vmstat_fd;
|
int vmstat_fd;
|
||||||
int vmstat_was_read;
|
|
||||||
int dirty_stacks;
|
int dirty_stacks;
|
||||||
struct vmstat_hist hist;
|
struct vmstat_hist hist;
|
||||||
int numitems;
|
int numitems;
|
||||||
@ -1029,11 +1028,6 @@ static int vmstat_read_failed (
|
|||||||
head = tail + 1;
|
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;
|
return 0;
|
||||||
} // end: vmstat_read_failed
|
} // end: vmstat_read_failed
|
||||||
|
|
||||||
@ -1135,7 +1129,8 @@ PROCPS_EXPORT int procps_vmstat_new (
|
|||||||
|
|
||||||
/* do a priming read here for the following potential benefits: |
|
/* do a priming read here for the following potential benefits: |
|
||||||
1) ensure there will be no problems with subsequent access |
|
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))) {
|
if ((rc = vmstat_read_failed(p))) {
|
||||||
procps_vmstat_unref(&p);
|
procps_vmstat_unref(&p);
|
||||||
return rc;
|
return rc;
|
||||||
|
Loading…
Reference in New Issue
Block a user