From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0EC1DA04A2; Tue, 12 May 2020 14:22:38 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6C8661C00D; Tue, 12 May 2020 14:22:19 +0200 (CEST) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2057.outbound.protection.outlook.com [40.107.20.57]) by dpdk.org (Postfix) with ESMTP id 0E0971BFEC for ; Tue, 12 May 2020 14:22:17 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CEtkoQ1AC9JUilMSvubV9UoiSvJMAk3wZ3m6cSdKrMyFuP4MtacTKzf+gLcOqywZbqkfUhr/+ZqX6V4uuWTtzgERIT/42stwaqJpgfFOA/42Y5kOei30k+3Ph+RLsqegFTyQceS03zEesVyy+oAq67sqV8A82WLpd21wmjBuMVVUTeHXWhBYJYO87sE2W/k/Oazca03pJYiEfD10UtkXN7UgZDv9V3dWtMs/4luGysCbwnYnsLXqh9AWeVzoQYw4X8b7oYXFMWS78QTpJmeV3MMHklmLuA+Y0lyxwnFDfIJqD3BkA94zQu6vlqEtBBi5fiOvjFCSVtlLvg6OG+Upfg== 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-SenderADCheck; bh=SfnQY21BEyHrM2kTJmHJmP4QWZYtNdpMsEdN6QpBQAU=; b=Z8slV1q2dZoeHIEChGYhhEGwI/Qmu89PL+5dHu+AeORuG1DSkrrF0kpyYe9aKTOWyKfQdWKtYysCfngPyW2O3UEQk+f15d+XsELBVhMEnDThssCjOB6EvHOJqMG2HqHzpLkzT3rrTIH9n2cz1lC/Pvv6zb/CDUUTX2xyeFfwgb0hoo3qso2ojmfdqCKRS5hz0RwL+2GvvnHNz9Ch8xLlfIdS8cCDpKDy582rw4956Zh3pHpDB9JLyxxdlHoPGGQ8/+itqpli0GNpA/IJF9AwZU7prnGBP1ojK0ctfi6PXcrsHtsiZhViGBUJ6PIhD158x9D2byxUoCTa2E9mSfbaiw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=mellanox.com; dmarc=pass action=none header.from=mellanox.com; dkim=pass header.d=mellanox.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SfnQY21BEyHrM2kTJmHJmP4QWZYtNdpMsEdN6QpBQAU=; b=UXeXavDhIuw90sZOk7bDFGn8ss6A1WQRYoQx4qLyuNIVTg2HdHKVfwggNrzjXHsr1raAiAUZjVrvpvqyi3uioYZApkRKGwIZbz5eb6EfCv0weIdtLAHXIV4zIOFoibt8TKuS8zss1azpS4zsHc9b0wWEbub653JJGEOAW2Pp9Lg= Authentication-Results: dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=none action=none header.from=mellanox.com; Received: from AM0PR0502MB3874.eurprd05.prod.outlook.com (2603:10a6:208:1a::29) by AM0PR0502MB3844.eurprd05.prod.outlook.com (2603:10a6:208:20::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.27; Tue, 12 May 2020 12:22:16 +0000 Received: from AM0PR0502MB3874.eurprd05.prod.outlook.com ([fe80::2cea:8f0a:cb2f:2a85]) by AM0PR0502MB3874.eurprd05.prod.outlook.com ([fe80::2cea:8f0a:cb2f:2a85%6]) with mapi id 15.20.2979.033; Tue, 12 May 2020 12:22:16 +0000 From: Shiri Kuzin To: dev@dpdk.org Cc: matan@mellanox.com, viacheslavo@mellanox.com Date: Tue, 12 May 2020 15:21:46 +0300 Message-Id: <1589286106-23411-4-git-send-email-shirik@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1589286106-23411-1-git-send-email-shirik@mellanox.com> References: <1589286106-23411-1-git-send-email-shirik@mellanox.com> Content-Type: text/plain X-ClientProxiedBy: AM3PR07CA0138.eurprd07.prod.outlook.com (2603:10a6:207:8::24) To AM0PR0502MB3874.eurprd05.prod.outlook.com (2603:10a6:208:1a::29) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from mellanox.com (94.188.199.18) by AM3PR07CA0138.eurprd07.prod.outlook.com (2603:10a6:207:8::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.12 via Frontend Transport; Tue, 12 May 2020 12:22:14 +0000 X-Mailer: git-send-email 1.8.3.1 X-Originating-IP: [94.188.199.18] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: fd8eab8e-039a-4302-5854-08d7f66f1b81 X-MS-TrafficTypeDiagnostic: AM0PR0502MB3844:|AM0PR0502MB3844: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:16; X-Forefront-PRVS: 0401647B7F X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: N561RmCxZT3UlyhSQcp0by0twlKzPrtBWfyKS+crgql/dES88+I99AB1ISDStGLhi5HfCtA8exRCFl/85ivlGXks1z3r6SwmUQCs3ModMqm5mlgbcosRen4WmV0Y6TtamzUbhhpprLOALyEsKkn+RscnrwzKfl74uO/WlR39ys1lsJzYGZVsRkNxUa56jAff//zCuuLab8t+HrdXaaGy4BHCs5LYJYXGLPpEsgOXejsbfbuC0F1uHsIHz2oedwNsMILqvXZrhqBxidc6ucK2Y3rLbVvHLcw8HS3KjpeIFShtVZBbJ0Jc+VE+MRg50Mhr7o4BYCzmo39SpvWn3nHVdvX58neLQ57+ZwvPEROBHW+Qe4jImQgXFlK1hMU8vjPxhzhse9NALeV9MNJ5EwxlmlurgSkAHN6baYMFu0YQVYqhVjZw0DMiMhujYo7q+idTq7VVXeHyM5LSe6MzSPzv2gmEQJ7fix8cnWPDpB2eIiNlr7YltkPUiJwWG1FqEa8pOycWMDINc4gZRcqpzxmenQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR0502MB3874.eurprd05.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(346002)(39860400002)(376002)(136003)(366004)(396003)(33430700001)(8936002)(4326008)(55016002)(86362001)(107886003)(5660300002)(956004)(316002)(66946007)(66556008)(66476007)(2616005)(2906002)(52116002)(186003)(26005)(7696005)(16526019)(33440700001)(8886007)(6666004)(6916009)(8676002)(478600001)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: yZZH+S1E33iWwUY6MM1vBct4QL1yP/gADfk+7aKWANHdPjyh6+cwX1u1uqITdC86/RKNhX3K0w5OzYjXA8TGBN3mG9ynll407ZtGWWPyuojHTlA4nd1cwnATeBRKnfVl+7ab1l4IIvfGuwXbnLxt3GMfJ6rXXGoBJ0t6SAVG7W4GdxchyWQge9TjqiTpu2kzMk7t6ri2pcIVXfHGVGASxW5FTIWXh3D64y+Qs7UMCMGdV66UbfZIuhwBYhI0i/9FSbz7dZQ0JJAbW25iSvH0FJtjDQs4eK46jSUI9V79vKvgcaVozEtbbP1Duxi2cKaHP/aQ6JzWaWOo72jJ3OUckYtCo1I8iUzIOGFuyWVcdy/6m50erM+5lt5NmU4IN9f/uwLoK93OVxBr83f4WW3Dh0g0LTWOASAnK0riz1W1CJu25BF8jbU5T1j8O75olCaffUadtmfQIVO/3YUsyPe/PRZe6u/znB3cIdp4YLo8QM4= X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: fd8eab8e-039a-4302-5854-08d7f66f1b81 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 May 2020 12:22:16.0868 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: RfuMV4zSiBFSIU+Ce/rz7ItIGPvkAAex15HVz7HN4SplYma7g6fXOaxcINCETBOPJyPQdIexGyPFZeKtxzbAxQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0502MB3844 Subject: [dpdk-dev] [PATCH 3/3] common/mlx5: disable relaxed ordering in unsuitable cpus X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" Relaxed ordering is a PCI optimization that enables reordering reads/writes in order to improve performance. Relaxed ordering was enabled for all processors causing a degradation in performance in Haswell and Broadwell processors that don't support this optimization. In order to avoid that we check if the processor is Haswell or Broadwell and if so we disable relaxed ordering. Signed-off-by: Shiri Kuzin --- drivers/common/mlx5/mlx5_common.c | 82 ++++++++++++++++++++++++++++++++++++ drivers/common/mlx5/mlx5_common.h | 2 + drivers/common/mlx5/mlx5_common_mr.c | 6 ++- drivers/net/mlx5/mlx5_flow_dv.c | 3 +- 4 files changed, 90 insertions(+), 3 deletions(-) diff --git a/drivers/common/mlx5/mlx5_common.c b/drivers/common/mlx5/mlx5_common.c index 4261045..1c77763 100644 --- a/drivers/common/mlx5/mlx5_common.c +++ b/drivers/common/mlx5/mlx5_common.c @@ -22,6 +22,8 @@ const struct mlx5_glue *mlx5_glue; #endif +uint8_t haswell_broadwell_cpu; + /** * Get PCI information by sysfs device path. * @@ -292,6 +294,29 @@ enum mlx5_class #endif +/* In case this is an x86_64 intel processor to check if + * we should use relaxed ordering. + */ +#ifdef RTE_ARCH_X86_64 +/** + * This function returns processor identification and feature information + * into the registers. + * + * @param eax, ebx, ecx, edx + * Pointers to the registers that will hold cpu information. + * @param level + * The main category of information returned. + */ +static inline void mlx5_cpu_id(unsigned int level, + unsigned int *eax, unsigned int *ebx, + unsigned int *ecx, unsigned int *edx) +{ + __asm__("cpuid\n\t" + : "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx) + : "0" (level)); +} +#endif + RTE_INIT_PRIO(mlx5_log_init, LOG) { mlx5_common_logtype = rte_log_register("pmd.common.mlx5"); @@ -350,3 +375,60 @@ enum mlx5_class mlx5_glue = NULL; return; } + +/** + * This function is responsible of initializing the variable + * haswell_broadwell_cpu by checking if the cpu is intel + * and reading the data returned from mlx5_cpu_id(). + * since haswell and broadwell cpus don't have improved performance + * when using relaxed ordering we want to check the cpu type before + * before deciding whether to enable RO or not. + * if the cpu is haswell or broadwell the variable will be set to 1 + * otherwise it will be 0. + */ +RTE_INIT_PRIO(mlx5_is_haswell_broadwell_cpu, LOG) +{ +#ifdef RTE_ARCH_X86_64 + unsigned int broadwell_models[4] = {0x3d, 0x47, 0x4F, 0x56}; + unsigned int haswell_models[4] = {0x3c, 0x3f, 0x45, 0x46}; + unsigned int i, model, family, brand_id, vendor; + unsigned int signature_intel_ebx = 0x756e6547; + unsigned int extended_model; + unsigned int eax = 0; + unsigned int ebx = 0; + unsigned int ecx = 0; + unsigned int edx = 0; + int max_level; + + mlx5_cpu_id(0, &eax, &ebx, &ecx, &edx); + vendor = ebx; + max_level = eax; + if (max_level < 1) { + haswell_broadwell_cpu = 0; + return; + } + mlx5_cpu_id(1, &eax, &ebx, &ecx, &edx); + model = (eax >> 4) & 0x0f; + family = (eax >> 8) & 0x0f; + brand_id = ebx & 0xff; + extended_model = (eax >> 12) & 0xf0; + /* Check if the processor is Haswell or Broadwell */ + if (vendor == signature_intel_ebx) { + if (family == 0x06) + model += extended_model; + if (brand_id == 0 && family == 0x6) { + for (i = 0; i < RTE_DIM(broadwell_models); i++) + if (model == broadwell_models[i]) { + haswell_broadwell_cpu = 1; + return; + } + for (i = 0; i < RTE_DIM(haswell_models); i++) + if (model == haswell_models[i]) { + haswell_broadwell_cpu = 1; + return; + } + } + } +#endif + haswell_broadwell_cpu = 0; +} diff --git a/drivers/common/mlx5/mlx5_common.h b/drivers/common/mlx5/mlx5_common.h index b37b820..8cd3ea5 100644 --- a/drivers/common/mlx5/mlx5_common.h +++ b/drivers/common/mlx5/mlx5_common.h @@ -213,4 +213,6 @@ enum mlx5_class { void mlx5_translate_port_name(const char *port_name_in, struct mlx5_switch_info *port_info_out); +extern uint8_t haswell_broadwell_cpu; + #endif /* RTE_PMD_MLX5_COMMON_H_ */ diff --git a/drivers/common/mlx5/mlx5_common_mr.c b/drivers/common/mlx5/mlx5_common_mr.c index 9d4a06d..3b46446 100644 --- a/drivers/common/mlx5/mlx5_common_mr.c +++ b/drivers/common/mlx5/mlx5_common_mr.c @@ -770,7 +770,8 @@ struct mlx5_mr * */ mr->ibv_mr = mlx5_glue->reg_mr(pd, (void *)data.start, len, IBV_ACCESS_LOCAL_WRITE | - IBV_ACCESS_RELAXED_ORDERING); + (haswell_broadwell_cpu ? 0 : + IBV_ACCESS_RELAXED_ORDERING)); if (mr->ibv_mr == NULL) { DEBUG("Fail to create a verbs MR for address (%p)", (void *)addr); @@ -1045,7 +1046,8 @@ struct mlx5_mr * return NULL; mr->ibv_mr = mlx5_glue->reg_mr(pd, (void *)addr, len, IBV_ACCESS_LOCAL_WRITE | - IBV_ACCESS_RELAXED_ORDERING); + (haswell_broadwell_cpu ? 0 : + IBV_ACCESS_RELAXED_ORDERING)); if (mr->ibv_mr == NULL) { DRV_LOG(WARNING, "Fail to create a verbs MR for address (%p)", diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index c7702c5..8b018fb 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -4134,7 +4134,8 @@ struct field_modify_info modify_tcp[] = { mkey_attr.klm_array = NULL; mkey_attr.klm_num = 0; if (priv->config.hca_attr.relaxed_ordering_write && - priv->config.hca_attr.relaxed_ordering_read) + priv->config.hca_attr.relaxed_ordering_read && + !haswell_broadwell_cpu) mkey_attr.relaxed_ordering = 1; mem_mng->dm = mlx5_devx_cmd_mkey_create(sh->ctx, &mkey_attr); if (!mem_mng->dm) { -- 1.8.3.1