aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/pmcstat
diff options
context:
space:
mode:
authorFabien Thomas <fabient@FreeBSD.org>2011-10-18 15:25:43 +0000
committerFabien Thomas <fabient@FreeBSD.org>2011-10-18 15:25:43 +0000
commitdceed24a7c730b6c50166d699e2110379c196a79 (patch)
tree3965b86bd8e0e5d008fd4219e7d38fa2351bfcac /usr.sbin/pmcstat
parenta7e054044c3fa072d72ecf23db03e37915403137 (diff)
downloadsrc-dceed24a7c730b6c50166d699e2110379c196a79.tar.gz
src-dceed24a7c730b6c50166d699e2110379c196a79.zip
Add a flush of the current PMC log buffer before displaying the next top.
As the underlying block is 4KB if the PMC throughput is low the measurement will be reported on the next tick. pmcstat(8) use the modified flush API to reclaim current buffer before displaying next top. MFC after: 1 month
Notes
Notes: svn path=/head/; revision=226514
Diffstat (limited to 'usr.sbin/pmcstat')
-rw-r--r--usr.sbin/pmcstat/pmcstat.c18
-rw-r--r--usr.sbin/pmcstat/pmcstat_log.c2
2 files changed, 11 insertions, 9 deletions
diff --git a/usr.sbin/pmcstat/pmcstat.c b/usr.sbin/pmcstat/pmcstat.c
index 31ef87770536..5d9db61952db 100644
--- a/usr.sbin/pmcstat/pmcstat.c
+++ b/usr.sbin/pmcstat/pmcstat.c
@@ -552,7 +552,7 @@ main(int argc, char **argv)
int hcpu, option, npmc, ncpu;
int c, check_driver_stats, current_cpu, current_sampling_count;
int do_callchain, do_descendants, do_logproccsw, do_logprocexit;
- int do_print;
+ int do_print, do_read;
size_t dummy;
int graphdepth;
int pipefd[2], rfd;
@@ -1328,7 +1328,7 @@ main(int argc, char **argv)
* are killed by a SIGINT.
*/
runstate = PMCSTAT_RUNNING;
- do_print = 0;
+ do_print = do_read = 0;
do {
if ((c = kevent(pmcstat_kq, NULL, 0, &kev, 1, NULL)) <= 0) {
if (errno != EINTR)
@@ -1351,8 +1351,10 @@ main(int argc, char **argv)
(args.pa_flags & FLAG_DO_TOP)) {
if (pmcstat_keypress_log())
runstate = pmcstat_close_log();
- } else
+ } else {
+ do_read = 0;
runstate = pmcstat_process_log();
+ }
break;
case EVFILT_SIGNAL:
@@ -1377,9 +1379,6 @@ main(int argc, char **argv)
/* Kill the child process if we started it */
if (args.pa_flags & FLAG_HAS_COMMANDLINE)
pmcstat_kill_process();
- /* Close the pipe to self, if present. */
- if (args.pa_flags & FLAG_HAS_PIPE)
- (void) close(pipefd[READPIPEFD]);
runstate = pmcstat_close_log();
} else if (kev.ident == SIGWINCH) {
if (ioctl(fileno(args.pa_printfile),
@@ -1394,12 +1393,15 @@ main(int argc, char **argv)
break;
case EVFILT_TIMER: /* print out counting PMCs */
+ if ((args.pa_flags & FLAG_DO_TOP) &&
+ pmc_flush_logfile() != ENOBUFS)
+ do_read = 1;
do_print = 1;
break;
}
- if (do_print) {
+ if (do_print && !do_read) {
if ((args.pa_required & FLAG_HAS_OUTPUT_LOGFILE) == 0) {
pmcstat_print_pmcs();
if (runstate == PMCSTAT_FINISHED && /* final newline */
@@ -1420,7 +1422,7 @@ main(int argc, char **argv)
/* flush any pending log entries */
if (args.pa_flags & (FLAG_HAS_OUTPUT_LOGFILE | FLAG_HAS_PIPE))
- pmc_flush_logfile();
+ pmc_close_logfile();
pmcstat_cleanup();
diff --git a/usr.sbin/pmcstat/pmcstat_log.c b/usr.sbin/pmcstat/pmcstat_log.c
index b7dc956d807b..6d0403f00585 100644
--- a/usr.sbin/pmcstat/pmcstat_log.c
+++ b/usr.sbin/pmcstat/pmcstat_log.c
@@ -1702,7 +1702,7 @@ pmcstat_close_log(void)
* so keep the status to EXITING.
*/
if (args.pa_logfd != -1) {
- if (pmc_flush_logfile() < 0)
+ if (pmc_close_logfile() < 0)
err(EX_OSERR, "ERROR: logging failed");
}