RFR: 8262291: Refactor reserve_memory_special_huge_tlbfs [v6]

Stefan Johansson sjohanss at openjdk.java.net
Mon Apr 12 09:31:22 UTC 2021


> Please review this refactoring of the hugetlbfs reservation code.
> 
> **Summary**
> In recent adventures in this area of the code I noticed a strange condition in `reserve_memory_special_huge_tlbfs` where we take the "mixed-mapping" route even if the size doesn't require any small pages to be used:
> 
>   if (is_aligned(bytes, os::large_page_size()) && alignment <= os::large_page_size()) {
>     return reserve_memory_special_huge_tlbfs_only(bytes, req_addr, exec);
>   } else {
>     return reserve_memory_special_huge_tlbfs_mixed(bytes, alignment, req_addr, exec);
>   }
> 
> 
> The second condition here is needed because if the alignment is larger than the large page size, we needed to enforce this and can't just trust `mmap` to give us a properly aligned address. Doing this by using the mixed-function feels a bit weird and looking a bit more at this I found a way to refactor this function to avoid having the two helpers. 
> 
> Instead of only having the mixed path honor the passed down alignment, make sure that is always done. This will also have the side-effect that all large pages in a "mixed"-mapping will be at the start and then we will have a tail of small pages. This actually also ensures that we will use large pages for a mixed mapping, in the past there was a corner case where we could end up with just a head and tail of small pages and no large page in between (if the mapping was smaller than 2 large pages and there was no alignment constraint).
> 
> **Testing**
> Mach5 tier1-3 and a lot of local testing with different large page configurations.

Stefan Johansson has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains six additional commits since the last revision:

 - Merge branch 'master' into 8262291-one-special-alloc
 - Thomas review.
   
   Changed commit_memory_special to return bool to signal if the request succeeded or not.
 - Self review.
   
   Update helper name to better match commit_memory_special().
 - Marcus review.
   
   Updated comments.
 - Ivan review
   
   Renamed helper to commit_memory_special and updated the comments.
 - 8262291: Refactor reserve_memory_special_huge_tlbfs

-------------

Changes:
  - all: https://git.openjdk.java.net/jdk/pull/3073/files
  - new: https://git.openjdk.java.net/jdk/pull/3073/files/787b87fe..44936c49

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=jdk&pr=3073&range=05
 - incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=3073&range=04-05

  Stats: 66087 lines in 2243 files changed: 43116 ins; 12682 del; 10289 mod
  Patch: https://git.openjdk.java.net/jdk/pull/3073.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/3073/head:pull/3073

PR: https://git.openjdk.java.net/jdk/pull/3073


More information about the hotspot-dev mailing list