From patchwork Fri Sep 21 13:26:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 10610035 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 90814112B for ; Fri, 21 Sep 2018 13:26:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7FEBF2DB18 for ; Fri, 21 Sep 2018 13:26:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7262E2DB1A; Fri, 21 Sep 2018 13:26:55 +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=-2.9 required=2.0 tests=BAYES_00,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 1853B2DB18 for ; Fri, 21 Sep 2018 13:26:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9628F8E0006; Fri, 21 Sep 2018 09:26:50 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 93A0A8E0001; Fri, 21 Sep 2018 09:26:50 -0400 (EDT) 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 82CD08E0006; Fri, 21 Sep 2018 09:26:50 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by kanga.kvack.org (Postfix) with ESMTP id 2562F8E0001 for ; Fri, 21 Sep 2018 09:26:50 -0400 (EDT) Received: by mail-wr1-f70.google.com with SMTP id v6-v6so1368448wrr.20 for ; Fri, 21 Sep 2018 06:26:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=Qxl2mXI3o+wV6JwzDlazHiKHGPEuy6rtVwzXjk1okdE=; b=K05B15M4KIl0aZC6UfhOArTcaHJ8+ctDaDoKGFc0AT2FdXWKbu87dksfZe7KN3NqRu UsCQQHDB8/DWvoVjaf/lr6lbqZwV/nQSHCmELdRBDPcHyiggfoYVdZhQanz3SPxkBM+T RQA1gHS3MtwiteVj5coxEjwhzpuMvkjH/O/sKmv6zkXszOeMjfX4Z+k2I4XEGrcYm4/Q vxZhKJ7CmI+vjbpm3iRya9r9k0I6V5VdBzTIXqRnS3u+kVq4rbM4nQBFGba4/6Z5TakO TpS6zFo2ilBHTqvycjs0pBCR08vjCwKY1MXfnXy1fYplVRTT+84wjUpQEVKODQUbpcdu ZfvA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of osalvador.vilardaga@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=osalvador.vilardaga@gmail.com X-Gm-Message-State: APzg51COFHhmcBtT98w9rN4JLYF856nL0fI+QYcQc/NXdAlSVbN9Cuhg TddEZbdTaLpb9Qrtsd6X3v5SB/q71Mkl0cdsyQ7lWHjFIQQZrjy+kMXIMm/go6afKfJJ6zi3z6F +77zPRuBzLvQ6GMdyJQiINMrSA1X83OXDTmJFTXKHrT8fSOxKtHhcdGWD2gW/KjwsdK808+39Gb aolqfsSgU3UZEALN+9hxJzHYJHghzmOPHGix0J5er1ORmJAiPM7ok1Kmw6PQpqHewVYm7Q1uvmL wXPJgYq/2mNliusOlOX+fijKggkixeWWUeLffZHLdQKz+JbDXDw0PcIx+rEKKxzymDClOdm3/cL NBInIxbAvInZROc5yIsk48LTZVMHeU2QApYNDS/DZ1FP3lsSzGzqQfqg852xxESi23gYi4cudA= = X-Received: by 2002:adf:9d1c:: with SMTP id k28-v6mr39248627wre.104.1537536409620; Fri, 21 Sep 2018 06:26:49 -0700 (PDT) X-Received: by 2002:adf:9d1c:: with SMTP id k28-v6mr39248574wre.104.1537536408861; Fri, 21 Sep 2018 06:26:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537536408; cv=none; d=google.com; s=arc-20160816; b=b1nI57kF9oCfQOgRwobOYSNfDCgXCMdteystiUKBU5vDTa0Emin/8T07RrhXfIcpjx Gj54jNpTlzSMu0TRZv5HPzM+kzEJZsQ0DaJeFiGEWqcLATGrlC/kqcq8Rg7wv+YvjSTl etPHLWMwPXAwTOlX+8/tkFeAWGuvSCe97yKAL1rEETAJJB6LoJGqAfVxsnh+ceKITMQL HY43Hs+DN3if45eive/ihNGp+VTjziUcjFHm/DMf7or6PQctJHxUHXs3uwVpTPJOmAeX dRNJK/gPOSvhCSUCY8we1iDRuD7P4XsdGFAXfbdHYoWDsgkzEBIH+iTOKfADOnorFEob yVhw== 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; bh=Qxl2mXI3o+wV6JwzDlazHiKHGPEuy6rtVwzXjk1okdE=; b=bm2iQ0ilWUFgYD5RN9LA0XSPw0tSOIJtcsGN7pZ5HNuV/dJwC6uXAmPYtLMsmhLSKP OeRrXJVjKYXJZrhvyjffYPkwILbkW35ckJsMyWUDpCS1s8+dQohPxvVZ///n2MeH6EFo rHKPVAEvr1UWcm539tPYmiYoNuiWFNFPdGEKANSL5/b37t//eKvC3W2oGbIvW6I5sUro bUDk5zqZcX3GDaYw+5iOKvEoLaTI6Ott01Do1BpAIxSI0y+46mQWwboZMjcBKz9QJG3j YTHKfStnNCePhkyubS9mrsfHIAMiU5T31GugtshQNDbb3C237pHqFUFPyRVKVsIevfKR koeA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of osalvador.vilardaga@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=osalvador.vilardaga@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 143-v6sor4139853wmb.14.2018.09.21.06.26.48 for (Google Transport Security); Fri, 21 Sep 2018 06:26:48 -0700 (PDT) Received-SPF: pass (google.com: domain of osalvador.vilardaga@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; spf=pass (google.com: domain of osalvador.vilardaga@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=osalvador.vilardaga@gmail.com X-Google-Smtp-Source: ANB0VdYJqGQbcR5DVFKfPLIbcC0Qyje79CqbHhvieO3dVpxWazGjanFWB/C4Azg2y2ezAqVxUyaVHw== X-Received: by 2002:a1c:b5d3:: with SMTP id e202-v6mr7170862wmf.23.1537536401935; Fri, 21 Sep 2018 06:26:41 -0700 (PDT) Received: from techadventures.net (techadventures.net. [62.201.165.239]) by smtp.gmail.com with ESMTPSA id 75-v6sm7858782wml.21.2018.09.21.06.26.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Sep 2018 06:26:41 -0700 (PDT) Received: from d104.suse.de (nat.nue.novell.com [195.135.221.2]) by techadventures.net (Postfix) with ESMTPA id 0DA31125332; Fri, 21 Sep 2018 15:26:40 +0200 (CEST) From: Oscar Salvador To: akpm@linux-foundation.org Cc: mhocko@suse.com, dan.j.williams@intel.com, david@redhat.com, Pavel.Tatashin@microsoft.com, Jonathan.Cameron@huawei.com, yasu.isimatu@gmail.com, malat@debian.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Oscar Salvador Subject: [PATCH v2 1/4] mm/memory_hotplug: Spare unnecessary calls to node_set_state Date: Fri, 21 Sep 2018 15:26:31 +0200 Message-Id: <20180921132634.10103-2-osalvador@techadventures.net> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180921132634.10103-1-osalvador@techadventures.net> References: <20180921132634.10103-1-osalvador@techadventures.net> 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 From: Oscar Salvador In node_states_check_changes_online, we check if the node will have to be set for any of the N_*_MEMORY states after the pages have been onlined. Later on, we perform the activation in node_states_set_node. Currently, in node_states_set_node we set the node to N_MEMORY unconditionally. This means that we call node_set_state for N_MEMORY every time pages go online, but we only need to do it if the node has not yet been set for N_MEMORY. Fix this by checking status_change_nid. Signed-off-by: Oscar Salvador Reviewed-by: Pavel Tatashin --- mm/memory_hotplug.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 38d94b703e9d..63facfc57224 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -753,7 +753,8 @@ static void node_states_set_node(int node, struct memory_notify *arg) if (arg->status_change_nid_high >= 0) node_set_state(node, N_HIGH_MEMORY); - node_set_state(node, N_MEMORY); + if (arg->status_change_nid >= 0) + node_set_state(node, N_MEMORY); } static void __meminit resize_zone_range(struct zone *zone, unsigned long start_pfn, From patchwork Fri Sep 21 13:26:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 10610029 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 CBEAB112B for ; Fri, 21 Sep 2018 13:26:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BB8D62DB18 for ; Fri, 21 Sep 2018 13:26:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AF27B2DB1A; Fri, 21 Sep 2018 13:26:48 +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=-2.9 required=2.0 tests=BAYES_00,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 9968E2DB18 for ; Fri, 21 Sep 2018 13:26:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D0F868E0003; Fri, 21 Sep 2018 09:26:44 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C95668E0001; Fri, 21 Sep 2018 09:26:44 -0400 (EDT) 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 B61978E0003; Fri, 21 Sep 2018 09:26:44 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by kanga.kvack.org (Postfix) with ESMTP id 53F138E0001 for ; Fri, 21 Sep 2018 09:26:44 -0400 (EDT) Received: by mail-wm1-f69.google.com with SMTP id v1-v6so2457655wmh.4 for ; Fri, 21 Sep 2018 06:26:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=0+jHGq6Iwq96rM0u3yCt0rOallYZv8FDz6OCFetpq3Y=; b=PxOxFdwTCFUGFt9XySKsBRrkYl3G/z2eTxq87Lq+d/WVlJWMvLOE7D5cE/eapmOMwn Y0TtoIVHLbetxdTBCBJZK8GWauwFy1/36dYCDo4l173rtZwEMvNhqDiXJ9FWJyLHKBgo DnHA8LDj768jtzLNccqjd6Eb03ZrWg9OmxI2W1M2KsU5b4K6ah/V6l2u8CUALTRwCzgS Pd4Tg0ZTMIJsBvsG3dkuJb7AlqAMQYkjNDVlrT+lVMOucFcYFAQUaCXciop83e48vY6b grTzvagoWjJ+lyYovg6exqT9/CXDU235IRlT7nC0Odu0bwfIrAWRyUIfuMcWKUX+jB8L KzcQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of osalvador.vilardaga@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=osalvador.vilardaga@gmail.com X-Gm-Message-State: APzg51CI+nO0LuZ3p/3CFEk5BMXn/I/vIo4VAa5uFUXvra9bL3UdfIxw puG/hBNX1zQrfypqyWwTK5K03sgnrBjoi2aXAs7x/sR8WhIzMSLTiDB2/tJukM1RfPBGWc9sKEo lZypFxfgUb2B1ITkDB6056/9jIHXNViKpi1ST+LjCSpEyeGmYUzIJ1w0gHMeVRZfFEfLq3yhQd7 FMRRgAItI29gD6zZFlkZ6zTV7sBgwLwANZP/r6I4d3ElNvoL7DM5d+pRSqT8SkNH9ASpRWhfYAI RHAcvaI9alxDsGz43lawZjy9e6oycfayheCJErh2b4dOJuAtCmlF+xRs8lNQsv7Jc/LMqyg8wPj G+Pi5LGUp6OE4UZfcZUMNCSSWQ0VpfNMvwXt1HfDmKs79diUcNRWw098UkuQeXTjkQi58fpu2g= = X-Received: by 2002:adf:b3d7:: with SMTP id x23-v6mr36978907wrd.253.1537536403822; Fri, 21 Sep 2018 06:26:43 -0700 (PDT) X-Received: by 2002:adf:b3d7:: with SMTP id x23-v6mr36978837wrd.253.1537536402831; Fri, 21 Sep 2018 06:26:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537536402; cv=none; d=google.com; s=arc-20160816; b=qpJghbPKJsmPMT9AHi36324K+aFuEqWynqS/mzHqqRT6G8cRbqS8XqMkw5o8JidKFa kE2OuzvSszV9KTpxzaW6k4nMWwiRQiY7FAsE4SzRZVRf45Ao1Or9QNQTSTROh3JqIMyE /k86Tkw367YLkUrbIryIwwQ59t40SHRFNp0kj/IhLJrkToZy8bfiaaF2tVufDMCVkRkx WVG8F+iOiIEucNrkRK9RZJjO9IUwBktfLexT+N4iCoY7rjqQuEawi4CTv3mZ9g/HkNLn /mKjiq/OXeRYdgw58dTQSjUMYRwDfIV2d65GO4de3oLcpk/skWVLmZBlWzNcaIdn6DMH Nkjg== 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; bh=0+jHGq6Iwq96rM0u3yCt0rOallYZv8FDz6OCFetpq3Y=; b=DnxueFUiAL6ZfSfiuNsRPZYsrpU+Uq3TyfORHet7n+uv/bmPN9t1Nz/QWWjwGz7pf7 g3rv4NaUsaBRC97akK8aiTQxDkMSU0mIkZ+g98Jb23JQrMOMf3QhEvakN2ayjoXh0GWR 2BzB+BKe6z0rjf3y6lgaY900cXSXuUUi+YtTcSfJWndwlr4W1yLYaoywl4oaG441Jo+o u7YE/ybNHrXD5DNkIRhUfG12kNklZSevslXp7SIgZeNppaBaSYFFSZOFayDxu8aKkmKa 6AmA3ZtWTmNuZqV+uB5hVZ12T/TZiZmmFy+RCZfIETru68D5eS8sRcFWCCLZrSU25SVy 6Vsg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of osalvador.vilardaga@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=osalvador.vilardaga@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 o6-v6sor4220764wmg.12.2018.09.21.06.26.42 for (Google Transport Security); Fri, 21 Sep 2018 06:26:42 -0700 (PDT) Received-SPF: pass (google.com: domain of osalvador.vilardaga@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; spf=pass (google.com: domain of osalvador.vilardaga@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=osalvador.vilardaga@gmail.com X-Google-Smtp-Source: ACcGV63VnEIdtWdmykAmtjohRoKq43GYZCAWnbD21lKsgOQ0NIOfDFUJEGrdmBu11s3W5JMpAc74/Q== X-Received: by 2002:a1c:148f:: with SMTP id 137-v6mr7024221wmu.61.1537536402509; Fri, 21 Sep 2018 06:26:42 -0700 (PDT) Received: from techadventures.net (techadventures.net. [62.201.165.239]) by smtp.gmail.com with ESMTPSA id x204-v6sm5567205wmg.27.2018.09.21.06.26.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Sep 2018 06:26:41 -0700 (PDT) Received: from d104.suse.de (nat.nue.novell.com [195.135.221.2]) by techadventures.net (Postfix) with ESMTPA id 4F88D125334; Fri, 21 Sep 2018 15:26:40 +0200 (CEST) From: Oscar Salvador To: akpm@linux-foundation.org Cc: mhocko@suse.com, dan.j.williams@intel.com, david@redhat.com, Pavel.Tatashin@microsoft.com, Jonathan.Cameron@huawei.com, yasu.isimatu@gmail.com, malat@debian.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Oscar Salvador Subject: [PATCH v2 2/4] mm/memory_hotplug: Tidy up node_states_clear_node Date: Fri, 21 Sep 2018 15:26:32 +0200 Message-Id: <20180921132634.10103-3-osalvador@techadventures.net> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180921132634.10103-1-osalvador@techadventures.net> References: <20180921132634.10103-1-osalvador@techadventures.net> 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 From: Oscar Salvador node_states_clear has the following if statements: if ((N_MEMORY != N_NORMAL_MEMORY) && (arg->status_change_nid_high >= 0)) ... if ((N_MEMORY != N_HIGH_MEMORY) && (arg->status_change_nid >= 0)) ... N_MEMORY can never be equal to neither N_NORMAL_MEMORY nor N_HIGH_MEMORY. Similar problem was found in [1]. Since this is wrong, let us get rid of it. [1] https://patchwork.kernel.org/patch/10579155/ Signed-off-by: Oscar Salvador Reviewed-by: Pavel Tatashin --- mm/memory_hotplug.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 63facfc57224..561c44761f95 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1582,12 +1582,10 @@ static void node_states_clear_node(int node, struct memory_notify *arg) if (arg->status_change_nid_normal >= 0) node_clear_state(node, N_NORMAL_MEMORY); - if ((N_MEMORY != N_NORMAL_MEMORY) && - (arg->status_change_nid_high >= 0)) + if (arg->status_change_nid_high >= 0) node_clear_state(node, N_HIGH_MEMORY); - if ((N_MEMORY != N_HIGH_MEMORY) && - (arg->status_change_nid >= 0)) + if (arg->status_change_nid >= 0) node_clear_state(node, N_MEMORY); } From patchwork Fri Sep 21 13:26:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 10610031 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 19503157B for ; Fri, 21 Sep 2018 13:26:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0949B2DB18 for ; Fri, 21 Sep 2018 13:26:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F1ADA2DB1A; Fri, 21 Sep 2018 13:26:51 +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=-2.9 required=2.0 tests=BAYES_00,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 EBC912DB18 for ; Fri, 21 Sep 2018 13:26:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C9AE68E0004; Fri, 21 Sep 2018 09:26:45 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C1FDA8E0001; Fri, 21 Sep 2018 09:26:45 -0400 (EDT) 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 AE86C8E0004; Fri, 21 Sep 2018 09:26:45 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by kanga.kvack.org (Postfix) with ESMTP id 516378E0001 for ; Fri, 21 Sep 2018 09:26:45 -0400 (EDT) Received: by mail-wm1-f70.google.com with SMTP id v1-v6so2457679wmh.4 for ; Fri, 21 Sep 2018 06:26:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=RCTTXVkL71qkxGQmeRTBKaL8TjPr8oGCumoctB9DgDA=; b=EqVIF8pbKBa6UsIQe2IF6ORoF4dOw7WngdeOzQqpRuzp1GoPC8Wd8uAD2llvGkTjoS VlzcXThsh9UJ1PHlmAI602oFKg0pLqimuDRZzetLc2uh8BXgy02/pwZTEgl+6G8AjYPZ 3KEbCNNMRUffFC45WoItJ2v1YbMmVj+9z4ESUdZNr9DohowQc0Xxnj8GLe29F6teZlni 0gpW4yEUJ5T2iJFrqt/FeyAsCRVhZNNd+ROWIsDZxTn9V0AWi7caGqjNaT2qz/W5p3D9 4s3JQv2iJ24ihfDOXO2yXLAk6VcSj/VOLGHAyU+AlX7VmtL/MnRnmfv3w/FiqvkACZk6 l7og== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of osalvador.vilardaga@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=osalvador.vilardaga@gmail.com X-Gm-Message-State: ABuFfojRDwcjB1CBKxm9dmgdvNv/q0GK2qN2KgStuJsyQ68KX1jsVc5a wbaiHUNZn5jRyTrHgeyG2smVLbIlmXfUsdSNXO9iB128COWoxaaH9Ut1CFpvTJ5oE4D/8X4A+QX kPcWCyPM87BbqiUVOvyE4glngoK5bbrQyAQi8tOj3noRH8sTXasKL4QKnJRhHPZbqjE601krwL8 KsID16TrvTLTFHwLT6/3yo6oWla+5iHOYzpTGWD46gobvl7vDB20XPWOZX91TePWiKIM7LLbdzO 6+AHZbJmPInVWLv84y17evv5GK0SvvqNna8rcZxLScg9NuedvCPRXQskYqtqoiu2ho6IntDJTOZ 7Mqo0yNZfAsieelCi3LMKj9dHJIqCx1ma6IBtDAibeaSJnIDQF24VRFRbyBzOfAAPf0CLs1fzg= = X-Received: by 2002:a1c:2108:: with SMTP id h8-v6mr7036875wmh.108.1537536404781; Fri, 21 Sep 2018 06:26:44 -0700 (PDT) X-Received: by 2002:a1c:2108:: with SMTP id h8-v6mr7036815wmh.108.1537536403869; Fri, 21 Sep 2018 06:26:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537536403; cv=none; d=google.com; s=arc-20160816; b=CTMOV+LidHueLg0Hhx2/w8vpu22e3cgDSCoGjlh2U9Ooo7kpXIvV8MLNz51Abw40wV 8bgTXrSe5PJB1zO1POpmtl0PTyBHEOkQMieaAR/byw9IR3BQJxaE0MF+1z/bprJ/3e0W q9q4bWz9IzrTcEdDJnK4+spxkVlc/qDyreOOxjs6goHje7WNhet/ZJcz0eKKBf9raftm DwoEBu+lREta5J6COJSG4r3HiBcOa46LDRuOfxrWGR9Q8LzjQiqd0nu1hJrW0Ib0SKZK G7uc1io6DOeTH9kHIsLpeeEmKcUl7HxvyAvo58yOS/ZTNZKK7r5Jx+po0BxB6L+DR2kE 1kxw== 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; bh=RCTTXVkL71qkxGQmeRTBKaL8TjPr8oGCumoctB9DgDA=; b=ibVlWSeIJ60cgRAnAE9rENaE1YS6mZkgjXK7jRBWNUUYGieKFeVXwWqzd2XHsyCh/0 bCyK3PkmmpSs1v6vHJv6SiWeXSekjq637JovkiViyEjP5irywtuPNLtu3ilwrMbiGJUX t/Zbj0DRSiawmmNYszfx+1LTx79VEHoE3n0E+xEYgy0UpR9H/emWwpRhPJzDR1CSXhMI FIW2ErFY9V7xJy6vMGhWfTGYWEL4Fb8Wj+YQY7mX9qnhygUP1txAmXfKnTnliNdBCCyK fTRJtNSbS5gK78X46RK3v0llCOkLGmBwDui0cO7BzRCcynba6x3P4CSjUctut6f/OQa4 pQEg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of osalvador.vilardaga@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=osalvador.vilardaga@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 i8-v6sor10922075wrs.28.2018.09.21.06.26.43 for (Google Transport Security); Fri, 21 Sep 2018 06:26:43 -0700 (PDT) Received-SPF: pass (google.com: domain of osalvador.vilardaga@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; spf=pass (google.com: domain of osalvador.vilardaga@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=osalvador.vilardaga@gmail.com X-Google-Smtp-Source: ANB0VdbdQH2QGULdBiqI2bwJ+Av8EaBk4PfgnTPNz4WhXo+tilr8wkafVPnOGz47MIFZJcrZPhzqNA== X-Received: by 2002:adf:fc44:: with SMTP id e4-v6mr11704736wrs.9.1537536403548; Fri, 21 Sep 2018 06:26:43 -0700 (PDT) Received: from techadventures.net (techadventures.net. [62.201.165.239]) by smtp.gmail.com with ESMTPSA id y17-v6sm23774170wrh.49.2018.09.21.06.26.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Sep 2018 06:26:42 -0700 (PDT) Received: from d104.suse.de (nat.nue.novell.com [195.135.221.2]) by techadventures.net (Postfix) with ESMTPA id C655E12533E; Fri, 21 Sep 2018 15:26:40 +0200 (CEST) From: Oscar Salvador To: akpm@linux-foundation.org Cc: mhocko@suse.com, dan.j.williams@intel.com, david@redhat.com, Pavel.Tatashin@microsoft.com, Jonathan.Cameron@huawei.com, yasu.isimatu@gmail.com, malat@debian.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Oscar Salvador Subject: [PATCH v2 3/4] mm/memory_hotplug: Simplify node_states_check_changes_online Date: Fri, 21 Sep 2018 15:26:33 +0200 Message-Id: <20180921132634.10103-4-osalvador@techadventures.net> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180921132634.10103-1-osalvador@techadventures.net> References: <20180921132634.10103-1-osalvador@techadventures.net> 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 From: Oscar Salvador While looking at node_states_check_changes_online, I stumbled upon some confusing things. Right after entering the function, we find this: if (N_MEMORY == N_NORMAL_MEMORY) zone_last = ZONE_MOVABLE; This is wrong. N_MEMORY cannot really be equal to N_NORMAL_MEMORY. My guess is that this wanted to be something like: if (N_NORMAL_MEMORY == N_HIGH_MEMORY) to check if we have CONFIG_HIGHMEM. Later on, in the CONFIG_HIGHMEM block, we have: if (N_MEMORY == N_HIGH_MEMORY) zone_last = ZONE_MOVABLE; Again, this is wrong, and will never be evaluated to true. Besides removing these wrong if statements, I simplified the function a bit. Signed-off-by: Oscar Salvador Suggested-by: Pavel Tatashin Reviewed-by: Pavel Tatashin --- mm/memory_hotplug.c | 57 +++++++---------------------------------------------- 1 file changed, 7 insertions(+), 50 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 561c44761f95..eadd149eb7bc 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -687,62 +687,19 @@ static void node_states_check_changes_online(unsigned long nr_pages, struct zone *zone, struct memory_notify *arg) { int nid = zone_to_nid(zone); - enum zone_type zone_last = ZONE_NORMAL; - /* - * If we have HIGHMEM or movable node, node_states[N_NORMAL_MEMORY] - * contains nodes which have zones of 0...ZONE_NORMAL, - * set zone_last to ZONE_NORMAL. - * - * If we don't have HIGHMEM nor movable node, - * node_states[N_NORMAL_MEMORY] contains nodes which have zones of - * 0...ZONE_MOVABLE, set zone_last to ZONE_MOVABLE. - */ - if (N_MEMORY == N_NORMAL_MEMORY) - zone_last = ZONE_MOVABLE; + arg->status_change_nid = -1; + arg->status_change_nid_normal = -1; + arg->status_change_nid_high = -1; - /* - * if the memory to be online is in a zone of 0...zone_last, and - * the zones of 0...zone_last don't have memory before online, we will - * need to set the node to node_states[N_NORMAL_MEMORY] after - * the memory is online. - */ - if (zone_idx(zone) <= zone_last && !node_state(nid, N_NORMAL_MEMORY)) + if (!node_state(nid, N_MEMORY)) + arg->status_change_nid = nid; + if (zone_idx(zone) <= ZONE_NORMAL && !node_state(nid, N_NORMAL_MEMORY)) arg->status_change_nid_normal = nid; - else - arg->status_change_nid_normal = -1; - #ifdef CONFIG_HIGHMEM - /* - * If we have movable node, node_states[N_HIGH_MEMORY] - * contains nodes which have zones of 0...ZONE_HIGHMEM, - * set zone_last to ZONE_HIGHMEM. - * - * If we don't have movable node, node_states[N_NORMAL_MEMORY] - * contains nodes which have zones of 0...ZONE_MOVABLE, - * set zone_last to ZONE_MOVABLE. - */ - zone_last = ZONE_HIGHMEM; - if (N_MEMORY == N_HIGH_MEMORY) - zone_last = ZONE_MOVABLE; - - if (zone_idx(zone) <= zone_last && !node_state(nid, N_HIGH_MEMORY)) + if (zone_idx(zone) <= N_HIGH_MEMORY && !node_state(nid, N_HIGH_MEMORY)) arg->status_change_nid_high = nid; - else - arg->status_change_nid_high = -1; -#else - arg->status_change_nid_high = arg->status_change_nid_normal; #endif - - /* - * if the node don't have memory befor online, we will need to - * set the node to node_states[N_MEMORY] after the memory - * is online. - */ - if (!node_state(nid, N_MEMORY)) - arg->status_change_nid = nid; - else - arg->status_change_nid = -1; } static void node_states_set_node(int node, struct memory_notify *arg) From patchwork Fri Sep 21 13:26:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 10610033 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 3D591157B for ; Fri, 21 Sep 2018 13:26:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2B0142DB18 for ; Fri, 21 Sep 2018 13:26:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F4D42DB1A; Fri, 21 Sep 2018 13:26:53 +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=-2.9 required=2.0 tests=BAYES_00,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 7EB362DB18 for ; Fri, 21 Sep 2018 13:26:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DAC8B8E0005; Fri, 21 Sep 2018 09:26:46 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id CE2F48E0001; Fri, 21 Sep 2018 09:26:46 -0400 (EDT) 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 B176D8E0005; Fri, 21 Sep 2018 09:26:46 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by kanga.kvack.org (Postfix) with ESMTP id 492B08E0001 for ; Fri, 21 Sep 2018 09:26:46 -0400 (EDT) Received: by mail-wm1-f71.google.com with SMTP id z11-v6so2454891wma.4 for ; Fri, 21 Sep 2018 06:26:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=o52x8tjPTmNioW0bBVA6BC8kUEvUd+5T8EUKIIECF/I=; b=caDBhDlqXa5tsVEApJHt/8JLmg/iXxYwjBxp9TPaYpgUqM8XfMR0fG+EsHstWmIwkK FfM6xj/cg7+wau+8gqE1D6G8zqLwcM8XW7DwPMI0vlxgcVvylbTemNyWaUooodcgN1R/ sFgCe7q4HboN9B8N0DKV7hzcFFZrI3c/MTHrAOEJNHFYBCr/g7rMrlMlKLtEpGMTLwib zubVMFdI22z20EQNGVCwyXVBrJ/y4Tq1//K4rVJZj1PjYjxNAX0a311wTgZzhS+sEOwH jYYggZwRcZOD4dYc8q5Hka/Msj7LEzNrmwRctMCMbae4l7Zhp6nE8LbTCkYo61XZvpg6 O8sw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of osalvador.vilardaga@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=osalvador.vilardaga@gmail.com X-Gm-Message-State: APzg51DpJrAafEcL512hVZDk47/dIY27lI7kLA6Ek/0LZCH0//86+pl7 PE9PkiHWI6rYrChlZs4tna6AVK3z9t3jQ8Y5nyFG6SdSf4JNZGGDMw9RshE+9AdMBmIIHvLd3z8 I8Y9P2xG91Dy/qC0eDbAFKVKOokZ2dU96FDCK62QHdj2bHqCjvF+NWxbrdywQtJyLuL1pIg7RBT 7D0jhKf7KLui1EDxD/pAzNfYTURskBJJ81/thYC6wUT82spGKlpLT1ZeMUD7/PTBIqNwOd7I10p 4GUeiciTcNhGaNzBmuhRGWxwsUTo9iSmumWbZkqJxcvraQohddk4MS2a5QQO5NH/NJcHkQgsoXY wlFbzM4IyYnNT4sQ5VTRKodr8NEEaToxHFNQVmpXhk9aRR2PT+tW8bV9gUuXSFslq1icSAI/6w= = X-Received: by 2002:adf:9ae5:: with SMTP id a92-v6mr40064674wrc.125.1537536405730; Fri, 21 Sep 2018 06:26:45 -0700 (PDT) X-Received: by 2002:adf:9ae5:: with SMTP id a92-v6mr40064590wrc.125.1537536404477; Fri, 21 Sep 2018 06:26:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537536404; cv=none; d=google.com; s=arc-20160816; b=uMZ0brLMKTnGmsR/U9eMmnqXZW79HqOhInzvrHzzbLVxm/aEUrQAjp75uUlE/h5Mor Vu+bIDc96+wZW5XYNKBrNaHKBw43alEzJ/esTg746E5cQ9rEPBXTHwU8ePyHKRt51SVx jEFSaoeXohnEt7loyx5AM3LixNVkW+fBeM+iDwSkydZEv9rvwzY0fQf86d5/ZG1tV+Ze pZ5vTOf40+TDehu0/4lG+km9tnVY0eS7/FNqd3hi0CNXyCR489eHfDy/SwymvDlj0gFP WmSQt7RnDOTz5aAJoxkbAeEJK7EzZ7+cKkIVFiu9nkBKrXHURoQhb5AvjU+aUsllwi3c MQhQ== 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; bh=o52x8tjPTmNioW0bBVA6BC8kUEvUd+5T8EUKIIECF/I=; b=bj3pykzZaoC4oM2YpCldAX9UT27Pb8VwP9ynNmDxh7gtXN3jdsDOjdy5cA5PzjC6nD XXE80okO4YQWO28iDGQvWc5pK8GiA95Y5MqOtr8RvljyNMT24ZIL/6dsp9kpePcdUICM nrWIRhIyqLQVKzwbY1MiiEjKyaMt7ulbYTTAFtgOq2JDs0mQjhs8DNJaYWAeOACbLRQo WJBp0J4odyTnxdoch5yA4dxEcXiyTgMD4yytYOC0nviMgoP49XrBnRIkhnrIkmWUMMLK nMgbjJvZLN8eJqfk+9R/sPdsC3wLb0kSH5j9qbw1asnLIomfdhm+U92BKMeDOpHj/AyC kPIQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of osalvador.vilardaga@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=osalvador.vilardaga@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 z10-v6sor4152858wmb.1.2018.09.21.06.26.44 for (Google Transport Security); Fri, 21 Sep 2018 06:26:44 -0700 (PDT) Received-SPF: pass (google.com: domain of osalvador.vilardaga@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; spf=pass (google.com: domain of osalvador.vilardaga@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=osalvador.vilardaga@gmail.com X-Google-Smtp-Source: ACcGV60CN8yYgQgtMyKP5pJBF54wt/SEU1TVEMerZNaayS+2J2mGov6d4qsltfjXR0n9cwwo49tWAw== X-Received: by 2002:a1c:501:: with SMTP id 1-v6mr7033567wmf.140.1537536403982; Fri, 21 Sep 2018 06:26:43 -0700 (PDT) Received: from techadventures.net (techadventures.net. [62.201.165.239]) by smtp.gmail.com with ESMTPSA id u1-v6sm19805759wrt.59.2018.09.21.06.26.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Sep 2018 06:26:42 -0700 (PDT) Received: from d104.suse.de (nat.nue.novell.com [195.135.221.2]) by techadventures.net (Postfix) with ESMTPA id 0C50E125344; Fri, 21 Sep 2018 15:26:41 +0200 (CEST) From: Oscar Salvador To: akpm@linux-foundation.org Cc: mhocko@suse.com, dan.j.williams@intel.com, david@redhat.com, Pavel.Tatashin@microsoft.com, Jonathan.Cameron@huawei.com, yasu.isimatu@gmail.com, malat@debian.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Oscar Salvador Subject: [PATCH v2 4/4] mm/memory_hotplug: Clean up node_states_check_changes_offline Date: Fri, 21 Sep 2018 15:26:34 +0200 Message-Id: <20180921132634.10103-5-osalvador@techadventures.net> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180921132634.10103-1-osalvador@techadventures.net> References: <20180921132634.10103-1-osalvador@techadventures.net> 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 From: Oscar Salvador This patch, as the previous one, gets rid of the wrong if statements. While at it, I realized that the comments are sometimes very confusing, to say the least, and wrong. For example: diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index eadd149eb7bc..f19b63f024c9 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1463,75 +1463,53 @@ static void node_states_check_changes_offline(unsigned long nr_pages, { struct pglist_data *pgdat = zone->zone_pgdat; unsigned long present_pages = 0; - enum zone_type zt, zone_last = ZONE_NORMAL; + enum zone_type zt; - /* - * If we have HIGHMEM or movable node, node_states[N_NORMAL_MEMORY] - * contains nodes which have zones of 0...ZONE_NORMAL, - * set zone_last to ZONE_NORMAL. - * - * If we don't have HIGHMEM nor movable node, - * node_states[N_NORMAL_MEMORY] contains nodes which have zones of - * 0...ZONE_MOVABLE, set zone_last to ZONE_MOVABLE. - */ - if (N_MEMORY == N_NORMAL_MEMORY) - zone_last = ZONE_MOVABLE; + arg->status_change_nid = -1; + arg->status_change_nid_normal = -1; + arg->status_change_nid_high = -1; /* - * check whether node_states[N_NORMAL_MEMORY] will be changed. - * If the memory to be offline is in a zone of 0...zone_last, - * and it is the last present memory, 0...zone_last will - * become empty after offline , thus we can determind we will - * need to clear the node from node_states[N_NORMAL_MEMORY]. + * Check whether node_states[N_NORMAL_MEMORY] will be changed. + * If the memory to be offline is within the range + * [0..ZONE_NORMAL], and it is the last present memory there, + * the zones in that range will become empty after the offlining, + * thus we can determine that we need to clear the node from + * node_states[N_NORMAL_MEMORY]. */ - for (zt = 0; zt <= zone_last; zt++) + for (zt = 0; zt <= ZONE_NORMAL; zt++) present_pages += pgdat->node_zones[zt].present_pages; - if (zone_idx(zone) <= zone_last && nr_pages >= present_pages) + if (zone_idx(zone) <= ZONE_NORMAL && nr_pages >= present_pages) arg->status_change_nid_normal = zone_to_nid(zone); - else - arg->status_change_nid_normal = -1; #ifdef CONFIG_HIGHMEM /* - * If we have movable node, node_states[N_HIGH_MEMORY] - * contains nodes which have zones of 0...ZONE_HIGHMEM, - * set zone_last to ZONE_HIGHMEM. - * - * If we don't have movable node, node_states[N_NORMAL_MEMORY] - * contains nodes which have zones of 0...ZONE_MOVABLE, - * set zone_last to ZONE_MOVABLE. + * node_states[N_HIGH_MEMORY] contains nodes which + * have normal memory or high memory. + * Here we add the present_pages belonging to ZONE_HIGHMEM. + * If the zone is within the range of [0..ZONE_HIGHMEM), and + * we determine that the zones in that range become empty, + * we need to clear the node for N_HIGH_MEMORY. */ - zone_last = ZONE_HIGHMEM; - if (N_MEMORY == N_HIGH_MEMORY) - zone_last = ZONE_MOVABLE; - - for (; zt <= zone_last; zt++) - present_pages += pgdat->node_zones[zt].present_pages; - if (zone_idx(zone) <= zone_last && nr_pages >= present_pages) + present_pages += pgdat->node_zones[ZONE_HIGHMEM].present_pages; + if (zone_idx(zone) <= ZONE_HIGHMEM && nr_pages >= present_pages) arg->status_change_nid_high = zone_to_nid(zone); - else - arg->status_change_nid_high = -1; -#else - arg->status_change_nid_high = arg->status_change_nid_normal; #endif /* - * node_states[N_HIGH_MEMORY] contains nodes which have 0...ZONE_MOVABLE + * We have accounted the pages from [0..ZONE_NORMAL), and + * in case of CONFIG_HIGHMEM the pages from ZONE_HIGHMEM + * as well. + * Here we count the possible pages from ZONE_MOVABLE. + * If after having accounted all the pages, we see that the nr_pages + * to be offlined is over or equal to the accounted pages, + * we know that the node will become empty, and so, we can clear + * it for N_MEMORY as well. */ - zone_last = ZONE_MOVABLE; + present_pages += pgdat->node_zones[ZONE_MOVABLE].present_pages; - /* - * check whether node_states[N_HIGH_MEMORY] will be changed - * If we try to offline the last present @nr_pages from the node, - * we can determind we will need to clear the node from - * node_states[N_HIGH_MEMORY]. - */ - for (; zt <= zone_last; zt++) - present_pages += pgdat->node_zones[zt].present_pages; if (nr_pages >= present_pages) arg->status_change_nid = zone_to_nid(zone); - else - arg->status_change_nid = -1; } static void node_states_clear_node(int node, struct memory_notify *arg)