* Question: Is "maxspin=0" in pthread_cond_wait.c dead code or bug?
@ 2022-11-14 3:32 Xiaoming Ni
2022-11-17 17:40 ` Adhemerval Zanella Netto
0 siblings, 1 reply; 2+ messages in thread
From: Xiaoming Ni @ 2022-11-14 3:32 UTC (permalink / raw)
To: triegel, carlos, davem, dvhart, libc-alpha, 1464268895.17104.14.camel
nptl/pthread_cond_common.c:204: const unsigned int maxspin = 0;
nptl/pthread_cond_common.c:259: for (unsigned int spin = maxspin;
((r >> 1) > 0) && (spin > 0); spin--)
"(spin > 0)" is a conditional judgment that is always false.
nptl/pthread_cond_wait.c:382: const int maxspin = 0;
nptl/pthread_cond_wait.c:448: unsigned int spin = maxspin;
nptl/pthread_cond_wait.c:449: while (signals == 0 && spin > 0)
nptl/pthread_cond_wait.c:460: spin--;
"(spin > 0)" is a conditional judgment that is always false.
It's been six years since 2016,
commit ed19993b5b ("New condvar implementation that provides stronger
ordering guarantees.")
https://public-inbox.org/libc-alpha/1464268895.17104.14.camel@localhost.localdomain
Is this a logic bug caused by a mistake, or is it just useless
deleteable code?
Thanks
Xiaoming Ni
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Question: Is "maxspin=0" in pthread_cond_wait.c dead code or bug?
2022-11-14 3:32 Question: Is "maxspin=0" in pthread_cond_wait.c dead code or bug? Xiaoming Ni
@ 2022-11-17 17:40 ` Adhemerval Zanella Netto
0 siblings, 0 replies; 2+ messages in thread
From: Adhemerval Zanella Netto @ 2022-11-17 17:40 UTC (permalink / raw)
To: Xiaoming Ni, triegel, carlos, davem, dvhart, libc-alpha,
1464268895.17104.14.camel
On 14/11/22 00:32, Xiaoming Ni via Libc-alpha wrote:
> nptl/pthread_cond_common.c:204: const unsigned int maxspin = 0;
> nptl/pthread_cond_common.c:259: for (unsigned int spin = maxspin; ((r >> 1) > 0) && (spin > 0); spin--)
>
> "(spin > 0)" is a conditional judgment that is always false.
>
> nptl/pthread_cond_wait.c:382: const int maxspin = 0;
> nptl/pthread_cond_wait.c:448: unsigned int spin = maxspin;
> nptl/pthread_cond_wait.c:449: while (signals == 0 && spin > 0)
> nptl/pthread_cond_wait.c:460: spin--;
>
> "(spin > 0)" is a conditional judgment that is always false.
>
> It's been six years since 2016,
> commit ed19993b5b ("New condvar implementation that provides stronger ordering guarantees.")
> https://public-inbox.org/libc-alpha/1464268895.17104.14.camel@localhost.localdomain
>
> Is this a logic bug caused by a mistake, or is it just useless deleteable code?
>
> Thanks
> Xiaoming Ni
It seems a TODO feature (backlog spinning, similar to adaptive mutexes), not
implemented, since Torvald did add a TODO comment for it. Maybe replace it
a comment just keep the placeholder for a possible future optimization,
although I think compiler will most likely optimize this loop away.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-11-17 17:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-14 3:32 Question: Is "maxspin=0" in pthread_cond_wait.c dead code or bug? Xiaoming Ni
2022-11-17 17:40 ` Adhemerval Zanella Netto
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).