!629 Optimizing __random for single-threaded scenarios
From: @jiangyingxin1 Reviewed-by: @liqingqing_1229 Signed-off-by: @liqingqing_1229
This commit is contained in:
commit
f192c942cd
44
0001-Optimizing-__random-for-single-threaded-scenarios.patch
Normal file
44
0001-Optimizing-__random-for-single-threaded-scenarios.patch
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
From f54e1ddea12343991b402abf28be2b94ffbac2c5 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Tian Tao <tiantao6@hisilicon.com>
|
||||||
|
Date: Tue, 11 Jul 2023 08:42:56 +0800
|
||||||
|
Subject: [PATCH] Optimizing __random for single-threaded scenarios
|
||||||
|
|
||||||
|
The __random function does not need to be locked by __libc_lock_lock and
|
||||||
|
unlocked by __libc_lock_unlock in a single-threaded scenario, so we can
|
||||||
|
remove these locks in a single-threaded scenario to improve performance.
|
||||||
|
|
||||||
|
Signed-off-by: Tian Tao <tiantao6@hisilicon.com>
|
||||||
|
---
|
||||||
|
stdlib/random.c | 14 +++++++++++---
|
||||||
|
1 file changed, 11 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/stdlib/random.c b/stdlib/random.c
|
||||||
|
index 62f22fac8d..9035df8d18 100644
|
||||||
|
--- a/stdlib/random.c
|
||||||
|
+++ b/stdlib/random.c
|
||||||
|
@@ -288,11 +288,19 @@ __random (void)
|
||||||
|
{
|
||||||
|
int32_t retval;
|
||||||
|
|
||||||
|
- __libc_lock_lock (lock);
|
||||||
|
+ if (__libc_single_threaded) {
|
||||||
|
|
||||||
|
- (void) __random_r (&unsafe_state, &retval);
|
||||||
|
+ (void) __random_r (&unsafe_state, &retval);
|
||||||
|
|
||||||
|
- __libc_lock_unlock (lock);
|
||||||
|
+ } else {
|
||||||
|
+
|
||||||
|
+ __libc_lock_lock (lock);
|
||||||
|
+
|
||||||
|
+ (void) __random_r (&unsafe_state, &retval);
|
||||||
|
+
|
||||||
|
+ __libc_lock_unlock (lock);
|
||||||
|
+
|
||||||
|
+ }
|
||||||
|
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.33.0
|
||||||
|
|
||||||
@ -65,7 +65,7 @@
|
|||||||
##############################################################################
|
##############################################################################
|
||||||
Name: glibc
|
Name: glibc
|
||||||
Version: 2.36
|
Version: 2.36
|
||||||
Release: 17
|
Release: 18
|
||||||
Summary: The GNU libc libraries
|
Summary: The GNU libc libraries
|
||||||
License: %{all_license}
|
License: %{all_license}
|
||||||
URL: http://www.gnu.org/software/glibc/
|
URL: http://www.gnu.org/software/glibc/
|
||||||
@ -114,6 +114,7 @@ Patch9013: x86-use-total-l3cache-for-non_temporal_threshold.patch
|
|||||||
Patch9014: strcmp-delete-align-for-loop_aligned.patch
|
Patch9014: strcmp-delete-align-for-loop_aligned.patch
|
||||||
Patch9015: add-pthread_cond_clockwait-GLIBC_2_28.patch
|
Patch9015: add-pthread_cond_clockwait-GLIBC_2_28.patch
|
||||||
Patch9016: add-GB18030-2022-charmap-BZ-30243.patch
|
Patch9016: add-GB18030-2022-charmap-BZ-30243.patch
|
||||||
|
Patch9017: 0001-Optimizing-__random-for-single-threaded-scenarios.patch
|
||||||
|
|
||||||
Provides: ldconfig rtld(GNU_HASH) bundled(gnulib)
|
Provides: ldconfig rtld(GNU_HASH) bundled(gnulib)
|
||||||
|
|
||||||
@ -1273,6 +1274,9 @@ fi
|
|||||||
%endif
|
%endif
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue Jul 11 2023 jiangyingxin<jiangyingxin1@huawei.com> - 2.36-18
|
||||||
|
- Optimizing __random for single-threaded scenarios
|
||||||
|
|
||||||
* Tue Jul 11 2023 lijianglin<lijianglin2@huawei.com> - 2.36-17
|
* Tue Jul 11 2023 lijianglin<lijianglin2@huawei.com> - 2.36-17
|
||||||
- add the test of the entire GB18030 charmap
|
- add the test of the entire GB18030 charmap
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user