diff options
author | Sverker Eriksson <[email protected]> | 2012-11-15 11:38:59 +0100 |
---|---|---|
committer | Sverker Eriksson <[email protected]> | 2012-11-15 18:20:49 +0100 |
commit | facbc93c04c757c1e5c10097d90187d177d0c376 (patch) | |
tree | 287d7aa1de3ede68340ddf2d2dd66a598d10afd7 /erts/emulator | |
parent | 1ff4fffe893346160e5136a3e4a1999e8927b5ec (diff) | |
download | otp-facbc93c04c757c1e5c10097d90187d177d0c376.tar.gz otp-facbc93c04c757c1e5c10097d90187d177d0c376.tar.bz2 otp-facbc93c04c757c1e5c10097d90187d177d0c376.zip |
erts: Ensure MBC limits due to super alignment
Diffstat (limited to 'erts/emulator')
-rw-r--r-- | erts/emulator/beam/erl_alloc_util.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/erts/emulator/beam/erl_alloc_util.c b/erts/emulator/beam/erl_alloc_util.c index c8e2d28c49..c0884c0013 100644 --- a/erts/emulator/beam/erl_alloc_util.c +++ b/erts/emulator/beam/erl_alloc_util.c @@ -204,6 +204,8 @@ MBC after deallocating first block: #if HAVE_SUPER_ALIGNED_MB_CARRIERS +# define MBC_SZ_MAX_LIMIT ((((UWord)1 << CARRIER_OFFSET_BITS) - 1) << MSEG_ALIGN_BITS) + # define BLK_CARRIER_OFFSET(B, C) (((char*)(B) - (char*)(C)) >> MSEG_UNIT_SHIFT) # define SET_MBC_ABLK_HDR(B, Sz, F, C) \ @@ -251,6 +253,8 @@ MBC after deallocating first block: #else /* !HAVE_SUPER_ALIGNED_MB_CARRIERS */ +# define MBC_SZ_MAX_LIMIT ((UWord)~0) + # define SET_MBC_ABLK_HDR(B, Sz, F, C) \ (ASSERT(((Sz) & FLG_MASK) == 0), \ ASSERT(!((UWord)(F) & (~FLG_MASK|THIS_FREE_BLK_HDR_FLG))), \ @@ -2111,6 +2115,7 @@ create_carrier(Allctr_t *allctr, Uint umem_sz, UWord flags) goto sbc_final_touch; } else { + ASSERT(crr_sz <= MBC_SZ_MAX_LIMIT); SET_CARRIER_HDR(crr, crr_sz, SCH_MSEG|SCH_MBC, allctr); STAT_MSEG_MBC_ALLOC(allctr, crr_sz); goto mbc_final_touch; @@ -4153,6 +4158,12 @@ erts_alcu_start(Allctr_t *allctr, AllctrInit_t *init) allctr->ramv = init->ramv; allctr->main_carrier_size = init->mmbcs; allctr->sbc_threshold = init->sbct; +#if HAVE_SUPER_ALIGNED_MB_CARRIERS + if (allctr->sbc_threshold > MBC_ABLK_SZ_MASK - ABLK_HDR_SZ) { + allctr->sbc_threshold = MBC_ABLK_SZ_MASK - ABLK_HDR_SZ + 1; + } +#endif + #if HAVE_ERTS_MSEG allctr->mseg_opt.abs_shrink_th = init->asbcst; allctr->mseg_opt.rel_shrink_th = init->rsbcst; @@ -4169,6 +4180,12 @@ erts_alcu_start(Allctr_t *allctr, AllctrInit_t *init) #endif allctr->largest_mbc_size = MAX(init->lmbcs, init->smbcs); +#if HAVE_SUPER_ALIGNED_MB_CARRIERS + if (allctr->largest_mbc_size > MBC_SZ_MAX_LIMIT) { + allctr->largest_mbc_size = MBC_SZ_MAX_LIMIT; + } +#endif + allctr->smallest_mbc_size = init->smbcs; allctr->mbc_growth_stages = MAX(1, init->mbcgs); @@ -4340,11 +4357,6 @@ erts_alcu_init(AlcUInit_t *init) ASSERT(SBC_BLK_SZ_MASK == MBC_FBLK_SZ_MASK); /* see BLK_SZ */ #if HAVE_ERTS_MSEG ASSERT(erts_mseg_unit_size() == MSEG_UNIT_SZ); -# if HAVE_SUPER_ALIGNED_MB_CARRIERS - /*SVERK Add assert about CARRIER_OFFSET_BITS and max MBC size - *SVERK Add assert about CARRIER_OFFSET_SHIFT and max MBC block size - */ -# endif max_mseg_carriers = init->mmc; sys_alloc_carrier_size = MSEG_UNIT_CEILING(init->ycs); #else /* #if HAVE_ERTS_MSEG */ |