Bug 200616

Summary: pmcstat runs out of buckets
Product: Base System Reporter: Hans Petter Selasky <hselasky>
Component: kernAssignee: George V. Neville-Neil <gnn>
Status: Closed FIXED    
Severity: Affects Only Me CC: fernape
Priority: --- Keywords: patch
Version: CURRENT   
Hardware: Any   
OS: Any   

Description Hans Petter Selasky freebsd_committer freebsd_triage 2015-06-03 16:11:07 UTC
Hi,

It has been observed that pmcstat can run out of buckets leading to an assert, when converting trace data into gprof compatible format. Applying the following patch, temporarily solves the problem:

diff --git a/usr.sbin/pmcstat/pmcpl_gprof.c b/usr.sbin/pmcstat/pmcpl_gprof.c
index 9ff78e8..4a8849f 100644
--- a/usr.sbin/pmcstat/pmcpl_gprof.c
+++ b/usr.sbin/pmcstat/pmcpl_gprof.c
@@ -445,8 +445,8 @@ pmcpl_gmon_process(struct pmcstat_process *pp, struct pmcstat_pmcrecord *pmcr,
                image, pmcid);
            pgf->pgf_pmcid = pmcid;
            assert(image->pi_end > image->pi_start);
-               pgf->pgf_nbuckets = (image->pi_end - image->pi_start) /
-                   FUNCTION_ALIGNMENT; /* see <machine/profile.h> */
+               pgf->pgf_nbuckets = (image->pi_end - image->pi_start); // /
+       //                  FUNCTION_ALIGNMENT; /* see <machine/profile.h> */
            pgf->pgf_ndatabytes = sizeof(struct gmonhdr) +
                pgf->pgf_nbuckets * sizeof(HISTCOUNTER);
            pgf->pgf_nsamples = 0; 

--HPS
Comment 1 Fernando ApesteguĂ­a freebsd_committer freebsd_triage 2023-01-25 12:28:09 UTC
I'd say this calculation was fixed with the use of the howmany macro?
Comment 2 Fernando ApesteguĂ­a freebsd_committer freebsd_triage 2023-02-01 11:52:39 UTC
Closing since this seems to be fixed by the use of the "howmany" macro.