lkml.org 
[lkml]   [2010]   [Aug]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[PATCH 06/20] mm: Use refcounts for page_lock_anon_vma()
    Convert page_lock_anon_vma() over to use refcounts. This is
    done for each of convertion of anon_vma from spinlock to mutex.

    Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
    ---
    mm/rmap.c | 23 +++++++++++++++++------
    1 file changed, 17 insertions(+), 6 deletions(-)

    Index: linux-2.6/mm/rmap.c
    ===================================================================
    --- linux-2.6.orig/mm/rmap.c
    +++ linux-2.6/mm/rmap.c
    @@ -332,9 +332,9 @@ void __init anon_vma_init(void)
    * that the anon_vma pointer from page->mapping is valid if there is a
    * mapcount, we can dereference the anon_vma after observing those.
    */
    -struct anon_vma *page_lock_anon_vma(struct page *page)
    +struct anon_vma *page_get_anon_vma(struct page *page)
    {
    - struct anon_vma *anon_vma;
    + struct anon_vma *anon_vma = NULL;
    unsigned long anon_mapping;

    rcu_read_lock();
    @@ -345,17 +345,28 @@ struct anon_vma *page_lock_anon_vma(stru
    goto out;

    anon_vma = (struct anon_vma *) (anon_mapping - PAGE_MAPPING_ANON);
    - anon_vma_lock(anon_vma);
    - return anon_vma;
    + if (!atomic_inc_not_zero(&anon_vma->refcount))
    + anon_vma = NULL;
    out:
    rcu_read_unlock();
    - return NULL;
    +
    + return anon_vma;
    +}
    +
    +struct anon_vma *page_lock_anon_vma(struct page *page)
    +{
    + struct anon_vma *anon_vma = page_get_anon_vma(page);
    +
    + if (anon_vma)
    + anon_vma_lock(anon_vma);
    +
    + return anon_vma;
    }

    void page_unlock_anon_vma(struct anon_vma *anon_vma)
    {
    anon_vma_unlock(anon_vma);
    - rcu_read_unlock();
    + put_anon_vma(anon_vma);
    }

    /*



    \
     
     \ /
      Last update: 2010-08-28 16:33    [W:0.043 / U:0.176 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site