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 99F5DA0C55; Wed, 13 Oct 2021 13:02:04 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8C2A6411B4; Wed, 13 Oct 2021 13:01:55 +0200 (CEST) Received: from AZHDRRW-EX01.nvidia.com (azhdrrw-ex01.nvidia.com [20.51.104.162]) by mails.dpdk.org (Postfix) with ESMTP id C0DF2411AE for ; Wed, 13 Oct 2021 13:01:52 +0200 (CEST) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (104.47.56.176) by mxs.oss.nvidia.com (10.13.234.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.858.15; Wed, 13 Oct 2021 04:01:52 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Rsspgklb8ZdkbmKTnE7EfBq+BdoAMGdaGk4PPKtDieQVhjlRbPE682JySm8Ug99QZHhpsRi2240jbSs/MgAGGfoszf/Opyql5mtuMvDZPVgior9ib3IpYfjzzDPhDvT1AlG1fL9NnKZAfsKnDL1P3Z3ToikuzFlPtWLwcobywPigx7Sn1mYvdup72mXCMfN8CMQvFSGj2XHb2+Jx3DQ8pGhxF2uHdLRYHNty264Mm3PtstNl9G/34v3/MEhGpxE09uKbh8joEFicUsl0GjF6tDlUSGasCrJrNV1IOyFHE276LpDGqrlHZgOejARjSdm58hPYwdgLMDUdMOC1EZm95g== 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=G2q/TVDNFUQqnMJd9UbY00OHIkKUb+CCS77prS1sdss=; b=PR8/WL0daOV3mk3ZVkQWdEFLiFRHIOOpMU/B6qaLQSXNf+Rqq+ssoHltow8ez0gugWf3GeMoo8VJWytfrIFOZS8L9p5+OcE/oW751Lxi5QKYE+dWVC8CvEvQbExgvnwtARHhSmYP9z4iEb0U6IX7uA88z/Qdbhoe9v3DnQkj1jjjMzMyHXJrLppXbm+P1OWiiiEm+n52vl2PvdhnthQgtF4wdH1QMpyB4KD1DRZXbIO9zVPhEyygUovZonsziMF1Rs9k/3YwXEJoA/yidcwDWS2wO7jpeLIcpZkZYjNMi0VSJtLKQMSzt9flJB0wPf/C+EJOrxTHjva9/oUCiQoxqw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=6wind.com smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=G2q/TVDNFUQqnMJd9UbY00OHIkKUb+CCS77prS1sdss=; b=gAQOibPVTZClO882kSXrB00WZduiPLzaiUQVUlMc//sV+zkj1e83xRI7hLGOnDPL9rCdpqTG/vA/sLWAxUNLAnRaTglsgpBr/LOmkseW37i5EEa4qcK6cAzBG5JJmwYxe11fICnlCgA14Ugq9tyEefbhcXI63ALoYVc9Y4zCE1MkMGwJPkhOaaKH5MvKIX4rVhVQER4GqJGq5l9WGqcWLACur6JCztNGgdQ8i8gy5K+hFiDNeFZjK5ZW64iGTHsE7uEDu/aweEWtgTZ5nXyAJszEEfMlNPc3J696XLGKaN/RPBL1MkdPzIFU5jP6mQnmNINVqlQ/3oeyEpPZ3fV7DA== Received: from DM5PR21CA0041.namprd21.prod.outlook.com (2603:10b6:3:ed::27) by DM6PR12MB5565.namprd12.prod.outlook.com (2603:10b6:5:1b6::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.25; Wed, 13 Oct 2021 11:01:51 +0000 Received: from DM6NAM11FT029.eop-nam11.prod.protection.outlook.com (2603:10b6:3:ed:cafe::dc) by DM5PR21CA0041.outlook.office365.com (2603:10b6:3:ed::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.3 via Frontend Transport; Wed, 13 Oct 2021 11:01:51 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; 6wind.com; dkim=none (message not signed) header.d=none;6wind.com; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by DM6NAM11FT029.mail.protection.outlook.com (10.13.173.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4608.15 via Frontend Transport; Wed, 13 Oct 2021 11:01:50 +0000 Received: from nvidia.com (172.20.187.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Wed, 13 Oct 2021 11:01:49 +0000 From: Dmitry Kozlyuk To: CC: Andrew Rybchenko , Matan Azrad , Olivier Matz Date: Wed, 13 Oct 2021 14:01:29 +0300 Message-ID: <20211013110131.2909604-3-dkozlyuk@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211013110131.2909604-1-dkozlyuk@nvidia.com> References: <20211012000409.2751908-1-dkozlyuk@nvidia.com> <20211013110131.2909604-1-dkozlyuk@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.6] X-ClientProxiedBy: HQMAIL111.nvidia.com (172.20.187.18) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3aec2971-f4c8-4cce-d079-08d98e38dbee X-MS-TrafficTypeDiagnostic: DM6PR12MB5565: X-Microsoft-Antispam-PRVS: X-MS-Exchange-Transport-Forked: True X-MS-Oob-TLC-OOBClassifiers: OLM:1107; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XGsicT0QT+q/Rc9jJ29VqSIy11wk+Fp5HThNWMLnKYfxps8kNddws/qxE4GXAK4IvmoB6yru4e+gGjmAVLpL9fg3egXH0C4KCAQ6fuloFLfkUaxhHjy2zfaZoaBVaAH562ZbdMfNzc99sy5LyUH6R6iJnPOmzWFUNfERhE6bLaYkGlKWlSX8TOMHicxSjQ/hTLG7qACDyJ7ChuVrz1np6gHarmwDMfM9BwDU1ahbKyCemhw7t+qilPkJu1KjMrf+InvygJy00junF+/SpnRxt80HHoxkFs1mIHk9IN2NO//54Vs9MhLgKfefa4BeNhWUq6tyWtfl9ISy/1mxd7+EfUHqWeIk4S0A6qsiiB/kz4fS7fcl6KBSEVN/wLy+WqGYAMs8rETmSrDuJBl2mzH+vbJ+XAo7qFA1a7KSaHNh9/5vhIowK36rRbYN3cepbUYTzEhzFzd9bh8QGGWZZIGApwzOn54FldoOB32ty/kWMeyRmrLJCjNZY9Yj76630UbIO+iccOPWl6mQAbTyOouFqRNs6HQ7jAlVHEQMYeF+1YT5e6/V1af9v7zxqU9/TFScdo7pJJ56hOViaDHbHEd/X4arRAG6b8Thy3nky/ymitvwj1IEF3bto1iY3N7gAn0oytEibLC01bhpabFpT+brjTn8u6KhMownN9l6g6YutcillI9yneAFTKYRovv+my0YTqIzDpEpv4gPDH1LFeBuuxGSjY4sTMLTtZSH1yNtGWd8dxc6fvzLO2JabYvHlwl4Uy9m8vcmHp5uxrovxSCXn+beg4NjfMZ4nj7/dOCqtqA= X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(46966006)(36840700001)(55016002)(8936002)(83380400001)(336012)(6666004)(36860700001)(107886003)(356005)(26005)(426003)(86362001)(508600001)(36756003)(70206006)(5660300002)(2616005)(4326008)(70586007)(966005)(82310400003)(6286002)(47076005)(7696005)(16526019)(54906003)(1076003)(2906002)(7636003)(8676002)(316002)(186003)(6916009); DIR:OUT; SFP:1101; X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Oct 2021 11:01:50.7710 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3aec2971-f4c8-4cce-d079-08d98e38dbee X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT029.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB5565 Subject: [dpdk-dev] [PATCH v4 2/4] mempool: add non-IO flag X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Mempool is a generic allocator that is not necessarily used for device IO operations and its memory for DMA. Add MEMPOOL_F_NON_IO flag to mark such mempools automatically if their objects are not contiguous or IOVA are not available. Components can inspect this flag in order to optimize their memory management. Discussion: https://mails.dpdk.org/archives/dev/2021-August/216654.html Signed-off-by: Dmitry Kozlyuk Acked-by: Matan Azrad --- app/test/test_mempool.c | 76 ++++++++++++++++++++++++++ doc/guides/rel_notes/release_21_11.rst | 3 + lib/mempool/rte_mempool.c | 2 + lib/mempool/rte_mempool.h | 5 ++ 4 files changed, 86 insertions(+) diff --git a/app/test/test_mempool.c b/app/test/test_mempool.c index bc0cc9ed48..15146dd737 100644 --- a/app/test/test_mempool.c +++ b/app/test/test_mempool.c @@ -672,6 +672,74 @@ test_mempool_events_safety(void) return 0; } +static int +test_mempool_flag_non_io_set_when_no_iova_contig_set(void) +{ + struct rte_mempool *mp; + int ret; + + mp = rte_mempool_create_empty("empty", MEMPOOL_SIZE, + MEMPOOL_ELT_SIZE, 0, 0, + SOCKET_ID_ANY, MEMPOOL_F_NO_IOVA_CONTIG); + RTE_TEST_ASSERT_NOT_NULL(mp, "Cannot create mempool: %s", + rte_strerror(rte_errno)); + rte_mempool_set_ops_byname(mp, rte_mbuf_best_mempool_ops(), NULL); + ret = rte_mempool_populate_default(mp); + RTE_TEST_ASSERT(ret > 0, "Failed to populate mempool: %s", + rte_strerror(rte_errno)); + RTE_TEST_ASSERT(mp->flags & MEMPOOL_F_NON_IO, + "NON_IO flag is not set when NO_IOVA_CONTIG is set"); + rte_mempool_free(mp); + return 0; +} + +static int +test_mempool_flag_non_io_set_when_populated_with_bad_iova(void) +{ + void *addr; + size_t size = 1 << 16; + struct rte_mempool *mp; + int ret; + + addr = rte_malloc("test_mempool", size, 0); + RTE_TEST_ASSERT_NOT_NULL(addr, "Cannot allocate memory"); + mp = rte_mempool_create_empty("empty", MEMPOOL_SIZE, + MEMPOOL_ELT_SIZE, 0, 0, + SOCKET_ID_ANY, 0); + RTE_TEST_ASSERT_NOT_NULL(mp, "Cannot create mempool: %s", + rte_strerror(rte_errno)); + ret = rte_mempool_populate_iova(mp, addr, RTE_BAD_IOVA, size, + NULL, NULL); + /* The flag must be inferred even if population isn't full. */ + RTE_TEST_ASSERT(ret > 0, "Failed to populate mempool: %s", + rte_strerror(rte_errno)); + RTE_TEST_ASSERT(mp->flags & MEMPOOL_F_NON_IO, + "NON_IO flag is not set when mempool is populated with RTE_BAD_IOVA"); + rte_mempool_free(mp); + rte_free(addr); + return 0; +} + +static int +test_mempool_flag_non_io_unset_by_default(void) +{ + struct rte_mempool *mp; + int ret; + + mp = rte_mempool_create_empty("empty", MEMPOOL_SIZE, + MEMPOOL_ELT_SIZE, 0, 0, + SOCKET_ID_ANY, 0); + RTE_TEST_ASSERT_NOT_NULL(mp, "Cannot create mempool: %s", + rte_strerror(rte_errno)); + ret = rte_mempool_populate_default(mp); + RTE_TEST_ASSERT_EQUAL(ret, (int)mp->size, "Failed to populate mempool: %s", + rte_strerror(rte_errno)); + RTE_TEST_ASSERT(!(mp->flags & MEMPOOL_F_NON_IO), + "NON_IO flag is set by default"); + rte_mempool_free(mp); + return 0; +} + static int test_mempool(void) { @@ -854,6 +922,14 @@ test_mempool(void) if (test_mempool_events_safety() < 0) GOTO_ERR(ret, err); + /* test NON_IO flag inference */ + if (test_mempool_flag_non_io_unset_by_default() < 0) + GOTO_ERR(ret, err); + if (test_mempool_flag_non_io_set_when_no_iova_contig_set() < 0) + GOTO_ERR(ret, err); + if (test_mempool_flag_non_io_set_when_populated_with_bad_iova() < 0) + GOTO_ERR(ret, err); + rte_mempool_list_dump(stdout); ret = 0; diff --git a/doc/guides/rel_notes/release_21_11.rst b/doc/guides/rel_notes/release_21_11.rst index f643a61f44..74e0e6f495 100644 --- a/doc/guides/rel_notes/release_21_11.rst +++ b/doc/guides/rel_notes/release_21_11.rst @@ -226,6 +226,9 @@ API Changes the crypto/security operation. This field will be used to communicate events such as soft expiry with IPsec in lookaside mode. +* mempool: Added ``MEMPOOL_F_NON_IO`` flag to give a hint to DPDK components + that objects from this pool will not be used for device IO (e.g. DMA). + ABI Changes ----------- diff --git a/lib/mempool/rte_mempool.c b/lib/mempool/rte_mempool.c index 51c0ba2931..2204f140b3 100644 --- a/lib/mempool/rte_mempool.c +++ b/lib/mempool/rte_mempool.c @@ -371,6 +371,8 @@ rte_mempool_populate_iova(struct rte_mempool *mp, char *vaddr, STAILQ_INSERT_TAIL(&mp->mem_list, memhdr, next); mp->nb_mem_chunks++; + if (iova == RTE_BAD_IOVA) + mp->flags |= MEMPOOL_F_NON_IO; /* Report the mempool as ready only when fully populated. */ if (mp->populated_size >= mp->size) diff --git a/lib/mempool/rte_mempool.h b/lib/mempool/rte_mempool.h index 663123042f..029b62a650 100644 --- a/lib/mempool/rte_mempool.h +++ b/lib/mempool/rte_mempool.h @@ -262,6 +262,8 @@ struct rte_mempool { #define MEMPOOL_F_SC_GET 0x0008 /**< Default get is "single-consumer".*/ #define MEMPOOL_F_POOL_CREATED 0x0010 /**< Internal: pool is created. */ #define MEMPOOL_F_NO_IOVA_CONTIG 0x0020 /**< Don't need IOVA contiguous objs. */ +#define MEMPOOL_F_NON_IO 0x0040 + /**< Internal: pool is not usable for device IO (DMA). */ /** * @internal When debug is enabled, store some statistics. @@ -991,6 +993,9 @@ typedef void (rte_mempool_ctor_t)(struct rte_mempool *, void *); * "single-consumer". Otherwise, it is "multi-consumers". * - MEMPOOL_F_NO_IOVA_CONTIG: If set, allocated objects won't * necessarily be contiguous in IO memory. + * - MEMPOOL_F_NON_IO: If set, the mempool is considered to be + * never used for device IO, i.e. for DMA operations. + * It's a hint to other components and does not affect the mempool behavior. * @return * The pointer to the new allocated mempool, on success. NULL on error * with rte_errno set appropriately. Possible rte_errno values include: -- 2.25.1