@Test @DisplayName("getHugepageSize()") void getHugepageSize() { assumeTrue(mmanager != null); val pageSize = mmanager.getHugepageSize(); assertThat(pageSize).isPositive().withFailMessage("should be a power of two").isEqualTo(pageSize & -pageSize); }
@Override @Contract(value = " -> fail", pure = true) @SuppressWarnings({"deprecation", "PMD.DataflowAnomalyAnalysis"}) public long getHugepageSize() { if (!OPTIMIZED && unsafe == null) throw new NullPointerException("The Unsafe object is not available."); if (DEBUG >= LOG_TRACE) log.trace("Checking the huge page size."); if (!existsInMtab(MTAB_PATH, "hugetlbfs", DEFAULT_HUGEPAGE_PATH, "hugetlbfs")) { return hugepageSize = HUGE_PAGE_NOT_SUPPORTED; } if (DEBUG >= LOG_DEBUG) log.debug("Parsing file '{}'.", MEMINFO_PATH); try (val meminfo = bufferedReader(new File(MEMINFO_PATH))) { val pattern = Pattern.compile("Hugepagesize:[\\t\\s ]+(\\d+)[\\t\\s ]+([kMG]?B)"); for (var line = meminfo.readLine(); line != null; line = meminfo.readLine()) { val matcher = pattern.matcher(line); if (matcher.find()) { return hugepageSize = applyFactor(Long.parseLong(matcher.group(1)), matcher.group(2)); } } } catch (final FileNotFoundException e) { if (DEBUG >= LOG_ERROR) log.error("The file '{}' cannot be found.", MEMINFO_PATH, e); } catch (final IOException e) { if (DEBUG >= LOG_ERROR) log.error("The file '{}' cannot be read or closed.", MEMINFO_PATH, e); } return hugepageSize = 0; }
SmartUnsafeMemoryManager extends UnsafeMemoryManager { @Override @Contract(value = " -> fail", pure = true) @SuppressWarnings({"deprecation", "PMD.DataflowAnomalyAnalysis"}) public long getHugepageSize() { if (!OPTIMIZED && unsafe == null) throw new NullPointerException("The Unsafe object is not available."); if (DEBUG >= LOG_TRACE) log.trace("Checking the huge page size."); if (!existsInMtab(MTAB_PATH, "hugetlbfs", DEFAULT_HUGEPAGE_PATH, "hugetlbfs")) { return hugepageSize = HUGE_PAGE_NOT_SUPPORTED; } if (DEBUG >= LOG_DEBUG) log.debug("Parsing file '{}'.", MEMINFO_PATH); try (val meminfo = bufferedReader(new File(MEMINFO_PATH))) { val pattern = Pattern.compile("Hugepagesize:[\\t\\s ]+(\\d+)[\\t\\s ]+([kMG]?B)"); for (var line = meminfo.readLine(); line != null; line = meminfo.readLine()) { val matcher = pattern.matcher(line); if (matcher.find()) { return hugepageSize = applyFactor(Long.parseLong(matcher.group(1)), matcher.group(2)); } } } catch (final FileNotFoundException e) { if (DEBUG >= LOG_ERROR) log.error("The file '{}' cannot be found.", MEMINFO_PATH, e); } catch (final IOException e) { if (DEBUG >= LOG_ERROR) log.error("The file '{}' cannot be read or closed.", MEMINFO_PATH, e); } return hugepageSize = 0; } }
SmartUnsafeMemoryManager extends UnsafeMemoryManager { @Override @Contract(value = " -> fail", pure = true) @SuppressWarnings({"deprecation", "PMD.DataflowAnomalyAnalysis"}) public long getHugepageSize() { if (!OPTIMIZED && unsafe == null) throw new NullPointerException("The Unsafe object is not available."); if (DEBUG >= LOG_TRACE) log.trace("Checking the huge page size."); if (!existsInMtab(MTAB_PATH, "hugetlbfs", DEFAULT_HUGEPAGE_PATH, "hugetlbfs")) { return hugepageSize = HUGE_PAGE_NOT_SUPPORTED; } if (DEBUG >= LOG_DEBUG) log.debug("Parsing file '{}'.", MEMINFO_PATH); try (val meminfo = bufferedReader(new File(MEMINFO_PATH))) { val pattern = Pattern.compile("Hugepagesize:[\\t\\s ]+(\\d+)[\\t\\s ]+([kMG]?B)"); for (var line = meminfo.readLine(); line != null; line = meminfo.readLine()) { val matcher = pattern.matcher(line); if (matcher.find()) { return hugepageSize = applyFactor(Long.parseLong(matcher.group(1)), matcher.group(2)); } } } catch (final FileNotFoundException e) { if (DEBUG >= LOG_ERROR) log.error("The file '{}' cannot be found.", MEMINFO_PATH, e); } catch (final IOException e) { if (DEBUG >= LOG_ERROR) log.error("The file '{}' cannot be read or closed.", MEMINFO_PATH, e); } return hugepageSize = 0; } private  SmartUnsafeMemoryManager(); }
SmartUnsafeMemoryManager extends UnsafeMemoryManager { @Override @Contract(value = " -> fail", pure = true) @SuppressWarnings({"deprecation", "PMD.DataflowAnomalyAnalysis"}) public long getHugepageSize() { if (!OPTIMIZED && unsafe == null) throw new NullPointerException("The Unsafe object is not available."); if (DEBUG >= LOG_TRACE) log.trace("Checking the huge page size."); if (!existsInMtab(MTAB_PATH, "hugetlbfs", DEFAULT_HUGEPAGE_PATH, "hugetlbfs")) { return hugepageSize = HUGE_PAGE_NOT_SUPPORTED; } if (DEBUG >= LOG_DEBUG) log.debug("Parsing file '{}'.", MEMINFO_PATH); try (val meminfo = bufferedReader(new File(MEMINFO_PATH))) { val pattern = Pattern.compile("Hugepagesize:[\\t\\s ]+(\\d+)[\\t\\s ]+([kMG]?B)"); for (var line = meminfo.readLine(); line != null; line = meminfo.readLine()) { val matcher = pattern.matcher(line); if (matcher.find()) { return hugepageSize = applyFactor(Long.parseLong(matcher.group(1)), matcher.group(2)); } } } catch (final FileNotFoundException e) { if (DEBUG >= LOG_ERROR) log.error("The file '{}' cannot be found.", MEMINFO_PATH, e); } catch (final IOException e) { if (DEBUG >= LOG_ERROR) log.error("The file '{}' cannot be read or closed.", MEMINFO_PATH, e); } return hugepageSize = 0; } private  SmartUnsafeMemoryManager(); @Override @Contract(pure = true) boolean isValid(); @Override @Contract(pure = true) long getPageSize(); @Override @Contract(value = " -> fail", pure = true) @SuppressWarnings({"deprecation", "PMD.DataflowAnomalyAnalysis"}) long getHugepageSize(); @Override @Contract(pure = true) @SuppressWarnings("BooleanParameter") long allocate(long bytes, boolean huge, boolean lock); @Override @SuppressWarnings("BooleanParameter") void free(long address, long bytes, final boolean huge, final boolean lock); @Override @Contract(pure = true) @SuppressWarnings({"deprecation", "BooleanParameter", "IOResourceOpenedButNotSafelyClosed", "resource"}) long mmap(final @NotNull File file, final boolean huge, final boolean lock); @Override @SuppressWarnings({"deprecation", "BooleanParameter", "PMD.DataflowAnomalyAnalysis"}) void munmap(final long address, final @NotNull File file, final boolean huge, final boolean lock); @Override @Contract(pure = true) @SuppressWarnings("deprecation") @SuppressFBWarnings("") long virt2phys(final long address); @Override @Contract(value = "_, _, _ -> fail", pure = true) @SuppressWarnings({"deprecation", "BooleanParameter"}) @NotNull DmaMemory dmaAllocate(final long bytes, final boolean huge, final boolean lock); }
SmartUnsafeMemoryManager extends UnsafeMemoryManager { @Override @Contract(value = " -> fail", pure = true) @SuppressWarnings({"deprecation", "PMD.DataflowAnomalyAnalysis"}) public long getHugepageSize() { if (!OPTIMIZED && unsafe == null) throw new NullPointerException("The Unsafe object is not available."); if (DEBUG >= LOG_TRACE) log.trace("Checking the huge page size."); if (!existsInMtab(MTAB_PATH, "hugetlbfs", DEFAULT_HUGEPAGE_PATH, "hugetlbfs")) { return hugepageSize = HUGE_PAGE_NOT_SUPPORTED; } if (DEBUG >= LOG_DEBUG) log.debug("Parsing file '{}'.", MEMINFO_PATH); try (val meminfo = bufferedReader(new File(MEMINFO_PATH))) { val pattern = Pattern.compile("Hugepagesize:[\\t\\s ]+(\\d+)[\\t\\s ]+([kMG]?B)"); for (var line = meminfo.readLine(); line != null; line = meminfo.readLine()) { val matcher = pattern.matcher(line); if (matcher.find()) { return hugepageSize = applyFactor(Long.parseLong(matcher.group(1)), matcher.group(2)); } } } catch (final FileNotFoundException e) { if (DEBUG >= LOG_ERROR) log.error("The file '{}' cannot be found.", MEMINFO_PATH, e); } catch (final IOException e) { if (DEBUG >= LOG_ERROR) log.error("The file '{}' cannot be read or closed.", MEMINFO_PATH, e); } return hugepageSize = 0; } private  SmartUnsafeMemoryManager(); @Override @Contract(pure = true) boolean isValid(); @Override @Contract(pure = true) long getPageSize(); @Override @Contract(value = " -> fail", pure = true) @SuppressWarnings({"deprecation", "PMD.DataflowAnomalyAnalysis"}) long getHugepageSize(); @Override @Contract(pure = true) @SuppressWarnings("BooleanParameter") long allocate(long bytes, boolean huge, boolean lock); @Override @SuppressWarnings("BooleanParameter") void free(long address, long bytes, final boolean huge, final boolean lock); @Override @Contract(pure = true) @SuppressWarnings({"deprecation", "BooleanParameter", "IOResourceOpenedButNotSafelyClosed", "resource"}) long mmap(final @NotNull File file, final boolean huge, final boolean lock); @Override @SuppressWarnings({"deprecation", "BooleanParameter", "PMD.DataflowAnomalyAnalysis"}) void munmap(final long address, final @NotNull File file, final boolean huge, final boolean lock); @Override @Contract(pure = true) @SuppressWarnings("deprecation") @SuppressFBWarnings("") long virt2phys(final long address); @Override @Contract(value = "_, _, _ -> fail", pure = true) @SuppressWarnings({"deprecation", "BooleanParameter"}) @NotNull DmaMemory dmaAllocate(final long bytes, final boolean huge, final boolean lock);  }