From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <users-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 79002A050D
	for <public@inbox.dpdk.org>; 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 <users@dpdk.org>; Thu, 14 Apr 2022 10:20:42 +0200 (CEST)
Received: by mail-lj1-f174.google.com with SMTP id m8so5075105ljc.7
 for <users@dpdk.org>; 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: <CAO8pfFmiSYf=z5kK4EBwJkyJEpSCUrCqZspbNb3dC8nEPipUBw@mail.gmail.com>
 <20220408162629.372dfd0d@sovereign>
 <CAO8pfF=nVXqj5GBZKH3xVtZL79dDRGvXbMMnZiCJdStztGsZfg@mail.gmail.com>
 <CAO8pfFnGc+T0o18zUu8m3JPrkWD6eLG4qQrUu1B9YiTB+TSfSw@mail.gmail.com>
 <20220411203011.4df9f6f4@sovereign>
In-Reply-To: <20220411203011.4df9f6f4@sovereign>
From: Antonio Di Bacco <a.dibacco.ks@gmail.com>
Date: Thu, 14 Apr 2022 10:20:30 +0200
Message-ID: <CAO8pfF=-cPa0n_AhWdGbqcwEK9n8VHmkRh5qR6UyqbhPRFKZ7w@mail.gmail.com>
Subject: Re: Shared memory between two primary DPDK processes
To: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
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 <users.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/users>,
 <mailto:users-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/users/>
List-Post: <mailto:users@dpdk.org>
List-Help: <mailto:users-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/users>,
 <mailto:users-request@dpdk.org?subject=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

<div dir=3D"ltr"><div dir=3D"ltr"></div><br><div class=3D"gmail_quote"><div=
 dir=3D"ltr" class=3D"gmail_attr">Il giorno lun 11 apr 2022 alle ore 19:30 =
Dmitry Kozlyuk &lt;<a href=3D"mailto:dmitry.kozliuk@gmail.com">dmitry.kozli=
uk@gmail.com</a>&gt; ha scritto:<br></div><blockquote class=3D"gmail_quote"=
 style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);p=
adding-left:1ex">2022-04-11 15:03 (UTC+0200), Antonio Di Bacco:<br>
&gt; I did a short program where a=C2=A0 primary (--file-prefix=3Dp1) alloc=
ates a<br>
&gt; memzone and generates a file descriptor that is passed to another prim=
ary<br>
&gt; (--file-prefix=3Dp2) .<br>
&gt; The process P2 tries to mmap the memory but I get an error (Bad file<b=
r>
&gt; descriptor):<br>
&gt; <br>
&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0uint64_t* addr =3D mmap(NULL, 1024*10=
24*1024, PROT_READ, flags,<br>
&gt; mem_fd, 0);<br>
&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (addr =3D=3D -1)<br>
&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0perror(&quot;mmap&quot;=
);<br>
<br>
How do you pass the FD?<br>
Memif does the same thing under the hood, so you should be able too.<br></b=
lockquote><div><br></div><div><br></div><div>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</div><div>Anyway the procedure seems a little bit clunky and =
I think I&#39;m going to use the new SYSCALL pidfd_getfd=C2=A0</div><div>to=
 achieve the same result.=C2=A0 In your opinion this method (getfd_pidfd) c=
ould also work if the two DPDK processes</div><div>are inside different doc=
ker containers?=C2=A0</div><div>Or is there another mechanims=C2=A0like usi=
ng handles to hugepages present in the filesystem to share between two</div=
><div>different containers?=C2=A0</div><div><br></div><div><br></div></div>=
</div>

--00000000000041473a05dc98f85e--