Move clearing of objects outside IRQ disabled section,
to minimize time spend with local IRQs off.

Signed-off-by: Jesper Dangaard Brouer <bro...@redhat.com>
---
 mm/slub.c |   11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/mm/slub.c b/mm/slub.c
index d10de5a33c03..26f64005a347 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -2781,13 +2781,18 @@ bool kmem_cache_alloc_bulk(struct kmem_cache *s, gfp_t 
flags, size_t size,
 
                c->freelist = get_freepointer(s, object);
                p[i] = object;
-
-               if (unlikely(flags & __GFP_ZERO))
-                       memset(object, 0, s->object_size);
        }
        c->tid = next_tid(c->tid);
        local_irq_enable();
 
+       /* Clear memory outside IRQ disabled fastpath loop */
+       if (unlikely(flags & __GFP_ZERO)) {
+               int j;
+
+               for (j = 0; j < i; j++)
+                       memset(p[j], 0, s->object_size);
+       }
+
        /* Fallback to single elem alloc */
        for (; i < size; i++) {
                void *x = p[i] = kmem_cache_alloc(s, flags);

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to