lkml.org 
[lkml]   [2008]   [Mar]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH] [7/18] Abstract out the NUMA node round robin code into a separate function
    Date

    Need this as a separate function for a future patch.

    No behaviour change.

    Signed-off-by: Andi Kleen <ak@suse.de>

    ---
    mm/hugetlb.c | 37 ++++++++++++++++++++++---------------
    1 file changed, 22 insertions(+), 15 deletions(-)

    Index: linux/mm/hugetlb.c
    ===================================================================
    --- linux.orig/mm/hugetlb.c
    +++ linux/mm/hugetlb.c
    @@ -219,6 +219,27 @@ static struct page *alloc_fresh_huge_pag
    return page;
    }

    +/*
    + * Use a helper variable to find the next node and then
    + * copy it back to hugetlb_next_nid afterwards:
    + * otherwise there's a window in which a racer might
    + * pass invalid nid MAX_NUMNODES to alloc_pages_node.
    + * But we don't need to use a spin_lock here: it really
    + * doesn't matter if occasionally a racer chooses the
    + * same nid as we do. Move nid forward in the mask even
    + * if we just successfully allocated a hugepage so that
    + * the next caller gets hugepages on the next node.
    + */
    +static int huge_next_node(struct hstate *h)
    +{
    + int next_nid;
    + next_nid = next_node(h->hugetlb_next_nid, node_online_map);
    + if (next_nid == MAX_NUMNODES)
    + next_nid = first_node(node_online_map);
    + h->hugetlb_next_nid = next_nid;
    + return next_nid;
    +}
    +
    static int alloc_fresh_huge_page(struct hstate *h)
    {
    struct page *page;
    @@ -232,21 +253,7 @@ static int alloc_fresh_huge_page(struct
    page = alloc_fresh_huge_page_node(h, h->hugetlb_next_nid);
    if (page)
    ret = 1;
    - /*
    - * Use a helper variable to find the next node and then
    - * copy it back to hugetlb_next_nid afterwards:
    - * otherwise there's a window in which a racer might
    - * pass invalid nid MAX_NUMNODES to alloc_pages_node.
    - * But we don't need to use a spin_lock here: it really
    - * doesn't matter if occasionally a racer chooses the
    - * same nid as we do. Move nid forward in the mask even
    - * if we just successfully allocated a hugepage so that
    - * the next caller gets hugepages on the next node.
    - */
    - next_nid = next_node(h->hugetlb_next_nid, node_online_map);
    - if (next_nid == MAX_NUMNODES)
    - next_nid = first_node(node_online_map);
    - h->hugetlb_next_nid = next_nid;
    + next_nid = huge_next_node(h);
    } while (!page && h->hugetlb_next_nid != start_nid);

    return ret;

    \
     
     \ /
      Last update: 2008-03-17 03:03    [W:0.023 / U:33.188 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site