Page MenuHomeFreeBSD

hwpmc: keep all samples when a log is closed
Needs ReviewPublic

Authored by afscoelho_gmail.com on Wed, Sep 30, 9:09 PM.
Tags
None
Referenced Files
F174464136: D60186.id.diff
Sat, Oct 3, 11:18 AM
F174453219: D60186.id188483.diff
Sat, Oct 3, 8:38 AM
F174444931: D60186.id188483.diff
Sat, Oct 3, 6:51 AM
F174427529: D60186.id188268.diff
Sat, Oct 3, 3:19 AM
Unknown Object (File)
Fri, Oct 2, 8:10 AM
Unknown Object (File)
Thu, Oct 1, 10:49 PM
Unknown Object (File)
Thu, Oct 1, 10:43 PM
Unknown Object (File)
Thu, Oct 1, 8:33 AM
Subscribers

Details

Reviewers
mhorne
ali_mashtizadeh.com
gnn
Group Reviewers
pmc
Summary

A sampling log could lose most of its samples at close, and
pmcstat -R then read few or none, with no error.

  • pmclog_close() wrote the close record before it queued the buffers of the other CPUs. Their samples came after the close record, where pmclog_read() stops.
  • pmclog_stop_kthread() cleared PMC_PO_OWNS_LOGFILE before the helper wrote its queue. The helper exited, and pmclog_deconfigure_log() freed the queued buffers.

Queue all buffers, set PMC_PO_SHUTDOWN, queue again, and write the
close record last. After a close, let the helper write its queue
before it exits. Stop waiting after 500 ms without progress, e.g.
when nobody reads a pipe.

Add a test: write records on one CPU, close the log on another, and
check that no record follows the close record.

Sponsored by: AMD

Test Plan
pmcstat -n 1000000 -P instructions -O /tmp/s.log <cpu-bound loop>
pmcstat -R /tmp/s.log -o /dev/stdout | grep -c ^callchain

Before: 486 NMIs, pmcstat -R reads 0-2 samples; most samples are
after the close record.
After: 486 of 486. Same with -S and SIGINT: no record after the close
record. With a pipe that nobody reads, pmcstat still exits in about
1 s on SIGINT or SIGKILL.

tests/sys/pmc/pmc_log_test:close_record_is_last fails before and
passes after.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 77563
Build 74446: arc lint + arc unit