Hi, I need some explanation about INVARIANTS compile option. This option has the description that enable calls of extra sanity checking. What does sanity mean here? Where and why we need to use this option? I find some codes in kern/kern_malloc.c in 5.4 kernel: 511 kmemzones[indx].kz_zone = uma_zcreate(name, size, 512 #ifdef INVARIANTS 513 mtrash_ctor, mtrash_dtor, mtrash_init, mtrash_fini, 514 #else 515 NULL, NULL, NULL, NULL, 516 #endif 517 UMA_ALIGN_PTR, UMA_ZONE_MALLOC); In the case INVARIANTS is defined, kz_zone will be set up with the constructor function mtrash_ctor and destructor function mtrash_dtor. When kz_zone free some items, kernel will call mtrash_dtor(), every item will be filled with the value of uma_junk. When some items will be reallocated, kernel calls mtrash_ctor() and makes sure the constructing item has'nt been overwritten since it was freed through comparing every int of the item with uma_junk. Why kmemzones need this check, while other zones and memory areas need't? Where comes the danger that the memory item will be overwritted after its free? ThanksReceived on Wed Nov 02 2005 - 01:12:28 UTC
This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:46 UTC