Closed zinechant closed 3 years ago
It is necessary for the majority of calls to __page_alloc. mmap'ed pages are required to be zeroed, and of course there's no guarantee that main memory is already zeroed. (The fact that Spike zeroes main memory at boot is an implementation detail and is not true of other RISC-V implementations.)
Besides mmap, other uses of __page_alloc within pk rely on the zero initialization, including when new page tables are allocated.
Search for the word "zero-fills" on this page for more details on the mmap situation: https://pubs.opengroup.org/onlinepubs/7908799/xsh/mmap.html
That was fast! Thanks! I am happy with a little hack that commenting out the memset for my purpose. Going to close this issue.
Cool, good luck.
This would pollute caches and produce strange cache numbers in spike-isa-sim. Especially for the case where compute is not intensive, or for the case when a large array is malloced but only a small portion is used. Opening this issue to open the discussion on whether this memset is necessary.