# Linux Kernel Module Cheat

#### 24.21.4. gem5 `CommMonitor`

You can place this SimObject in between two ports to get extra statistics about the packets that are going through.

It only works on timing requests, and does not seem to dump any memory values, only add extra statistics.

For example, the patch patches/manual/gem5-commmonitor-se.patch hack a `CommMonitor` between the CPU and the L1 cache on top of gem5 1c3662c9557c85f0d25490dc4fbde3f8ab0cb350:

    patch -d "$(./getvar gem5_source_dir)" -p 1 < patches/manual/gem5-commmonitor-se.patch

That patch was done largely by copying what `fs.py --memcheck` does with a `MemChecker` object.

You can then run with:

    ./run \
      --arch aarch64 \
      --emulator gem5 \
      --userland userland/arch/aarch64/freestanding/linux/hello.S \
      -- \
      --caches \
      --cpu-type TimingSimpleCPU \
    ;

and now we have some new extra histogram statistics such as:

    system.cpu.dcache_mon.readBurstLengthHist::samples            1

One neat thing about this is that it is agnostic to the memory object type, so you don’t have to recode those statistics for every new type of object that operates on memory packets.