]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
memfd_create: simplify HUGETLB support a little bit
authorkevans <kevans@FreeBSD.org>
Fri, 11 Sep 2020 02:02:15 +0000 (02:02 +0000)
committerkevans <kevans@FreeBSD.org>
Fri, 11 Sep 2020 02:02:15 +0000 (02:02 +0000)
commite45432bf2002262ff5617638c182f6f977e549ee
tree90402555c936b63614029ab800c86f3adc9f0ec2
parentaa34c93d38c3f3dcef5a91fb30da58158146ccfa
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