diff options
Diffstat (limited to 'src/H5Cdbg.c')
-rw-r--r-- | src/H5Cdbg.c | 534 |
1 files changed, 462 insertions, 72 deletions
diff --git a/src/H5Cdbg.c b/src/H5Cdbg.c index 0411e8e..19d31f1 100644 --- a/src/H5Cdbg.c +++ b/src/H5Cdbg.c @@ -13,8 +13,6 @@ /*------------------------------------------------------------------------- * * Created: H5Cdbg.c - * July 8 2016 - * Quincey Koziol * * Purpose: Debugging Routines for the generic cache structure or entries. * @@ -69,9 +67,6 @@ * * Return: Non-negative on success/Negative on failure * - * Programmer: John Mainzer - * 10/10/10 - * *------------------------------------------------------------------------- */ herr_t @@ -86,7 +81,6 @@ H5C_dump_cache(H5C_t *cache_ptr, const char *cache_name) /* Sanity check */ assert(cache_ptr != NULL); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); assert(cache_name != NULL); /* First, create a skip list */ @@ -101,7 +95,6 @@ H5C_dump_cache(H5C_t *cache_ptr, const char *cache_name) entry_ptr = cache_ptr->index[i]; while (entry_ptr != NULL) { - assert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); if (H5SL_insert(slist_ptr, entry_ptr, &(entry_ptr->addr)) < 0) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "can't insert entry in skip list") @@ -131,8 +124,6 @@ H5C_dump_cache(H5C_t *cache_ptr, const char *cache_name) i = 0; entry_ptr = (H5C_cache_entry_t *)H5SL_remove_first(slist_ptr); while (entry_ptr != NULL) { - assert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - /* Print entry */ fprintf(stdout, "%s%5d ", cache_ptr->prefix, i); fprintf(stdout, " 0x%16llx ", (long long)(entry_ptr->addr)); @@ -178,9 +169,6 @@ done: * * Return: Non-negative on success/Negative on failure * - * Programmer: John Mainzer - * 10/10/10 - * *------------------------------------------------------------------------- */ herr_t @@ -193,7 +181,6 @@ H5C_dump_cache_LRU(H5C_t *cache_ptr, const char *cache_name) /* Sanity check */ assert(cache_ptr != NULL); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); assert(cache_name != NULL); fprintf(stdout, "\n\nDump of metadata cache LRU \"%s\"\n", cache_name); @@ -218,8 +205,6 @@ H5C_dump_cache_LRU(H5C_t *cache_ptr, const char *cache_name) entry_ptr = cache_ptr->LRU_head_ptr; while (entry_ptr != NULL) { - assert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - /* Print entry */ fprintf(stdout, "%s%5d ", cache_ptr->prefix, i); fprintf(stdout, " 0x%16llx ", (long long)(entry_ptr->addr)); @@ -247,7 +232,6 @@ H5C_dump_cache_LRU(H5C_t *cache_ptr, const char *cache_name) #endif /* NDEBUG */ /*------------------------------------------------------------------------- - * * Function: H5C_dump_cache_skip_list * * Purpose: Debugging routine that prints a summary of the contents of @@ -256,9 +240,6 @@ H5C_dump_cache_LRU(H5C_t *cache_ptr, const char *cache_name) * * Return: Non-negative on success/Negative on failure * - * Programmer: John Mainzer - * 11/15/14 - * *------------------------------------------------------------------------- */ #ifndef NDEBUG @@ -273,7 +254,6 @@ H5C_dump_cache_skip_list(H5C_t *cache_ptr, char *calling_fcn) FUNC_ENTER_NOAPI_NOERR assert(cache_ptr != NULL); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); assert(calling_fcn != NULL); fprintf(stdout, "\n\nDumping metadata cache skip list from %s.\n", calling_fcn); @@ -297,7 +277,6 @@ H5C_dump_cache_skip_list(H5C_t *cache_ptr, char *calling_fcn) entry_ptr = NULL; while (entry_ptr != NULL) { - assert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); fprintf(stdout, "%s%d 0x%016llx %4lld %d/%d %d %s\n", cache_ptr->prefix, i, (long long)(entry_ptr->addr), (long long)(entry_ptr->size), (int)(entry_ptr->is_protected), (int)(entry_ptr->is_pinned), (int)(entry_ptr->is_dirty), @@ -329,9 +308,6 @@ H5C_dump_cache_skip_list(H5C_t *cache_ptr, char *calling_fcn) * * Return: Non-negative on success/Negative on failure * - * Programmer: John Mainzer - * 1/20/06 - * *------------------------------------------------------------------------- */ herr_t @@ -341,8 +317,7 @@ H5C_set_prefix(H5C_t *cache_ptr, char *prefix) FUNC_ENTER_NOAPI(FAIL) - if ((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC) || (prefix == NULL) || - (HDstrlen(prefix) >= H5C__PREFIX_LEN)) + if (cache_ptr == NULL || prefix == NULL || HDstrlen(prefix) >= H5C__PREFIX_LEN) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad param(s) on entry") HDstrncpy(&(cache_ptr->prefix[0]), prefix, (size_t)(H5C__PREFIX_LEN)); @@ -360,9 +335,6 @@ done: * * Return: Non-negative on success/Negative on failure * - * Programmer: John Mainzer - * 6/2/04 - * *------------------------------------------------------------------------- */ herr_t @@ -416,12 +388,7 @@ H5C_stats(H5C_t *cache_ptr, const char *cache_name, FUNC_ENTER_NOAPI(FAIL) - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); - - /* This would normally be an assert, but we need to use an HGOTO_ERROR - * call to shut up the compiler. - */ - if ((NULL == cache_ptr) || (cache_ptr->magic != H5C__H5C_T_MAGIC) || (NULL == cache_name)) + if (NULL == cache_ptr || NULL == cache_name) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad cache_ptr or cache_name") #if H5C_COLLECT_CACHE_STATS @@ -694,15 +661,12 @@ done: } /* H5C_stats() */ /*------------------------------------------------------------------------- - * * Function: H5C_stats__reset * * Purpose: Reset the stats fields to their initial values. * * Return: void * - * Programmer: John Mainzer, 4/28/04 - * *------------------------------------------------------------------------- */ void @@ -710,7 +674,7 @@ void H5C_stats__reset(H5C_t *cache_ptr) #else /* NDEBUG */ #if H5C_COLLECT_CACHE_STATS -H5C_stats__reset(H5C_t *cache_ptr) +H5C_stats__reset(H5C_t *cache_ptr) #else /* H5C_COLLECT_CACHE_STATS */ H5C_stats__reset(H5C_t H5_ATTR_UNUSED *cache_ptr) #endif /* H5C_COLLECT_CACHE_STATS */ @@ -721,7 +685,6 @@ H5C_stats__reset(H5C_t H5_ATTR_UNUSED *cache_ptr) #endif /* H5C_COLLECT_CACHE_STATS */ assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); #if H5C_COLLECT_CACHE_STATS for (i = 0; i <= cache_ptr->max_type_id; i++) { @@ -827,9 +790,6 @@ H5C_stats__reset(H5C_t H5_ATTR_UNUSED *cache_ptr) * Return: SUCCEED on success/FAIL on failure. Note that * *fd_exists_ptr is undefined on failure. * - * Programmer: John Mainzer - * 9/28/16 - * *------------------------------------------------------------------------- */ #ifndef NDEBUG @@ -845,18 +805,14 @@ H5C_flush_dependency_exists(H5C_t *cache_ptr, haddr_t parent_addr, haddr_t child /* Sanity checks */ assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); assert(H5_addr_defined(parent_addr)); assert(H5_addr_defined(child_addr)); assert(fd_exists_ptr); - H5C__SEARCH_INDEX(cache_ptr, parent_addr, parent_ptr, FAIL) - H5C__SEARCH_INDEX(cache_ptr, child_addr, child_ptr, FAIL) + H5C__SEARCH_INDEX(cache_ptr, parent_addr, parent_ptr, FAIL); + H5C__SEARCH_INDEX(cache_ptr, child_addr, child_ptr, FAIL); if (parent_ptr && child_ptr) { - assert(parent_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - assert(child_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - if (child_ptr->flush_dep_nparents > 0) { unsigned u; /* Local index variable */ @@ -881,7 +837,6 @@ done: #endif /* NDEBUG */ /*------------------------------------------------------------------------- - * * Function: H5C_validate_index_list * * Purpose: Debugging function that scans the index list for errors. @@ -892,8 +847,6 @@ done: * * Return: FAIL if error is detected, SUCCEED otherwise. * - * Programmer: John Mainzer, 9/16/16 - * *------------------------------------------------------------------------- */ #ifndef NDEBUG @@ -916,7 +869,6 @@ H5C_validate_index_list(H5C_t *cache_ptr) /* Sanity checks */ assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); for (i = 0; i < H5C_RING_NTYPES; i++) { index_ring_len[i] = 0; @@ -997,7 +949,6 @@ done: #endif /* NDEBUG */ /*------------------------------------------------------------------------- - * * Function: H5C_get_entry_ptr_from_addr() * * Purpose: Debugging function that attempts to look up an entry in the @@ -1028,8 +979,6 @@ done: * * Return: FAIL if error is detected, SUCCEED otherwise. * - * Programmer: John Mainzer, 5/30/14 - * *------------------------------------------------------------------------- */ #ifndef NDEBUG @@ -1043,11 +992,10 @@ H5C_get_entry_ptr_from_addr(H5C_t *cache_ptr, haddr_t addr, void **entry_ptr_ptr /* Sanity checks */ assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); assert(H5_addr_defined(addr)); assert(entry_ptr_ptr); - H5C__SEARCH_INDEX(cache_ptr, addr, entry_ptr, FAIL) + H5C__SEARCH_INDEX(cache_ptr, addr, entry_ptr, FAIL); if (entry_ptr == NULL) /* the entry doesn't exist in the cache -- report this @@ -1074,9 +1022,6 @@ done: * * Return: Current value of cache_ptr->serialization_in_progress. * - * Programmer: John Mainzer - * 8/24/15 - * *------------------------------------------------------------------------- */ #ifndef NDEBUG @@ -1087,14 +1032,12 @@ H5C_get_serialization_in_progress(const H5C_t *cache_ptr) /* Sanity check */ assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); FUNC_LEAVE_NOAPI(cache_ptr->serialization_in_progress) } /* H5C_get_serialization_in_progress() */ #endif /* NDEBUG */ /*------------------------------------------------------------------------- - * * Function: H5C_cache_is_clean() * * Purpose: Debugging function that verifies that all rings in the @@ -1106,8 +1049,6 @@ H5C_get_serialization_in_progress(const H5C_t *cache_ptr) * * Return: TRUE if the indicated ring(s) are clean, and FALSE otherwise. * - * Programmer: John Mainzer, 6/18/16 - * *------------------------------------------------------------------------- */ #ifndef NDEBUG @@ -1121,13 +1062,12 @@ H5C_cache_is_clean(const H5C_t *cache_ptr, H5C_ring_t inner_ring) /* Sanity checks */ assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); assert(inner_ring >= H5C_RING_USER); assert(inner_ring <= H5C_RING_SB); while (ring <= inner_ring) { if (cache_ptr->dirty_index_ring_size[ring] > 0) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); ring++; } /* end while */ @@ -1138,7 +1078,6 @@ done: #endif /* NDEBUG */ /*------------------------------------------------------------------------- - * * Function: H5C_verify_entry_type() * * Purpose: Debugging function that attempts to look up an entry in the @@ -1158,8 +1097,6 @@ done: * * Return: FAIL if error is detected, SUCCEED otherwise. * - * Programmer: John Mainzer, 5/30/14 - * *------------------------------------------------------------------------- */ #ifndef NDEBUG @@ -1174,13 +1111,12 @@ H5C_verify_entry_type(H5C_t *cache_ptr, haddr_t addr, const H5C_class_t *expecte /* Sanity checks */ assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); assert(H5_addr_defined(addr)); assert(expected_type); assert(in_cache_ptr); assert(type_ok_ptr); - H5C__SEARCH_INDEX(cache_ptr, addr, entry_ptr, FAIL) + H5C__SEARCH_INDEX(cache_ptr, addr, entry_ptr, FAIL); if (entry_ptr == NULL) /* the entry doesn't exist in the cache -- report this @@ -1200,3 +1136,457 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_verify_entry_type() */ #endif /* NDEBUG */ + +/*------------------------------------------------------------------------- + * Function: H5C_def_auto_resize_rpt_fcn + * + * Purpose: Print results of a automatic cache resize. + * + * This function should only be used where printf() behaves + * well -- i.e. not on Windows. + * + * Return: void + * + *------------------------------------------------------------------------- + */ +void +H5C_def_auto_resize_rpt_fcn(H5C_t *cache_ptr, +#ifndef NDEBUG + int32_t version, +#else + int32_t H5_ATTR_UNUSED version, +#endif + double hit_rate, enum H5C_resize_status status, size_t old_max_cache_size, + size_t new_max_cache_size, size_t old_min_clean_size, size_t new_min_clean_size) +{ + assert(cache_ptr != NULL); + assert(version == H5C__CURR_AUTO_RESIZE_RPT_FCN_VER); + + switch (status) { + case in_spec: + fprintf(stdout, "%sAuto cache resize -- no change. (hit rate = %lf)\n", cache_ptr->prefix, + hit_rate); + break; + + case increase: + assert(hit_rate < cache_ptr->resize_ctl.lower_hr_threshold); + assert(old_max_cache_size < new_max_cache_size); + + fprintf(stdout, "%sAuto cache resize -- hit rate (%lf) out of bounds low (%6.5lf).\n", + cache_ptr->prefix, hit_rate, cache_ptr->resize_ctl.lower_hr_threshold); + fprintf(stdout, "%scache size increased from (%zu/%zu) to (%zu/%zu).\n", cache_ptr->prefix, + old_max_cache_size, old_min_clean_size, new_max_cache_size, new_min_clean_size); + break; + + case flash_increase: + assert(old_max_cache_size < new_max_cache_size); + + fprintf(stdout, "%sflash cache resize(%d) -- size threshold = %zu.\n", cache_ptr->prefix, + (int)(cache_ptr->resize_ctl.flash_incr_mode), cache_ptr->flash_size_increase_threshold); + fprintf(stdout, "%s cache size increased from (%zu/%zu) to (%zu/%zu).\n", cache_ptr->prefix, + old_max_cache_size, old_min_clean_size, new_max_cache_size, new_min_clean_size); + break; + + case decrease: + assert(old_max_cache_size > new_max_cache_size); + + switch (cache_ptr->resize_ctl.decr_mode) { + case H5C_decr__off: + fprintf(stdout, "%sAuto cache resize -- decrease off. HR = %lf\n", cache_ptr->prefix, + hit_rate); + break; + + case H5C_decr__threshold: + assert(hit_rate > cache_ptr->resize_ctl.upper_hr_threshold); + + fprintf(stdout, "%sAuto cache resize -- decrease by threshold. HR = %lf > %6.5lf\n", + cache_ptr->prefix, hit_rate, cache_ptr->resize_ctl.upper_hr_threshold); + fprintf(stdout, "%sout of bounds high (%6.5lf).\n", cache_ptr->prefix, + cache_ptr->resize_ctl.upper_hr_threshold); + break; + + case H5C_decr__age_out: + fprintf(stdout, "%sAuto cache resize -- decrease by ageout. HR = %lf\n", + cache_ptr->prefix, hit_rate); + break; + + case H5C_decr__age_out_with_threshold: + assert(hit_rate > cache_ptr->resize_ctl.upper_hr_threshold); + + fprintf(stdout, + "%sAuto cache resize -- decrease by ageout with threshold. HR = %lf > %6.5lf\n", + cache_ptr->prefix, hit_rate, cache_ptr->resize_ctl.upper_hr_threshold); + break; + + default: + fprintf(stdout, "%sAuto cache resize -- decrease by unknown mode. HR = %lf\n", + cache_ptr->prefix, hit_rate); + } + + fprintf(stdout, "%s cache size decreased from (%zu/%zu) to (%zu/%zu).\n", cache_ptr->prefix, + old_max_cache_size, old_min_clean_size, new_max_cache_size, new_min_clean_size); + break; + + case at_max_size: + fprintf(stdout, "%sAuto cache resize -- hit rate (%lf) out of bounds low (%6.5lf).\n", + cache_ptr->prefix, hit_rate, cache_ptr->resize_ctl.lower_hr_threshold); + fprintf(stdout, "%s cache already at maximum size so no change.\n", cache_ptr->prefix); + break; + + case at_min_size: + fprintf(stdout, "%sAuto cache resize -- hit rate (%lf) -- can't decrease.\n", cache_ptr->prefix, + hit_rate); + fprintf(stdout, "%s cache already at minimum size.\n", cache_ptr->prefix); + break; + + case increase_disabled: + fprintf(stdout, "%sAuto cache resize -- increase disabled -- HR = %lf.", cache_ptr->prefix, + hit_rate); + break; + + case decrease_disabled: + fprintf(stdout, "%sAuto cache resize -- decrease disabled -- HR = %lf.\n", cache_ptr->prefix, + hit_rate); + break; + + case not_full: + assert(hit_rate < cache_ptr->resize_ctl.lower_hr_threshold); + + fprintf(stdout, "%sAuto cache resize -- hit rate (%lf) out of bounds low (%6.5lf).\n", + cache_ptr->prefix, hit_rate, cache_ptr->resize_ctl.lower_hr_threshold); + fprintf(stdout, "%s cache not full so no increase in size.\n", cache_ptr->prefix); + break; + + default: + fprintf(stdout, "%sAuto cache resize -- unknown status code.\n", cache_ptr->prefix); + break; + } +} /* H5C_def_auto_resize_rpt_fcn() */ + +/*------------------------------------------------------------------------- + * Function: H5C__validate_lru_list + * + * Purpose: Debugging function that scans the LRU list for errors. + * + * If an error is detected, the function generates a + * diagnostic and returns FAIL. If no error is detected, + * the function returns SUCCEED. + * + * Return: FAIL if error is detected, SUCCEED otherwise. + * + *------------------------------------------------------------------------- + */ +#ifdef H5C_DO_EXTREME_SANITY_CHECKS +herr_t +H5C__validate_lru_list(H5C_t *cache_ptr) +{ + int32_t len = 0; + size_t size = 0; + H5C_cache_entry_t *entry_ptr = NULL; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + assert(cache_ptr); + + if (((cache_ptr->LRU_head_ptr == NULL) || (cache_ptr->LRU_tail_ptr == NULL)) && + (cache_ptr->LRU_head_ptr != cache_ptr->LRU_tail_ptr)) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "LRU list head/tail check failed") + + if ((cache_ptr->LRU_list_len == 1) && + ((cache_ptr->LRU_head_ptr != cache_ptr->LRU_tail_ptr) || (cache_ptr->LRU_head_ptr == NULL) || + (cache_ptr->LRU_head_ptr->size != cache_ptr->LRU_list_size))) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "LRU list sanity check failed") + + if ((cache_ptr->LRU_list_len >= 1) && + ((cache_ptr->LRU_head_ptr == NULL) || (cache_ptr->LRU_head_ptr->prev != NULL) || + (cache_ptr->LRU_tail_ptr == NULL) || (cache_ptr->LRU_tail_ptr->next != NULL))) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "LRU list sanity check failed") + + entry_ptr = cache_ptr->LRU_head_ptr; + while (entry_ptr != NULL) { + if ((entry_ptr != cache_ptr->LRU_head_ptr) && + ((entry_ptr->prev == NULL) || (entry_ptr->prev->next != entry_ptr))) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "entry has bad prev/next pointers") + + if ((entry_ptr != cache_ptr->LRU_tail_ptr) && + ((entry_ptr->next == NULL) || (entry_ptr->next->prev != entry_ptr))) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "entry has bad prev/next pointers") + + if (entry_ptr->is_pinned || entry_ptr->pinned_from_client || entry_ptr->pinned_from_cache) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "invalid entry 'pin origin' fields") + + len++; + size += entry_ptr->size; + entry_ptr = entry_ptr->next; + } + + if ((cache_ptr->LRU_list_len != (uint32_t)len) || (cache_ptr->LRU_list_size != size)) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "LRU list length/size check failed") + +done: + if (ret_value != SUCCEED) + assert(0); + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__validate_lru_list() */ +#endif /* H5C_DO_EXTREME_SANITY_CHECKS */ + +/*------------------------------------------------------------------------- + * Function: H5C__validate_pinned_entry_list + * + * Purpose: Debugging function that scans the pinned entry list for + * errors. + * + * If an error is detected, the function generates a + * diagnostic and returns FAIL. If no error is detected, + * the function returns SUCCEED. + * + * Return: FAIL if error is detected, SUCCEED otherwise. + * + *------------------------------------------------------------------------- + */ +#ifdef H5C_DO_EXTREME_SANITY_CHECKS +herr_t +H5C__validate_pinned_entry_list(H5C_t *cache_ptr) +{ + int32_t len = 0; + size_t size = 0; + H5C_cache_entry_t *entry_ptr = NULL; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + assert(cache_ptr); + + if (((cache_ptr->pel_head_ptr == NULL) || (cache_ptr->pel_tail_ptr == NULL)) && + (cache_ptr->pel_head_ptr != cache_ptr->pel_tail_ptr)) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "pinned list head/tail check failed") + + if ((cache_ptr->pel_len == 1) && + ((cache_ptr->pel_head_ptr != cache_ptr->pel_tail_ptr) || (cache_ptr->pel_head_ptr == NULL) || + (cache_ptr->pel_head_ptr->size != cache_ptr->pel_size))) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "pinned list sanity check failed") + + if ((cache_ptr->pel_len >= 1) && + ((cache_ptr->pel_head_ptr == NULL) || (cache_ptr->pel_head_ptr->prev != NULL) || + (cache_ptr->pel_tail_ptr == NULL) || (cache_ptr->pel_tail_ptr->next != NULL))) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "pinned list sanity check failed") + + entry_ptr = cache_ptr->pel_head_ptr; + while (entry_ptr != NULL) { + if ((entry_ptr != cache_ptr->pel_head_ptr) && + ((entry_ptr->prev == NULL) || (entry_ptr->prev->next != entry_ptr))) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "entry has bad prev/next pointers") + + if ((entry_ptr != cache_ptr->pel_tail_ptr) && + ((entry_ptr->next == NULL) || (entry_ptr->next->prev != entry_ptr))) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "entry has bad prev/next pointers") + + if (!entry_ptr->is_pinned) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "pinned list contains unpinned entry") + + if (!(entry_ptr->pinned_from_client || entry_ptr->pinned_from_cache)) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "invalid entry 'pin origin' fields") + + len++; + size += entry_ptr->size; + entry_ptr = entry_ptr->next; + } + + if ((cache_ptr->pel_len != (uint32_t)len) || (cache_ptr->pel_size != size)) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "pinned list length/size check failed") + +done: + if (ret_value != SUCCEED) + assert(0); + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__validate_pinned_entry_list() */ +#endif /* H5C_DO_EXTREME_SANITY_CHECKS */ + +/*------------------------------------------------------------------------- + * Function: H5C__validate_protected_entry_list + * + * Purpose: Debugging function that scans the protected entry list for + * errors. + * + * If an error is detected, the function generates a + * diagnostic and returns FAIL. If no error is detected, + * the function returns SUCCEED. + * + * Return: FAIL if error is detected, SUCCEED otherwise. + * + *------------------------------------------------------------------------- + */ +#ifdef H5C_DO_EXTREME_SANITY_CHECKS +herr_t +H5C__validate_protected_entry_list(H5C_t *cache_ptr) +{ + int32_t len = 0; + size_t size = 0; + H5C_cache_entry_t *entry_ptr = NULL; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + assert(cache_ptr); + + if (((cache_ptr->pl_head_ptr == NULL) || (cache_ptr->pl_tail_ptr == NULL)) && + (cache_ptr->pl_head_ptr != cache_ptr->pl_tail_ptr)) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "protected list head/tail check failed") + + if ((cache_ptr->pl_len == 1) && + ((cache_ptr->pl_head_ptr != cache_ptr->pl_tail_ptr) || (cache_ptr->pl_head_ptr == NULL) || + (cache_ptr->pl_head_ptr->size != cache_ptr->pl_size))) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "protected list sanity check failed") + + if ((cache_ptr->pl_len >= 1) && + ((cache_ptr->pl_head_ptr == NULL) || (cache_ptr->pl_head_ptr->prev != NULL) || + (cache_ptr->pl_tail_ptr == NULL) || (cache_ptr->pl_tail_ptr->next != NULL))) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "protected list sanity check failed") + + entry_ptr = cache_ptr->pl_head_ptr; + while (entry_ptr != NULL) { + if ((entry_ptr != cache_ptr->pl_head_ptr) && + ((entry_ptr->prev == NULL) || (entry_ptr->prev->next != entry_ptr))) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "entry has bad prev/next pointers") + + if ((entry_ptr != cache_ptr->pl_tail_ptr) && + ((entry_ptr->next == NULL) || (entry_ptr->next->prev != entry_ptr))) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "entry has bad prev/next pointers") + + if (!entry_ptr->is_protected) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "protected list contains unprotected entry") + + if (entry_ptr->is_read_only && (entry_ptr->ro_ref_count <= 0)) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "read-only entry has non-positive ref count") + + len++; + size += entry_ptr->size; + entry_ptr = entry_ptr->next; + } + + if ((cache_ptr->pl_len != (uint32_t)len) || (cache_ptr->pl_size != size)) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "protected list length/size check failed") + +done: + if (ret_value != SUCCEED) + assert(0); + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__validate_protected_entry_list() */ +#endif /* H5C_DO_EXTREME_SANITY_CHECKS */ + +/*------------------------------------------------------------------------- + * Function: H5C__entry_in_skip_list + * + * Purpose: Debugging function that scans skip list to see if it + * is in present. We need this, as it is possible for + * an entry to be in the skip list twice. + * + * Return: FALSE if the entry is not in the skip list, and TRUE + * if it is. + * + *------------------------------------------------------------------------- + */ +#ifdef H5C_DO_SLIST_SANITY_CHECKS +hbool_t +H5C__entry_in_skip_list(H5C_t *cache_ptr, H5C_cache_entry_t *target_ptr) +{ + H5SL_node_t *node_ptr; + hbool_t in_slist; + hbool_t ret_value; + + FUNC_ENTER_PACKAGE + + /* Assertions */ + assert(cache_ptr); + assert(cache_ptr->slist_ptr); + + node_ptr = H5SL_first(cache_ptr->slist_ptr); + in_slist = FALSE; + while ((node_ptr != NULL) && (!in_slist)) { + H5C_cache_entry_t *entry_ptr; + + entry_ptr = (H5C_cache_entry_t *)H5SL_item(node_ptr); + + assert(entry_ptr); + assert(entry_ptr->is_dirty); + assert(entry_ptr->in_slist); + + if (entry_ptr == target_ptr) + in_slist = TRUE; + else + node_ptr = H5SL_next(node_ptr); + } + + /* Set return value */ + ret_value = in_slist; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__entry_in_skip_list() */ +#endif /* H5C_DO_SLIST_SANITY_CHECKS */ + +/*------------------------------------------------------------------------- + * Function: H5C__image_stats + * + * Purpose: Prints statistics specific to the cache image. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +#if H5C_COLLECT_CACHE_STATS +H5C__image_stats(H5C_t *cache_ptr, hbool_t print_header) +#else /* H5C_COLLECT_CACHE_STATS */ +H5C__image_stats(H5C_t *cache_ptr, hbool_t H5_ATTR_UNUSED print_header) +#endif /* H5C_COLLECT_CACHE_STATS */ +{ +#if H5C_COLLECT_CACHE_STATS + int i; + int64_t total_hits = 0; + int64_t total_misses = 0; + double hit_rate; + double prefetch_use_rate; +#endif /* H5C_COLLECT_CACHE_STATS */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + if (NULL == cache_ptr) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad cache_ptr") + +#if H5C_COLLECT_CACHE_STATS + for (i = 0; i <= cache_ptr->max_type_id; i++) { + total_hits += cache_ptr->hits[i]; + total_misses += cache_ptr->misses[i]; + } /* end for */ + + if ((total_hits > 0) || (total_misses > 0)) + hit_rate = 100.0 * ((double)(total_hits)) / ((double)(total_hits + total_misses)); + else + hit_rate = 0.0; + + if (cache_ptr->prefetches > 0) + prefetch_use_rate = 100.0 * ((double)(cache_ptr->prefetch_hits)) / ((double)(cache_ptr->prefetches)); + else + prefetch_use_rate = 0.0; + + if (print_header) { + fprintf(stdout, "\nhit prefetches prefetch image pf hit\n"); + fprintf(stdout, "rate: total: dirty: hits: flshs: evct: size: rate:\n"); + } /* end if */ + + fprintf(stdout, "%3.1lf %5lld %5lld %5lld %5lld %5lld %5lld %3.1lf\n", hit_rate, + (long long)(cache_ptr->prefetches), (long long)(cache_ptr->dirty_prefetches), + (long long)(cache_ptr->prefetch_hits), (long long)(cache_ptr->flushes[H5AC_PREFETCHED_ENTRY_ID]), + (long long)(cache_ptr->evictions[H5AC_PREFETCHED_ENTRY_ID]), + (long long)(cache_ptr->last_image_size), prefetch_use_rate); +#endif /* H5C_COLLECT_CACHE_STATS */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__image_stats() */ |