Skip to content

fix: fix bthread_id_unlock failed in aarch64 cpu(fix issue #3083)#3084

Merged
Huixxi merged 1 commit intoapache:masterfrom
zhoukangsheng:fix_bthread_id_unlock_failed
Sep 15, 2025
Merged

fix: fix bthread_id_unlock failed in aarch64 cpu(fix issue #3083)#3084
Huixxi merged 1 commit intoapache:masterfrom
zhoukangsheng:fix_bthread_id_unlock_failed

Conversation

@zhoukangsheng
Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: fix #3083

Problem Summary:

What is changed and the side effects?

Changed:

Side effects:

  • Performance effects:

  • Breaking backward compatibility:


Check List:

@zhoukangsheng
Copy link
Copy Markdown
Contributor Author

After this modification, no similar problem in issue #3083 occurs

@zhoukangsheng
Copy link
Copy Markdown
Contributor Author

ref: #2156

Comment thread src/butil/object_pool_inl.h Outdated

inline LocalPool* get_or_new_local_pool() {
LocalPool* lp = _local_pool;
LocalPool* lp = BAIDU_GET_VOLATILE_THREAD_LOCAL(_local_pool);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indent

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread src/butil/object_pool_inl.h Outdated
}
BAIDU_SCOPED_LOCK(_change_thread_mutex); //avoid race with clear()
_local_pool = lp;
BAIDU_SET_VOLATILE_THREAD_LOCAL(_local_pool, lp);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indent

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indent

done

Comment thread src/butil/resource_pool_inl.h Outdated

inline LocalPool* get_or_new_local_pool() {
LocalPool* lp = _local_pool;
LocalPool* lp = BAIDU_GET_VOLATILE_THREAD_LOCAL(_local_pool);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indent

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indent

done

Comment thread src/butil/resource_pool_inl.h Outdated
}
BAIDU_SCOPED_LOCK(_change_thread_mutex); //avoid race with clear()
_local_pool = lp;
BAIDU_SET_VOLATILE_THREAD_LOCAL(_local_pool, lp);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indent

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indent

done

@zhoukangsheng zhoukangsheng force-pushed the fix_bthread_id_unlock_failed branch from 5aacb93 to c1ac17a Compare September 9, 2025 14:07
@wwbmmm
Copy link
Copy Markdown
Contributor

wwbmmm commented Sep 10, 2025

LGTM

@Huixxi
Copy link
Copy Markdown
Contributor

Huixxi commented Sep 13, 2025

Does this implementation and modification ensure that compilation on architectures other than aarch64 will not be affected?

@zhoukangsheng
Copy link
Copy Markdown
Contributor Author

Does this implementation and modification ensure that compilation on architectures other than aarch64 will not be affected?

only gcc compilers under aarch64 and clang under any architectures will optimize the reading and writing of thread_local variables, so these two will be affected by this modification.

It is implemented by different macro expansion of BAIDU_GET_VOLATILE_THREAD_LOCAL under different compilation conditions.For more detailed discussion, you can refer to #2156
image

@Huixxi Huixxi merged commit 7229c36 into apache:master Sep 15, 2025
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bthread_id_unlock 失败

3 participants