@@ -530,7 +530,6 @@ INTERNAL_HIDDEN iso_alloc_zone_t *_iso_new_zone(size_t size, bool internal, int3
530530 if (new_zone -> tagged == true) {
531531 create_guard_page (p + g_page_size + tag_mapping_size );
532532 new_zone -> user_pages_start = (p + g_page_size + tag_mapping_size + g_page_size );
533-
534533 uint64_t * _mtp = p + g_page_size ;
535534
536535 /* Generate random tags */
@@ -963,7 +962,7 @@ INTERNAL_HIDDEN ASSUME_ALIGNED void *_iso_alloc_bitslot_from_zone(bit_slot_t bit
963962
964963 /* This chunk was either previously allocated and free'd
965964 * or it's a canary chunk. In either case this means it
966- * has a canary written in its first dword . Here we check
965+ * has a canary written in its first qword . Here we check
967966 * that canary and abort if its been corrupted */
968967#if !ENABLE_ASAN && !DISABLE_CANARY
969968 if ((GET_BIT (b , (which_bit + 1 ))) == 1 ) {
@@ -972,6 +971,9 @@ INTERNAL_HIDDEN ASSUME_ALIGNED void *_iso_alloc_bitslot_from_zone(bit_slot_t bit
972971 }
973972#endif
974973
974+ zone -> af_count ++ ;
975+ zone -> alloc_count ++ ;
976+
975977 /* Set the in-use bit */
976978 SET_BIT (b , which_bit );
977979
@@ -981,19 +983,17 @@ INTERNAL_HIDDEN ASSUME_ALIGNED void *_iso_alloc_bitslot_from_zone(bit_slot_t bit
981983 * as a canary chunk. This bit is set again upon free */
982984 UNSET_BIT (b , (which_bit + 1 ));
983985 bm [dwords_to_bit_slot ] = b ;
984- zone -> af_count ++ ;
985- zone -> alloc_count ++ ;
986986 return p ;
987987}
988988
989989/* Does not require the root is locked */
990990INTERNAL_HIDDEN INLINE void populate_zone_cache (iso_alloc_zone_t * zone ) {
991- if (UNLIKELY (zone -> internal == false)) {
991+ /* Don't cache this zone if it was recently cached */
992+ if (zone_cache_count != 0 && zone_cache [zone_cache_count - 1 ].zone == zone ) {
992993 return ;
993994 }
994995
995- /* Don't cache this zone if it was recently cached */
996- if (zone_cache_count != 0 && zone_cache [zone_cache_count - 1 ].zone == zone ) {
996+ if (UNLIKELY (zone -> internal == false)) {
997997 return ;
998998 }
999999
@@ -1408,7 +1408,9 @@ INTERNAL_HIDDEN void iso_free_chunk_from_zone(iso_alloc_zone_t *zone, void *rest
14081408 * which could result in a page fault */
14091409 bitmap_index_t b = bm [dwords_to_bit_slot ];
14101410
1411- /* Ensure the pointer is a multiple of chunk size */
1411+ /* Ensure the pointer is a multiple of chunk size. Chunk size
1412+ * should always be a power of 2 so this bitwise AND works and
1413+ * is generally faster than modulo */
14121414 if (UNLIKELY ((chunk_offset & (zone -> chunk_size - 1 )) != 0 )) {
14131415 LOG_AND_ABORT ("Chunk at 0x%p is not a multiple of zone[%d] chunk size %d. Off by %lu bits" ,
14141416 p , zone -> index , zone -> chunk_size , (chunk_offset & (zone -> chunk_size - 1 )));
0 commit comments