]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
memfd_create: simplify HUGETLB support a little bit
authorKyle Evans <kevans@FreeBSD.org>
Fri, 11 Sep 2020 02:02:15 +0000 (02:02 +0000)
committerKyle Evans <kevans@FreeBSD.org>
Fri, 11 Sep 2020 02:02:15 +0000 (02:02 +0000)
commit8b8cf4ece660f8068313c4891bd675c5ef895cf4
tree90402555c936b63614029ab800c86f3adc9f0ec2
parent0b39e3448aeace003ccdbcc54a32662e673c3131
memfd_create: simplify HUGETLB support a little bit

This also fixes a minor issue that was missed in the initial review; the
layout of the MFD_HUGE_* flags is actually not 1:1 bit:flag -- it instead
borrowed the Linux convention of how this is laid out since it was
originally implemented on Linux, the top 6 bits represent the shift required
for the requested page size.

This allows us to remove the flag <-> pgsize mapping table and simplify the
logic just prior to validation of the requested page size.

While we're here, fix two small nits:

- HUGETLB memfd shouldn't exhibit the SHM_GROW_ON_WRITE behavior. We can
  only grow largepage shm by appropriately aligned (i.e. requested pagesize)
  sizes, so it can't work in the typical/sane fashion. Furthermore, Linux
  does the same, so let's be compatible.

- We don't allow MFD_HUGETLB without specifying a pagesize, so no need to
  check for that later.

Reviewed by: kib (slightly earlier version)
lib/libc/sys/shm_open.c