]> git.ipfire.org Git - thirdparty/libvirt.git/commit
virhostmem: Introduce virHostMemGetTHPSize()
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 20 Jan 2021 10:30:34 +0000 (11:30 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 1 Oct 2021 08:58:27 +0000 (10:58 +0200)
commit45aa4c1d2aaebf3ec1f85827222bcbb215c28d73
tree69603c30db3e3e7d566cb339a41b3a9c70c7e21b
parent9c47d2754ca23cac41e993631b4dfdab2eee288b
virhostmem: Introduce virHostMemGetTHPSize()

New virHostMemGetTHPSize() is introduced which allows caller to
obtain THP PMD (Page Middle Directory) size, which is equal to
the minimal size that THP can use, taken from kernel doc
(Documentation/admin-guide/mm/transhuge.rst):

  Some userspace (such as a test program, or an optimized memory allocation
  library) may want to know the size (in bytes) of a transparent hugepage::

    cat /sys/kernel/mm/transparent_hugepage/hpage_pmd_size

Since this size depends on the host architecture and the kernel
it won't change whilst libvirtd is running. Therefore, we can use
virOnce() and cache the value. Of course, we can be running under
kernel that has THP disabled or has no notion of THP at all. In
that case a negative value is returned to signal error.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/libvirt_private.syms
src/util/virhostmem.c
src/util/virhostmem.h
tests/domaincapsmock.c