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 870FFA034C for ; Fri, 8 Apr 2022 16:36:12 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 572CC4067E; Fri, 8 Apr 2022 16:36:12 +0200 (CEST) Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam07on2067.outbound.protection.outlook.com [40.107.95.67]) by mails.dpdk.org (Postfix) with ESMTP id CB5604003F for ; Fri, 8 Apr 2022 16:36:10 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BBPH2qEPbJFJJuDl7eL8+zNl8CFjLFRs+Qq4AaVVm3fiK49cArWHsguTNVNOqz7/opzaKalhj4zI7VomQzi5KXumnwgK8Zjj3P7L9Z1iUD5hiGlPPxQvEEg9xxk5d8KkVwqcz35qkJCGW6gLMk4N3s9P+j2XQzrcOi04FrtJ6EeFuGSnCQI+198nkZToEkpvPv4VyQyLy239HQce4r/cios+MpWfG74+8XHwaNR8FAVdhdbewBKSZQiR5nRV+MffoL8xLV7uf1z3dL0g55wWaGVl07B1H6y4PMhlNynaEntGnOHLotYudbOyURPgtTuJcjbCAtlJoRzg080PwsgS6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=UeLVCqtGTwdgY7EAgGPx4c96Ut7vV0r/YxSkkPzSQwA=; b=DKLeP34MI1rKpt3IQPXp8EFqPlgoOuWcOesT494dRPb0CZYABAXNX+ACpZJl2tnFQpDoYblHVgpwlyLEx9NsfBMGrLpJCxYt0brG5763JcoZ1AKObXZ5bHWmmBcVJ6jxyAdFk/QCazF3s+AqLNO6gT9ylXkfr0YHClbsLsqqAhKCUJkCsSDBbS8yfAk2eU9+o8YFtJ1p5X7PpTT6Lb4W8rPbl9W2uLbPm+niu9jAImK7GoKSFiQevzrp2MMKdaS+CrAey1er8p0o/eZuzlgtSNuN8mI7AdauyabMhINfZOMvYxo7jqWW6jBG3Xq5yNuE8RAvpirnugL/JL4fBzXK2A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.80.198) smtp.rcpttodomain=gmail.com smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UeLVCqtGTwdgY7EAgGPx4c96Ut7vV0r/YxSkkPzSQwA=; b=XjIXG188a7UOBIvbV/G9N8kmo0GylDL1IhtyrGVEunRyG3ylYrjpxlLa5j+CUnRQ6FEp6zQNTErjDdlS03thlVl9y4+u5piOomWnvTKYBeX9JzCIMVQJ0mvj+149rZCLkT9jqzid+U38aUUiS3sKBaD4TJLHeDh9GIzc5pacOs0= Received: from BN0PR04CA0147.namprd04.prod.outlook.com (2603:10b6:408:ed::32) by DM6PR02MB5164.namprd02.prod.outlook.com (2603:10b6:5:50::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5144.22; Fri, 8 Apr 2022 14:36:08 +0000 Received: from BN1NAM02FT039.eop-nam02.prod.protection.outlook.com (2603:10b6:408:ed:cafe::4a) by BN0PR04CA0147.outlook.office365.com (2603:10b6:408:ed::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5144.25 via Frontend Transport; Fri, 8 Apr 2022 14:36:08 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.80.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.80.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.80.198; helo=xir-pvapexch01.xlnx.xilinx.com; Received: from xir-pvapexch01.xlnx.xilinx.com (149.199.80.198) by BN1NAM02FT039.mail.protection.outlook.com (10.13.2.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5144.21 via Frontend Transport; Fri, 8 Apr 2022 14:36:08 +0000 Received: from xir-pvapexch02.xlnx.xilinx.com (172.21.17.17) by xir-pvapexch01.xlnx.xilinx.com (172.21.17.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Fri, 8 Apr 2022 15:36:07 +0100 Received: from smtp.xilinx.com (172.21.105.197) by xir-pvapexch02.xlnx.xilinx.com (172.21.17.17) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Fri, 8 Apr 2022 15:36:07 +0100 Envelope-to: dmitry.kozliuk@gmail.com, a.dibacco.ks@gmail.com, users@dpdk.org Received: from [10.71.119.200] (port=51125) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1ncpiY-0000qi-Jb; Fri, 08 Apr 2022 15:36:07 +0100 Message-ID: <6c204c1a-bf3c-f7e0-c899-284d9f8938c7@xilinx.com> Date: Fri, 8 Apr 2022 15:36:06 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: Shared memory between two primary DPDK processes Content-Language: en-US To: Dmitry Kozlyuk , Antonio Di Bacco CC: References: <20220408162629.372dfd0d@sovereign> From: Ferruh Yigit In-Reply-To: <20220408162629.372dfd0d@sovereign> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: df9a290e-a2e0-4578-c42e-08da196d1e9e X-MS-TrafficTypeDiagnostic: DM6PR02MB5164:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dkv6IjyfikIc6HKgrp0v+IvFRk1FYycaZEColxoCEFRrmKz6O5VyTU/y4errBHJN2x/o8s1xNXvxVSNmhSvpqJVA55ei6v9vglK85WlLtHGAK4hvzaayCJP2JvQsBYxkPx3VVYMiPmWTNRNwy0E7eRmUWXPLExVd1R/bCgLFZEXVLUShHz0X4esfvFJkuuCNk+llNYcM2gNJXOl4byhelb75Oj2lr4cTGZwr9Pnoog+LDUpQBNDlp1B/BqAqmEQu32lou/Rzl1rxnfC43STMMEJGlfbTnkDTf939vJq9DL5qz2vYa/1zF4ErbFgsVV4AxoalKB7s7oIWDSQDjTByg0o3HuoFkuxSKXTUd3qIHMTYa+IropBA7WJplTYVpLhv1vBJtJUSsA1szWdvlwgcnOb3VaV0ZPf9kfYcIjvIUyHlJggeshCY7jEHzG2dgKqtatsaUUJuBzWNiMgaM7qZTLKRuudbqqWXDrleDeYETrM7zxPWV/sEFEzFdWHI7n4uMTcH60GsImVVnv4HUU7hkmvEvDhQCeYd71MJptv8kiA8GUFhMfE0qRhHJ7OvtzQA/d25pwdoCbcvkv+YcT0yyseO7PZ1SpXC2u+uhEtokr7BVjF1itS8NnFCaKD6noxuLpgCQM9Gv0jByKmisDCWkSMNzmhTnCyFK8PMxkglcijMaMwIrB/iyLKlputvQjcnj9xcw0f2FSGKinQZPaOp9iy1PzDu/sW4z94KURbWlRGogztSQtCaq5UwmYMr0LWXHYnw9mHwzV7dAtTHgOxFJKnCy5sd1ydo7eeSEF8smCrGkhpQiSw2UaL/r/fHGUL9 X-Forefront-Antispam-Report: CIP:149.199.80.198; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:xir-pvapexch01.xlnx.xilinx.com; PTR:unknown-80-198.xilinx.com; CAT:NONE; SFS:(13230001)(4636009)(40470700004)(46966006)(36840700001)(426003)(70586007)(4326008)(8676002)(70206006)(336012)(40460700003)(31696002)(53546011)(508600001)(8936002)(5660300002)(26005)(186003)(9786002)(2906002)(966005)(83380400001)(44832011)(47076005)(2616005)(316002)(36756003)(36860700001)(356005)(31686004)(7636003)(82310400005)(110136005)(50156003)(43740500002); DIR:OUT; SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Apr 2022 14:36:08.0478 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: df9a290e-a2e0-4578-c42e-08da196d1e9e X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.80.198]; Helo=[xir-pvapexch01.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: BN1NAM02FT039.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR02MB5164 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 On 4/8/2022 2:26 PM, Dmitry Kozlyuk wrote: > CAUTION: This message has originated from an External Source. Please use proper judgment and caution when opening attachments, clicking links, or responding to this email. > > > 2022-04-08 14:31 (UTC+0200), Antonio Di Bacco: >> I know that it is possible to share memory between a primary and secondary >> process using rte_memzone_reserve_aligned to allocate memory in primary >> that is "seen" also by the secondary. If we have two primary processes >> (started with different file-prefix) the same approach is not feasible. I >> wonder how to share a chunk of memory hosted on a hugepage between two >> primaries. >> >> Regards. > > Hi Antonio, > > Correction: all hugepages allocated by DPDK are shared > between primary and secondary processes, not only memzones. > > I assume we're talking about processes within one host, > because your previous similar question was about sharing memory between hosts > (as we have discussed offline), which is out of scope for DPDK. > > As for the question directly, you need to map the same part of the same file > in the second primary as the hugepage is mapped from in the first primary. > I don't recommend to work with file paths, because their management > is not straightforward (--single-file-segments, for one) and is undocumented. > > There is a way to share DPDK memory segment file descriptors. > Although public, this DPDK API is dangerous in the sense that you must > clearly understand what you're doing and how DPDK works. > Hence the question: what is the task you need this sharing for? > Maybe there is a simpler way. > > 1. In the first primary: > > mz = rte_memzone_reserve() > ms = rte_mem_virt2memseg(mz->addr) > fd = rte_memseg_get_fd(ms) > offset = rte_memseg_get_fd_offset(ms) > > 2. Use Unix domain sockets with SCM_RIGHTS > to send "fd" and "offset" to the second primary. > > 3. In the second primary, after receiving "fd" and "offset": > > flags = MAP_SHARED | MAP_HUGE | (30 << MAP_HUGE_SHIFT) > addr = mmap(fd, offset, flags) > > Note that "mz" may consist of multiple "ms" depending on the sizes > of the zone and hugepages, and on the zone alignment. > Also "addr" may (and probably will) differ from "mz->addr". > It is possible to pass "mz->addr" and try to force it, > like DPDK does for primary/secondary. > Also 'net/memif' driver can be used: https://doc.dpdk.org/guides/nics/memif.html