I'm working on a Linux project, and I have a question ㅜㅜ

Asked 2 years ago, Updated 2 years ago, 78 views

Using Raspberry Pi, output the L1 cache miss rate to the screen every 1 minute, and turn on the LED bulb when the cache miss rate exceeds 50%.

The LED light bulb will be turned on using GPIO, but I wonder how to arbitrarily raise the L1 cache miss rate by more than 50% with the source code. I've been googling all day, but it's not coming out well.

And if you use perf or valgrind, L2 comes out, but L1 doesn't come out, and I1 comes out... How can I print out L1? What should I do if I want to give each minute?

Masters, please answer. It's hard because it's my first time with the kernel ㅜ<

linux kernel raspberry-pi

2022-09-21 20:02

1 Answers

https://hashcode.co.kr/questions/1521See

The following command is a list of measurements that can be obtained through perf.

perf list

The next item in perf is L1 cache.

L1-dcache-loads
L1-dcache-load-misses
L1-dcache-stores
L1-dcache-store-misses
L1-dcache-prefetches
L1-dcache-prefetch-misses
L1-icache-loads
L1-icache-load-misses
L1-icache-prefetches
L1-icache-prefetch-misses

perf <perf command> -e <measurement items,...> <Execution Commands>

Simple perf command

Example

perf stat -e  L1-dcache-loads,L1-dcache-load-misses ls

The above example will output the L1 cache measurements of the ls command.

Reference

How to run commands repeatedly

watch -n <N seconds> <Command to repeat>

Write the previous perf command syntax in the command syntax to repeat, and if you set N to 60, it will repeat every minute.


2022-09-21 20:02

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.