Skip to content

Commit

Permalink
Updated the code as per the review.
Browse files Browse the repository at this point in the history
  • Loading branch information
amitdpawar committed Oct 13, 2020
1 parent d81c3b9 commit e6c072c
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 29 deletions.
1 change: 0 additions & 1 deletion src/hotspot/share/gc/parallel/mutableSpace.cpp
Expand Up @@ -112,7 +112,6 @@ void MutableSpace::initialize(MemRegion mr,
}

if (AlwaysPreTouch) {

size_t page_size = UseLargePages ? os::large_page_size() : os::vm_page_size();

PretouchTask::pretouch("ParallelGC PreTouch head", (char*)head.start(), (char*)head.end(),
Expand Down
9 changes: 3 additions & 6 deletions src/hotspot/share/gc/parallel/psYoungGen.cpp
Expand Up @@ -638,8 +638,8 @@ void PSYoungGen::resize_spaces(size_t requested_eden_size,
to_space()->check_mangled_unused_area(limit);
}

WorkGang* workers = Thread::current()->is_VM_thread() ?
&ParallelScavengeHeap::heap()->workers() : NULL;
WorkGang* workers = &ParallelScavengeHeap::heap()->workers();

// When an existing space is being initialized, it is not
// mangled because the space has been previously mangled.
eden_space()->initialize(edenMR,
Expand Down Expand Up @@ -794,14 +794,11 @@ void PSYoungGen::reset_survivors_after_shrink() {
if (new_end < space_shrinking->end()) {
MemRegion mr(space_shrinking->bottom(), new_end);

WorkGang* workers = Thread::current()->is_VM_thread() ?
&ParallelScavengeHeap::heap()->workers() : NULL;

space_shrinking->initialize(mr,
SpaceDecorator::DontClear,
SpaceDecorator::Mangle,
MutableSpace::SetupPages,
workers);
&ParallelScavengeHeap::heap()->workers());
}
}

Expand Down
23 changes: 20 additions & 3 deletions src/hotspot/share/gc/shared/preTouchTask.cpp
Expand Up @@ -22,11 +22,30 @@
*
*/

#include "precompiled.hpp"
#include "gc/shared/preTouchTask.hpp"
#include "runtime/atomic.hpp"
#include "runtime/globals.hpp"
#include "runtime/os.hpp"

void PretouchTask::work(uint worker_id) {
PretouchTask::PretouchTask(const char* task_name, char* start_address, char* end_address, size_t page_size) :
AbstractGangTask(task_name),
_cur_addr(start_address),
_start_addr(start_address),
_end_addr(end_address),
_page_size(0) {
#ifdef LINUX
_page_size = UseTransparentHugePages ? (size_t)os::vm_page_size(): page_size;
#else
_page_size = page_size;
#endif
}

size_t PretouchTask::chunk_size() {
return PreTouchParallelChunkSize;
}

void PretouchTask::work(uint worker_id) {
size_t const actual_chunk_size = MAX2(chunk_size(), _page_size);

while (true) {
Expand All @@ -41,10 +60,8 @@ void PretouchTask::work(uint worker_id) {
}
}


void PretouchTask::pretouch(const char* task_name, char* start_address, char* end_address,
size_t page_size, WorkGang* pretouch_gang) {

PretouchTask task(task_name, start_address, end_address, page_size);
size_t total_bytes = (end_address - start_address);

Expand Down
23 changes: 4 additions & 19 deletions src/hotspot/share/gc/shared/preTouchTask.hpp
Expand Up @@ -26,37 +26,22 @@
#define SHARE_GC_SHARED_PRETOUCH_HPP

#include "gc/shared/workgroup.hpp"
#include "runtime/globals.hpp"
#include "runtime/os.hpp"

class PretouchTask : public AbstractGangTask {

private:
char* volatile _cur_addr;
char* const _start_addr;
char* const _end_addr;
size_t _page_size;

public:
PretouchTask(const char* task_name, char* start_address, char* end_address, size_t page_size) :
AbstractGangTask(task_name),
_cur_addr(start_address),
_start_addr(start_address),
_end_addr(end_address),
_page_size(0) {
#ifdef LINUX
_page_size = UseTransparentHugePages ? (size_t)os::vm_page_size(): page_size;
#else
_page_size = page_size;
#endif
}
PretouchTask(const char* task_name, char* start_address, char* end_address, size_t page_size);

virtual void work(uint worker_id);

static size_t chunk_size() { return PreTouchParallelChunkSize; }
static size_t chunk_size();

static void pretouch(const char* task_name, char* start_address, char* end_address, size_t page_size,
WorkGang* pretouch_gang);
static void pretouch(const char* task_name, char* start_address, char* end_address,
size_t page_size, WorkGang* pretouch_gang);

};

Expand Down

0 comments on commit e6c072c

Please sign in to comment.