diff options
| author | Sunil Dora <sunilkumar.dora@windriver.com> | 2025-06-17 03:08:49 -0700 |
|---|---|---|
| committer | Steve Sakoman <steve@sakoman.com> | 2025-06-20 08:06:30 -0700 |
| commit | a9b8182e899dd3257713f2391341fea2fbea632b (patch) | |
| tree | c8dbd99de54e232270e4f5a3eba88c93086c6479 | |
| parent | 218c9ec684cf13229d7d9ef6cf4bc4f7be564faf (diff) | |
| download | poky-a9b8182e899dd3257713f2391341fea2fbea632b.tar.gz | |
glibc: nptl Update comments and indentation for new condvar implementation
The following commits have been cherry-picked from Glibc master branch:
Bug : https://sourceware.org/bugzilla/show_bug.cgi?id=25847
Upstream-Status: Backport
[https://sourceware.org/git/?p=glibc.git;a=commit;h=0cc973160c23bb67f895bc887dd6942d29f8fee3]
(From OE-Core rev: e5296415e97e4d704c4c8d11ad243061a1e14997)
Signed-off-by: Sunil Dora <sunilkumar.dora@windriver.com>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
| -rw-r--r-- | meta/recipes-core/glibc/glibc/0026-PR25847-2.patch | 144 | ||||
| -rw-r--r-- | meta/recipes-core/glibc/glibc_2.35.bb | 1 |
2 files changed, 145 insertions, 0 deletions
diff --git a/meta/recipes-core/glibc/glibc/0026-PR25847-2.patch b/meta/recipes-core/glibc/glibc/0026-PR25847-2.patch new file mode 100644 index 0000000000..cb89431769 --- /dev/null +++ b/meta/recipes-core/glibc/glibc/0026-PR25847-2.patch | |||
| @@ -0,0 +1,144 @@ | |||
| 1 | From 6aab1191e35a3da66e8c49d95178a9d77c119a1f Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Malte Skarupke <malteskarupke@fastmail.fm> | ||
| 3 | Date: Mon, 16 Jun 2025 23:17:53 -0700 | ||
| 4 | Subject: [PATCH] nptl: Update comments and indentation for new condvar | ||
| 5 | implementation | ||
| 6 | |||
| 7 | Some comments were wrong after the most recent commit. This fixes that. | ||
| 8 | Also fixing indentation where it was using spaces instead of tabs. | ||
| 9 | |||
| 10 | The following commits have been cherry-picked from Glibc master branch: | ||
| 11 | Bug : https://sourceware.org/bugzilla/show_bug.cgi?id=25847 | ||
| 12 | |||
| 13 | Upstream-Status: Backport | ||
| 14 | [https://sourceware.org/git/?p=glibc.git;a=commit;h=0cc973160c23bb67f895bc887dd6942d29f8fee3] | ||
| 15 | |||
| 16 | Signed-off-by: Sunil Dora <sunilkumar.dora@windriver.com> | ||
| 17 | --- | ||
| 18 | nptl/pthread_cond_common.c | 5 +++-- | ||
| 19 | nptl/pthread_cond_wait.c | 39 +++++++++++++++++++------------------- | ||
| 20 | 2 files changed, 22 insertions(+), 22 deletions(-) | ||
| 21 | |||
| 22 | diff --git a/nptl/pthread_cond_common.c b/nptl/pthread_cond_common.c | ||
| 23 | index 8dd7037923..306a207dd6 100644 | ||
| 24 | --- a/nptl/pthread_cond_common.c | ||
| 25 | +++ b/nptl/pthread_cond_common.c | ||
| 26 | @@ -221,8 +221,9 @@ __condvar_quiesce_and_switch_g1 (pthread_cond_t *cond, uint64_t wseq, | ||
| 27 | * New waiters arriving concurrently with the group switching will all go | ||
| 28 | into G2 until we atomically make the switch. Waiters existing in G2 | ||
| 29 | are not affected. | ||
| 30 | - * Waiters in G1 will be closed out immediately by the advancing of | ||
| 31 | - __g_signals to the next "lowseq" (low 31 bits of the new g1_start), | ||
| 32 | + * Waiters in G1 have already received a signal and been woken. If they | ||
| 33 | + haven't woken yet, they will be closed out immediately by the advancing | ||
| 34 | + of __g_signals to the next "lowseq" (low 31 bits of the new g1_start), | ||
| 35 | which will prevent waiters from blocking using a futex on | ||
| 36 | __g_signals since it provides enough signals for all possible | ||
| 37 | remaining waiters. As a result, they can each consume a signal | ||
| 38 | diff --git a/nptl/pthread_cond_wait.c b/nptl/pthread_cond_wait.c | ||
| 39 | index 1cb3dbf7b0..cee1968756 100644 | ||
| 40 | --- a/nptl/pthread_cond_wait.c | ||
| 41 | +++ b/nptl/pthread_cond_wait.c | ||
| 42 | @@ -249,7 +249,7 @@ __condvar_cleanup_waiting (void *arg) | ||
| 43 | figure out whether they are in a group that has already been completely | ||
| 44 | signaled (i.e., if the current G1 starts at a later position that the | ||
| 45 | waiter's position). Waiters cannot determine whether they are currently | ||
| 46 | - in G2 or G1 -- but they do not have too because all they are interested in | ||
| 47 | + in G2 or G1 -- but they do not have to because all they are interested in | ||
| 48 | is whether there are available signals, and they always start in G2 (whose | ||
| 49 | group slot they know because of the bit in the waiter sequence. Signalers | ||
| 50 | will simply fill the right group until it is completely signaled and can | ||
| 51 | @@ -412,7 +412,7 @@ __pthread_cond_wait_common (pthread_cond_t *cond, pthread_mutex_t *mutex, | ||
| 52 | } | ||
| 53 | |||
| 54 | /* Now wait until a signal is available in our group or it is closed. | ||
| 55 | - Acquire MO so that if we observe a value of zero written after group | ||
| 56 | + Acquire MO so that if we observe (signals == lowseq) after group | ||
| 57 | switching in __condvar_quiesce_and_switch_g1, we synchronize with that | ||
| 58 | store and will see the prior update of __g1_start done while switching | ||
| 59 | groups too. */ | ||
| 60 | @@ -422,8 +422,8 @@ __pthread_cond_wait_common (pthread_cond_t *cond, pthread_mutex_t *mutex, | ||
| 61 | { | ||
| 62 | while (1) | ||
| 63 | { | ||
| 64 | - uint64_t g1_start = __condvar_load_g1_start_relaxed (cond); | ||
| 65 | - unsigned int lowseq = (g1_start & 1) == g ? signals : g1_start & ~1U; | ||
| 66 | + uint64_t g1_start = __condvar_load_g1_start_relaxed (cond); | ||
| 67 | + unsigned int lowseq = (g1_start & 1) == g ? signals : g1_start & ~1U; | ||
| 68 | |||
| 69 | /* Spin-wait first. | ||
| 70 | Note that spinning first without checking whether a timeout | ||
| 71 | @@ -447,21 +447,21 @@ __pthread_cond_wait_common (pthread_cond_t *cond, pthread_mutex_t *mutex, | ||
| 72 | |||
| 73 | /* Reload signals. See above for MO. */ | ||
| 74 | signals = atomic_load_acquire (cond->__data.__g_signals + g); | ||
| 75 | - g1_start = __condvar_load_g1_start_relaxed (cond); | ||
| 76 | - lowseq = (g1_start & 1) == g ? signals : g1_start & ~1U; | ||
| 77 | + g1_start = __condvar_load_g1_start_relaxed (cond); | ||
| 78 | + lowseq = (g1_start & 1) == g ? signals : g1_start & ~1U; | ||
| 79 | spin--; | ||
| 80 | } | ||
| 81 | |||
| 82 | - if (seq < (g1_start >> 1)) | ||
| 83 | + if (seq < (g1_start >> 1)) | ||
| 84 | { | ||
| 85 | - /* If the group is closed already, | ||
| 86 | + /* If the group is closed already, | ||
| 87 | then this waiter originally had enough extra signals to | ||
| 88 | consume, up until the time its group was closed. */ | ||
| 89 | goto done; | ||
| 90 | - } | ||
| 91 | + } | ||
| 92 | |||
| 93 | /* If there is an available signal, don't block. | ||
| 94 | - If __g1_start has advanced at all, then we must be in G1 | ||
| 95 | + If __g1_start has advanced at all, then we must be in G1 | ||
| 96 | by now, perhaps in the process of switching back to an older | ||
| 97 | G2, but in either case we're allowed to consume the available | ||
| 98 | signal and should not block anymore. */ | ||
| 99 | @@ -483,22 +483,23 @@ __pthread_cond_wait_common (pthread_cond_t *cond, pthread_mutex_t *mutex, | ||
| 100 | sequence. */ | ||
| 101 | atomic_fetch_add_acquire (cond->__data.__g_refs + g, 2); | ||
| 102 | signals = atomic_load_acquire (cond->__data.__g_signals + g); | ||
| 103 | - g1_start = __condvar_load_g1_start_relaxed (cond); | ||
| 104 | - lowseq = (g1_start & 1) == g ? signals : g1_start & ~1U; | ||
| 105 | + g1_start = __condvar_load_g1_start_relaxed (cond); | ||
| 106 | + lowseq = (g1_start & 1) == g ? signals : g1_start & ~1U; | ||
| 107 | |||
| 108 | - if (seq < (g1_start >> 1)) | ||
| 109 | + if (seq < (g1_start >> 1)) | ||
| 110 | { | ||
| 111 | - /* group is closed already, so don't block */ | ||
| 112 | + /* group is closed already, so don't block */ | ||
| 113 | __condvar_dec_grefs (cond, g, private); | ||
| 114 | goto done; | ||
| 115 | } | ||
| 116 | |||
| 117 | if ((int)(signals - lowseq) >= 2) | ||
| 118 | { | ||
| 119 | - /* a signal showed up or G1/G2 switched after we grabbed the refcount */ | ||
| 120 | + /* a signal showed up or G1/G2 switched after we grabbed the | ||
| 121 | + refcount */ | ||
| 122 | __condvar_dec_grefs (cond, g, private); | ||
| 123 | break; | ||
| 124 | - } | ||
| 125 | + } | ||
| 126 | |||
| 127 | // Now block. | ||
| 128 | struct _pthread_cleanup_buffer buffer; | ||
| 129 | @@ -536,10 +537,8 @@ __pthread_cond_wait_common (pthread_cond_t *cond, pthread_mutex_t *mutex, | ||
| 130 | if (seq < (__condvar_load_g1_start_relaxed (cond) >> 1)) | ||
| 131 | goto done; | ||
| 132 | } | ||
| 133 | - /* Try to grab a signal. Use acquire MO so that we see an up-to-date value | ||
| 134 | - of __g1_start below (see spinning above for a similar case). In | ||
| 135 | - particular, if we steal from a more recent group, we will also see a | ||
| 136 | - more recent __g1_start below. */ | ||
| 137 | + /* Try to grab a signal. See above for MO. (if we do another loop | ||
| 138 | + iteration we need to see the correct value of g1_start) */ | ||
| 139 | while (!atomic_compare_exchange_weak_acquire (cond->__data.__g_signals + g, | ||
| 140 | &signals, signals - 2)); | ||
| 141 | |||
| 142 | -- | ||
| 143 | 2.49.0 | ||
| 144 | |||
diff --git a/meta/recipes-core/glibc/glibc_2.35.bb b/meta/recipes-core/glibc/glibc_2.35.bb index f15e031971..92c4dad023 100644 --- a/meta/recipes-core/glibc/glibc_2.35.bb +++ b/meta/recipes-core/glibc/glibc_2.35.bb | |||
| @@ -63,6 +63,7 @@ SRC_URI = "${GLIBC_GIT_URI};branch=${SRCBRANCH};name=glibc \ | |||
| 63 | file://0024-fix-create-thread-failed-in-unprivileged-process-BZ-.patch \ | 63 | file://0024-fix-create-thread-failed-in-unprivileged-process-BZ-.patch \ |
| 64 | file://0025-CVE-2025-4802.patch \ | 64 | file://0025-CVE-2025-4802.patch \ |
| 65 | file://0026-PR25847-1.patch \ | 65 | file://0026-PR25847-1.patch \ |
| 66 | file://0026-PR25847-2.patch \ | ||
| 66 | \ | 67 | \ |
| 67 | file://0001-Revert-Linux-Implement-a-useful-version-of-_startup_.patch \ | 68 | file://0001-Revert-Linux-Implement-a-useful-version-of-_startup_.patch \ |
| 68 | file://0002-get_nscd_addresses-Fix-subscript-typos-BZ-29605.patch \ | 69 | file://0002-get_nscd_addresses-Fix-subscript-typos-BZ-29605.patch \ |
