< prev index next >

src/hotspot/share/gc/g1/g1PageBasedVirtualSpace.cpp

Print this page




 244   char* const _start_addr;
 245   char* const _end_addr;
 246   size_t _page_size;
 247 public:
 248   G1PretouchTask(char* start_address, char* end_address, size_t page_size) :
 249     AbstractGangTask("G1 PreTouch"),
 250     _cur_addr(start_address),
 251     _start_addr(start_address),
 252     _end_addr(end_address),
 253     _page_size(0) {
 254 #ifdef LINUX
 255     _page_size = UseTransparentHugePages ? (size_t)os::vm_page_size(): page_size;
 256 #else
 257     _page_size = page_size;
 258 #endif
 259   }
 260 
 261   virtual void work(uint worker_id) {
 262     size_t const actual_chunk_size = MAX2(chunk_size(), _page_size);
 263     while (true) {
 264       char* touch_addr = Atomic::add(actual_chunk_size, &_cur_addr) - actual_chunk_size;
 265       if (touch_addr < _start_addr || touch_addr >= _end_addr) {
 266         break;
 267       }
 268       char* end_addr = touch_addr + MIN2(actual_chunk_size, pointer_delta(_end_addr, touch_addr, sizeof(char)));
 269       os::pretouch_memory(touch_addr, end_addr, _page_size);
 270     }
 271   }
 272 
 273   static size_t chunk_size() { return PreTouchParallelChunkSize; }
 274 };
 275 
 276 void G1PageBasedVirtualSpace::pretouch(size_t start_page, size_t size_in_pages, WorkGang* pretouch_gang) {
 277   G1PretouchTask cl(page_start(start_page), bounded_end_addr(start_page + size_in_pages), _page_size);
 278 
 279   if (pretouch_gang != NULL) {
 280     size_t num_chunks = MAX2((size_t)1, size_in_pages * _page_size / MAX2(G1PretouchTask::chunk_size(), _page_size));
 281 
 282     uint num_workers = MIN2((uint)num_chunks, pretouch_gang->total_workers());
 283     log_debug(gc, heap)("Running %s with %u workers for " SIZE_FORMAT " work units pre-touching " SIZE_FORMAT "B.",
 284                         cl.name(), num_workers, num_chunks, size_in_pages * _page_size);




 244   char* const _start_addr;
 245   char* const _end_addr;
 246   size_t _page_size;
 247 public:
 248   G1PretouchTask(char* start_address, char* end_address, size_t page_size) :
 249     AbstractGangTask("G1 PreTouch"),
 250     _cur_addr(start_address),
 251     _start_addr(start_address),
 252     _end_addr(end_address),
 253     _page_size(0) {
 254 #ifdef LINUX
 255     _page_size = UseTransparentHugePages ? (size_t)os::vm_page_size(): page_size;
 256 #else
 257     _page_size = page_size;
 258 #endif
 259   }
 260 
 261   virtual void work(uint worker_id) {
 262     size_t const actual_chunk_size = MAX2(chunk_size(), _page_size);
 263     while (true) {
 264       char* touch_addr = Atomic::add(&_cur_addr, actual_chunk_size) - actual_chunk_size;
 265       if (touch_addr < _start_addr || touch_addr >= _end_addr) {
 266         break;
 267       }
 268       char* end_addr = touch_addr + MIN2(actual_chunk_size, pointer_delta(_end_addr, touch_addr, sizeof(char)));
 269       os::pretouch_memory(touch_addr, end_addr, _page_size);
 270     }
 271   }
 272 
 273   static size_t chunk_size() { return PreTouchParallelChunkSize; }
 274 };
 275 
 276 void G1PageBasedVirtualSpace::pretouch(size_t start_page, size_t size_in_pages, WorkGang* pretouch_gang) {
 277   G1PretouchTask cl(page_start(start_page), bounded_end_addr(start_page + size_in_pages), _page_size);
 278 
 279   if (pretouch_gang != NULL) {
 280     size_t num_chunks = MAX2((size_t)1, size_in_pages * _page_size / MAX2(G1PretouchTask::chunk_size(), _page_size));
 281 
 282     uint num_workers = MIN2((uint)num_chunks, pretouch_gang->total_workers());
 283     log_debug(gc, heap)("Running %s with %u workers for " SIZE_FORMAT " work units pre-touching " SIZE_FORMAT "B.",
 284                         cl.name(), num_workers, num_chunks, size_in_pages * _page_size);


< prev index next >