This commit is contained in:
Jesper Wilhelmsson 2014-10-30 01:01:37 +01:00
commit 1486e4bf7d
3 changed files with 60 additions and 80 deletions
hotspot
src/share/vm/gc_implementation/g1
test/gc/arguments

@ -127,41 +127,6 @@ public:
};
class ClearLoggedCardTableEntryClosure: public CardTableEntryClosure {
size_t _num_processed;
CardTableModRefBS* _ctbs;
int _histo[256];
public:
ClearLoggedCardTableEntryClosure() :
_num_processed(0), _ctbs(G1CollectedHeap::heap()->g1_barrier_set())
{
for (int i = 0; i < 256; i++) _histo[i] = 0;
}
bool do_card_ptr(jbyte* card_ptr, uint worker_i) {
unsigned char* ujb = (unsigned char*)card_ptr;
int ind = (int)(*ujb);
_histo[ind]++;
*card_ptr = (jbyte)CardTableModRefBS::clean_card_val();
_num_processed++;
return true;
}
size_t num_processed() { return _num_processed; }
void print_histo() {
gclog_or_tty->print_cr("Card table value histogram:");
for (int i = 0; i < 256; i++) {
if (_histo[i] != 0) {
gclog_or_tty->print_cr(" %d: %d", i, _histo[i]);
}
}
}
};
class RedirtyLoggedCardTableEntryClosure : public CardTableEntryClosure {
private:
size_t _num_processed;
@ -475,48 +440,6 @@ bool G1CollectedHeap::is_scavengable(const void* p) {
return !hr->is_humongous();
}
void G1CollectedHeap::check_ct_logs_at_safepoint() {
DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set();
CardTableModRefBS* ct_bs = g1_barrier_set();
// Count the dirty cards at the start.
CountNonCleanMemRegionClosure count1(this);
ct_bs->mod_card_iterate(&count1);
int orig_count = count1.n();
// First clear the logged cards.
ClearLoggedCardTableEntryClosure clear;
dcqs.apply_closure_to_all_completed_buffers(&clear);
dcqs.iterate_closure_all_threads(&clear, false);
clear.print_histo();
// Now ensure that there's no dirty cards.
CountNonCleanMemRegionClosure count2(this);
ct_bs->mod_card_iterate(&count2);
if (count2.n() != 0) {
gclog_or_tty->print_cr("Card table has %d entries; %d originally",
count2.n(), orig_count);
}
guarantee(count2.n() == 0, "Card table should be clean.");
RedirtyLoggedCardTableEntryClosure redirty;
dcqs.apply_closure_to_all_completed_buffers(&redirty);
dcqs.iterate_closure_all_threads(&redirty, false);
gclog_or_tty->print_cr("Log entries = %d, dirty cards = %d.",
clear.num_processed(), orig_count);
guarantee(redirty.num_processed() == clear.num_processed(),
err_msg("Redirtied "SIZE_FORMAT" cards, bug cleared "SIZE_FORMAT,
redirty.num_processed(), clear.num_processed()));
CountNonCleanMemRegionClosure count3(this);
ct_bs->mod_card_iterate(&count3);
if (count3.n() != orig_count) {
gclog_or_tty->print_cr("Should have restored them all: orig = %d, final = %d.",
orig_count, count3.n());
guarantee(count3.n() >= orig_count, "Should have restored them all.");
}
}
// Private class members.
G1CollectedHeap* G1CollectedHeap::_g1h;

@ -797,9 +797,6 @@ protected:
// The closure used to refine a single card.
RefineCardTableEntryClosure* _refine_cte_cl;
// A function to check the consistency of dirty card logs.
void check_ct_logs_at_safepoint();
// A DirtyCardQueueSet that is used to hold cards that contain
// references into the current collection set. This is used to
// update the remembered sets of the regions in the collection

@ -0,0 +1,60 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* @test TestUseNUMAInterleaving
* @summary Tests that UseNUMAInterleaving enabled for all collectors by
* ergonomics, on all platforms when UseNUMA feature is enabled.
* @bug 8059614
* @key gc
* @library /testlibrary
* @run driver TestUseNUMAInterleaving
*/
import com.oracle.java.testlibrary.ProcessTools;
import com.oracle.java.testlibrary.OutputAnalyzer;
public class TestUseNUMAInterleaving {
public static void main(String[] args) throws Exception {
String[] vmargs = new String[]{
"-XX:+UseNUMA",
"-XX:+PrintFlagsFinal",
"-version"
};
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, vmargs);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
boolean isNUMAEnabled
= Boolean.parseBoolean(output.firstMatch(NUMA_FLAG_PATTERN, 1));
if (isNUMAEnabled) {
output.shouldMatch("\\bUseNUMAInterleaving\\b.*?=.*?true");
System.out.println(output.getStdout());
} else {
System.out.println(output.firstMatch(NUMA_FLAG_PATTERN));
System.out.println(output.firstMatch(NUMA_FLAG_PATTERN, 1));
}
}
private static final String NUMA_FLAG_PATTERN = "\\bUseNUMA\\b.*?=.*?([a-z]+)";
}