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 D71B6A0C43; Tue, 16 Nov 2021 12:56:04 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4E68C40141; Tue, 16 Nov 2021 12:56:04 +0100 (CET) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2056.outbound.protection.outlook.com [40.107.223.56]) by mails.dpdk.org (Postfix) with ESMTP id 4771740040 for ; Tue, 16 Nov 2021 12:56:03 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZGVYLygO6w8BM9+yD3qgqGHIImsJTk6/rWJTETzwwiiVBL9RXeZRABAz1FMMqKDGKTUgT+w78QgwbVWSYjCoHuuRbYzuHof+cDIhKN5T7rJ3I/79C1207dtA8SLw6jf87mA9jsbzw8VmWthI43eMOtf810iSw/3uUJEAtKqnsqu1oXVshqU4ljPvlUnThoglwYqS/RU7z6fXZTcXMbcmlSidkk8uSjDzEFLSrqUbUAjfT298skdr8Nh037YytKnauxlEmsUJIfaNTodogX2+6Z/8W1siQUeSDK3+hfmvrEYdPoAsZ24l/nwppQOCBlCtx6F8ndV8eehCACypsh1ScA== 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=4GAJlM1SrYgOL91ptqaVa4ZVy7J9y/iDqZZJPO6+mhg=; b=E7qX2h9K42wK9ziRk+3voervvvjjNdv9Egs4+ZUG2bygPdWdMoAh76ADdxAS7CJi2ase7f+WEnQvJW+w5DD+HuKitK1LA+7DsleDddhSmtF1ecvChIOPxfOv1Ef2RFMu9bOKsPIr+dva0E9FhwXMxWTcfTeZ6Tc4PENYHRFfED2UeOxguzKPq9F6R4EJ9FmBnTnN9/HSNqNZroM7MJKvrhFKPJ5AsZMjzF2cMhgczzCAjJhs0lBVKfG044xmoZpJOE7buYzUru5VSUnr60vCNPOjq//tZHb05GT2okmd8kakyFGbcnRcNHACiiqNJt5XU9TPgRJfkWkotqKNjZtcGQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=dpdk.org 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=4GAJlM1SrYgOL91ptqaVa4ZVy7J9y/iDqZZJPO6+mhg=; b=sDo8dznHq+ecmwd6EGl0iZz89oq5rHMhB6wta3DS7+u8DnHQVaVHXg5A2pz+4Wwu4kogw1FwZTg5zi1VSgRjTRVKRhyIfW4oRIaQt8Ar2Exc0vLjznRrls3/ZkreYW10MdMfUtUfie3Kovlnx3JwYe195q+npv+XC48R46wbIEYllS/UY5AQvt1M16VpCK93yyQoij58CjIwBgF7sNy4XVuplVDYZ0QJkZba8ji2ucX82cYC0iSEfp2YxnWe6rM7Jb4J3ZD8/A0dz4AF4leuw9D58QspECcZuT2KV/AzqrNUbrPVD8VXOtZWOIuwnqq2E81zZ/qQ8AjyZ31EDmjCLQ== Received: from BN9PR03CA0877.namprd03.prod.outlook.com (2603:10b6:408:13c::12) by BY5PR12MB4289.namprd12.prod.outlook.com (2603:10b6:a03:204::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.17; Tue, 16 Nov 2021 11:56:01 +0000 Received: from BN8NAM11FT031.eop-nam11.prod.protection.outlook.com (2603:10b6:408:13c:cafe::5f) by BN9PR03CA0877.outlook.office365.com (2603:10b6:408:13c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.19 via Frontend Transport; Tue, 16 Nov 2021 11:56:01 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;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 BN8NAM11FT031.mail.protection.outlook.com (10.13.177.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4690.15 via Frontend Transport; Tue, 16 Nov 2021 11:56:00 +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; Tue, 16 Nov 2021 11:55:58 +0000 From: Dmitry Kozlyuk To: CC: Matan Azrad , Raslan Darawsheh , Viacheslav Ovsiienko Subject: [PATCH v2] common/mlx5: fix MPRQ mempool registration Date: Tue, 16 Nov 2021 13:55:44 +0200 Message-ID: <20211116115545.2441025-1-dkozlyuk@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211116085752.2419240-1-dkozlyuk@nvidia.com> References: <20211116085752.2419240-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: 393edde3-c5e2-48d1-fa2b-08d9a8f80f22 X-MS-TrafficTypeDiagnostic: BY5PR12MB4289: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:339; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XkbAl04fl0GfNtSb3keF7sV+HQjcMKGFAYLCx8HfdYz9B9Qev0s+wGF813NWNqXpsb8PaB1E2RwpxPJ34zhZBluxMJLq7WQLlmLUccYAh3mVrgdaL3R6F9ICss9d9j2pSxsxR27NBxiZNkpbjVp7iQ8UaRrhLV1Efh8q1U6VogE3FEGfxyZfVmy+Qg8FBdxtFDxi+gYbRkRuiL7skSRo1i536/kRJd9pQjjtX/wlTh8Op84HGBgINPEv4kIQcxwjnMKCNpiv7mxDThCi8SwDQRwmY5RldpbB0i+mZOTZyQ9+XTd/mrDXBzyQtxGkaJe8V5gWHT3hAziNDJj5ItBsiyph/dtc5FSU+YaqLX8LfQffQFerGgaYZRq044ubon1muamJlwAHRtD3O1WJsRi2Artlp6ok8vokGXE/UM2H7/Sa9+ZMNDkuIteduGG7Zu6i67uRtepTV+1uykDIwGjCIoJ3ZULGm4pt3IDuqGtf/fSyHxluYD7XQRFheXbI4vyV/b7gezwzp3gTssoDjRJhGIm3V6Sj9tHyRbrC/cC8YNSsE1JJv9e37NxjMloj56fRK902kExmxZhrG0yEdsZo6925rdYdiDFL4vuJETUoYqH+PFvvAgFiOyFjUjSpm0VKGHvUO9u75SZfVljQhYHCxHTr8Hqb2r/ue7Jwl3/jSVQ4yMi4pp+I4psFLu3n3cyeVi4FDy33stSPeWAo2qDK/6QUYqEXnahiVHykhLZpjP8= 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)(356005)(2616005)(36756003)(426003)(316002)(7696005)(36860700001)(70586007)(70206006)(6286002)(6916009)(47076005)(86362001)(8936002)(6666004)(336012)(4326008)(5660300002)(16526019)(508600001)(55016002)(186003)(1076003)(7636003)(2906002)(8676002)(83380400001)(26005)(54906003)(107886003)(82310400003)(290074003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Nov 2021 11:56:00.7213 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 393edde3-c5e2-48d1-fa2b-08d9a8f80f22 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: BN8NAM11FT031.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4289 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 Mempool registration code had a wrong assumption that it is always dealing with packet mempools and always called rte_pktmbuf_priv_flags(), which returned a random value for different types of mempools. In particular, it could consider MPRQ mempools as having externally pinned buffers, which is wrong. Packet mempools cannot be reliably recognized, but it is sufficient to check that the mempool is not a packet one, so it cannot have externally pinned buffers. Compare mempool private data size to that of packet mempools to check. Fixes: 690b2a88c2f7 ("common/mlx5: add mempool registration facilities") Fixes: fec28ca0e3a9 ("net/mlx5: support mempool registration") Signed-off-by: Dmitry Kozlyuk Acked-by: Viacheslav Ovsiienko --- v2: improve logging, add ack. drivers/common/mlx5/mlx5_common.c | 3 +-- drivers/common/mlx5/mlx5_common_mr.c | 5 ++++- drivers/common/mlx5/mlx5_common_mr.h | 10 ++++++++++ drivers/net/mlx5/mlx5_trigger.c | 5 +++-- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/drivers/common/mlx5/mlx5_common.c b/drivers/common/mlx5/mlx5_common.c index b9ed5ee676..66c2c08b7d 100644 --- a/drivers/common/mlx5/mlx5_common.c +++ b/drivers/common/mlx5/mlx5_common.c @@ -390,8 +390,7 @@ mlx5_dev_mempool_event_cb(enum rte_mempool_event event, struct rte_mempool *mp, void *arg) { struct mlx5_common_device *cdev = arg; - bool extmem = rte_pktmbuf_priv_flags(mp) & - RTE_PKTMBUF_POOL_F_PINNED_EXT_BUF; + bool extmem = mlx5_mempool_is_extmem(mp); switch (event) { case RTE_MEMPOOL_EVENT_READY: diff --git a/drivers/common/mlx5/mlx5_common_mr.c b/drivers/common/mlx5/mlx5_common_mr.c index 49feea4474..a7a499f6f9 100644 --- a/drivers/common/mlx5/mlx5_common_mr.c +++ b/drivers/common/mlx5/mlx5_common_mr.c @@ -1302,6 +1302,7 @@ mlx5_mempool_get_chunks(struct rte_mempool *mp, struct mlx5_range **out, struct mlx5_range *chunks; unsigned int n; + DRV_LOG(DEBUG, "Collecting chunks of regular mempool %s", mp->name); n = mp->nb_mem_chunks; chunks = calloc(sizeof(chunks[0]), n); if (chunks == NULL) @@ -1382,6 +1383,8 @@ mlx5_mempool_get_extmem(struct rte_mempool *mp, struct mlx5_range **out, { struct mlx5_mempool_get_extmem_data data; + DRV_LOG(DEBUG, "Recovering external pinned pages of mempool %s", + mp->name); memset(&data, 0, sizeof(data)); rte_mempool_obj_iter(mp, mlx5_mempool_get_extmem_cb, &data); if (data.ret < 0) @@ -1414,7 +1417,7 @@ mlx5_get_mempool_ranges(struct rte_mempool *mp, struct mlx5_range **out, int ret; /* Collect the pool underlying memory. */ - ret = (rte_pktmbuf_priv_flags(mp) & RTE_PKTMBUF_POOL_F_PINNED_EXT_BUF) ? + ret = mlx5_mempool_is_extmem(mp) ? mlx5_mempool_get_extmem(mp, &chunks, &chunks_n) : mlx5_mempool_get_chunks(mp, &chunks, &chunks_n); if (ret < 0) diff --git a/drivers/common/mlx5/mlx5_common_mr.h b/drivers/common/mlx5/mlx5_common_mr.h index dc7ddc3513..442b9d4694 100644 --- a/drivers/common/mlx5/mlx5_common_mr.h +++ b/drivers/common/mlx5/mlx5_common_mr.h @@ -263,4 +263,14 @@ int mlx5_mr_mempool_unregister(struct mlx5_common_device *cdev, struct rte_mempool *mp); +/** Check if @p mp has buffers pinned in external memory. */ +static inline bool +mlx5_mempool_is_extmem(struct rte_mempool *mp) +{ + return (mp->private_data_size == + sizeof(struct rte_pktmbuf_pool_private)) && + (mp->elt_size >= sizeof(struct rte_mbuf)) && + (rte_pktmbuf_priv_flags(mp) & RTE_PKTMBUF_POOL_F_PINNED_EXT_BUF); +} + #endif /* RTE_PMD_MLX5_COMMON_MR_H_ */ diff --git a/drivers/net/mlx5/mlx5_trigger.c b/drivers/net/mlx5/mlx5_trigger.c index 1952d68444..4440a765d9 100644 --- a/drivers/net/mlx5/mlx5_trigger.c +++ b/drivers/net/mlx5/mlx5_trigger.c @@ -149,13 +149,14 @@ mlx5_rxq_mempool_register(struct mlx5_rxq_ctrl *rxq_ctrl) uint32_t flags; mp = rxq_ctrl->rxq.rxseg[s].mp; - flags = rte_pktmbuf_priv_flags(mp); + flags = mp != rxq_ctrl->rxq.mprq_mp ? + rte_pktmbuf_priv_flags(mp) : 0; ret = mlx5_mr_mempool_register(rxq_ctrl->sh->cdev, mp); if (ret < 0 && rte_errno != EEXIST) return ret; if ((flags & RTE_PKTMBUF_POOL_F_PINNED_EXT_BUF) == 0) rte_mempool_mem_iter(mp, mlx5_rxq_mempool_register_cb, - &rxq_ctrl->rxq); + &rxq_ctrl->rxq); } return 0; } -- 2.25.1