diff options
author | liqiang <liqiang64@huawei.com> | 2022-01-06 09:09:20 +0100 |
---|---|---|
committer | liqiang <liqiang64@huawei.com> | 2022-01-06 09:09:20 +0100 |
commit | ddb493f63ec2f2521ba3f511ba894fcc55190cd7 (patch) | |
tree | b08e5879b00294d06d784a7b16b3f53bde298a4c /src/common/mempool.cc | |
parent | Merge pull request #43570 from ljflores/wip-pg-stats (diff) | |
download | ceph-ddb493f63ec2f2521ba3f511ba894fcc55190cd7.tar.xz ceph-ddb493f63ec2f2521ba3f511ba894fcc55190cd7.zip |
Use thread-local pointer variables to save the shard location required by this thread.
Signed-off-by: liqiang <liqiang64@huawei.com>
Diffstat (limited to 'src/common/mempool.cc')
-rw-r--r-- | src/common/mempool.cc | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/common/mempool.cc b/src/common/mempool.cc index e4ab5d4a10a..669ea192167 100644 --- a/src/common/mempool.cc +++ b/src/common/mempool.cc @@ -15,7 +15,7 @@ #include "include/mempool.h" #include "include/demangle.h" - +static thread_local mempool::shard_t *thread_shard = NULL; // default to debug_mode off bool mempool::debug_mode = false; @@ -92,9 +92,9 @@ size_t mempool::pool_t::allocated_items() const void mempool::pool_t::adjust_count(ssize_t items, ssize_t bytes) { - shard_t *shard = pick_a_shard(); - shard->items += items; - shard->bytes += bytes; + thread_shard = (thread_shard == NULL) ? pick_a_shard() : thread_shard; + thread_shard->items += items; + thread_shard->bytes += bytes; } void mempool::pool_t::get_stats( |