Re: [PATCH v2 2/2] mm: speed up mremap by 500x on large regions

From: David Miller
Date: Fri Oct 12 2018 - 14:18:41 EST


From: Joel Fernandes <joel@xxxxxxxxxxxxxxxxx>
Date: Fri, 12 Oct 2018 05:50:46 -0700

> If its an issue, then how do transparent huge pages work on Sparc? I don't
> see the huge page code (move_huge_pages) during mremap doing anything special
> for Sparc architecture when moving PMDs..

This is because all huge pages are larger than SHMLBA. So no cache flushing
necessary.

> Also, do we not flush the caches from any path when we munmap
> address space? We do call do_munmap on the old mapping from mremap
> after moving to the new one.

Sparc makes sure that shared mapping have consistent colors. Therefore
all that's left are private mappings and those will be initialized by
block stores to clear the page out or similar.

Also, when creating new mappings, we flush the D-cache when necessary
in update_mmu_cache().

We also maintain a bit in the page struct to track when a page which
was potentially written to on one cpu ends up mapped into another
address space and flush as necessary.

The cache is write-through, which simplifies the preconditions we have
to maintain.