lkml.org 
[lkml]   [2009]   [Mar]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 20/35] Use a pre-calculated value for num_online_nodes()
    Date
    num_online_nodes() is called by the page allocator to decide whether the
    zonelist needs to be filtered based on cpusets or the zonelist cache.
    This is actually a heavy function and touches a number of cache lines.
    This patch stores the number of online nodes at boot time and when
    nodes get onlined and offlined.

    Signed-off-by: Mel Gorman <mel@csn.ul.ie>
    ---
    include/linux/nodemask.h | 16 ++++++++++++++--
    mm/page_alloc.c | 6 ++++--
    2 files changed, 18 insertions(+), 4 deletions(-)

    diff --git a/include/linux/nodemask.h b/include/linux/nodemask.h
    index 848025c..4749e30 100644
    --- a/include/linux/nodemask.h
    +++ b/include/linux/nodemask.h
    @@ -449,13 +449,25 @@ static inline int num_node_state(enum node_states state)
    node; \
    })

    +/* Recorded value for num_online_nodes() */
    +extern int static_num_online_nodes;
    +
    #define num_online_nodes() num_node_state(N_ONLINE)
    #define num_possible_nodes() num_node_state(N_POSSIBLE)
    #define node_online(node) node_state((node), N_ONLINE)
    #define node_possible(node) node_state((node), N_POSSIBLE)

    -#define node_set_online(node) node_set_state((node), N_ONLINE)
    -#define node_set_offline(node) node_clear_state((node), N_ONLINE)
    +static inline void node_set_online(int nid)
    +{
    + node_set_state(nid, N_ONLINE);
    + static_num_online_nodes = num_node_state(N_ONLINE);
    +}
    +
    +static inline void node_set_offline(int nid)
    +{
    + node_clear_state(nid, N_ONLINE);
    + static_num_online_nodes = num_node_state(N_ONLINE);
    +}

    #define for_each_node(node) for_each_node_state(node, N_POSSIBLE)
    #define for_each_online_node(node) for_each_node_state(node, N_ONLINE)
    diff --git a/mm/page_alloc.c b/mm/page_alloc.c
    index e620c91..d297780 100644
    --- a/mm/page_alloc.c
    +++ b/mm/page_alloc.c
    @@ -70,6 +70,7 @@ EXPORT_SYMBOL(node_states);
    unsigned long totalram_pages __read_mostly;
    unsigned long totalreserve_pages __read_mostly;
    unsigned long highest_memmap_pfn __read_mostly;
    +int static_num_online_nodes __read_mostly;
    int percpu_pagelist_fraction;

    #ifdef CONFIG_HUGETLB_PAGE_SIZE_VARIABLE
    @@ -1442,7 +1443,7 @@ get_page_from_freelist(gfp_t gfp_mask, nodemask_t *nodemask, unsigned int order,
    /* Determine in advance if the zonelist needs filtering */
    if ((alloc_flags & ALLOC_CPUSET) && unlikely(number_of_cpusets > 1))
    zonelist_filter = 1;
    - if (num_online_nodes() > 1)
    + if (static_num_online_nodes > 1)
    zonelist_filter = 1;

    zonelist_scan:
    @@ -1488,7 +1489,7 @@ this_zone_full:
    zlc_mark_zone_full(zonelist, z);
    try_next_zone:
    if (NUMA_BUILD && zonelist_filter) {
    - if (!did_zlc_setup && num_online_nodes() > 1) {
    + if (!did_zlc_setup && static_num_online_nodes > 1) {
    /*
    * do zlc_setup after the first zone is tried
    * but only if there are multiple nodes to make
    @@ -2645,6 +2646,7 @@ void build_all_zonelists(void)
    else
    page_group_by_mobility_disabled = 0;

    + static_num_online_nodes = num_node_state(N_ONLINE);
    printk("Built %i zonelists in %s order, mobility grouping %s. "
    "Total pages: %ld\n",
    num_online_nodes(),
    --
    1.5.6.5


    \
     
     \ /
      Last update: 2009-03-16 10:55    [W:3.312 / U:0.376 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site