United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: 6895788 G1: SATB and Update buffer allocation code allocates too much space
6895788 : G1: SATB and Update buffer allocation code allocates too much space

Details
Type:
Bug
Submit Date:
2009-10-27
Status:
Resolved
Updated Date:
2010-05-10
Project Name:
JDK
Resolved Date:
2010-01-14
Component:
hotspot
OS:
generic,solaris_10
Sub-Component:
gc
CPU:
x86,sparc,generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
hs16,hs17
Fixed Versions:
hs17

Related Reports
Backport:
Backport:
Backport:
Backport:
Duplicate:

Sub Tasks

Description
While investigating 6889740 it was discovered that the code that allocates the buffers that are used for the SATB and Update processing allocates too much space.

For the SATB buffers we set the size of the SATB Queue set (the _sz field) to be G1SATBLogBufferSize * oopSize during VM initialization. With the default value of G1SATBLogBufferSize (1K) this gives _sz = 8*1K or 4*1K (for 32 bit). The actual buffers are allocated using NEW_C_HEAP_ARRAY and given void* as the type. This means that size requested of the allocation routine is 8K*8 = 64K (or 4K*4 = 16K for 32 bit).

This seenms to be incorrect. The buffers are indexed using a helper routine byte_index_to_index which takes an index (usually the value of the _index field) and divides it by oopSize to give an index into the buffer array. The _index field is initialized to the value of _sz (8*1K). Suppose we have _index == 8184 (_sz - oopSize), the value of byte_index_to_index for 8184 gives 1023. So we assign into _buf[1023].

So we assign values into _buf[0..(_sz/oopSize)-1] but we have allocated a buffer with enough space to hold 8K entries (64K bytes). 

The fix is relatively simple: the code in allocate_buffer and deallocate_buffer should be changed to use:

   (void**)NEW_C_HEAP_ARRAY(char, _sz);

This will give 8K byte buffers - which looks like what was intended from the generated barrier code and the indexing code in the flush routine.

                                    

Comments
EVALUATION

http://hg.openjdk.java.net/hsx/hsx16/master/rev/9f7d1f6201ab
                                     
2009-11-13
EVALUATION

http://hg.openjdk.java.net/hsx/hsx16/baseline/rev/9f7d1f6201ab
                                     
2009-11-12
EVALUATION

http://hg.openjdk.java.net/jdk7/hotspot-gc/hotspot/rev/5f932a151fd4
                                     
2009-11-06
EVALUATION

PrintMallocFree flag confirms that we seem to be allocating more space for the SATB and update buffers than what we actually index.
                                     
2009-11-03
SUGGESTED FIX

The fix is relatively simple: the code in allocate_buffer and deallocate_buffer should be changed to use:

   (void**)NEW_C_HEAP_ARRAY(char, _sz);

This will give 8K byte buffers - which looks like what was intended from the generated barrier code and the indexing code in the flush routine.
                                     
2009-11-03



Hardware and Software, Engineered to Work Together