mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-07-24 05:33:06 +00:00
improve hpdata_assert_consistent()
A few ways this consistency check can be improved: * Print which conditions fail and associated values. * Accumulate the result so that we can print all conditions that fail. * Turn hpdata_assert_consistent() into a macro so, when it fails, we can get line number where it's called from.
This commit is contained in:
committed by
Guangli Dai
parent
86b7219213
commit
1d018d8fda
@@ -342,39 +342,76 @@ hpdata_assert_empty(hpdata_t *hpdata) {
|
|||||||
*/
|
*/
|
||||||
static inline bool
|
static inline bool
|
||||||
hpdata_consistent(hpdata_t *hpdata) {
|
hpdata_consistent(hpdata_t *hpdata) {
|
||||||
if (fb_urange_longest(hpdata->active_pages, HUGEPAGE_PAGES)
|
bool res = true;
|
||||||
!= hpdata_longest_free_range_get(hpdata)) {
|
|
||||||
return false;
|
const size_t active_urange_longest = fb_urange_longest(
|
||||||
|
hpdata->active_pages, HUGEPAGE_PAGES);
|
||||||
|
const size_t longest_free_range = hpdata_longest_free_range_get(hpdata);
|
||||||
|
if (active_urange_longest != longest_free_range) {
|
||||||
|
malloc_printf(
|
||||||
|
"<jemalloc>: active_fb_urange_longest=%zu != hpdata_longest_free_range=%zu\n",
|
||||||
|
active_urange_longest, longest_free_range);
|
||||||
|
res = false;
|
||||||
}
|
}
|
||||||
if (fb_scount(hpdata->active_pages, HUGEPAGE_PAGES, 0, HUGEPAGE_PAGES)
|
|
||||||
!= hpdata->h_nactive) {
|
const size_t active_scount = fb_scount(
|
||||||
return false;
|
hpdata->active_pages, HUGEPAGE_PAGES, 0, HUGEPAGE_PAGES);
|
||||||
|
if (active_scount != hpdata->h_nactive) {
|
||||||
|
malloc_printf(
|
||||||
|
"<jemalloc>: active_fb_scount=%zu != hpdata_nactive=%zu\n",
|
||||||
|
active_scount, hpdata->h_nactive);
|
||||||
|
res = false;
|
||||||
}
|
}
|
||||||
if (fb_scount(hpdata->touched_pages, HUGEPAGE_PAGES, 0, HUGEPAGE_PAGES)
|
|
||||||
!= hpdata->h_ntouched) {
|
const size_t touched_scount = fb_scount(
|
||||||
return false;
|
hpdata->touched_pages, HUGEPAGE_PAGES, 0, HUGEPAGE_PAGES);
|
||||||
|
if (touched_scount != hpdata->h_ntouched) {
|
||||||
|
malloc_printf(
|
||||||
|
"<jemalloc>: touched_fb_scount=%zu != hpdata_ntouched=%zu\n",
|
||||||
|
touched_scount, hpdata->h_ntouched);
|
||||||
|
res = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hpdata->h_ntouched < hpdata->h_nactive) {
|
if (hpdata->h_ntouched < hpdata->h_nactive) {
|
||||||
return false;
|
malloc_printf(
|
||||||
|
"<jemalloc>: hpdata_ntouched=%zu < hpdata_nactive=%zu\n",
|
||||||
|
hpdata->h_ntouched, hpdata->h_nactive);
|
||||||
|
res = false;
|
||||||
}
|
}
|
||||||
if (hpdata->h_huge && hpdata->h_ntouched != HUGEPAGE_PAGES) {
|
|
||||||
return false;
|
if (hpdata->h_huge && (hpdata->h_ntouched != HUGEPAGE_PAGES)) {
|
||||||
|
malloc_printf(
|
||||||
|
"<jemalloc>: hpdata_huge=%d && (hpdata_ntouched=%zu != hugepage_pages=%zu)\n",
|
||||||
|
hpdata->h_huge, hpdata->h_ntouched, HUGEPAGE_PAGES);
|
||||||
|
res = false;
|
||||||
}
|
}
|
||||||
if (hpdata_changing_state_get(hpdata)
|
|
||||||
&& ((hpdata->h_purge_allowed) || hpdata->h_hugify_allowed)) {
|
const bool changing_state = hpdata_changing_state_get(hpdata);
|
||||||
return false;
|
if (changing_state
|
||||||
|
&& (hpdata->h_purge_allowed || hpdata->h_hugify_allowed)) {
|
||||||
|
malloc_printf(
|
||||||
|
"<jemalloc>: hpdata_changing_state=%d && (hpdata_purge_allowed=%d || hpdata_hugify_allowed=%d)\n",
|
||||||
|
changing_state, hpdata->h_purge_allowed,
|
||||||
|
hpdata->h_hugify_allowed);
|
||||||
|
res = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hpdata_hugify_allowed_get(hpdata)
|
if (hpdata_hugify_allowed_get(hpdata)
|
||||||
!= hpdata_in_psset_hugify_container_get(hpdata)) {
|
!= hpdata_in_psset_hugify_container_get(hpdata)) {
|
||||||
return false;
|
malloc_printf(
|
||||||
|
"<jemalloc>: hpdata_hugify_allowed=%d != hpdata_in_psset_hugify_container=%d\n",
|
||||||
|
hpdata_hugify_allowed_get(hpdata),
|
||||||
|
hpdata_in_psset_hugify_container_get(hpdata));
|
||||||
|
res = false;
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
#define hpdata_assert_consistent(hpdata) \
|
||||||
hpdata_assert_consistent(hpdata_t *hpdata) {
|
do { \
|
||||||
assert(hpdata_consistent(hpdata));
|
assert(hpdata_consistent(hpdata)); \
|
||||||
}
|
} while (0)
|
||||||
|
|
||||||
static inline bool
|
static inline bool
|
||||||
hpdata_empty(const hpdata_t *hpdata) {
|
hpdata_empty(const hpdata_t *hpdata) {
|
||||||
|
|||||||
Reference in New Issue
Block a user