[jdk17] RFR: 8269865: Async UL needs to handle ERANGE on exceeding SEM_VALUE_MAX [v7]

Patricio Chilano Mateo pchilanomate at openjdk.java.net
Wed Jul 14 01:21:17 UTC 2021


On Tue, 13 Jul 2021 19:08:47 GMT, Xin Liu <xliu at openjdk.org> wrote:

>> This patch solved the sempahore overflow issue with errno ERANGE or EOVERFLOW.
>> Previously, we have asymmetric p/v operations for semaphore _sem. Each iteration
>> only decrements _sem 1 but dequeues N messages. If logging threads keep preempting
>> async logging thread, it may cause the value of _sem accumulates until overflow! 
>> 
>> We decide to ditch counting semaphore.  os::PlatformMonitor can be used as low-level 
>> combination of Mutex/CondVar.  It may work if we simply ignore Semaphore::signal failure 
>> due to value overflow, but we have to pollute Semaphore interface.  Also it seems that MacOS
>> semaphore which is non-posix doesn't fail in this case.
>
> Xin Liu has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Replace counting semaphore with os::PlatformMontor.
>   
>   Second attempt. This patch also removed semaphore-based lock because
>   PlatformMonitor can also be used as a Mutex lock.

Hi Xin,

Looks good to me too.
The only small suggestion is that you could do the pop_all() and _stats.iterate when coming out of wait() since you are already holding the monitor, and then pass the logs to write(). Either way is fine though.

Thanks,
Patricio

-------------

Marked as reviewed by pchilanomate (Committer).

PR: https://git.openjdk.java.net/jdk17/pull/216


More information about the hotspot-runtime-dev mailing list