!74 修改ceph低版本pick_a_shard选择不合理,导致大量线程竞争的性能问题

Merge pull request !74 from liqiang2020/lq_2003-LTS-SP3-FIX
This commit is contained in:
openeuler-ci-bot 2021-12-29 06:20:02 +00:00 committed by Gitee
commit bb6694ef1a
4 changed files with 102 additions and 1 deletions

View File

@ -0,0 +1,39 @@
From e4e07de8f36d0d44b341d5784a8bf56192201b95 Mon Sep 17 00:00:00 2001
From: Adam Kupczyk <akupczyk@redhat.com>
Date: Mon, 25 Jan 2021 11:33:28 +0100
Subject: [PATCH] common/mempool: Add test for mempool shards
Add test that checks quality of mempool sharing.
It refuses to accept cases when variance is too large.
Signed-off-by: Adam Kupczyk <akupczyk@redhat.com>
---
src/include/mempool.h | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/include/mempool.h b/src/include/mempool.h
index 2247cb15bc0..a18f6a502da 100644
--- a/src/include/mempool.h
+++ b/src/include/mempool.h
@@ -255,11 +255,16 @@ public:
void adjust_count(ssize_t items, ssize_t bytes);
- shard_t* pick_a_shard() {
+ static size_t pick_a_shard_int() {
// Dirt cheap, see:
- // http://fossies.org/dox/glibc-2.24/pthread__self_8c_source.html
+ // https://fossies.org/dox/glibc-2.32/pthread__self_8c_source.html
size_t me = (size_t)pthread_self();
size_t i = (me >> 3) & ((1 << num_shard_bits) - 1);
+ return i;
+ }
+
+ shard_t* pick_a_shard() {
+ size_t i = pick_a_shard_int();
return &shard[i];
}
--
2.23.0.windows.1

View File

@ -0,0 +1,28 @@
From fccbdc0905e3868666fbb10803bac6b73f687cb1 Mon Sep 17 00:00:00 2001
From: Adam Kupczyk <akupczyk@redhat.com>
Date: Mon, 25 Jan 2021 11:45:06 +0100
Subject: [PATCH] common/mempool: Modify shard selection function
Modify shard selection function, so no longer all threads use the same shard 0.
Signed-off-by: Adam Kupczyk <akupczyk@redhat.com>
---
src/include/mempool.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/include/mempool.h b/src/include/mempool.h
index a18f6a502da..c03aa175cfa 100644
--- a/src/include/mempool.h
+++ b/src/include/mempool.h
@@ -259,7 +259,7 @@ public:
// Dirt cheap, see:
// https://fossies.org/dox/glibc-2.32/pthread__self_8c_source.html
size_t me = (size_t)pthread_self();
- size_t i = (me >> 3) & ((1 << num_shard_bits) - 1);
+ size_t i = (me >> 12) & ((1 << num_shard_bits) - 1);
return i;
}
--
2.23.0.windows.1

View File

@ -0,0 +1,27 @@
From db79769d6d557acc021a434ff285db2d69458d0a Mon Sep 17 00:00:00 2001
From: singuliere <singuliere@autistici.org>
Date: Wed, 17 Mar 2021 07:35:04 +0100
Subject: [PATCH] common/mempool: only fail tests if sharding is very bad
Fixes: https://tracker.ceph.com/issues/49781
Signed-off-by: singuliere <singuliere@autistici.org>
---
src/include/mempool.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/include/mempool.h b/src/include/mempool.h
index c03aa175cfa..fe84f3b8f09 100644
--- a/src/include/mempool.h
+++ b/src/include/mempool.h
@@ -259,7 +259,7 @@ public:
// Dirt cheap, see:
// https://fossies.org/dox/glibc-2.32/pthread__self_8c_source.html
size_t me = (size_t)pthread_self();
- size_t i = (me >> 12) & ((1 << num_shard_bits) - 1);
+ size_t i = (me >> CEPH_PAGE_SHIFT) & ((1 << num_shard_bits) - 1);
return i;
}
--
2.23.0.windows.1

View File

@ -68,7 +68,7 @@
#################################################################################
Name: ceph
Version: 12.2.8
Release: 15
Release: 16
Epoch: 2
# define _epoch_prefix macro which will expand to the empty string if epoch is
@ -104,6 +104,9 @@ Patch17: 0017-CVE-2021-3524-1.patch
Patch18: 0018-CVE-2020-1760-1.patch
Patch19: 0019-CVE-2020-1760-2.patch
Patch20: 0020-CVE-2020-1760-3.patch
Patch21: 0021-common-mempool-Add-test-for-mempool-shards.patch
Patch22: 0022-common-mempool-Modify-shard-selection-function.patch
Patch23: 0023-common-mempool-only-fail-tests-if-sharding-is-very-b.patch
%if 0%{?suse_version}
%if 0%{?is_opensuse}
@ -1812,6 +1815,10 @@ exit 0
%changelog
* Wed Dec 29 2021 Li Qiang <liqiang64@huawei.com> - 1:12.2.8-16
- Synchronize the performance optimization of the pick_a_shard
- function in the upstream community.
* Fri Aug 6 2021 chixinze <xmdxcxz@gmail.com> - 1:12.2.8-15
- fix https://gitee.com/src-openeuler/ceph/issues/I43TE9