lkml.org 
[lkml]   [2021]   [Apr]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 6/9] userfaultfd/selftests: create alias mappings in the shmem test
On Mon, Apr 12, 2021 at 10:17:18PM -0700, Axel Rasmussen wrote:
> static void shmem_allocate_area(void **alloc_area)
> {
> - unsigned long offset =
> - alloc_area == (void **)&area_src ? 0 : nr_pages * page_size;
> + void *area_alias = NULL;
> + bool is_src = alloc_area == (void **)&area_src;
> + unsigned long offset = is_src ? 0 : nr_pages * page_size;
>
> *alloc_area = mmap(NULL, nr_pages * page_size, PROT_READ | PROT_WRITE,
> MAP_SHARED, shm_fd, offset);
> if (*alloc_area == MAP_FAILED)
> err("mmap of memfd failed");
> +
> + area_alias = mmap(NULL, nr_pages * page_size, PROT_READ | PROT_WRITE,
> + MAP_SHARED, shm_fd, offset);
> + if (area_alias == MAP_FAILED)
> + err("mmap of memfd alias failed");
> +
> + if (is_src)
> + area_src_alias = area_alias;
> + else
> + area_dst_alias = area_alias;
> +}

It would be nice if shmem_allocate_area() could merge with
hugetlb_allocate_area() somehow, but not that urgent.

Reviewed-by: Peter Xu <peterx@redhat.com>

--
Peter Xu

\
 
 \ /
  Last update: 2021-04-13 22:18    [W:0.117 / U:4.392 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site