diff --git a/0001-Optimizing-__random-for-single-threaded-scenarios.patch b/0001-Optimizing-__random-for-single-threaded-scenarios.patch new file mode 100644 index 0000000..cbc113e --- /dev/null +++ b/0001-Optimizing-__random-for-single-threaded-scenarios.patch @@ -0,0 +1,44 @@ +From f54e1ddea12343991b402abf28be2b94ffbac2c5 Mon Sep 17 00:00:00 2001 +From: Tian Tao +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 +--- + 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 + diff --git a/glibc.spec b/glibc.spec index e37b5bd..f3aee52 100644 --- a/glibc.spec +++ b/glibc.spec @@ -65,7 +65,7 @@ ############################################################################## Name: glibc Version: 2.36 -Release: 17 +Release: 18 Summary: The GNU libc libraries License: %{all_license} 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 Patch9015: add-pthread_cond_clockwait-GLIBC_2_28.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) @@ -1273,6 +1274,9 @@ fi %endif %changelog +* Tue Jul 11 2023 jiangyingxin - 2.36-18 +- Optimizing __random for single-threaded scenarios + * Tue Jul 11 2023 lijianglin - 2.36-17 - add the test of the entire GB18030 charmap