return 0;
}
-static void sheaf_flush_unused(struct kmem_cache *s, struct slab_sheaf *sheaf);
-
-static struct slab_sheaf *alloc_full_sheaf(struct kmem_cache *s, gfp_t gfp)
-{
- struct slab_sheaf *sheaf = alloc_empty_sheaf(s, gfp);
-
- if (!sheaf)
- return NULL;
-
- if (refill_sheaf(s, sheaf, gfp | __GFP_NOMEMALLOC | __GFP_NOWARN)) {
- sheaf_flush_unused(s, sheaf);
- free_empty_sheaf(s, sheaf);
- return NULL;
- }
-
- return sheaf;
-}
-
/*
* Maximum number of objects freed during a single flush of main pcs sheaf.
* Translates directly to an on-stack array size.
if (!allow_spin)
return NULL;
- if (empty) {
- if (!refill_sheaf(s, empty, gfp | __GFP_NOMEMALLOC | __GFP_NOWARN)) {
- full = empty;
- } else {
- /*
- * we must be very low on memory so don't bother
- * with the barn
- */
- sheaf_flush_unused(s, empty);
- free_empty_sheaf(s, empty);
- }
- } else {
- full = alloc_full_sheaf(s, gfp);
+ if (!empty) {
+ empty = alloc_empty_sheaf(s, gfp);
+ if (!empty)
+ return NULL;
}
- if (!full)
+ if (refill_sheaf(s, empty, gfp | __GFP_NOMEMALLOC | __GFP_NOWARN)) {
+ /*
+ * we must be very low on memory so don't bother
+ * with the barn
+ */
+ sheaf_flush_unused(s, empty);
+ free_empty_sheaf(s, empty);
+
return NULL;
+ }
+
+ full = empty;
+ empty = NULL;
if (!local_trylock(&s->cpu_sheaves->lock))
goto barn_put;
pcs = this_cpu_ptr(s->cpu_sheaves);
/*
- * If we are returning empty sheaf, we either got it from the
- * barn or had to allocate one. If we are returning a full
- * sheaf, it's due to racing or being migrated to a different
- * cpu. Breaching the barn's sheaf limits should be thus rare
- * enough so just ignore them to simplify the recovery.
+ * If we put any empty or full sheaf to the barn below, it's due to
+ * racing or being migrated to a different cpu. Breaching the barn's
+ * sheaf limits should be thus rare enough so just ignore them to
+ * simplify the recovery.
*/
if (pcs->main->size == 0) {