lkml.org 
[lkml]   [2021]   [Apr]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH v8 1/8] drivers/base/memory: Introduce memory_block_{online,offline}
    Date
    This is a preparatory patch that introduces two new functions:
    memory_block_online() and memory_block_offline().

    For now, these functions will only call online_pages() and offline_pages()
    respectively, but they will be later in charge of preparing the vmemmap
    pages, carrying out the initialization and proper accounting of such
    pages.

    Since memory_block struct contains all the information, pass this struct
    down the chain till the end functions.

    Signed-off-by: Oscar Salvador <osalvador@suse.de>
    Reviewed-by: David Hildenbrand <david@redhat.com>
    ---
    drivers/base/memory.c | 33 +++++++++++++++++++++------------
    1 file changed, 21 insertions(+), 12 deletions(-)

    diff --git a/drivers/base/memory.c b/drivers/base/memory.c
    index f35298425575..f209925a5d4e 100644
    --- a/drivers/base/memory.c
    +++ b/drivers/base/memory.c
    @@ -169,30 +169,41 @@ int memory_notify(unsigned long val, void *v)
    return blocking_notifier_call_chain(&memory_chain, val, v);
    }

    +static int memory_block_online(struct memory_block *mem)
    +{
    + unsigned long start_pfn = section_nr_to_pfn(mem->start_section_nr);
    + unsigned long nr_pages = PAGES_PER_SECTION * sections_per_block;
    +
    + return online_pages(start_pfn, nr_pages, mem->online_type, mem->nid);
    +}
    +
    +static int memory_block_offline(struct memory_block *mem)
    +{
    + unsigned long start_pfn = section_nr_to_pfn(mem->start_section_nr);
    + unsigned long nr_pages = PAGES_PER_SECTION * sections_per_block;
    +
    + return offline_pages(start_pfn, nr_pages);
    +}
    +
    /*
    * MEMORY_HOTPLUG depends on SPARSEMEM in mm/Kconfig, so it is
    * OK to have direct references to sparsemem variables in here.
    */
    static int
    -memory_block_action(unsigned long start_section_nr, unsigned long action,
    - int online_type, int nid)
    +memory_block_action(struct memory_block *mem, unsigned long action)
    {
    - unsigned long start_pfn;
    - unsigned long nr_pages = PAGES_PER_SECTION * sections_per_block;
    int ret;

    - start_pfn = section_nr_to_pfn(start_section_nr);
    -
    switch (action) {
    case MEM_ONLINE:
    - ret = online_pages(start_pfn, nr_pages, online_type, nid);
    + ret = memory_block_online(mem);
    break;
    case MEM_OFFLINE:
    - ret = offline_pages(start_pfn, nr_pages);
    + ret = memory_block_offline(mem);
    break;
    default:
    WARN(1, KERN_WARNING "%s(%ld, %ld) unknown action: "
    - "%ld\n", __func__, start_section_nr, action, action);
    + "%ld\n", __func__, mem->start_section_nr, action, action);
    ret = -EINVAL;
    }

    @@ -210,9 +221,7 @@ static int memory_block_change_state(struct memory_block *mem,
    if (to_state == MEM_OFFLINE)
    mem->state = MEM_GOING_OFFLINE;

    - ret = memory_block_action(mem->start_section_nr, to_state,
    - mem->online_type, mem->nid);
    -
    + ret = memory_block_action(mem, to_state);
    mem->state = ret ? from_state_req : to_state;

    return ret;
    --
    2.16.3
    \
     
     \ /
      Last update: 2021-04-16 12:22    [W:4.565 / U:0.144 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site