Page MenuHomeFreeBSD

hwpmc_amd: split allocation paths
Needs ReviewPublic

Authored by mhorne on Mon, Sep 28, 6:09 PM.
Tags
None
Referenced Files
F173881677: D60101.id187910.diff
Tue, Sep 29, 2:27 AM
F173875314: D60101.diff
Tue, Sep 29, 1:26 AM
F173868552: D60101.id187910.diff
Tue, Sep 29, 12:20 AM
F173844574: D60101.id187910.diff
Mon, Sep 28, 8:42 PM
F173843904: D60101.diff
Mon, Sep 28, 8:34 PM
F173833003: D60101.diff
Mon, Sep 28, 6:51 PM
F173832436: D60101.diff
Mon, Sep 28, 6:44 PM
F173831505: D60101.diff
Mon, Sep 28, 6:37 PM
Subscribers

Details

Summary

The legacy and modern (pmu-events) allocation paths are distinct.
Further clarify this by splitting the function in two.

Diff Detail

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

Event Timeline

sys/dev/hwpmc/hwpmc_amd.c
413

should we not check for PMC_F_EV_PMU here also?

if ((a->pm_flags & PMC_F_EV_PMU) != 0)
              return (EXTERROR(EINVAL,
                  "AMD pmu-events are not supported on this CPU"));
419

PMCDBG2(MDP, ALL, 1,"amd-allocate-legacy ri=%d caps=0x%x", ri, caps);

468

PMCDBG2(MDP, ALL, 2, "amd-allocate-legacy ri=%d -> config=0x%x", ri, config);

505

I think you need to put this check also in the beginning of the legacy path, otherwise if a client fills all core counters, a wrong allocation can happen on the L3 row. For example, the command

pmcstat -s k8-fr-retired-x86-instructions -s k8-bu-cpu-clk-unhalted \
        -s k8-dc-access -s k8-dc-miss -s k8-ic-miss \
        -s k8-fr-retired-taken-branches -s k8-ic-fetch  sleep 5

will put k8-ic-fetch on an L3 counter. Today it returns an error (expected):

❯ sudo pmcstat -s k8-fr-retired-x86-instructions -s k8-bu-cpu-clk-unhalted \                                                                                                                                                                        -s k8-dc-access -s k8-dc-miss -s k8-ic-miss \                                                                                                                                                                                               -s k8-fr-retired-taken-branches -s k8-ic-fetch  sleep 5                                                                                                                                                                             pmcstat: ERROR: Cannot allocate system-mode pmc with specification "k8-ic-fetch": Invalid argument (No PMC row accepted the allocation request)