MCPcopy Create free account
hub / github.com/F-Stack/f-stack / cache_alloc

Function cache_alloc

freebsd/kern/vfs_cache.c:645–672  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

643}
644
645static struct namecache *
646cache_alloc(int len, bool ts)
647{
648 u_long lnumcache;
649
650 /*
651 * Avoid blowout in namecache entries.
652 *
653 * Bugs:
654 * 1. filesystems may end up trying to add an already existing entry
655 * (for example this can happen after a cache miss during concurrent
656 * lookup), in which case we will call cache_neg_evict despite not
657 * adding anything.
658 * 2. the routine may fail to free anything and no provisions are made
659 * to make it try harder (see the inside for failure modes)
660 * 3. it only ever looks at negative entries.
661 */
662 lnumcache = atomic_fetchadd_long(&numcache, 1) + 1;
663 if (cache_neg_evict_cond(lnumcache)) {
664 lnumcache = atomic_load_long(&numcache);
665 }
666 if (__predict_false(lnumcache >= ncsize)) {
667 atomic_subtract_long(&numcache, 1);
668 counter_u64_add(numdrops, 1);
669 return (NULL);
670 }
671 return (cache_alloc_uma(len, ts));
672}
673
674static void
675cache_free(struct namecache *ncp)

Callers 1

cache_enter_timeFunction · 0.70

Calls 5

cache_neg_evict_condFunction · 0.85
atomic_subtract_longFunction · 0.85
cache_alloc_umaFunction · 0.85
atomic_fetchadd_longFunction · 0.50
counter_u64_addFunction · 0.50

Tested by

no test coverage detected