/* pool debugging flags */
#define POOL_DBG_FAIL_ALLOC 0x00000001 // randomly fail memory allocations
#define POOL_DBG_DONT_MERGE 0x00000002 // do not merge same-size pools
+#define POOL_DBG_COLD_FIRST 0x00000004 // pick cold objects first
/* This is the head of a thread-local cache */
return NULL;
}
+ if (unlikely(pool_debugging & POOL_DBG_COLD_FIRST)) {
+ /* allocate oldest objects first so as to keep them as long as possible
+ * in the cache before being reused and maximizing the chance to detect
+ * an overwrite.
+ */
+ item = LIST_PREV(&ph->list, typeof(item), by_pool);
+ } else {
+ /* allocate hottest objects first */
+ item = LIST_NEXT(&ph->list, typeof(item), by_pool);
+ }
#if defined(DEBUG_POOL_INTEGRITY)
- /* allocate oldest objects first so as to keep them as long as possible
- * in the cache before being reused and maximizing the chance to detect
- * an overwrite.
- */
- item = LIST_PREV(&ph->list, typeof(item), by_pool);
pool_check_pattern(ph, item, pool->size);
-#else
- /* allocate hottest objects first */
- item = LIST_NEXT(&ph->list, typeof(item), by_pool);
#endif
BUG_ON(&item->by_pool == &ph->list);
LIST_DELETE(&item->by_pool);