Re: selftests: bpf: mmap question

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

 



On Thu, Jul 23, 2020 at 4:02 AM Yauheni Kaliuta
<yauheni.kaliuta@xxxxxxxxxx> wrote:
>
> Hi!
>
> I have a question about the part of the test:
>

[...]

>
> In my configuration the first mapping
>
>         /* map all but last page: pages 1-3 mapped */
>         tmp1 = mmap(NULL, 3 * page_size, PROT_READ, MAP_SHARED,
>                           data_map_fd, 0);
>
>
> maps the area to the 3 pages right before the TLS page.
> I find it's pretty ok.

Hm... I never ran into this problem. The point here is to be able to
re-mmap partial ranges. One way would be to re-write all those
manipulations to start with a full range map, and then do partial
un-mmaps/re-mmaps, eventually just re-mmaping everything back. I think
that would work, right, as long as we never unmmap the last page? Do
you mind trying to fix the test in such a fashion?

>
> But then the 4 page mapping
>
>         /* re-map all 4 pages */
>         tmp2 = mmap(tmp1, 4 * page_size, PROT_READ, MAP_SHARED | MAP_FIXED,
>                     data_map_fd, 0);
>
>
> since it has MAP_FIXED flag, unmaps TLS and maps the former TLS
> address BPF map.
>
> Which is again exactly the behaviour of MAP_FIXED, but it breaks
> the test.
>
> Using MAP_FIXED_NOREPLACE fails the check:
>
> CHECK(tmp1 != tmp2, "adv_mmap6", "tmp1: %p, tmp2: %p\n", tmp1, tmp2);
>
> as expected.
>
>
> Should the test be modified to be a bit more relaxed? Since the
> kernel behaviour looks correct or I'm missing something?
>
>
> PS: BTW, the previous data_map mapping left unmmaped. Is it expected?

Not intentional, the idea is that each test exits with a clean state.

>
> --
> WBR,
> Yauheni Kaliuta
>



[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