diff --git a/SOURCES/0002-mlx5-Allocate-accurate-aligned-DM-memory-size.patch b/SOURCES/0002-mlx5-Allocate-accurate-aligned-DM-memory-size.patch new file mode 100644 index 0000000..41c9310 --- /dev/null +++ b/SOURCES/0002-mlx5-Allocate-accurate-aligned-DM-memory-size.patch @@ -0,0 +1,176 @@ +From 0290582355c4c7f1a30c80b206f62d7ddaa2de05 Mon Sep 17 00:00:00 2001 +From: Erez Shitrit +Date: Thu, 20 Feb 2020 15:27:30 +0200 +Subject: [PATCH 2/8] mlx5: Allocate accurate aligned DM memory size + +[ Upstream commit 96bd5476194106deb4c9edaf405e92646623465a ] + +Allocate the exact memory size and only when failed to allocate an aligned +memory size fallback to allocate double size of DM memory. + +Fixes: 6235899cdf7a ("mlx5: ICM pool memory allocator") +Signed-off-by: Erez Shitrit +Reviewed-by: Alex Vesker +Signed-off-by: Yishai Hadas +Signed-off-by: Nicolas Morey-Chaisemartin +--- + providers/mlx5/dr_icm_pool.c | 103 ++++++++++++++++++++++------------- + 1 file changed, 64 insertions(+), 39 deletions(-) + +diff --git a/providers/mlx5/dr_icm_pool.c b/providers/mlx5/dr_icm_pool.c +index 1e2853959b37..469e52552ccd 100644 +--- a/providers/mlx5/dr_icm_pool.c ++++ b/providers/mlx5/dr_icm_pool.c +@@ -89,16 +89,72 @@ struct dr_icm_mr { + struct list_node mr_list; + }; + +-static struct dr_icm_mr * +-dr_icm_pool_mr_create(struct dr_icm_pool *pool, +- enum mlx5_ib_uapi_dm_type dm_type, +- size_t align_base) ++static int ++dr_icm_allocate_aligned_dm(struct dr_icm_pool *pool, ++ struct dr_icm_mr *icm_mr, ++ struct ibv_alloc_dm_attr *dm_attr) + { + struct mlx5dv_alloc_dm_attr mlx5_dm_attr = {}; ++ size_t log_align_base = 0; ++ bool fallback = false; ++ struct mlx5_dm *dm; ++ size_t size; ++ ++ /* create dm/mr for this pool */ ++ size = dr_icm_pool_chunk_size_to_byte(pool->max_log_chunk_sz, ++ pool->icm_type); ++ ++ if (pool->icm_type == DR_ICM_TYPE_STE) { ++ mlx5_dm_attr.type = MLX5_IB_UAPI_DM_TYPE_STEERING_SW_ICM; ++ /* Align base is the biggest chunk size */ ++ log_align_base = ilog32(size - 1); ++ } else if (pool->icm_type == DR_ICM_TYPE_MODIFY_ACTION) { ++ mlx5_dm_attr.type = MLX5_IB_UAPI_DM_TYPE_HEADER_MODIFY_SW_ICM; ++ /* Align base is 64B */ ++ log_align_base = ilog32(DR_ICM_MODIFY_HDR_ALIGN_BASE - 1); ++ } ++ ++ dm_attr->length = size; ++ ++alloc_dm: ++ icm_mr->dm = mlx5dv_alloc_dm(pool->dmn->ctx, dm_attr, &mlx5_dm_attr); ++ if (!icm_mr->dm) { ++ dr_dbg(pool->dmn, "Failed allocating DM\n"); ++ return errno; ++ } ++ ++ dm = to_mdm(icm_mr->dm); ++ icm_mr->icm_start_addr = dm->remote_va; ++ ++ if (icm_mr->icm_start_addr & ((1UL << log_align_base) - 1)) { ++ uint64_t align_base; ++ uint64_t align_diff; ++ ++ /* Fallback to previous implementation, ask for double size */ ++ dr_dbg(pool->dmn, "Got not aligned memory: %zu last_try: %d\n", ++ log_align_base, fallback); ++ if (fallback) { ++ align_base = 1UL << log_align_base; ++ align_diff = icm_mr->icm_start_addr % align_base; ++ icm_mr->used_length = align_base - align_diff; ++ return 0; ++ } ++ ++ mlx5_free_dm(icm_mr->dm); ++ /* retry to allocate, now double the size */ ++ dm_attr->length = size * 2; ++ fallback = true; ++ goto alloc_dm; ++ } ++ ++ return 0; ++} ++ ++static struct dr_icm_mr * ++dr_icm_pool_mr_create(struct dr_icm_pool *pool) ++{ + struct ibv_alloc_dm_attr dm_attr = {}; + struct dr_icm_mr *icm_mr; +- struct mlx5_dm *dm; +- size_t align_diff; + + icm_mr = calloc(1, sizeof(struct dr_icm_mr)); + if (!icm_mr) { +@@ -106,20 +162,8 @@ dr_icm_pool_mr_create(struct dr_icm_pool *pool, + return NULL; + } + +- icm_mr->pool = pool; +- list_node_init(&icm_mr->mr_list); +- +- mlx5_dm_attr.type = dm_type; +- +- /* 2^log_biggest_table * entry-size * double-for-alignment */ +- dm_attr.length = dr_icm_pool_chunk_size_to_byte(pool->max_log_chunk_sz, +- pool->icm_type) * 2; +- +- icm_mr->dm = mlx5dv_alloc_dm(pool->dmn->ctx, &dm_attr, &mlx5_dm_attr); +- if (!icm_mr->dm) { +- dr_dbg(pool->dmn, "Failed allocating DM\n"); ++ if (dr_icm_allocate_aligned_dm(pool, icm_mr, &dm_attr)) + goto free_icm_mr; +- } + + /* Register device memory */ + icm_mr->mr = ibv_reg_dm_mr(pool->dmn->pd, icm_mr->dm, 0, +@@ -133,13 +177,6 @@ dr_icm_pool_mr_create(struct dr_icm_pool *pool, + goto free_dm; + } + +- dm = to_mdm(icm_mr->dm); +- icm_mr->icm_start_addr = dm->remote_va; +- +- align_diff = icm_mr->icm_start_addr % align_base; +- if (align_diff) +- icm_mr->used_length = align_base - align_diff; +- + list_add_tail(&pool->icm_mr_list, &icm_mr->mr_list); + + return icm_mr; +@@ -199,33 +236,21 @@ static int dr_icm_chunks_create(struct dr_icm_bucket *bucket) + { + size_t mr_free_size, mr_req_size, mr_row_size; + struct dr_icm_pool *pool = bucket->pool; +- enum mlx5_ib_uapi_dm_type dm_type; + struct dr_icm_chunk *chunk; + struct dr_icm_mr *icm_mr; +- size_t align_base; + int i; + + mr_req_size = bucket->num_of_entries * bucket->entry_size; + mr_row_size = dr_icm_pool_chunk_size_to_byte(pool->max_log_chunk_sz, + pool->icm_type); + +- if (pool->icm_type == DR_ICM_TYPE_STE) { +- dm_type = MLX5_IB_UAPI_DM_TYPE_STEERING_SW_ICM; +- /* Align base is the biggest chunk size / row size */ +- align_base = mr_row_size; +- } else { +- dm_type = MLX5_IB_UAPI_DM_TYPE_HEADER_MODIFY_SW_ICM; +- /* Align base is 64B */ +- align_base = DR_ICM_MODIFY_HDR_ALIGN_BASE; +- } +- + pthread_mutex_lock(&pool->mr_mutex); + icm_mr = list_tail(&pool->icm_mr_list, struct dr_icm_mr, mr_list); + if (icm_mr) + mr_free_size = icm_mr->mr->length - icm_mr->used_length; + + if (!icm_mr || mr_free_size < mr_row_size) { +- icm_mr = dr_icm_pool_mr_create(pool, dm_type, align_base); ++ icm_mr = dr_icm_pool_mr_create(pool); + if (!icm_mr) + goto out_err; + } +-- +2.25.4 + diff --git a/SOURCES/0004-buildlib-Fix-a-warning-from-newer-pythons.patch b/SOURCES/0004-buildlib-Fix-a-warning-from-newer-pythons.patch new file mode 100644 index 0000000..6c72ab8 --- /dev/null +++ b/SOURCES/0004-buildlib-Fix-a-warning-from-newer-pythons.patch @@ -0,0 +1,32 @@ +From 27fd326938dbedc1f254caeb8cd087117e1f7cd7 Mon Sep 17 00:00:00 2001 +From: Jason Gunthorpe +Date: Tue, 5 May 2020 20:16:14 -0300 +Subject: [PATCH 4/8] buildlib: Fix a warning from newer pythons + +[ Upstream commit 7ba12afad433c1ee29877fc51662a203935e6c78 ] + +The % is typod into the string in check-build + +Fixes: 7cff8245374c ("Have travis check shared library filenames") +Signed-off-by: Jason Gunthorpe +Signed-off-by: Nicolas Morey-Chaisemartin +--- + buildlib/check-build | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/buildlib/check-build b/buildlib/check-build +index ab8524e5b98f..4e52d0d4785a 100755 +--- a/buildlib/check-build ++++ b/buildlib/check-build +@@ -84,7 +84,7 @@ def get_symbol_vers(fn,exported=True): + def check_lib_symver(args,fn): + g = re.match(r"lib([^.]+)\.so\.(\d+)\.(\d+)\.(.*)",fn); + if g.group(4) != args.PACKAGE_VERSION: +- raise ValueError("Shared Library filename %r does not have the package version %r (%r)%"( ++ raise ValueError("Shared Library filename %r does not have the package version %r (%r)"%( + fn,args.PACKAGE_VERSION,g.groups())); + + # umad/etc used the wrong symbol version name when they moved to soname 3.0 +-- +2.25.4 + diff --git a/SOURCES/0005-libibverbs-Fix-description-of-ibv_get_device_guid-ma.patch b/SOURCES/0005-libibverbs-Fix-description-of-ibv_get_device_guid-ma.patch new file mode 100644 index 0000000..8cefebf --- /dev/null +++ b/SOURCES/0005-libibverbs-Fix-description-of-ibv_get_device_guid-ma.patch @@ -0,0 +1,35 @@ +From 6e1a61ab829ba893858a50e799fcdbcd95169f35 Mon Sep 17 00:00:00 2001 +From: Leon Romanovsky +Date: Wed, 22 Apr 2020 15:43:22 +0300 +Subject: [PATCH 5/8] libibverbs: Fix description of ibv_get_device_guid man + page + +[ Upstream commit 4ca5cafd29f619233b8deb0297cef0024fcd6e90 ] + +There is a copy/paste error in the description of +ibv_get_device_guid(), fix it. + +Fixes: 7aca81e64aa9 ("verbs: Switch simpler man pages over to markdown format") +Reviewed-by: Yishai Hadas +Signed-off-by: Leon Romanovsky +Signed-off-by: Nicolas Morey-Chaisemartin +--- + libibverbs/man/ibv_get_device_guid.3.md | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/libibverbs/man/ibv_get_device_guid.3.md b/libibverbs/man/ibv_get_device_guid.3.md +index 683900f974ca..6dc96001d0af 100644 +--- a/libibverbs/man/ibv_get_device_guid.3.md ++++ b/libibverbs/man/ibv_get_device_guid.3.md +@@ -22,7 +22,7 @@ uint64_t ibv_get_device_guid(struct ibv_device *device); + + # DESCRIPTION + +-**ibv_get_device_name()** returns the Global Unique IDentifier (GUID) of the ++**ibv_get_device_guid()** returns the Global Unique IDentifier (GUID) of the + RDMA device *device*. + + # RETURN VALUE +-- +2.25.4 + diff --git a/SOURCES/0006-verbs-Fix-ibv_create_wq-to-set-wq_context.patch b/SOURCES/0006-verbs-Fix-ibv_create_wq-to-set-wq_context.patch new file mode 100644 index 0000000..c60a7cf --- /dev/null +++ b/SOURCES/0006-verbs-Fix-ibv_create_wq-to-set-wq_context.patch @@ -0,0 +1,31 @@ +From 24eb020845273acb301b69779921284475303d3a Mon Sep 17 00:00:00 2001 +From: Yishai Hadas +Date: Sun, 19 Apr 2020 14:06:15 +0300 +Subject: [PATCH 6/8] verbs: Fix ibv_create_wq() to set wq_context + +[ Upstream commit 130dc94863e754402bb79d52ef89a72a94041def ] + +Fix ibv_create_wq() to set wq_context upon a successful creation. + +Fixes: 2864904f82bf ("Introduce Work Queue object and its verbs") +Signed-off-by: Yishai Hadas +Signed-off-by: Nicolas Morey-Chaisemartin +--- + libibverbs/verbs.h | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/libibverbs/verbs.h b/libibverbs/verbs.h +index 288985d54975..5e256b4dc442 100644 +--- a/libibverbs/verbs.h ++++ b/libibverbs/verbs.h +@@ -3073,6 +3073,7 @@ static inline struct ibv_wq *ibv_create_wq(struct ibv_context *context, + + wq = vctx->create_wq(context, wq_init_attr); + if (wq) { ++ wq->wq_context = wq_init_attr->wq_context; + wq->events_completed = 0; + pthread_mutex_init(&wq->mutex, NULL); + pthread_cond_init(&wq->cond, NULL); +-- +2.25.4 + diff --git a/SOURCES/0008-libibverbs-Fix-ABI_placeholder1-and-ABI_placeholder2.patch b/SOURCES/0008-libibverbs-Fix-ABI_placeholder1-and-ABI_placeholder2.patch new file mode 100644 index 0000000..dfe3e17 --- /dev/null +++ b/SOURCES/0008-libibverbs-Fix-ABI_placeholder1-and-ABI_placeholder2.patch @@ -0,0 +1,79 @@ +From fccce505db388fbea2d65fb662111702bc60ad25 Mon Sep 17 00:00:00 2001 +From: Honggang Li +Date: Thu, 4 Jun 2020 14:33:38 +0800 +Subject: [PATCH 8/8] libibverbs: Fix ABI_placeholder1 and ABI_placeholder2 + assignment + +The assignment of ABI_placeholder1 and ABI_placeholder2 must be +after the provider populated context_ex->ibv_create_flow and +context_ex->ibv_destroy_flow. + +Applications, which compiled against old libibverbs released between +commit 501b53b30752 and 1111cf9895bb, will fail if they are linked +with libibverbs released after 1111cf9895bb and call ibv_create_flow. + +[1] 501b53b30752 ("Fix create/destroy flow API") + +Fixes: 1111cf9895bb ("verbs: Always allocate a verbs_context") +Signed-off-by: Honggang Li +(cherry picked from commit 88789b7ba618d55491026c74a9a31699805e5934) +Signed-off-by: Honggang Li +--- + libibverbs/device.c | 34 +++++++++++++++++----------------- + 1 file changed, 17 insertions(+), 17 deletions(-) + +diff --git a/libibverbs/device.c b/libibverbs/device.c +index bc7df1b06435..db97655c2d9e 100644 +--- a/libibverbs/device.c ++++ b/libibverbs/device.c +@@ -256,23 +256,6 @@ int verbs_init_context(struct verbs_context *context_ex, + context_ex->context.abi_compat = __VERBS_ABI_IS_EXTENDED; + context_ex->sz = sizeof(*context_ex); + +- /* +- * In order to maintain backward/forward binary compatibility +- * with apps compiled against libibverbs-1.1.8 that use the +- * flow steering addition, we need to set the two +- * ABI_placeholder entries to match the driver set flow +- * entries. This is because apps compiled against +- * libibverbs-1.1.8 use an inline ibv_create_flow and +- * ibv_destroy_flow function that looks in the placeholder +- * spots for the proper entry points. For apps compiled +- * against libibverbs-1.1.9 and later, the inline functions +- * will be looking in the right place. +- */ +- context_ex->ABI_placeholder1 = +- (void (*)(void))context_ex->ibv_create_flow; +- context_ex->ABI_placeholder2 = +- (void (*)(void))context_ex->ibv_destroy_flow; +- + context_ex->priv = calloc(1, sizeof(*context_ex->priv)); + if (!context_ex->priv) { + errno = ENOMEM; +@@ -330,6 +313,23 @@ static void set_lib_ops(struct verbs_context *vctx) + #undef ibv_query_port + vctx->context.ops._compat_query_port = ibv_query_port; + vctx->query_port = __lib_query_port; ++ ++ /* ++ * In order to maintain backward/forward binary compatibility ++ * with apps compiled against libibverbs-1.1.8 that use the ++ * flow steering addition, we need to set the two ++ * ABI_placeholder entries to match the driver set flow ++ * entries. This is because apps compiled against ++ * libibverbs-1.1.8 use an inline ibv_create_flow and ++ * ibv_destroy_flow function that looks in the placeholder ++ * spots for the proper entry points. For apps compiled ++ * against libibverbs-1.1.9 and later, the inline functions ++ * will be looking in the right place. ++ */ ++ vctx->ABI_placeholder1 = ++ (void (*)(void))vctx->ibv_create_flow; ++ vctx->ABI_placeholder2 = ++ (void (*)(void))vctx->ibv_destroy_flow; + } + + struct ibv_context *verbs_open_device(struct ibv_device *device, void *private_data) +-- +2.25.4 + diff --git a/SPECS/rdma-core.spec b/SPECS/rdma-core.spec index b2209ef..a5d2c2c 100644 --- a/SPECS/rdma-core.spec +++ b/SPECS/rdma-core.spec @@ -1,6 +1,6 @@ Name: rdma-core Version: 29.0 -Release: 2%{?dist} +Release: 3%{?dist} Summary: RDMA core userspace libraries and daemons # Almost everything is licensed under the OFA dual GPLv2, 2 Clause BSD license @@ -21,6 +21,11 @@ Patch2: i40iw-autoload-breaks-suspend.patch Patch3: udev-keep-NAME_KERNEL-as-default-interface-naming-co.patch # stable-v29 patch Patch101: 0001-ABI-Files.patch +Patch102: 0002-mlx5-Allocate-accurate-aligned-DM-memory-size.patch +Patch104: 0004-buildlib-Fix-a-warning-from-newer-pythons.patch +Patch105: 0005-libibverbs-Fix-description-of-ibv_get_device_guid-ma.patch +Patch106: 0006-verbs-Fix-ibv_create_wq-to-set-wq_context.patch +Patch108: 0008-libibverbs-Fix-ABI_placeholder1-and-ABI_placeholder2.patch # Do not build static libs by default. %define with_static %{?_with_static: 1} %{?!_with_static: 0} @@ -38,6 +43,7 @@ BuildRequires: valgrind-devel BuildRequires: systemd BuildRequires: python3-devel BuildRequires: sed +BuildRequires: perl-generators Requires: dracut, kmod, systemd %if 0%{?fedora} >= 24 @@ -156,6 +162,9 @@ Device-specific plug-in ibverbs userspace drivers are included: %package -n libibverbs-utils Summary: Examples for the libibverbs library Requires: libibverbs%{?_isa} = %{version}-%{release} +# rxe_cfg uses commands provided by these packages +Requires: iproute +Requires: ethtool %description -n libibverbs-utils Useful libibverbs example programs such as ibv_devinfo, which @@ -227,11 +236,16 @@ In conjunction with the kernel ib_srp driver, srp_daemon allows you to discover and use SCSI devices via the SCSI RDMA Protocol over InfiniBand. %prep -%setup +%setup -q %patch1 -p1 %patch2 -p1 %patch3 -p1 %patch101 -p1 +%patch102 -p1 +%patch104 -p1 +%patch105 -p1 +%patch106 -p1 +%patch108 -p1 %build @@ -477,17 +491,17 @@ find %{buildroot} -name '*efa*' -exec rm -fv {} \; %doc %{_docdir}/%{name}/libibverbs.md %doc %{_docdir}/%{name}/rxe.md %doc %{_docdir}/%{name}/tag_matching.md -%{_bindir}/rxe_cfg %{_mandir}/man7/rxe* %ifnarch s390 %{_mandir}/man7/mlx4dv* %{_mandir}/man7/mlx5dv* %endif -%{_mandir}/man8/rxe* %files -n libibverbs-utils %{_bindir}/ibv_* %{_mandir}/man1/ibv_* +%{_bindir}/rxe_cfg +%{_mandir}/man8/rxe* %files -n ibacm %config(noreplace) %{_sysconfdir}/rdma/ibacm_opts.cfg @@ -564,6 +578,11 @@ find %{buildroot} -name '*efa*' -exec rm -fv {} \; %doc %{_docdir}/%{name}/ibsrpdm.md %changelog +* Tue Jun 09 2020 Honggang Li - 29.0-3 +- BuildRequires perl-generators +- Backport upstream stable-v29 commits +- Resolves: bz1845420 + * Mon May 18 2020 Honggang Li - 29.0-2 - Suppress ibdev2netdev warning messgae - Unversioned documentation directory