abertschi / abertschi.ch

https://abertschi.ch
2 stars 2 forks source link

Lack of memory set for prefetching-probing example #1

Open usstq opened 6 months ago

usstq commented 6 months ago

I just wonder, there is no memory set on the probe_array just allocated, wouldn't Linux's Copy-On-Write mechanism just return the same all-zero physical page for the 8192 bytes (two pages) allocation?

https://github.com/abertschi/abertschi.ch/blob/d0b2bcc0bacf286d93609c0696c7fcfe7674a81e/hugo/content/blog/2022-09-prefetching/prefetching.md?plain=1#L225

abertschi commented 6 months ago

The code snippet cited shows how I measured the impact of the hardware prefetcher when accessing a desired sequence of memory accesses.

We dont care about what is in memory, we are only interested in what is being accessed and thus loaded into the cache.

The mmap invocation will return us a chunk of memory mapped into the address space which is eagerly mapped, so the kernel will page fault all memory and we receive an array of zero initialized memory upon completion of mmap call.

I hope this helps. Cheers.