library: add priming read at 'new' time <most modules>

A priming read at 'new' time in that <slabinfo> module
was important so that permission problems are detected
early. Plus, it also had the potential of making delta
values valid when 'get' or 'select' were first called.

It is for that latter reason that such a read was also
incorporated in the <diskstats> module 'new' function.
No other module, however, employed such priming reads.

This patch just brings those potential benefits to all
of our other newlib modules with the exception of that
<pids> guy. That module is, of necessity, sufficiently
different from those others to justify such exclusion.

Not only are there precious few DELTA enums in <pids>,
but the costs of a priming read would be much greater.

[ otherwise, these newly added priming reads have no ]
[ measurable negative impact on performance/timings. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner 2016-09-17 04:44:44 -05:00 committed by Craig Small
parent 5197fa0a71
commit 1a2b62c779
3 changed files with 25 additions and 0 deletions

View File

@ -749,6 +749,14 @@ PROCPS_EXPORT int procps_meminfo_new (
return rc;
}
/* 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 | */
if ((rc = meminfo_read_failed(p))) {
procps_meminfo_unref(&p);
return rc;
}
*info = p;
return 0;
} // end: procps_meminfo_new

View File

@ -828,6 +828,7 @@ PROCPS_EXPORT int procps_stat_new (
struct stat_info **info)
{
struct stat_info *p;
int rc;
if (info == NULL || *info != NULL)
return -EINVAL;
@ -869,6 +870,14 @@ PROCPS_EXPORT int procps_stat_new (
#endif
#endif
/* 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 | */
if ((rc = stat_read_failed(p))) {
procps_stat_unref(&p);
return rc;
}
*info = p;
return 0;
} // end :procps_stat_new

View File

@ -1133,6 +1133,14 @@ PROCPS_EXPORT int procps_vmstat_new (
return rc;
}
/* 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 | */
if ((rc = vmstat_read_failed(p))) {
procps_vmstat_unref(&p);
return rc;
}
*info = p;
return 0;
} // end: procps_vmstat_new