From patchwork Thu Nov 22 10:12:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 10693855 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DD2B513BF for ; Thu, 22 Nov 2018 10:13:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CD6E42CA74 for ; Thu, 22 Nov 2018 10:13:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C12F32CA8E; Thu, 22 Nov 2018 10:13:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 59AE62CA74 for ; Thu, 22 Nov 2018 10:13:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 84BAA6B2B0B; Thu, 22 Nov 2018 05:13:09 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 7FA806B2B0C; Thu, 22 Nov 2018 05:13:09 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 710BC6B2B0D; Thu, 22 Nov 2018 05:13:09 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) by kanga.kvack.org (Postfix) with ESMTP id 31D0F6B2B0B for ; Thu, 22 Nov 2018 05:13:09 -0500 (EST) Received: by mail-pg1-f199.google.com with SMTP id s22so2238151pgv.8 for ; Thu, 22 Nov 2018 02:13:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=osFOd6JvE9aSX31xUkvAVMQH0c+F0ZVkxSXH6n6zomE=; b=kWIPSZc/OjSZ9T3H3ZDBSos9rFFROQuvKnmzOJBTabjPH8vJTqMHgyacXh0xrhSwGr kkxF3D4grQbltscnGKG0HKpeXwBojZKANNw0CxsxmeUGm5MkwyFU5lEgGSvuh1GIH/Ja dMc3uFMZ/lTsgCI87k+UbtOXBpaZhKrJpc8jxtszqUZifkbWBPJr2GK8f33Naak7xDOY r8Yhm7GPHIwWH9ge4/yeZf40iYZL6Xo/cxz/N3uOD7UD2yBYglpHVWNe/9Jis1AFq1kF ZrZASLcQsyH5yxT84ZcTadlSrwAKeSYcY5fl/dEJlXdymjkZKWWYBnoh/qh2EgnM4y6G PGQA== X-Gm-Message-State: AA+aEWYgwC5kLD5P0g3O4O0lHDi8Ezxb2mvX+yGHTEzpZzgO9WknvvWb SrntI8HUIvTnVGUFsAP6I+i2QWbl7bSXLlLS1fIRGjdjcHrcbg8CvnYuUkKHYz7dioYiypYhQsx FOROPTB2Gh9dxPSPZhFy4iyF4QrGs1dqZVEONQLUtCJP6uoNpx8NX2N4mPREBsmBjyhCEgEkL6d h4ZfMgsQuTWQRq6NWhUZ7fue5/ZTkiOjjqLUKPESfQQvE2DF0Fmbk7aQmkE2MiE2C+ONz+ZBu5p 6wNZpo1L9yXEaeNJDfcft+mSfkAUH9IVfOJFj6h8hEA8pUXB9MrxkydmjMFHT98oPe0ipeoa2cw r4V5uT3cQuVeY7CH7vhkRK+7CFacq2QcrDBxiFnPVPrG+lC5//YzFeul4MdNVtMX2zUC07oxBZJ w X-Received: by 2002:a63:77ce:: with SMTP id s197mr9377402pgc.89.1542881588791; Thu, 22 Nov 2018 02:13:08 -0800 (PST) X-Received: by 2002:a63:77ce:: with SMTP id s197mr9377354pgc.89.1542881587961; Thu, 22 Nov 2018 02:13:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542881587; cv=none; d=google.com; s=arc-20160816; b=f3ifbG78PGOsNdOps9Sf+5gUoBlhZ9z6nuZmsRYlIB1RkKOaJCmqisUg10xCnmOzNb 3APb9MygA05AOdEZRtNJsYctDMl1vOArXI4ceSmwCxJqtwxw3nz8L9Etv5k6qjDqBmkJ r8xs6oumeMzsn0n2svPh18nF517r2FpQf/FLOQq2Nb09BwkrIhkOoCywXmHLuIjMDheo FIvkKMlx8wbvPx5cC0cjaXPlp+yYrkx8RPf6Yue/xL1ZnSfA6lwGY5fArwqZGGjutBAg efi4+nFDwqERr7jg94k0SiOAtRrxepcJY8tv/cPWWkUFS/iPT+09Bs/AIry0xVK/I78H AWFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=osFOd6JvE9aSX31xUkvAVMQH0c+F0ZVkxSXH6n6zomE=; b=tgEZ5tidpknl3ji7Q9ZVbASRDj4T14Zg0lBiAorDt3BaUiBbxwbxSx/LRiSi9/MBMB LMhj/7+WSURZU6FtB+R3Mnlm+e07o3okJ1T8dy+bO2H37RGb1wxu/z5vboExvCJ61mD+ yVw7CydMEvdIht1nk274YV3Tyr5NiL00Mjn5xitQsdB0Xt8iOugkdFf2ZJFbdfkM9gCM SIv5HFcZHv0hDsQdnMS2WMpBB2sG+4VdUO+yJhvSAMqVpAbqgAaujxNTqxUqGJl3XPbP 6tRCgCEVgcXg0F3Plg7IEAIKkdoA7FS7ytW+ZQWRlt0NCuX5oR/nyQctVjxxKmCBrL27 jFBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=bf0+pEqI; spf=pass (google.com: domain of richard.weiyang@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id g5sor16891686pgl.1.2018.11.22.02.13.07 for (Google Transport Security); Thu, 22 Nov 2018 02:13:07 -0800 (PST) Received-SPF: pass (google.com: domain of richard.weiyang@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=bf0+pEqI; spf=pass (google.com: domain of richard.weiyang@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=osFOd6JvE9aSX31xUkvAVMQH0c+F0ZVkxSXH6n6zomE=; b=bf0+pEqIGNlEetxQ8p2+jJm3lslB/v2jyc1DizaMTk9j7VQi9x3PbDOi+/GQv7vf30 WRC9XYZV38hluuGabBI81gx5VuFnT+/2dtmfRucWK8eQMNf5H0uxZBf/rwTiwi4tzDfa Mb+L8h2D1v5S4ZxZ5jQ8PGH3IUy1LtNjctcxjWwAYLGs1UbAqo0fP13j1FOzZ+eSi9tv o5quETZdobthB2A/2MIhe9F7OPsko+uC5rN6lSPOXxPd5XYRzwU65Rk8HWbyRibnZwZF sY1q3uvFBoJzeX1TX/FVgno9UrV8FZHlLAadsbqYF4z2sri7ltnPC0FPp2IgwuAmdN/H 7rtQ== X-Google-Smtp-Source: AFSGD/XbE3ycWBJKWRERANthIOZko0tdt5+LCkSMJeQnkLb0WUkAc4ks5aYpU+ggw/z6v6tKNlfn9Q== X-Received: by 2002:a63:9a09:: with SMTP id o9mr9102177pge.94.1542881587636; Thu, 22 Nov 2018 02:13:07 -0800 (PST) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id z14sm37387731pgv.47.2018.11.22.02.13.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Nov 2018 02:13:07 -0800 (PST) From: Wei Yang To: mhocko@suse.com, osalvador@suse.de Cc: akpm@linux-foundation.org, linux-mm@kvack.org, Wei Yang Subject: [PATCH v2] mm, hotplug: move init_currently_empty_zone() under zone_span_lock protection Date: Thu, 22 Nov 2018 18:12:41 +0800 Message-Id: <20181122101241.7965-1-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20181120014822.27968-1-richard.weiyang@gmail.com> References: <20181120014822.27968-1-richard.weiyang@gmail.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP During online_pages phase, pgdat->nr_zones will be updated in case this zone is empty. Currently the online_pages phase is protected by the global lock mem_hotplug_begin(), which ensures there is no contention during the update of nr_zones. But this global lock introduces scalability issues. This patch is a preparation for removing the global lock during online_pages phase. Also this patch changes the documentation of node_size_lock to include the protectioin of nr_zones. Signed-off-by: Wei Yang Acked-by: Michal Hocko Reviewed-by: Oscar Salvador --- v2: * commit log changes * modify the code in move_pfn_range_to_zone() instead of in init_currently_empty_zone() * documentation change --- include/linux/mmzone.h | 7 ++++--- mm/memory_hotplug.c | 5 ++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 68d7b558924b..1bb749bee284 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -636,9 +636,10 @@ typedef struct pglist_data { #endif #if defined(CONFIG_MEMORY_HOTPLUG) || defined(CONFIG_DEFERRED_STRUCT_PAGE_INIT) /* - * Must be held any time you expect node_start_pfn, node_present_pages - * or node_spanned_pages stay constant. Holding this will also - * guarantee that any pfn_valid() stays that way. + * Must be held any time you expect node_start_pfn, + * node_present_pages, node_spanned_pages or nr_zones stay constant. + * Holding this will also guarantee that any pfn_valid() stays that + * way. * * pgdat_resize_lock() and pgdat_resize_unlock() are provided to * manipulate node_size_lock without checking for CONFIG_MEMORY_HOTPLUG diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 61972da38d93..f626e7e5f57b 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -742,14 +742,13 @@ void __ref move_pfn_range_to_zone(struct zone *zone, unsigned long start_pfn, int nid = pgdat->node_id; unsigned long flags; - if (zone_is_empty(zone)) - init_currently_empty_zone(zone, start_pfn, nr_pages); - clear_zone_contiguous(zone); /* TODO Huh pgdat is irqsave while zone is not. It used to be like that before */ pgdat_resize_lock(pgdat, &flags); zone_span_writelock(zone); + if (zone_is_empty(zone)) + init_currently_empty_zone(zone, start_pfn, nr_pages); resize_zone_range(zone, start_pfn, nr_pages); zone_span_writeunlock(zone); resize_pgdat_range(pgdat, start_pfn, nr_pages);