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

David Holmes dholmes at openjdk.java.net
Tue Jul 13 23:51:16 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! 
>> 
>> The patch corrects the value of _sem after write(). n messages are dequeued/processed.
>> We need to invoke _sem.wait() max(n-1, 1) time. This ensures that each iteration
>> decrements n instead of 1.
>
> 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,

This looks good. I'll run it through our testing.

I'll also try to get @pchilano to review it.

Thanks,
David

src/hotspot/share/logging/logAsyncWriter.hpp line 139:

> 137:   static AsyncLogWriter* _instance;
> 138:   Semaphore _flush_sem;
> 139:   os::PlatformMonitor _lock;

Please add a comment before this:

// Can't use a Monitor here as we need a low-level API that can be used
// late in a thread's termination process.

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

Marked as reviewed by dholmes (Reviewer).

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


More information about the hotspot-runtime-dev mailing list