Re: [PATCH] perf, tools: Add script to easily decode addresses

From: Namhyung Kim
Date: Sun Mar 16 2014 - 20:44:04 EST


Hi Andi,

On Thu, 13 Mar 2014 12:53:58 -0700, Andi Kleen wrote:
> +def MASK(bits):
> + return (1 << bits) - 1
> +
> +def decode_bits(val, names, bits, shift):
> + v = (val >> shift) & MASK(bits)
> + s = ""
> + for name, index in zip(names, range(0, len(names))):
> + if v & (1 << index):
> + s += " " + name
> + return s
> +
> +# __u64 mem_op:5, /* type of opcode */
> +# mem_lvl:14, /* memory hierarchy level */
> +# mem_snoop:5, /* snoop mode */
> +# mem_lock:2, /* lock instr */
> +# mem_dtlb:7, /* tlb access */
> +# mem_rsvd:31;
> +
> +def decode_datasrc(d):
> + s = ""
> + s += decode_bits(d, ['', 'LOAD', 'STORE?', 'PREFETCH', 'EXEC'], 5, 0)
> + s += decode_bits(d, ['', 'HIT', 'MISS', 'L1', 'LFB', 'L2', 'L3',
> + 'LOC_RAM', 'REM-RAM-1', 'REM-RAM-2', 'REM-CACHE-1'
> + 'REM-CACHE-2', 'REM-IO', 'REM-UNCACHED'], 14, 5)
> + s += decode_bits(d, ['', 'NONE', 'MISS', 'HITM'], 19, 5)
> + s += decode_bits(d, ['', 'LOCKED'], 24, 2)
> + s += decode_bits(d, ['', 'L1', 'L2', 'WK', 'OS'], 26, 7)

Shouldn't it be like below (bits and shift exchanged)?

s += decode_bits(d, ['', 'NONE', 'MISS', 'HITM'], 5, 19)
s += decode_bits(d, ['', 'LOCKED'], 2, 24)
s += decode_bits(d, ['', 'L1', 'L2', 'WK', 'OS'], 7, 26)

Thanks,
Namhyung
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/