On Fri, 4 Dec 2015 11:17:02 -0600 (CST) Christoph Lameter <cl@xxxxxxxxx> wrote: > On Thu, 3 Dec 2015, Jesper Dangaard Brouer wrote: > > > +void kmem_cache_free_bulk(struct kmem_cache *orig_s, size_t size, void **p) > > orig_s? Thats strange > > > +{ > > + struct kmem_cache *s; > > s? The "s" comes from the slub.c code uses "struct kmem_cache *s" everywhere. > > + size_t i; > > + > > + local_irq_disable(); > > + for (i = 0; i < size; i++) { > > + void *objp = p[i]; > > + > > + s = cache_from_obj(orig_s, objp); > > Does this support freeing objects from a set of different caches? This is for supporting memcg (CONFIG_MEMCG_KMEM). Quoting from commit 033745189b1b ("slub: add missing kmem cgroup support to kmem_cache_free_bulk"): Incoming bulk free objects can belong to different kmem cgroups, and object free call can happen at a later point outside memcg context. Thus, we need to keep the orig kmem_cache, to correctly verify if a memcg object match against its "root_cache" (s->memcg_params.root_cache). > > + > > + debug_check_no_locks_freed(objp, s->object_size); > > + if (!(s->flags & SLAB_DEBUG_OBJECTS)) > > + debug_check_no_obj_freed(objp, s->object_size); > > + > > + __cache_free(s, objp, _RET_IP_); > > The function could be further optimized if you take the code from > __cache_free() and move stuff outside of the loop. The alien cache check > f.e. and the Pfmemalloc checking may be moved out. The call to > virt_to_head page may also be avoided if the objects are on the same > page as the last. So you may be able to function calls for the > fastpath in the inner loop which may accelerate frees significantly. Interesting! Maybe we can do a followup patch to pullout last optimization's. Right now I'm mostly interested in correctness and clean code. And we are already looking at a 80% speedup with these patches ;-) -- Best regards, Jesper Dangaard Brouer MSc.CS, Principal Kernel Engineer at Red Hat Author of http://www.iptv-analyzer.org LinkedIn: http://www.linkedin.com/in/brouer -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@xxxxxxxxx. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@xxxxxxxxx"> email@xxxxxxxxx </a>