From patchwork Fri Nov 30 06:58:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 10705821 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 16CA11057 for ; Fri, 30 Nov 2018 06:59:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0627F2FA8D for ; Fri, 30 Nov 2018 06:59:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EDF442FAA9; Fri, 30 Nov 2018 06:59: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 760022FA8D for ; Fri, 30 Nov 2018 06:59:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0DA326B56E3; Fri, 30 Nov 2018 01:59:09 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 088786B56E4; Fri, 30 Nov 2018 01:59: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 EBAE26B56E5; Fri, 30 Nov 2018 01:59:08 -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 AD1316B56E3 for ; Fri, 30 Nov 2018 01:59:08 -0500 (EST) Received: by mail-pg1-f199.google.com with SMTP id a2so2903376pgt.11 for ; Thu, 29 Nov 2018 22:59:08 -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=roosg87zGMcPfp+hCmgxvfCAaKYutiqkIorb7mdiaSw=; b=ict3AazM2LhLqPYvh7SXy3DJYPZ1JE0vYlmEmxNIRqbEj4iNZYlwedlGAbf1e6NCV1 XamO7WWQK5tTmMnIwC+la5Dn77gQyvjLimn3pUO8c7L3NQoTuKB0L1S21uXo5v/huI7h TXl/KrvKw0/LwFR5zO8zGvYfLCwRhfYK06SATdJRADw3wThcsry0q4XsmWNwS6uLbjku nVzpx+8Fw2dl2uXCv00gEQF1WRvmsIGFBdNr85Fs6+yB1sK2C5kXNpkdm5VDh2dm5A5Q LAywIE9LIe8y2G6Xe+4E7HiJbST3QBK6pwLYlR7ip4Lfx78SUKOv72EdKCJHw6XLdXig y27w== X-Gm-Message-State: AA+aEWYDLTs2SUDZKYoK4+oLnGeXiRzJSj/nzAFlOXzYf9GeTKy8Wj+6 qvVaSoEffRLmbMqe8M4jPtNnFhmEW+6slmR7dawkvnY9WxlIQmBwW49EcpPhkFEfUuljHVMlyrv XBsfd1+FJyK+6BvN5XsM+D6UYe/FUxDVchsu+7ho7XlvQE6AkzHtOfKSOHiLE6ik+39sukM8zto 3GPFCERtEhe9S2a6BbTvXaGGT1hAdjcodEUWJ8gBJk/jGFmY3cNHs+JKhzoOtb0usZWEqVBqDeR KiK5wWjbVI9cpTJgiPBPUirYkYkq1xzeJeexnuVmS+Xwded0rZyajKdAAINZcv2yNpDpeUH0g+8 aBPfo6sIDv3PC5wSjr2cSrt4EkyspZZv/GGaVVHj2XJzpGvwzhSnt/LOQIieKHE8k/QYvnFkOMf h X-Received: by 2002:a62:444b:: with SMTP id r72mr4569170pfa.184.1543561148280; Thu, 29 Nov 2018 22:59:08 -0800 (PST) X-Received: by 2002:a62:444b:: with SMTP id r72mr4569135pfa.184.1543561147300; Thu, 29 Nov 2018 22:59:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543561147; cv=none; d=google.com; s=arc-20160816; b=nN2jI1Xi+TH3kKUrc86ck/hU8pnlOPxvP+LhTPmMhAyZ8Cpulc9bpF6FwWoYHygs1B 8S8dBvu4901nMA6zLo8O4MFxyTH4paosYPTtBI1DUH10H3UEJ+zQdJu4TfWw3Uily3iM ZLJEHKtVCaMu+3nnNI3cOOaIefd5ZxMU39HY+UiOK/h6EDqpO2rus6F8qKNZ6+Rb7SUO St3tw73JQPko8TbRFxNLjVghEkDJm9Vo1RYIGph858n09dYFFau5rleJfJ5WU+p5nSu3 1GOlqCcaQCRwDrPi5yukphS0zjCO/YN6YtR9g7NE/biHRuDrmn0Fqtm4xPLpOVU3FsTc D5SQ== 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=roosg87zGMcPfp+hCmgxvfCAaKYutiqkIorb7mdiaSw=; b=No4t8F79Zh30Cyi+igCV241sT4hTRUnb4L7QvAfIT1viKuPnkgYPPF+axrXHmXCxnB aap3PDrQhzCE10Zr0gIpgTJDej2NhPz/qmIHXzsWii7dp4W/zLJzlUZeK7X02wZibOns bjgvfaf8gAIOHfDr6qeoK8W0JEvquQHeqnAf6+BLuJrB8+OYFsKhmk8520dD5Wo+oD1A RRXX7rDVEvIQTd1omDh0N2Z/UfuB+PCh8T6kay+LGHc44Neccv044f1bxICW0llgnERN WTPjLo2c/jTncNe2lT1jB/mzoAlxDePiUkkjU6eMwUANFBCk7Y2EmyTSS+vQZ1aR3Hrp IbYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=gskYHwkf; 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 x21-v6sor5716000pln.20.2018.11.29.22.59.07 for (Google Transport Security); Thu, 29 Nov 2018 22:59: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=gskYHwkf; 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=roosg87zGMcPfp+hCmgxvfCAaKYutiqkIorb7mdiaSw=; b=gskYHwkf+8GO2A1io5n/DMtGEQxwfSdCgUY5KMitu7Ppi9u7PFeXQTirNuEQz0qpW4 MHe83eeswFibzhu1Yt8woNCvnwjBVbyUwFy9pUUqoqKBcxPibG0fgin3AVcHKC48/sP5 YlyvdwZy1Z4pprmZIMnt/wh/v5Scf23rHwo8Dlj+UNOEWjBGzLIld4EfcJgr/A9IeXof elt0VwdZeh0f3qQh5Cgyl7eRXgtQZUHlV1Ui/Hnd8/JXfYyaqyZWHUmX1QkfQRa4cYXD jODXgTJYxEhGxq1kJZpfWo3Gsctm0r7ABVlV1WjXe3GGe+xOW09+uxOj2YZBdHnf1Jyt eTeg== X-Google-Smtp-Source: AFSGD/U1PLo+TXH30PZ0U4e7OdCZ1HUZR5HMkNH3+w6OyXF56iG4SO8s7JKyaqDBNVyPSCQru7Z/Ug== X-Received: by 2002:a17:902:654a:: with SMTP id d10mr4473646pln.324.1543561146827; Thu, 29 Nov 2018 22:59:06 -0800 (PST) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id x26sm5160752pfn.50.2018.11.29.22.59.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 22:59:06 -0800 (PST) From: Wei Yang To: mhocko@suse.com, osalvador@suse.de, david@redhat.com Cc: akpm@linux-foundation.org, linux-mm@kvack.org, Wei Yang Subject: [PATCH v3] mm, hotplug: move init_currently_empty_zone() under zone_span_lock protection Date: Fri, 30 Nov 2018 14:58:47 +0800 Message-Id: <20181130065847.13714-1-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20181122101241.7965-1-richard.weiyang@gmail.com> References: <20181122101241.7965-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. The patch moves init_currently_empty_zone under both zone_span_writelock and pgdat_resize_lock because both the pgdat state is changed (nr_zones) and the zone's start_pfn. 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 CC: David Hildenbrand --- David, I may not catch you exact comment on the code or changelog. If I missed, just let me know. --- v3: * slightly modify the last paragraph of changelog based on Michal's comment v2: * commit log changes * modify the code in move_pfn_range_to_zone() instead of in init_currently_empty_zone() * pgdat_resize_lock 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 3d0c472438d2..37d9c5c3faa6 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -635,9 +635,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);