summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhboehm <hboehm>2009-06-20 20:24:43 +0000
committerIvan Maidanski <ivmai@mail.ru>2011-07-26 21:06:45 +0400
commit68ed7473eb69ad894551afe2a78f0cc99af6f82e (patch)
tree52c5bb5d398d21fbac6f9834c1115e730b94747e
parentf4db11bf68b5fa1736f02f6e9b2b1e067fc386f7 (diff)
downloadbdwgc-68ed7473eb69ad894551afe2a78f0cc99af6f82e.tar.gz
2009-06-20 Hans Boehm <Hans.Boehm@hp.com>
* allchblk.c (GC_allochblk_nth): Add assertion. * checksums.c: Add GC_record_fault, GC_was_faulted, CC_n_faulted_dirty_errors. (GC_check_dirty): Remove register declarations, print dirty bit errors on faulted pages. * os_dep.c (GC_write_fault_handler): Call GC_record_fault(). * os_dep.c (GC_remove_protection): Compute index correctly.
-rw-r--r--ChangeLog10
-rw-r--r--allchblk.c3
-rw-r--r--checksums.c47
-rw-r--r--os_dep.c10
4 files changed, 63 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 248bba41..f3eaef21 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2009-06-20 Hans Boehm <Hans.Boehm@hp.com>
+
+ * allchblk.c (GC_allochblk_nth): Add assertion.
+ * checksums.c: Add GC_record_fault, GC_was_faulted,
+ CC_n_faulted_dirty_errors.
+ (GC_check_dirty): Remove register declarations, print
+ dirty bit errors on faulted pages.
+ * os_dep.c (GC_write_fault_handler): Call GC_record_fault().
+ * os_dep.c (GC_remove_protection): Compute index correctly.
+
2009-06-12 Hans Boehm <Hans.Boehm@hp.com>
* include/gc_version.h, configure.ac, doc/README:
diff --git a/allchblk.c b/allchblk.c
index 946f9711..b723a7f6 100644
--- a/allchblk.c
+++ b/allchblk.c
@@ -787,6 +787,9 @@ GC_allochblk_nth(size_t sz, int kind, unsigned flags, int n, GC_bool may_split)
/* Notify virtual dirty bit implementation that we are about to write. */
/* Ensure that pointerfree objects are not protected if it's avoidable. */
+ /* This also ensures that newly allocated blocks are treated as dirty. */
+ /* Necessary since we don't protect free blocks. */
+ GC_ASSERT((size_needed & (HBLKSIZE-1)) == 0);
GC_remove_protection(hbp, divHBLKSZ(size_needed),
(hhdr -> hb_descr == 0) /* pointer-free */);
diff --git a/checksums.c b/checksums.c
index 91f3b282..275026d5 100644
--- a/checksums.c
+++ b/checksums.c
@@ -34,6 +34,33 @@ typedef struct {
page_entry GC_sums [NSUMS];
+STATIC word GC_faulted[NSUMS]; /* Record of pages on which we saw a write */
+ /* fault. */
+STATIC size_t GC_n_faulted = 0;
+
+void GC_record_fault(struct hblk * h)
+{
+ word page = (word)h;
+
+ page += GC_page_size - 1;
+ page &= ~(GC_page_size - 1);
+ if (GC_n_faulted >= NSUMS) ABORT("write fault log overflowed");
+ GC_faulted[GC_n_faulted++] = page;
+}
+
+STATIC GC_bool GC_was_faulted(struct hblk *h)
+{
+ size_t i;
+ word page = (word)h;
+
+ page += GC_page_size - 1;
+ page &= ~(GC_page_size - 1);
+ for (i = 0; i < GC_n_faulted; ++i) {
+ if (GC_faulted[i] == page) return TRUE;
+ }
+ return FALSE;
+}
+
STATIC word GC_checksum(struct hblk *h)
{
register word *p = (word *)h;
@@ -64,6 +91,7 @@ STATIC GC_bool GC_on_free_list(struct hblk *h)
# endif
int GC_n_dirty_errors;
+int GC_n_faulted_dirty_errors;
int GC_n_changed_errors;
int GC_n_clean;
int GC_n_dirty;
@@ -96,7 +124,9 @@ STATIC void GC_update_check_page(struct hblk *h, int index)
&& hhdr != 0 && hhdr -> hb_descr != 0 /* may contain pointers */
&& pe -> old_sum != pe -> new_sum) {
if (!GC_page_was_dirty(h) || !GC_page_was_ever_dirty(h)) {
+ GC_bool was_faulted = GC_was_faulted(h);
/* Set breakpoint here */GC_n_dirty_errors++;
+ if (was_faulted) GC_n_faulted_dirty_errors++;
}
# ifdef STUBBORN_ALLOC
if (!HBLK_IS_FREE(hhdr)
@@ -144,14 +174,15 @@ STATIC void GC_check_blocks(void)
/* Should be called immediately after GC_read_dirty and GC_read_changed. */
void GC_check_dirty(void)
{
- register int index;
- register unsigned i;
- register struct hblk *h;
- register ptr_t start;
+ int index;
+ unsigned i;
+ struct hblk *h;
+ ptr_t start;
GC_check_blocks();
GC_n_dirty_errors = 0;
+ GC_n_faulted_dirty_errors = 0;
GC_n_changed_errors = 0;
GC_n_clean = 0;
GC_n_dirty = 0;
@@ -171,8 +202,8 @@ out:
GC_printf("Checked %lu clean and %lu dirty pages\n",
(unsigned long) GC_n_clean, (unsigned long) GC_n_dirty);
if (GC_n_dirty_errors > 0) {
- GC_printf("Found %lu dirty bit errors\n",
- (unsigned long)GC_n_dirty_errors);
+ GC_printf("Found %d dirty bit errors (%d were faulted)\n",
+ GC_n_dirty_errors, GC_n_faulted_dirty_errors);
}
if (GC_n_changed_errors > 0) {
GC_printf("Found %lu changed bit errors\n",
@@ -183,6 +214,10 @@ out:
"Also expect 1 per thread currently allocating a stubborn obj.\n");
# endif
}
+ for (i = 0; i < GC_n_faulted; ++i) {
+ GC_faulted[i] = 0; /* Don't expose block pointers to GC */
+ }
+ GC_n_faulted = 0;
}
# else
diff --git a/os_dep.c b/os_dep.c
index e3b98b36..bc41216b 100644
--- a/os_dep.c
+++ b/os_dep.c
@@ -2639,6 +2639,11 @@ STATIC GC_bool GC_old_segv_handler_used_si;
set_pht_entry_from_index(db, index)
#endif /* !THREADS */
+#ifdef CHECKSUMS
+ void GC_record_fault(struct hblk * h);
+ /* From checksums.c */
+#endif
+
#if !defined(DARWIN)
# include <errno.h>
# if defined(FREEBSD)
@@ -2696,6 +2701,9 @@ STATIC GC_bool GC_old_segv_handler_used_si;
register struct hblk * h =
(struct hblk *)((word)addr & ~(GC_page_size-1));
GC_bool in_allocd_block;
+# ifdef CHECKSUMS
+ GC_record_fault(h);
+# endif /* CHECKSUMS */
# ifdef SUNOS5SIGS
/* Address is only within the correct physical page. */
@@ -2814,7 +2822,7 @@ void GC_remove_protection(struct hblk *h, word nblocks, GC_bool is_ptrfree)
return;
}
for (current = h_trunc; current < h_end; ++current) {
- size_t index = PHT_HASH(h_trunc);
+ size_t index = PHT_HASH(current);
if (!is_ptrfree || current < h || current >= h + nblocks) {
async_set_pht_entry_from_index(GC_dirty_pages, index);
}