Cycle counter – user mode

Tagged: 

This topic contains 1 reply, has 2 voices, and was last updated by  paulburton 2 years, 8 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #31970

    johne
    Member

    If I understand it correctly the mfc0 instruction is only available in kernel mode and the rdhwr (which I’ve used on other mips to get this info) is not available for mips2.
    Is there an easy way to get a cycle count (or another “reliable” measurement for performance) without writing a kernel module with syscalls?

    #39469

    paulburton
    Member

    Hi Johne,

    First of all I’d like to point out that whilst the debian binaries shipped on the CI20 by default are built for the mips2 ISA (since that’s what the debian project choose to target), the XBurst cores in the jz4780 SoC used on the CI20 actually implement the mips32r2 ISA. Although they both end with “2”, the latter is somewhat newer & does include support for the rdhwr instruction so that instruction in itself should be safe to execute. Additionally, the kernel does implement support for emulating the rdhwr instruction on older systems which don’t provide it anyway (http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/arch/mips/kernel/traps.c#n608).

    However, the problem you’re likely to face here is that the XBurst CPU cores don’t actually implement the coprocessor 0 count & compare registers (aka r4k timer in kernel nomenclature). Which unfortunately means right now the answer is likely “no”… It should be possible to have the kernel disable the native rdhwr instruction for the count case though, and emulate it by returning something based upon a timer from the jz4780 timer/counter unit.

Viewing 2 posts - 1 through 2 (of 2 total)
The forum ‘Creator Platforms’ is closed to new topics and replies.