lkml.org 
[lkml]   [2011]   [May]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[slubllv4 12/16] slub: Avoid disabling interrupts in free slowpath
    Disabling interrupts can be avoided now. However, list operation still require
    disabling interrupts since allocations can occur from interrupt
    contexts and there is no way to perform atomic list operations. So
    acquire the list lock opportunistically if there is a chance
    that list operations would be needed. This may result in
    needless synchronizations but allows the avoidance of synchronization
    in the majority of the cases.

    Dropping interrupt handling significantly simplifies the slowpath.

    Signed-off-by: Christoph Lameter <cl@linux.com>

    ---
    mm/slub.c | 16 +++++-----------
    1 file changed, 5 insertions(+), 11 deletions(-)

    Index: linux-2.6/mm/slub.c
    ===================================================================
    --- linux-2.6.orig/mm/slub.c 2011-05-06 12:55:26.000000000 -0500
    +++ linux-2.6/mm/slub.c 2011-05-06 12:55:42.000000000 -0500
    @@ -2190,11 +2190,10 @@ static void __slab_free(struct kmem_cach
    struct kmem_cache_node *n = NULL;
    unsigned long flags;

    - local_irq_save(flags);
    stat(s, FREE_SLOWPATH);

    if (kmem_cache_debug(s) && !free_debug_processing(s, page, x, addr))
    - goto out_unlock;
    + return;

    do {
    prior = page->freelist;
    @@ -2213,7 +2212,7 @@ static void __slab_free(struct kmem_cach
    * Otherwise the list_lock will synchronize with
    * other processors updating the list of slabs.
    */
    - spin_lock(&n->list_lock);
    + spin_lock_irqsave(&n->list_lock, flags);
    }
    inuse = new.inuse;

    @@ -2229,7 +2228,7 @@ static void __slab_free(struct kmem_cach
    */
    if (was_frozen)
    stat(s, FREE_FROZEN);
    - goto out_unlock;
    + return;
    }

    /*
    @@ -2252,11 +2251,7 @@ static void __slab_free(struct kmem_cach
    stat(s, FREE_ADD_PARTIAL);
    }
    }
    -
    - spin_unlock(&n->list_lock);
    -
    -out_unlock:
    - local_irq_restore(flags);
    + spin_unlock_irqrestore(&n->list_lock, flags);
    return;

    slab_empty:
    @@ -2268,8 +2263,7 @@ slab_empty:
    stat(s, FREE_REMOVE_PARTIAL);
    }

    - spin_unlock(&n->list_lock);
    - local_irq_restore(flags);
    + spin_unlock_irqrestore(&n->list_lock, flags);
    stat(s, FREE_SLAB);
    discard_slab(s, page);
    }


    \
     
     \ /
      Last update: 2011-05-06 20:11    [W:0.027 / U:30.808 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site