Re: [PATCH bpf-next] selftests/xsk: fix munmap for hugepage allocated umem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> @@ -1286,16 +1287,19 @@ static void thread_common_ops(struct test_spec *test, struct ifobject *ifobject)
>         u64 umem_sz = ifobject->umem->num_frames * ifobject->umem->frame_size;
>         int mmap_flags = MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE;
>         LIBBPF_OPTS(bpf_xdp_query_opts, opts);
> +       off_t mmap_offset = 0;
>         void *bufs;
>         int ret;
>
> -       if (ifobject->umem->unaligned_mode)
> +       if (ifobject->umem->unaligned_mode) {
>                 mmap_flags |= MAP_HUGETLB;
> +               mmap_offset = MAP_HUGE_2MB;
> +       }

MAP_HUGE_2MB should be ORed into mmap_flags. The offset argument
should be zero for MAP_ANONYMOUS mappings. The tests may still fail if
the default hugepage size is not 2MB.

>
>         if (ifobject->shared_umem)
>                 umem_sz *= 2;
>
> -       bufs = mmap(NULL, umem_sz, PROT_READ | PROT_WRITE, mmap_flags, -1, 0);
> +       bufs = mmap(NULL, umem_sz, PROT_READ | PROT_WRITE, mmap_flags, -1, mmap_offset);
>         if (bufs == MAP_FAILED)
>                 exit_with_error(errno);
>

-Kal



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux