public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2] nptl: pthread_rwlock_rdlock return in low priority
@ 2023-03-07 11:38 abush wang
  2023-03-07 11:49 ` Xi Ruoyao
  0 siblings, 1 reply; 3+ messages in thread
From: abush wang @ 2023-03-07 11:38 UTC (permalink / raw)
  To: drepper.fsp, abushwang via Libc-alpha

[-- Attachment #1: Type: text/plain, Size: 2270 bytes --]

(*This is just a mail for advisory*)

hi, I have noticed reader will return directly on fast-path in
pthread_rwlock_common.c

>*  /* We have registered as a reader, so if we are in a read phase, we have
*>*     acquired a read lock.  This is also the reader--reader fast-path.
*>*     Even if there is a primary writer, we just return.  If writers are to
*>*     be preferred and we are the only active reader, we could try to enter a
*>*     write phase to let the writer proceed.  This would be okay because we
*>*     cannot have acquired the lock previously as a reader (which could result
*>*     in deadlock if we would wait for the primary writer to run).  However,
*>*     this seems to be a corner case and handling it specially not
be worth the
*>*     complexity.  */
*>*  if (__glibc_likely ((r & PTHREAD_RWLOCK_WRPHASE) == 0))
*>*    return 0;
*
However, there is a situation:
    main, thread_wr, thread_rd.

    SCHED_FIFO priority:
        main > thread_wr > thread_rd
    main first acquires read lock, then create thread_wr which will
block on the lock.
    Next, main creates thread_rd. this thread will acquires read lock
on fast-path even
    though it has a lower priority compared to thread_wr.

You can get demo from the following
repository:https://github.com/emscripten-core/posixtestsuite.git
./conformance/interfaces/pthread_rwlock_rdlock/2-1.c

According to "man -M man-pages-posix-2017/ 3p pthread_rwlock_rdlock"

>* DESCRIPTION
*>* The pthread_rwlock_rdlock() function shall apply a read lock to the
*>* read-write lock referenced by rwlock.  The calling thread acquires the
*>* read lock  if  a writer does not hold the lock and there are no
*>* writers blocked on the lock.
*>>* If  the  Thread  Execution  Scheduling  option  is supported,  and the
*>* threads involved in the lock are executing with the scheduling
*>* policies SCHED_FIFO or SCHED_RR, the calling thread shall not acquire
*>* the lock if a writer holds the lock or if writers of higher or equal
*>* priority are blocked on the lock;  other‐ wise, the calling thread
*>* shall acquire the lock.
*
I was wondering that whether this fast-path is reasonable, and whether
this posix standard should be enforced.

Thanks

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] nptl: pthread_rwlock_rdlock return in low priority
  2023-03-07 11:38 [PATCH v2] nptl: pthread_rwlock_rdlock return in low priority abush wang
@ 2023-03-07 11:49 ` Xi Ruoyao
  2023-03-07 12:08   ` abush wang
  0 siblings, 1 reply; 3+ messages in thread
From: Xi Ruoyao @ 2023-03-07 11:49 UTC (permalink / raw)
  To: abush wang, drepper.fsp, abushwang via Libc-alpha

On Tue, 2023-03-07 at 19:38 +0800, abush wang via Libc-alpha wrote:
> (*This is just a mail for advisory*)

Do not overuse git send-email anymore.  By adding [PATCH] in the title
your message appears as a junk in the patchwork interface.

If you can't use another CLI tool, stop preventing you are clever and go
to use a normal mail client.  This is just annoying.

-- 
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] nptl: pthread_rwlock_rdlock return in low priority
  2023-03-07 11:49 ` Xi Ruoyao
@ 2023-03-07 12:08   ` abush wang
  0 siblings, 0 replies; 3+ messages in thread
From: abush wang @ 2023-03-07 12:08 UTC (permalink / raw)
  To: Xi Ruoyao; +Cc: drepper.fsp, abushwang via Libc-alpha

[-- Attachment #1: Type: text/plain, Size: 640 bytes --]

this message is from gmail.
Please pay attention on this issue,

Xi Ruoyao <xry111@xry111.site> 于2023年3月7日周二 19:49写道:

> On Tue, 2023-03-07 at 19:38 +0800, abush wang via Libc-alpha wrote:
> > (*This is just a mail for advisory*)
>
> Do not overuse git send-email anymore.  By adding [PATCH] in the title
> your message appears as a junk in the patchwork interface.
>
> If you can't use another CLI tool, stop preventing you are clever and go
> to use a normal mail client.  This is just annoying.
>
> --
> Xi Ruoyao <xry111@xry111.site>
> School of Aerospace Science and Technology, Xidian University
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-03-07 12:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-07 11:38 [PATCH v2] nptl: pthread_rwlock_rdlock return in low priority abush wang
2023-03-07 11:49 ` Xi Ruoyao
2023-03-07 12:08   ` abush wang

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).