diff options
| author | Sunil Dora <sunilkumar.dora@windriver.com> | 2025-10-14 07:43:45 -0700 |
|---|---|---|
| committer | Steve Sakoman <steve@sakoman.com> | 2025-10-17 07:27:24 -0700 |
| commit | b48d3ea982b5199cefb424782828d2e939b13a50 (patch) | |
| tree | 597e47c2a6a90e76150ba15b5a859b47fe391849 | |
| parent | 42b3adafcc6708d3f9340db7119f5c35c338c9cb (diff) | |
| download | poky-b48d3ea982b5199cefb424782828d2e939b13a50.tar.gz | |
glibc: nptl rename __condvar_quiesce_and_switch_g1
The following commits have been cherry-picked from Glibc master branch:
Bug : https://sourceware.org/bugzilla/show_bug.cgi?id=25847
[1] https://sourceware.org/git/?p=glibc.git;a=commit;h=4b79e27a5073c02f6bff9aa8f4791230a0ab1867
[2] https://sourceware.org/pipermail/libc-stable/2025-July/002281.html
(From OE-Core rev: 0a9ccd040037c12aa2e7fbc2213ca60b30dafcc4)
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-8.patch | 161 | ||||
| -rw-r--r-- | meta/recipes-core/glibc/glibc_2.35.bb | 1 |
2 files changed, 162 insertions, 0 deletions
diff --git a/meta/recipes-core/glibc/glibc/0026-PR25847-8.patch b/meta/recipes-core/glibc/glibc/0026-PR25847-8.patch new file mode 100644 index 0000000000..83d9ca01a9 --- /dev/null +++ b/meta/recipes-core/glibc/glibc/0026-PR25847-8.patch | |||
| @@ -0,0 +1,161 @@ | |||
| 1 | From 20d84dfa0b9a32f88259269bbeaae588744ae4ae Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Malte Skarupke <malteskarupke@fastmail.fm> | ||
| 3 | Date: Tue, 14 Oct 2025 06:33:50 -0700 | ||
| 4 | Subject: [PATCH] nptl: rename __condvar_quiesce_and_switch_g1 | ||
| 5 | |||
| 6 | This function no longer waits for threads to leave g1, so rename it to | ||
| 7 | __condvar_switch_g1 | ||
| 8 | |||
| 9 | The following commits have been cherry-picked from Glibc master branch: | ||
| 10 | Bug : https://sourceware.org/bugzilla/show_bug.cgi?id=25847 | ||
| 11 | commit: 4b79e27a5073c02f6bff9aa8f4791230a0ab1867 | ||
| 12 | |||
| 13 | Upstream-Status: Submitted | ||
| 14 | [https://sourceware.org/pipermail/libc-stable/2025-July/002281.html] | ||
| 15 | |||
| 16 | Signed-off-by: Sunil Dora <sunilkumar.dora@windriver.com> | ||
| 17 | --- | ||
| 18 | nptl/pthread_cond_broadcast.c | 4 ++-- | ||
| 19 | nptl/pthread_cond_common.c | 26 ++++++++++++-------------- | ||
| 20 | nptl/pthread_cond_signal.c | 17 ++++++++--------- | ||
| 21 | nptl/pthread_cond_wait.c | 9 ++++----- | ||
| 22 | 4 files changed, 26 insertions(+), 30 deletions(-) | ||
| 23 | |||
| 24 | diff --git a/nptl/pthread_cond_broadcast.c b/nptl/pthread_cond_broadcast.c | ||
| 25 | index 5ae141ac..a0743558 100644 | ||
| 26 | --- a/nptl/pthread_cond_broadcast.c | ||
| 27 | +++ b/nptl/pthread_cond_broadcast.c | ||
| 28 | @@ -60,7 +60,7 @@ ___pthread_cond_broadcast (pthread_cond_t *cond) | ||
| 29 | cond->__data.__g_size[g1] << 1); | ||
| 30 | cond->__data.__g_size[g1] = 0; | ||
| 31 | |||
| 32 | - /* We need to wake G1 waiters before we quiesce G1 below. */ | ||
| 33 | + /* We need to wake G1 waiters before we switch G1 below. */ | ||
| 34 | /* TODO Only set it if there are indeed futex waiters. We could | ||
| 35 | also try to move this out of the critical section in cases when | ||
| 36 | G2 is empty (and we don't need to quiesce). */ | ||
| 37 | @@ -69,7 +69,7 @@ ___pthread_cond_broadcast (pthread_cond_t *cond) | ||
| 38 | |||
| 39 | /* G1 is complete. Step (2) is next unless there are no waiters in G2, in | ||
| 40 | which case we can stop. */ | ||
| 41 | - if (__condvar_quiesce_and_switch_g1 (cond, wseq, &g1, private)) | ||
| 42 | + if (__condvar_switch_g1 (cond, wseq, &g1, private)) | ||
| 43 | { | ||
| 44 | /* Step (3): Send signals to all waiters in the old G2 / new G1. */ | ||
| 45 | atomic_fetch_add_relaxed (cond->__data.__g_signals + g1, | ||
| 46 | diff --git a/nptl/pthread_cond_common.c b/nptl/pthread_cond_common.c | ||
| 47 | index f976a533..3baac4da 100644 | ||
| 48 | --- a/nptl/pthread_cond_common.c | ||
| 49 | +++ b/nptl/pthread_cond_common.c | ||
| 50 | @@ -189,16 +189,15 @@ __condvar_get_private (int flags) | ||
| 51 | return FUTEX_SHARED; | ||
| 52 | } | ||
| 53 | |||
| 54 | -/* This closes G1 (whose index is in G1INDEX), waits for all futex waiters to | ||
| 55 | - leave G1, converts G1 into a fresh G2, and then switches group roles so that | ||
| 56 | - the former G2 becomes the new G1 ending at the current __wseq value when we | ||
| 57 | - eventually make the switch (WSEQ is just an observation of __wseq by the | ||
| 58 | - signaler). | ||
| 59 | +/* This closes G1 (whose index is in G1INDEX), converts G1 into a fresh G2, | ||
| 60 | + and then switches group roles so that the former G2 becomes the new G1 | ||
| 61 | + ending at the current __wseq value when we eventually make the switch | ||
| 62 | + (WSEQ is just an observation of __wseq by the signaler). | ||
| 63 | If G2 is empty, it will not switch groups because then it would create an | ||
| 64 | empty G1 which would require switching groups again on the next signal. | ||
| 65 | Returns false iff groups were not switched because G2 was empty. */ | ||
| 66 | static bool __attribute__ ((unused)) | ||
| 67 | -__condvar_quiesce_and_switch_g1 (pthread_cond_t *cond, uint64_t wseq, | ||
| 68 | +__condvar_switch_g1 (pthread_cond_t *cond, uint64_t wseq, | ||
| 69 | unsigned int *g1index, int private) | ||
| 70 | { | ||
| 71 | unsigned int g1 = *g1index; | ||
| 72 | @@ -214,8 +213,7 @@ __condvar_quiesce_and_switch_g1 (pthread_cond_t *cond, uint64_t wseq, | ||
| 73 | + cond->__data.__g_size[g1 ^ 1]) == 0) | ||
| 74 | return false; | ||
| 75 | |||
| 76 | - /* Now try to close and quiesce G1. We have to consider the following kinds | ||
| 77 | - of waiters: | ||
| 78 | + /* We have to consider the following kinds of waiters: | ||
| 79 | * Waiters from less recent groups than G1 are not affected because | ||
| 80 | nothing will change for them apart from __g1_start getting larger. | ||
| 81 | * New waiters arriving concurrently with the group switching will all go | ||
| 82 | @@ -223,12 +221,12 @@ __condvar_quiesce_and_switch_g1 (pthread_cond_t *cond, uint64_t wseq, | ||
| 83 | are not affected. | ||
| 84 | * Waiters in G1 have already received a signal and been woken. */ | ||
| 85 | |||
| 86 | - /* Update __g1_start, which finishes closing this group. The value we add | ||
| 87 | - will never be negative because old_orig_size can only be zero when we | ||
| 88 | - switch groups the first time after a condvar was initialized, in which | ||
| 89 | - case G1 will be at index 1 and we will add a value of 1. | ||
| 90 | - Relaxed MO is fine because the change comes with no additional | ||
| 91 | - constraints that others would have to observe. */ | ||
| 92 | + /* Update __g1_start, which closes this group. The value we add will never | ||
| 93 | + be negative because old_orig_size can only be zero when we switch groups | ||
| 94 | + the first time after a condvar was initialized, in which case G1 will be | ||
| 95 | + at index 1 and we will add a value of 1. Relaxed MO is fine because the | ||
| 96 | + change comes with no additional constraints that others would have to | ||
| 97 | + observe. */ | ||
| 98 | __condvar_add_g1_start_relaxed (cond, | ||
| 99 | (old_orig_size << 1) + (g1 == 1 ? 1 : - 1)); | ||
| 100 | |||
| 101 | diff --git a/nptl/pthread_cond_signal.c b/nptl/pthread_cond_signal.c | ||
| 102 | index 14800ba0..a9bc10dc 100644 | ||
| 103 | --- a/nptl/pthread_cond_signal.c | ||
| 104 | +++ b/nptl/pthread_cond_signal.c | ||
| 105 | @@ -69,18 +69,17 @@ ___pthread_cond_signal (pthread_cond_t *cond) | ||
| 106 | bool do_futex_wake = false; | ||
| 107 | |||
| 108 | /* If G1 is still receiving signals, we put the signal there. If not, we | ||
| 109 | - check if G2 has waiters, and if so, quiesce and switch G1 to the former | ||
| 110 | - G2; if this results in a new G1 with waiters (G2 might have cancellations | ||
| 111 | - already, see __condvar_quiesce_and_switch_g1), we put the signal in the | ||
| 112 | - new G1. */ | ||
| 113 | + check if G2 has waiters, and if so, switch G1 to the former G2; if this | ||
| 114 | + results in a new G1 with waiters (G2 might have cancellations already, | ||
| 115 | + see __condvar_switch_g1), we put the signal in the new G1. */ | ||
| 116 | if ((cond->__data.__g_size[g1] != 0) | ||
| 117 | - || __condvar_quiesce_and_switch_g1 (cond, wseq, &g1, private)) | ||
| 118 | + || __condvar_switch_g1 (cond, wseq, &g1, private)) | ||
| 119 | { | ||
| 120 | /* Add a signal. Relaxed MO is fine because signaling does not need to | ||
| 121 | - establish a happens-before relation (see above). We do not mask the | ||
| 122 | - release-MO store when initializing a group in | ||
| 123 | - __condvar_quiesce_and_switch_g1 because we use an atomic | ||
| 124 | - read-modify-write and thus extend that store's release sequence. */ | ||
| 125 | + establish a happens-before relation (see above). We do not mask the | ||
| 126 | + release-MO store when initializing a group in __condvar_switch_g1 | ||
| 127 | + because we use an atomic read-modify-write and thus extend that | ||
| 128 | + store's release sequence. */ | ||
| 129 | atomic_fetch_add_relaxed (cond->__data.__g_signals + g1, 2); | ||
| 130 | cond->__data.__g_size[g1]--; | ||
| 131 | /* TODO Only set it if there are indeed futex waiters. */ | ||
| 132 | diff --git a/nptl/pthread_cond_wait.c b/nptl/pthread_cond_wait.c | ||
| 133 | index adf26a80..40a74342 100644 | ||
| 134 | --- a/nptl/pthread_cond_wait.c | ||
| 135 | +++ b/nptl/pthread_cond_wait.c | ||
| 136 | @@ -354,8 +354,7 @@ __pthread_cond_wait_common (pthread_cond_t *cond, pthread_mutex_t *mutex, | ||
| 137 | because we do not need to establish any happens-before relation with | ||
| 138 | signalers (see __pthread_cond_signal); modification order alone | ||
| 139 | establishes a total order of waiters/signals. We do need acquire MO | ||
| 140 | - to synchronize with group reinitialization in | ||
| 141 | - __condvar_quiesce_and_switch_g1. */ | ||
| 142 | + to synchronize with group reinitialization in __condvar_switch_g1. */ | ||
| 143 | uint64_t wseq = __condvar_fetch_add_wseq_acquire (cond, 2); | ||
| 144 | /* Find our group's index. We always go into what was G2 when we acquired | ||
| 145 | our position. */ | ||
| 146 | @@ -387,9 +386,9 @@ __pthread_cond_wait_common (pthread_cond_t *cond, pthread_mutex_t *mutex, | ||
| 147 | { | ||
| 148 | /* Now wait until a signal is available in our group or it is closed. | ||
| 149 | Acquire MO so that if we observe (signals == lowseq) after group | ||
| 150 | - switching in __condvar_quiesce_and_switch_g1, we synchronize with that | ||
| 151 | - store and will see the prior update of __g1_start done while switching | ||
| 152 | - groups too. */ | ||
| 153 | + switching in __condvar_switch_g1, we synchronize with that store and | ||
| 154 | + will see the prior update of __g1_start done while switching groups | ||
| 155 | + too. */ | ||
| 156 | unsigned int signals = atomic_load_acquire (cond->__data.__g_signals + g); | ||
| 157 | uint64_t g1_start = __condvar_load_g1_start_relaxed (cond); | ||
| 158 | unsigned int lowseq = (g1_start & 1) == g ? signals : g1_start & ~1U; | ||
| 159 | -- | ||
| 160 | 2.49.0 | ||
| 161 | |||
diff --git a/meta/recipes-core/glibc/glibc_2.35.bb b/meta/recipes-core/glibc/glibc_2.35.bb index 7ef2c8cb4c..265dcb9129 100644 --- a/meta/recipes-core/glibc/glibc_2.35.bb +++ b/meta/recipes-core/glibc/glibc_2.35.bb | |||
| @@ -69,6 +69,7 @@ SRC_URI = "${GLIBC_GIT_URI};branch=${SRCBRANCH};name=glibc \ | |||
| 69 | file://0026-PR25847-5.patch \ | 69 | file://0026-PR25847-5.patch \ |
| 70 | file://0026-PR25847-6.patch \ | 70 | file://0026-PR25847-6.patch \ |
| 71 | file://0026-PR25847-7.patch \ | 71 | file://0026-PR25847-7.patch \ |
| 72 | file://0026-PR25847-8.patch \ | ||
| 72 | \ | 73 | \ |
| 73 | file://0001-Revert-Linux-Implement-a-useful-version-of-_startup_.patch \ | 74 | file://0001-Revert-Linux-Implement-a-useful-version-of-_startup_.patch \ |
| 74 | file://0002-get_nscd_addresses-Fix-subscript-typos-BZ-29605.patch \ | 75 | file://0002-get_nscd_addresses-Fix-subscript-typos-BZ-29605.patch \ |
