Author: Armin Rigo <ar...@tunes.org> Branch: c7-more-segments Changeset: r1052:885ed3b0f6ee Date: 2014-03-16 17:55 +0100 http://bitbucket.org/pypy/stmgc/changeset/885ed3b0f6ee/
Log: Bug fixes diff --git a/c7/stm/core.c b/c7/stm/core.c --- a/c7/stm/core.c +++ b/c7/stm/core.c @@ -272,10 +272,11 @@ assert(_has_mutex_pages()); assert(!_is_young(obj)); + char *segment_base = get_segment(source_segment_num)->segment_base; uintptr_t start = (uintptr_t)obj; uintptr_t first_page = start / 4096UL; struct object_s *realobj = (struct object_s *) - REAL_ADDRESS(get_segment(source_segment_num)->segment_base, obj); + REAL_ADDRESS(segment_base, obj); if (realobj->stm_flags & GCFLAG_SMALL_UNIFORM) { abort();//XXX WRITE THE FAST CASE @@ -305,7 +306,7 @@ assert(copy_size > 0); assert(copy_size + (start & 4095) <= 4096); - char *src = REAL_ADDRESS(STM_SEGMENT->segment_base, start); + char *src = REAL_ADDRESS(segment_base, start); char *dst = REAL_ADDRESS(stm_object_pages, start); if (copy_size == 4096) pagecopy(dst, src); diff --git a/c7/stm/gcpage.c b/c7/stm/gcpage.c --- a/c7/stm/gcpage.c +++ b/c7/stm/gcpage.c @@ -253,29 +253,31 @@ long i; mutex_pages_lock(); + for (i = 1; i <= NB_SEGMENTS; i++) { + /* The 'modified_old_objects' list gives the list of objects + whose pages need to remain private. We temporarily remove + these bits from 'pages_privatized', so that these pages will + be skipped by the loop below (and by copy_object_to_shared()). + */ + major_hide_private_bits_for_modified_objects(i); /* For each segment, push the current overflow objects from - private pages to the corresponding shared pages, if necessary. + private pages to the corresponding shared pages, if + necessary. The pages that we will re-share must contain this + data; otherwise, it would exist only in the private pages, + and get lost in the loop below. */ struct list_s *lst = get_priv_segment(i)->large_overflow_objects; if (lst != NULL) { LIST_FOREACH_R(lst, object_t *, copy_object_to_shared(item, i)); } - - /* The 'modified_old_objects' list gives the list of objects - whose pages need to remain private. We temporarily remove - these bits from 'pages_privatized', so that these pages will - be skipped by the loop below. - */ - major_hide_private_bits_for_modified_objects(i); } /* Now loop over all pages that are still in 'pages_privatized', and re-share them. */ uintptr_t pagenum, endpagenum; - struct page_shared_s ps; pagenum = END_NURSERY_PAGE; /* starts after the nursery */ endpagenum = (uninitialized_page_start - stm_object_pages) / 4096UL; @@ -291,18 +293,7 @@ break; /* no pages in the 2nd section, so done too */ } - ps = pages_privatized[pagenum - PAGE_FLAG_START]; - if (ps.by_segment != 0) { - pages_privatized[pagenum - PAGE_FLAG_START].by_segment = 0; - - long j; - for (j = 0; j < NB_SEGMENTS; j++) { - if (ps.by_segment & (1 << j)) { - /* Page 'pagenum' is private in segment 'j + 1'. Reshare */ - page_reshare(j + 1, pagenum); - } - } - } + page_check_and_reshare(pagenum); pagenum++; } diff --git a/c7/stm/pages.c b/c7/stm/pages.c --- a/c7/stm/pages.c +++ b/c7/stm/pages.c @@ -140,30 +140,24 @@ mutex_pages_unlock(); } -static void page_reshare(long segment_num, uintptr_t pagenum) +static void page_reshare(uintptr_t pagenum) { - char *segment_base = get_segment(segment_num)->segment_base; + struct page_shared_s ps = pages_privatized[pagenum - PAGE_FLAG_START]; + pages_privatized[pagenum - PAGE_FLAG_START].by_segment = 0; -#if 0 /* disabled: the private page that we are removing is - typically missing the inter-object information from - largemalloc.c */ - long i, errors=0; - uint64_t *p = (uint64_t *)(stm_object_pages + pagenum * 4096UL); - uint64_t *q = (uint64_t *)(segment_base + pagenum * 4096UL); - for (i = 0; i < 4096 / 8; i++) { - if (p[i] != q[i]) { - fprintf(stderr, "%p: 0x%lx\t\t%p: 0x%lx\n", - &p[i], p[i], &q[i], q[i]); - errors++; + long j, total = 0; + for (j = 0; j < NB_SEGMENTS; j++) { + if (ps.by_segment & (1 << j)) { + /* Page 'pagenum' is private in segment 'j + 1'. Reshare */ + char *segment_base = stm_object_pages + NB_PAGES * 4096UL * (j+1); + + madvise(segment_base + pagenum * 4096UL, 4096, MADV_DONTNEED); + d_remap_file_pages(segment_base + pagenum * 4096UL, + 4096, pagenum); + total -= 4096; } } - assert(!errors); -#endif - - madvise(segment_base + pagenum * 4096UL, 4096, MADV_DONTNEED); - d_remap_file_pages(segment_base + pagenum * 4096UL, - 4096, pagenum); - increment_total_allocated(-4096); + increment_total_allocated(total); } diff --git a/c7/stm/pages.h b/c7/stm/pages.h --- a/c7/stm/pages.h +++ b/c7/stm/pages.h @@ -37,7 +37,7 @@ static void pages_initialize_shared(uintptr_t pagenum, uintptr_t count); static void page_privatize(uintptr_t pagenum); -static void page_reshare(long segment_num, uintptr_t pagenum); +static void page_reshare(uintptr_t pagenum); static void mutex_pages_lock(void); static void mutex_pages_unlock(void); @@ -53,3 +53,9 @@ uint64_t bitmask = 1UL << (segnum - 1); return (pages_privatized[pagenum - PAGE_FLAG_START].by_segment & bitmask); } + +static inline void page_check_and_reshare(uintptr_t pagenum) +{ + if (pages_privatized[pagenum - PAGE_FLAG_START].by_segment != 0) + page_reshare(pagenum); +} _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit