• Kajol Jain's avatar
    powerpc/perf: Adds support for programming of Thresholding in P10 · 82d2c16b
    Kajol Jain authored
    Thresholding, a performance monitoring unit feature, can be
    used to identify marked instructions which take more than
    expected cycles between start event and end event.
    Threshold compare (thresh_cmp) bits are programmed in MMCRA
    register. In Power9, thresh_cmp bits were part of the
    event code. But in case of P10, thresh_cmp are not part of
    event code due to inclusion of MMCR3 bits.
    
    Patch here adds an option to use attr.config1 variable
    to be used to pass thresh_cmp value to be programmed in
    MMCRA register. A new ppmu flag called PPMU_HAS_ATTR_CONFIG1
    has been added and this flag is used to notify the use of
    attr.config1 variable.
    
    Patch has extended the parameter list of 'compute_mmcr',
    to include power_pmu's 'flags' element and parameter list of
    get_constraint to include attr.config1 value. It also extend
    parameter list of power_check_constraints inorder to pass
    perf_event list.
    
    As stated by commit ef0e3b65 ("powerpc/perf: Fix Threshold
    Event Counter Multiplier width for P10"), constraint bits for
    thresh_cmp is also needed to be increased to 11 bits, which is
    handled as part of this patch. We added bit number 53 as part
    of constraint bits of thresh_cmp for power10 to make it an
    11 bit field.
    
    Updated layout for p10:
    
    /*
     * Layout of constraint bits:
     *
     *        60        56        52        48        44        40        36        32
     * | - - - - | - - - - | - - - - | - - - - | - - - - | - - - - | - - - - | - - - - |
     *   [   fab_match   ]         [       thresh_cmp      ] [   thresh_ctl    ] [   ]
     *                                          |                                  |
     *                           [  thresh_cmp bits for p10]           thresh_sel -*
     *
     *        28        24        20        16        12         8         4         0
     * | - - - - | - - - - | - - - - | - - - - | - - - - | - - - - | - - - - | - - - - |
     *               [ ] |   [ ] |  [  sample ]   [     ]   [6] [5]   [4] [3]   [2] [1]
     *                |  |    |  |                  |
     *      BHRB IFM -*  |    |  |*radix_scope      |      Count of events for each PMC.
     *              EBB -*    |                     |        p1, p2, p3, p4, p5, p6.
     *      L1 I/D qualifier -*                     |
     *                     nc - number of counters -*
     *
     * The PMC fields P1..P6, and NC, are adder fields. As we accumulate constraints
     * we want the low bit of each field to be added to any existing value.
     *
     * Everything else is a value field.
     */
    
    Result:
    command#: cat /sys/devices/cpu/format/thresh_cmp
    config1:0-17
    
    ex. usage:
    
    command#: perf record -I --weight -d  -e
    	 cpu/event=0x67340101EC,thresh_cmp=500/ ./ebizzy -S 2 -t 1 -s 4096
    1826636 records/s
    real  2.00 s
    user  2.00 s
    sys   0.00 s
    [ perf record: Woken up 1 times to write data ]
    [ perf record: Captured and wrote 0.038 MB perf.data (61 samples) ]
    Signed-off-by: default avatarKajol Jain <kjain@linux.ibm.com>
    Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20210209095234.837356-1-kjain@linux.ibm.com
    82d2c16b
power7-pmu.c 11.4 KB