RFR: 8154750: Add missing OrderAccess operations to ClassLoaderData lock-free data structures
Kim Barrett
kim.barrett at oracle.com
Tue Jun 7 20:13:05 UTC 2016
> On Jun 2, 2016, at 9:12 PM, David Holmes <david.holmes at oracle.com> wrote:
>
> Hi Karen,
>
> On 3/06/2016 12:32 AM, Karen Kinnear wrote:
>> David,
>>
>> Thank you for fixing this and catching the error. My bad for suggesting we remove the StoreStore rather than
>> figuring out why someone had thought we needed it initially.
>>
>> Question for you - do we need _klasses, _packages and _modules to be declared as volatile?
>
> Good question. Normally I always make any variable accessed lock-free, volatile - "just to be on the safe side". I had overlooked it here but will fix it (seeing as how my push has failed to happen anyway).
>
> Does it make any difference in this case? I think not but would have to defer to the compiler experts. Normally we apply 'volatile' to C variables to make sure the compiler doesn't do anything to them that might disrupt their correct use in lock-free environments when they might change without the compiler knowing. In this code the lock-free access is a load_ptr_acquire which already has such constraints built in to it.
I don't think it makes any technical difference, and I do think the
volatile keyword for the member declarations give a useful hint to the
reader. Someday we might be changing these to be using atomic types,
and volatile may serve as a helpful search key for finding code to
update.
More information about the hotspot-runtime-dev
mailing list