lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJ+HfNhkXmDJO7nZx2A0Gg9vj7s83iUOtkRtWi=wpi5446_NcQ@mail.gmail.com>
Date:   Mon, 24 Jun 2019 17:36:22 +0200
From:   Björn Töpel <bjorn.topel@...il.com>
To:     Kevin Laatz <kevin.laatz@...el.com>
Cc:     Netdev <netdev@...r.kernel.org>,
        Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        Björn Töpel <bjorn.topel@...el.com>,
        "Karlsson, Magnus" <magnus.karlsson@...el.com>,
        bpf <bpf@...r.kernel.org>,
        intel-wired-lan <intel-wired-lan@...ts.osuosl.org>,
        Bruce Richardson <bruce.richardson@...el.com>,
        ciara.loftus@...el.com
Subject: Re: [PATCH 10/11] samples/bpf: use hugepages in xdpsock app

On Thu, 20 Jun 2019 at 19:25, Kevin Laatz <kevin.laatz@...el.com> wrote:
>
> This patch modifies xdpsock to use mmap instead of posix_memalign. With
> this change, we can use hugepages when running the application in unaligned
> chunks mode. Using hugepages makes it more likely that we have physically
> contiguous memory, which supports the unaligned chunk mode better.
>
> Signed-off-by: Kevin Laatz <kevin.laatz@...el.com>

Acked-by: Björn Töpel <bjorn.topel@...el.com>

> ---
>  samples/bpf/xdpsock_user.c | 14 +++++++++-----
>  1 file changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/samples/bpf/xdpsock_user.c b/samples/bpf/xdpsock_user.c
> index 7b4ce047deb2..8ed63ad68428 100644
> --- a/samples/bpf/xdpsock_user.c
> +++ b/samples/bpf/xdpsock_user.c
> @@ -74,6 +74,7 @@ static int opt_interval = 1;
>  static u64 opt_buffer_size = XSK_UMEM__DEFAULT_FRAME_SIZE;
>  static u32 opt_umem_flags;
>  static int opt_unaligned_chunks;
> +static int opt_mmap_flags;
>  static u32 opt_xdp_bind_flags;
>  static __u32 prog_id;
>
> @@ -438,6 +439,7 @@ static void parse_command_line(int argc, char **argv)
>                 case 'u':
>                         opt_umem_flags |= XDP_UMEM_UNALIGNED_CHUNKS;
>                         opt_unaligned_chunks = 1;
> +                       opt_mmap_flags = MAP_HUGETLB;
>                         break;
>                 case 'b':
>                         opt_buffer_size = atoi(optarg);
> @@ -707,11 +709,13 @@ int main(int argc, char **argv)
>                 exit(EXIT_FAILURE);
>         }
>
> -       ret = posix_memalign(&bufs, getpagesize(), /* PAGE_SIZE aligned */
> -                            NUM_FRAMES * opt_buffer_size);
> -       if (ret)
> -               exit_with_error(ret);
> -
> +       /* Reserve memory for the umem. Use hugepages if unaligned chunk mode */
> +       bufs = mmap(NULL, NUM_FRAMES * opt_buffer_size, PROT_READ|PROT_WRITE,
> +                       MAP_PRIVATE|MAP_ANONYMOUS|opt_mmap_flags, -1, 0);
> +       if (bufs == MAP_FAILED) {
> +               printf("ERROR: mmap failed\n");
> +               exit(EXIT_FAILURE);
> +       }
>         /* Create sockets... */
>         umem = xsk_configure_umem(bufs,
>                                   NUM_FRAMES * opt_buffer_size);
> --
> 2.17.1
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ