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 ED313A00C4 for ; Mon, 18 Apr 2022 21:08:18 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 885E64014F; Mon, 18 Apr 2022 21:08:18 +0200 (CEST) Received: from mail-lj1-f173.google.com (mail-lj1-f173.google.com [209.85.208.173]) by mails.dpdk.org (Postfix) with ESMTP id 1ABE440141 for ; Mon, 18 Apr 2022 21:08:17 +0200 (CEST) Received: by mail-lj1-f173.google.com with SMTP id bj36so11983386ljb.13 for ; Mon, 18 Apr 2022 12:08:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZL4/KrvAcVzXiqWvRFTJAvdty/C4Xq1yixbWhswCkE4=; b=iF1pdDIwQ2XKyuaUWTKlWubMptFL4bhASjWLZkUSO3oHdXpF4TWHmegH9/m4MJ+u8t Ew5XxwwWELO3cWN7VoSWvGT8c1Ju7uz6c8GUOUQeyGdSRstHrv90pu7aaOkX8zcUVSvC hUPeeWsgM+GWRmrTXJHl/Vcyd3BdiHzbdUjlCLzoyfhXFDlP0v3h72RcY+vWXJ+6L40A 8X7/qm/Yek4vihwWAomasf6Jol8k1oYLwORMkwueCAKYtOpRFK9Nrrq/FVWAFQxhqw2Y fsgQh2We3jw6VhGWc5nemst5+tUVHgrxH2r4vNVqe0NKrCWzXZibs1xVzSgM1aYDAO90 G32w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZL4/KrvAcVzXiqWvRFTJAvdty/C4Xq1yixbWhswCkE4=; b=7vyfOn/uDg+ybXq7ITrzCqfl72NgIzUKXPRZO57QQSeOh3o0tURNzajjt14vB3rRBt ikpmaPU0jsIXfLfWzVJfSr/obSTjoEQEfgT7UJDoIWM7el6Ds+1Jp1nEyegjT73ad0jH y055dSBOaRfWSkEs4Y3vDL+vy8PGalmlj7qHmUebhfE5JZ8yhf3NYPJtY6r/yjxzqXc9 HbJJs6eOHLvJuAONwrFoTlbvPyUKjQ7KNbsxulLtuhi6qs63orY+NFcZALbmsWkTEKlZ ScWS3cMU3w3LZs+Q94S+pK6vYfEtVQgd+UxEpbEZMm5Mx1UzUShJyGplo61osqcTRd05 f9Kw== X-Gm-Message-State: AOAM531tbHZWLFpQU+j4BFksE3vkkVHm5rzYYnrZSjzOvJqtX1llsFmo O5REXKg7gqZjriYBKYnfqsk= X-Google-Smtp-Source: ABdhPJxqxNBvee0n8q2Oow9tqZW+nVq2Wse1ARjVB3enrQJ88Wj5ExaxoyDpbzOT/CYjvyqYoTPJ+g== X-Received: by 2002:a2e:2202:0:b0:24d:b3eb:a193 with SMTP id i2-20020a2e2202000000b0024db3eba193mr6574457lji.447.1650308896416; Mon, 18 Apr 2022 12:08:16 -0700 (PDT) Received: from sovereign (broadband-37-110-65-23.ip.moscow.rt.ru. [37.110.65.23]) by smtp.gmail.com with ESMTPSA id z12-20020a19650c000000b004699179dec6sm1291234lfb.23.2022.04.18.12.08.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Apr 2022 12:08:15 -0700 (PDT) Date: Mon, 18 Apr 2022 22:08:14 +0300 From: Dmitry Kozlyuk To: Antonio Di Bacco Cc: users@dpdk.org Subject: Re: Shared memory between two primary DPDK processes Message-ID: <20220418220814.08bebded@sovereign> In-Reply-To: References: <20220408162629.372dfd0d@sovereign> <20220411203011.4df9f6f4@sovereign> <20220414220148.0d638532@sovereign> X-Mailer: Claws Mail 3.18.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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 2022-04-18 19:53 (UTC+0200), Antonio Di Bacco: > Another info to add: > > The process that allocates the 1GB page has this map: > antodib@Ubuntu-20.04-5:: /proc> sudo cat /proc/27812/maps | grep huge > 140000000-180000000 rw-s 00000000 00:46 97193 > /dev/huge1G/rtemap_0 > > while the process that maps the 1GB page (--file-prefix p2) has this maps, > is stealing a new page? > antodib@Ubuntu-20.04-5:: /proc> sudo cat /proc/27906/maps | grep huge > 140000000-180000000 rw-s 00000000 00:46 113170 > /dev/huge1G/p2map_0 > 7f7bc0000000-7f7c00000000 rw-s 00000000 00:46 97193 > /dev/huge1G/rtemap_0 > > Il giorno lun 18 apr 2022 alle ore 19:34 Antonio Di Bacco < > a.dibacco.ks@gmail.com> ha scritto: > > > At the end I tried the pidfd_getfd syscall that is working really fine and > > giving me back a "clone" fd of an fd in that was opened from another > > process. I tested it opening a text file in the first process and after > > cloning the fd , I could really read the file also in the second process. > > Now the weird thing: > > 1) In the first process I allocate- a huge page, then get the fd > > 2) In the second process I get my "clone" fd and do an mmap, it works but > > if I write on that memory, the first process cannot see what I wrote > > > > int second_process(int remote_pid, int remote_mem_fd) { > > > > printf("remote_pid %d remote_mem_fd %d\n", remote_pid, > > remote_mem_fd); > > int pidfd = syscall(__NR_pidfd_open, remote_pid, 0); > > > > int my_mem_fd = syscall(438, pidfd, remote_mem_fd, 0); > > printf("my_mem_fd %d\n", my_mem_fd); // This is nice > > > > int flags = MAP_SHARED | MAP_HUGETLB | (30 << MAP_HUGE_SHIFT); > > uint64_t* addr = (uint64_t*) mmap(NULL, 1024 * 1024 * 1024, > > PROT_READ|PROT_WRITE, flags, my_mem_fd, 0); > > if (addr == -1) > > perror("mmap"); > > *addr = 0x0101010102020202; > > } I don't quite understand what do you mean by "stealing a new page", but it shows that the second process has mapped the same hugepage file as the first process (just confirms that mmap indeed works). rte_mem_virt2phy() can tell if the physical address is really the same in both processes. Are you sure that the 2nd process writes before the 1st one reads? Are you sure read/write is not optimized out?