From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 79002A050D for ; Thu, 14 Apr 2022 10:20:43 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0B06E40687; Thu, 14 Apr 2022 10:20:43 +0200 (CEST) Received: from mail-lj1-f174.google.com (mail-lj1-f174.google.com [209.85.208.174]) by mails.dpdk.org (Postfix) with ESMTP id 5BFA84003F for ; Thu, 14 Apr 2022 10:20:42 +0200 (CEST) Received: by mail-lj1-f174.google.com with SMTP id m8so5075105ljc.7 for ; Thu, 14 Apr 2022 01:20:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Xm4taup60uJQh1tBjH1QQQ47mi+TEvJB2PyMZ+jY+KU=; b=QymkJPzgO+NtjnfoPQvYWckdfY+v4m0qrhxO63VAQlz7vDwODUrS9/BCxU9uT08fs7 bp//QD1pD69tkDlBdZaQDZM4AZ9AHv1KpwgdTlxSETR5CmGTyikhqy4TCA0IFUeNHRkN Bv7wCKp1CbmrLHRos3ivhOvTfZdvomN77uDFGTmhvvxIJmNSkcb+QaG8phJY0NrhNmiv chG9B1apazagY4plBGI94H7ZdKh+qskE8hYI/T72/+OkqAr8GrHwpDnsiqDHk+T6fwA5 z6sSKYg7015bUJATY3n/pUtyKImistwHtdWEMcRJkWTR9En+E3sShyDbxHY+CPsvXOzM bsjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Xm4taup60uJQh1tBjH1QQQ47mi+TEvJB2PyMZ+jY+KU=; b=v1/SDHOEKqybQbEfH8mMdwjj3y/NfJjE9myw4rM38tRRCb8IkY5gGxQ8/RLVWUIc2Z fRvAICUlcFhtX8P5nnqqKboq7lF5reYI8OJMguoRZOHSojnmaNSALFpbuFiWR1P54oEA 3HyVe3SmKYTC3DgDYYiCvirpIivc6GyFMYOX/1NPxTe6+jRwrYre+AaT3a0v8lh3mxn0 mUTSZY5Mw89SHoekIIHwZPdaxENn6MMfdFg33wwFBJstL+ATQQyxrlmKHHWb3faxGxQY eLvgB7KpBctcDM+9ehZSAOTpUs2lWUrTctwDz0cC6Yl156xLLjX7vZ+Zh0xJxtuEugQQ tc/Q== X-Gm-Message-State: AOAM531NUPOIRwaLAUZEc9qKHB4qGVNO5a2PH0szA/XuDhTkUa6xqreI awkRYk2eM9onqtbLJ0Cma2hatiBWS+YS3xQmgJI= X-Google-Smtp-Source: ABdhPJxBf9xicSbSdWjCgALOQcy8KM3X/zMjJ/vyWVwT8c18+Kv4jD3QFo57RMR9szbHr79/e1rABOSJsKqfzYpupUA= X-Received: by 2002:a05:651c:1542:b0:249:a87f:8a34 with SMTP id y2-20020a05651c154200b00249a87f8a34mr956312ljp.442.1649924441719; Thu, 14 Apr 2022 01:20:41 -0700 (PDT) MIME-Version: 1.0 References: <20220408162629.372dfd0d@sovereign> <20220411203011.4df9f6f4@sovereign> In-Reply-To: <20220411203011.4df9f6f4@sovereign> From: Antonio Di Bacco Date: Thu, 14 Apr 2022 10:20:30 +0200 Message-ID: Subject: Re: Shared memory between two primary DPDK processes To: Dmitry Kozlyuk Cc: users@dpdk.org Content-Type: multipart/alternative; boundary="00000000000041473a05dc98f85e" X-BeenThere: users@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK usage discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: users-bounces@dpdk.org --00000000000041473a05dc98f85e Content-Type: text/plain; charset="UTF-8" Il giorno lun 11 apr 2022 alle ore 19:30 Dmitry Kozlyuk < dmitry.kozliuk@gmail.com> ha scritto: > 2022-04-11 15:03 (UTC+0200), Antonio Di Bacco: > > I did a short program where a primary (--file-prefix=p1) allocates a > > memzone and generates a file descriptor that is passed to another primary > > (--file-prefix=p2) . > > The process P2 tries to mmap the memory but I get an error (Bad file > > descriptor): > > > > uint64_t* addr = mmap(NULL, 1024*1024*1024, PROT_READ, flags, > > mem_fd, 0); > > if (addr == -1) > > perror("mmap"); > > How do you pass the FD? > Memif does the same thing under the hood, so you should be able too. > Ok, after having a look to memif I managed to exchange the fd between the two processes and it works. Anyway the procedure seems a little bit clunky and I think I'm going to use the new SYSCALL pidfd_getfd to achieve the same result. In your opinion this method (getfd_pidfd) could also work if the two DPDK processes are inside different docker containers? Or is there another mechanims like using handles to hugepages present in the filesystem to share between two different containers? --00000000000041473a05dc98f85e Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Il giorno lun 11 apr 2022 alle ore 19:30 = Dmitry Kozlyuk <dmitry.kozli= uk@gmail.com> ha scritto:
2022-04-11 15:03 (UTC+0200), Antonio Di Bacco:
> I did a short program where a=C2=A0 primary (--file-prefix=3Dp1) alloc= ates a
> memzone and generates a file descriptor that is passed to another prim= ary
> (--file-prefix=3Dp2) .
> The process P2 tries to mmap the memory but I get an error (Bad file > descriptor):
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0uint64_t* addr =3D mmap(NULL, 1024*10= 24*1024, PROT_READ, flags,
> mem_fd, 0);
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (addr =3D=3D -1)
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0perror("mmap"= );

How do you pass the FD?
Memif does the same thing under the hood, so you should be able too.


Ok, after having a look to mem= if=C2=A0I managed to exchange the fd=C2=A0 between the two processes and it= works.=C2=A0
Anyway the procedure seems a little bit clunky and = I think I'm going to use the new SYSCALL pidfd_getfd=C2=A0
to= achieve the same result.=C2=A0 In your opinion this method (getfd_pidfd) c= ould also work if the two DPDK processes
are inside different doc= ker containers?=C2=A0
Or is there another mechanims=C2=A0like usi= ng handles to hugepages present in the filesystem to share between two
different containers?=C2=A0


=
--00000000000041473a05dc98f85e--