From patchwork Wed Sep 19 10:08:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 10605579 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 B7353112B for ; Wed, 19 Sep 2018 10:08:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ACAEF2B59D for ; Wed, 19 Sep 2018 10:08:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A0A9E2B5F2; Wed, 19 Sep 2018 10:08:44 +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 40AB42B59D for ; Wed, 19 Sep 2018 10:08:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 82B9E8E0006; Wed, 19 Sep 2018 06:08:41 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 7E8398E0005; Wed, 19 Sep 2018 06:08:41 -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 5B7D08E0005; Wed, 19 Sep 2018 06:08:41 -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 F3EB78E0001 for ; Wed, 19 Sep 2018 06:08:40 -0400 (EDT) Received: by mail-wm1-f70.google.com with SMTP id b186-v6so3047872wmh.8 for ; Wed, 19 Sep 2018 03:08:40 -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=0E8GrSFo/1cWrkiXCf/RJ9KCZnuIkg29ttwOJg6NQJI=; b=GNgexiYyo5n9FWMFg+PQFMUhely4Sl47MxAjrnaKpFXSQO89Pkr20ofIQ5ti0Onw1y N7Qcu0LVQ9J9Co/I4/AEtedRNGUTYYRuvAhathKn8WD1awTuiu3ChCU0ZAwmLFYqtEPq Cswr7WNaggVi9PT5GCCsVkOIofiD6CtLL+At1BIrtACjUZmZCZQvl+N4KPm6vIO7K3jU vJ6APdhMP8eHAuNatpxbrUkgFXE35qP6cC0cbysU3QzkF536ZUbkIdWXYNs88JfaCnwf iPwtNXpHjNtyxyDHi6b0Hf4790pmxtsyzDIKDdQdHrM1QDdEgoDqOasUEjjXPZSuFva6 jVdg== 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: APzg51Dpdv78kuvZ1Wbah0AgRDdVXJXcvRBiLdl6JJ03QXuhSlV8tsv6 mE2ZTd+q4TpuKrVQeK+CHDxquqQsF1Ww6wJQAQ9HhH4iYYPSr/P1o9+MW1+tmVNiPkBxCl0r4mN 9N/2s+rvDvpZA3EaAZY523lVzUbAuYaYTxWU47+ZtVOC9twJbNhIlnmV1sTm5pbMRCwc9AIXclF o/94cnV01oNMoyBRIHN4s9fA63p1An4uygwTUm2fm0o6goABM7qfi5/AH+sKf6diuRaixIGOrHj u7xpDhcVrROhdCN8N/eMc3i7vFFPnq8JAbP5xn9ncJaMoRLgHHJyoe+aJ38qnmDcCv4buHtt1tf GWP96N8sbp9ZMp09leZvf1jYJQRf1HlHav1ae3Or4gTzF/9yvVue8fGMZMhNI3AkCHS/g/4lsQ= = X-Received: by 2002:adf:bd10:: with SMTP id j16-v6mr26936154wrh.267.1537351720531; Wed, 19 Sep 2018 03:08:40 -0700 (PDT) X-Received: by 2002:adf:bd10:: with SMTP id j16-v6mr26936081wrh.267.1537351719599; Wed, 19 Sep 2018 03:08:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537351719; cv=none; d=google.com; s=arc-20160816; b=ORvagxWpGaRSaCHg2RTQsgM8+qtq9R6/ZZmEQdKBObXbLPzKwwowvbIRrwTnfF1ysF FbJ6qy5PnibqGDcIluP8ulJR/5Lvxvj599sUuBQLTE2/3Z1Q+hhWWlq+yjNW3vMhjfMM H/Krpn5pNTLmaPbRhZodxHKaNjg6Yt0ro6qHlF5mT9VxN1KvoOiThLDsvMvaXWL4RNPg AinwmCMcsU0gFodCmT0N+QmU364ez8FEPPWq9PKI85ZO/pBFAXVQOCagjCo9760aaveO zRjVScZFWAc1oioMWm4BQ2dG7ZQsvSjuUnSFlrbl2dc0rYDCF2GaTzor4ybYh4YWaxn6 PIzg== 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=0E8GrSFo/1cWrkiXCf/RJ9KCZnuIkg29ttwOJg6NQJI=; b=sjafZg3xN7/vdSLEuY7k5lu92BDEQqMq/N5wB1wLMWw4dWQuA22516ES5BpHSwjcX4 JUUO+d9tS/nNVZCyO8F3P4J8/LGor1RVYSEuGCf+iJsvq9RTWPc7QCABkwrjDfOQZHkE WSROyprHuPvyCdx4ojYhrciDJENDwa+z0U+YCvN7EEQiR6XCiwkUXD+2he7XjWm4YwTX ZZMmA79uT0Qwnz46oYYzceFkqQN4+nC8kMHcqN63wKhL6mJH4L3qs/iYolQt4WwR1VBo ErVQYZscwtAL+F0dLSqkeCzyHA0JFKRQSgbiFwAtQyNZ08V7d900VEgIu+aTsOdtrT5X vB/Q== 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 l23-v6sor9496244wmc.6.2018.09.19.03.08.39 for (Google Transport Security); Wed, 19 Sep 2018 03:08:39 -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: ANB0Vdb34HC3HV+ZiMDEQ/899rzIBRO3em9du2agMFpbdsRrUU9mOEvH/Qb6iAdxyFjxFnYfjWwNwg== X-Received: by 2002:a1c:f11a:: with SMTP id p26-v6mr8343491wmh.92.1537351719329; Wed, 19 Sep 2018 03:08:39 -0700 (PDT) Received: from techadventures.net (techadventures.net. [62.201.165.239]) by smtp.gmail.com with ESMTPSA id h15-v6sm3058786wmb.21.2018.09.19.03.08.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Sep 2018 03:08:38 -0700 (PDT) Received: from d104.suse.de (charybdis-ext.suse.de [195.135.221.2]) by techadventures.net (Postfix) with ESMTPA id A83811253C2; Wed, 19 Sep 2018 12:08:37 +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 1/5] mm/memory_hotplug: Spare unnecessary calls to node_set_state Date: Wed, 19 Sep 2018 12:08:15 +0200 Message-Id: <20180919100819.25518-2-osalvador@techadventures.net> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180919100819.25518-1-osalvador@techadventures.net> References: <20180919100819.25518-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 Wed Sep 19 10:08:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 10605581 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 33380112B for ; Wed, 19 Sep 2018 10:08:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2944B2B59D for ; Wed, 19 Sep 2018 10:08:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1CE9B2B5F2; Wed, 19 Sep 2018 10:08:47 +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 B675E2B59D for ; Wed, 19 Sep 2018 10:08:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1E85B8E0005; Wed, 19 Sep 2018 06:08:42 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 14D958E0007; Wed, 19 Sep 2018 06:08:42 -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 DFC478E0005; Wed, 19 Sep 2018 06:08:41 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by kanga.kvack.org (Postfix) with ESMTP id 6F4E88E0001 for ; Wed, 19 Sep 2018 06:08:41 -0400 (EDT) Received: by mail-wr1-f69.google.com with SMTP id i11-v6so5195641wrr.10 for ; Wed, 19 Sep 2018 03:08:41 -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=thpIlUtOEixjbYz3iacVqH1ZUY3x4M6r2oBABcQxPm8=; b=ajqcXodhf9Ley29p6MLPiTqtKfaCYK2Oe8Zns1yKfJqMoQvz7TgLdVHUnk1s2kVZ4y XBnsGaBIeRRO/W0uJy4WLttM51NX3oxhp2s1H5239BlMySYVjAlKbfaHDwrwJpwTV+6s XYAWVBe6PFZhLXkrZYolYlK6qgHh8APlBKf4OSkL2oniCs4zbpQOiX3MXjtR8nIVTJ38 m3B8soPb1J5NlxImTyjy2yluZCMsXMI9+UuRIqrNVv8dW3BL0DJuuEacbJ+e16S1Pj4U MZUKh75rVzpTIs19cD8Ow1Kbmfz0jDWWYBENoyfOTo8gk5k3wNpbl5KLOOMdwXyoJcyU eEqw== 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: APzg51CPC1eLJ+hLIV8r2B7Uu+BaKQHdf60QxM8A5t74EoZCCWSW/K57 C+bn0+10BpBLh+STY3TYyXp4xV3qDGVH1+ooJ7lFCc2TWCU4FFC6KLcUIBhQyB6Pcpxzch/dxeB 9LvuhD9AEeiXEDPvxVNO4WEHqCv7jKbGJV2oR0FsRbD+lX6sr2nryCfRL4RG0P+grj9+rBzjWwN KRJbfp+difuY1d3hj2p7JEMNRPH5YsUS+G/lVT7A6m9y1C5xBVtJ9LPURAKUpBR+XK27hP+ln0b OSVOjQFWEkKMj0M98qXr0PuJo9vNC5aivm5PBwCi1Ho4KoH7/oCOwZv0p1nTprd6V/3zmxLBckc dSTwTzP+8d0/SQYImSqyTudyGxdsAIu9X9/Q1hXqoLn41tkzGfqUX6lvMi7XTM7OdPw4Vmpi8Q= = X-Received: by 2002:a5d:6243:: with SMTP id m3-v6mr28297574wrv.179.1537351720980; Wed, 19 Sep 2018 03:08:40 -0700 (PDT) X-Received: by 2002:a5d:6243:: with SMTP id m3-v6mr28297500wrv.179.1537351720154; Wed, 19 Sep 2018 03:08:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537351720; cv=none; d=google.com; s=arc-20160816; b=ZsmLw6ton3z/tC9Y95UYu9OPnkxlkB4dXO1mdTF17WZ4k5SY2/m4mL/c4FS/nNjRg5 /WmRbIATWWpn1bCi/i3Pbz0CPvKBpptugmESNULnJph+zmMcqJFrdQmgAJyona/k3Hca f8zYm6qMbnjBogWAaEX0gsld9+qzCqiEdXZ9xu9XKSPswcFoq8OkATQTLklECjPjOOqV opG/mSZheCcCXFnhoFRiu84DGIzDmeaWOJtl/PRveli4vhGX65rYbUx0I9sGQSRp4Dhi XzthOFFu9hRfXDZz/XdeBuigzXOPUuQfXj6Xzav0/FXZvfxAkfjaoLIdTJTgimFIYRi/ XfCQ== 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=thpIlUtOEixjbYz3iacVqH1ZUY3x4M6r2oBABcQxPm8=; b=ltIGJVMkNBHMJzr+EdCrm6eFUwYk8bPYGjimiEM6+8W0iFeJN7vNeOCQcg8+zqOOwX 39+Fzk1QJSH6ebprmupv4fZLiyhpYTnQeh52Mp3b9K1Y0lMtVMy65D7gF9xh31L1KnM2 U3cw4bWNpYkKXiHAeDaKCYFJm0SsGl7+7MAE+jAfUu447xEFohJ41Baj9Q/cAWzZykR4 QvSWSGyiGDYV9V38BDfb4g7IRt2X7/Ry9G7S5NUGeFKl2ebDwD6QDgvhnq7hRKrsygLc 3ikL+Qj3G6OLt8bzKvejmnnhqvDGRw5rwTvn1z2/NJNADfRaqjojMyWnz+f+OrkDvVDx 0MfQ== 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 y191-v6sor9532365wmc.9.2018.09.19.03.08.40 for (Google Transport Security); Wed, 19 Sep 2018 03:08:40 -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: ANB0Vdb9hbUjE5up832+eC7sgpf42oWyYQuNo3UFhWu4SB5IZgjb3XeecE0Hqcf9MEGI2nfbZKd9aQ== X-Received: by 2002:a1c:7704:: with SMTP id t4-v6mr18488447wmi.136.1537351719861; Wed, 19 Sep 2018 03:08:39 -0700 (PDT) Received: from techadventures.net (techadventures.net. [62.201.165.239]) by smtp.gmail.com with ESMTPSA id g7-v6sm18529017wrw.30.2018.09.19.03.08.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Sep 2018 03:08:38 -0700 (PDT) Received: from d104.suse.de (charybdis-ext.suse.de [195.135.221.2]) by techadventures.net (Postfix) with ESMTPA id E9D441253C3; Wed, 19 Sep 2018 12:08:37 +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 2/5] mm/memory_hotplug: Avoid node_set/clear_state(N_HIGH_MEMORY) when !CONFIG_HIGHMEM Date: Wed, 19 Sep 2018 12:08:16 +0200 Message-Id: <20180919100819.25518-3-osalvador@techadventures.net> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180919100819.25518-1-osalvador@techadventures.net> References: <20180919100819.25518-1-osalvador@techadventures.net> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000018, 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 Currently, when !CONFIG_HIGHMEM, status_change_nid_high is being set to status_change_nid_normal, but on such systems N_HIGH_MEMORY falls back to N_NORMAL_MEMORY. That means that if status_change_nid_normal is not -1, we will perform two calls to node_set_state for the same memory type. Set status_change_nid_high to -1 for !CONFIG_HIGHMEM, so we skip the double call in node_states_set_node. The same goes for node_clear_state. Signed-off-by: Oscar Salvador Reviewed-by: Pavel Tatashin --- mm/memory_hotplug.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 63facfc57224..c2c7359bd0a7 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -731,7 +731,11 @@ static void node_states_check_changes_online(unsigned long nr_pages, else arg->status_change_nid_high = -1; #else - arg->status_change_nid_high = arg->status_change_nid_normal; + /* + * When !CONFIG_HIGHMEM, N_HIGH_MEMORY equals N_NORMAL_MEMORY + * so setting the node for N_NORMAL_MEMORY is enough. + */ + arg->status_change_nid_high = -1; #endif /* @@ -1555,7 +1559,11 @@ static void node_states_check_changes_offline(unsigned long nr_pages, else arg->status_change_nid_high = -1; #else - arg->status_change_nid_high = arg->status_change_nid_normal; + /* + * When !CONFIG_HIGHMEM, N_HIGH_MEMORY equals N_NORMAL_MEMORY + * so clearing the node for N_NORMAL_MEMORY is enough. + */ + arg->status_change_nid_high = -1; #endif /* From patchwork Wed Sep 19 10:08:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 10605583 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 BF48F161F for ; Wed, 19 Sep 2018 10:08:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B33212B59D for ; Wed, 19 Sep 2018 10:08:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A7C312B5F2; Wed, 19 Sep 2018 10:08:49 +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 480A52B59D for ; Wed, 19 Sep 2018 10:08:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8F2CB8E0008; Wed, 19 Sep 2018 06:08:42 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 852B58E0001; Wed, 19 Sep 2018 06:08:42 -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 683848E0008; Wed, 19 Sep 2018 06:08:42 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by kanga.kvack.org (Postfix) with ESMTP id ED8658E0001 for ; Wed, 19 Sep 2018 06:08:41 -0400 (EDT) Received: by mail-wr1-f71.google.com with SMTP id g3-v6so2826643wrr.11 for ; Wed, 19 Sep 2018 03:08:41 -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=nPK6uXZN7cckrZujWIB4/aDojr48F0Bx+xBF9fcQrF4=; b=m2FB9o/aBPjOrlHwij7tSjbnX3FAjJAM4biR88lE/no+d/aZ86SdsuLPPRmSFGKmNH SPUOg7F3kS7cXADXWHhPSm2iw9XWszmq9Qe5GjQ3KLIlkD9McJYf5D2lWFuitTTiypJg 7DxAmI4cwyY+EZml6MqmUD+CNh5vt0K+WS+gkrjMUce6Awoh+45jvqoWAf8RQQNC62Hr GXSRklNK4kaYLo5G9GiwC7EnIoD9LOT8mY4rrYiDi4DzrzNaOu01AXbNZBOuKjk1hp1U IJ6OMbhN3ePJ6bXwQUVNq4cix84DS0TqLt23ofpoDmcbaj87K7zEa2zNMERBiSVIHs9B moKQ== 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: APzg51Cgd3DOfX5YkuFzEF6hJv84BldCjiH94mwSEpkzvGcFyTd8Y/m4 28uWpuI00cN2MZR0LCatt0ZFqmpMbJl8IcWctzAlOoFV6B7OnMyjpmu6DqGRYtrlaNpTCDBlx8v KfJ68hqhxoKWw7Q3J55+e2cwbjG71/wB+ISoN3fSRJwlFrHkQS5oukOdrejEmqKI41MksDjhXpN IhLW3zVyDNjzmvDMq4wwgdLVCsG6OeSsblIwHuKEQQJahrvVLltwMyjeC1MZDX1c41DZg4k8N1k Gha0/ytpnUR9tjEhDb8t/ySYey/oMXmT0zSaQDwG0FRZP65B1fluucCWOTY825TXBMqO8waWNpI l0WB02EjOdXyFtzF1n56rya/0o8nOPkc16mJfDCzDfZex1DghkGMbbc9DE0dsaD40KLPLVf8jg= = X-Received: by 2002:a1c:40d5:: with SMTP id n204-v6mr19474040wma.44.1537351721399; Wed, 19 Sep 2018 03:08:41 -0700 (PDT) X-Received: by 2002:a1c:40d5:: with SMTP id n204-v6mr19473985wma.44.1537351720666; Wed, 19 Sep 2018 03:08:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537351720; cv=none; d=google.com; s=arc-20160816; b=0lamJoijThnIH+VEFvFOpmt7Rzn0CWRhhrYK55XFJFKNDwFdXjvgT4NQTZJ2kHu+To tZPRaOhYt8BlamzVoKOSbhNquCiIbaKaoAMV7YhfslITduRjBTtjDJA8GsX0eymudB+Z cVSj963YGG3rqyzdmzVUwGTuuVE4JP01HRPKy2AV0NmTr7z1IVrHJQxF48J9snpPqvpD M3K60q5nz3+D9o3WooX9OdtYvRI/sa6WUr1Tu0ovX3LhVQx8bw3W/8ZXcLBiTToKFBPc AkOTIKS/kka6G5w+bHcCtSdJR4DbZYk3PTukoP12A3pRtSN17AEQCwR2YuyXWd9TlAG6 84jQ== 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=nPK6uXZN7cckrZujWIB4/aDojr48F0Bx+xBF9fcQrF4=; b=SYdu7BIfxKVAVwsaugFhd373SZdfraEKe9uI9pmlU2nHULwvbdV64kEEplfZESUuLe TDQbhuIveHojYRy8OyW3zpKF4TT1gpFUhHUExcJ06jLUAjUl9ZREXdCr0BHqTv7TnLMD T/LfcsRJbcRkboBvz3rf1L9AAJswSwnWRCmnKQ1xhweHzuFxMyXvyVDl5NexuljJZrxJ 0DnoZz59HaDIjvxJD6Dze9sXXiNK5RO8LgVKTEh6pbqkW4l7igROMvJFR6+WOcDtB5Ra AQFee06Fcbdweb2Xeb7FcyBL8duEV4pDCJC/EtOLfSMPez1JSR088iRqC8DMv3iJZo78 oHZQ== 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 c10-v6sor15438814wrm.23.2018.09.19.03.08.40 for (Google Transport Security); Wed, 19 Sep 2018 03:08:40 -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: ANB0VdYALQtAORNJdn6aMvxSVqH7BWIqAeiJ5ZgblOChmk/IZbwXHg1zQie6pixLaKS/+9PJwHGCww== X-Received: by 2002:a5d:68c9:: with SMTP id p9-v6mr27824256wrw.108.1537351720351; Wed, 19 Sep 2018 03:08:40 -0700 (PDT) Received: from techadventures.net (techadventures.net. [62.201.165.239]) by smtp.gmail.com with ESMTPSA id d18-v6sm2982148wmb.33.2018.09.19.03.08.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Sep 2018 03:08:39 -0700 (PDT) Received: from d104.suse.de (charybdis-ext.suse.de [195.135.221.2]) by techadventures.net (Postfix) with ESMTPA id 2ED381253C4; Wed, 19 Sep 2018 12:08:38 +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 3/5] mm/memory_hotplug: Tidy up node_states_clear_node Date: Wed, 19 Sep 2018 12:08:17 +0200 Message-Id: <20180919100819.25518-4-osalvador@techadventures.net> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180919100819.25518-1-osalvador@techadventures.net> References: <20180919100819.25518-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 c2c7359bd0a7..131c08106d54 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1590,12 +1590,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 Wed Sep 19 10:08:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 10605585 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 E5A18161F for ; Wed, 19 Sep 2018 10:08:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DA8C72B59D for ; Wed, 19 Sep 2018 10:08:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CE3562B5F2; Wed, 19 Sep 2018 10:08:52 +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 488832B59D for ; Wed, 19 Sep 2018 10:08:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0DB148E0009; Wed, 19 Sep 2018 06:08:43 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 066EE8E0007; Wed, 19 Sep 2018 06:08:42 -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 BFBDF8E0001; Wed, 19 Sep 2018 06:08:42 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by kanga.kvack.org (Postfix) with ESMTP id 584538E0007 for ; Wed, 19 Sep 2018 06:08:42 -0400 (EDT) Received: by mail-wr1-f69.google.com with SMTP id i11-v6so5195676wrr.10 for ; Wed, 19 Sep 2018 03:08:42 -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=mb6vYlvIYmKOjWLuG2K0eChvByDfjqgy7Ys9RpY0B4o=; b=Ai+GCeUSD8gJkUzvhUhwCts3dCU81E+0ALwx6JPwVQNddMAAts6X4tCqadP49mJZiS jPnD9GjH/jk2hHnLg4Je7fE5GUFvhxHq+eTUlqsYA7E5zIqaDkN221FT636jC0OClZux GedZ0JB0irp8WCqNs3NhwsU1sYYgd9e4PRkHfxIgWVmTcwnakyGVxmWd21D1Mydc6Epx vZVDZH8Ovhzqm/ccm7Sa5BPfc2NW7XxISQYP3qU+tYb1Cxv3aQRZ1zCNaoiPR7T+zg4y e+iWEAV0L7+oXIRBx8P0l2Ppa7FRhmu/DwMYPJ6nx4oZ9hLF2Xqu+r/T4hu1gu16MeK0 HdKQ== 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: APzg51AYiJvV3Qz8aotEDkKgdEbKcHLTqXuVa30VM0RS+OGSmhquB2IE vqlKAaqI/kU08Eo+GadD3sE/PmCYZFhN1hOAJWhkkH4tjjeSkgjekuZauZyBPFXfWuvBvs8n1hU ODt3lb1u8MDxFUmHdgIw5aNxzQMMvCH9vj87UAKApMpYbRNriH1QE+3lJxwEnz58O5mWnM8id3r kSuDc4XBbLhZaBLaDGj9XIrOTK6v7gs7ERA/Xd5k84dWQ5gKi+AcgWRJsI1vOmN1XaKgbPn75Tc f1nYS1+79uJbiUYPJsn1bIvVfahJT7I2iHEywf9PAniQG68ssUkdq6J+CHPoxTeyBfTo42qlXQM Ggwv+j7+xNO4cSiQGT4PSrOgESUxOr1njFhoLwSIRgE9OGW5RzlTk/JbzjBJbRHj4vAx+4hxDg= = X-Received: by 2002:a1c:a401:: with SMTP id n1-v6mr20229974wme.125.1537351721872; Wed, 19 Sep 2018 03:08:41 -0700 (PDT) X-Received: by 2002:a1c:a401:: with SMTP id n1-v6mr20229923wme.125.1537351721173; Wed, 19 Sep 2018 03:08:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537351721; cv=none; d=google.com; s=arc-20160816; b=DZWMbD2DuMl7oMLQJEIY8QDM4B/98Dgz6+Az8SOidSGLfy2/qgJYSxYOU9vAxK67Go Fe5+2Lv6/dL5UtmA7A7Cj708gAo8u32pUjOTGZ9UJQtv42EKvKWXPjQwflB41Dcy6KUf 9VlL/z/saBnvg283n1+kkeZzT+jttswmXsWwvQHpbgjPTAq+VTi7Fo/rjBGGwpbh9UYx gWu51wLw7gWqcMryScZW5V/9xyHKScE0w2HocxltqTEKSG0LrbVMSgoENYZIgPYSb9K5 f0RCnfK5d3NOmiPGL18ftRaZn3lIXNfyHVqtiPpQbVNmdAHTIe9Lw4NrM8iiJuzh1/uh 6rmw== 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=mb6vYlvIYmKOjWLuG2K0eChvByDfjqgy7Ys9RpY0B4o=; b=ukd7cP/cwO/tIwVyzmNnn0O9z9+LfvNlQpAMspKqzBjJ5Toer8F8nv0f0q6+OlBUtr oQ4sRvQu5dk2nq95op0yksMIKvEsKR1NQGKJIBAQyCTjNAr1QqMgj5aIrRpRiRpD3So9 qREY2w4NlTLWzhNCVTaxEgtmTBA38MZnJSsO9zLKB9ASr6ss4mlA3BMgkPDPOH8eLPmA RGc32ocO/b6cJPftiIos8CI8NbYYnRvgRxGGcuFAk0vJlMkMikyVYdl97G5yY4Q6Hosh u1Clw/aX79vwn4JhMkXQY0NJfxjFFSD9PZ9U6Y3/S5j3IVlLg+aA11vqNPees8nm8oXE PVbA== 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 42-v6sor15010060wrb.38.2018.09.19.03.08.41 for (Google Transport Security); Wed, 19 Sep 2018 03:08:41 -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: ANB0VdbHMUJFArsNd47dTIQSFcl+G6iSMJHasnwRtwV47Aiviqp45n5HWV7nKvoty7ZUX62TWeFkoA== X-Received: by 2002:adf:b3d7:: with SMTP id x23-v6mr26796918wrd.253.1537351720869; Wed, 19 Sep 2018 03:08:40 -0700 (PDT) Received: from techadventures.net (techadventures.net. [62.201.165.239]) by smtp.gmail.com with ESMTPSA id b10-v6sm16530345wrr.88.2018.09.19.03.08.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Sep 2018 03:08:39 -0700 (PDT) Received: from d104.suse.de (charybdis-ext.suse.de [195.135.221.2]) by techadventures.net (Postfix) with ESMTPA id 70E981253C5; Wed, 19 Sep 2018 12:08:38 +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 4/5] mm/memory_hotplug: Simplify node_states_check_changes_online Date: Wed, 19 Sep 2018 12:08:18 +0200 Message-Id: <20180919100819.25518-5-osalvador@techadventures.net> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180919100819.25518-1-osalvador@techadventures.net> References: <20180919100819.25518-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 --- mm/memory_hotplug.c | 71 +++++++++++++++++------------------------------------ 1 file changed, 23 insertions(+), 48 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 131c08106d54..ab3c1de18c5d 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -687,61 +687,36 @@ 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. + * zone_for_pfn_range() can only return a zone within + * (0..ZONE_NORMAL] or ZONE_MOVABLE. + * If the zone is within the range (0..ZONE_NORMAL], + * we need to check if: + * 1) We need to set the node for N_NORMAL_MEMORY + * 2) On CONFIG_HIGHMEM systems, we need to also set + * the node for N_HIGH_MEMORY. + * 3) On !CONFIG_HIGHMEM, we can disregard N_HIGH_MEMORY, + * as N_HIGH_MEMORY falls back to N_NORMAL_MEMORY. */ - if (N_MEMORY == N_NORMAL_MEMORY) - zone_last = ZONE_MOVABLE; - /* - * 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)) - 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_NORMAL) { + if (!node_state(nid, N_NORMAL_MEMORY)) + arg->status_change_nid_normal = nid; + else + arg->status_change_nid_normal = -1; - if (zone_idx(zone) <= zone_last && !node_state(nid, N_HIGH_MEMORY)) - arg->status_change_nid_high = nid; - else - arg->status_change_nid_high = -1; -#else - /* - * When !CONFIG_HIGHMEM, N_HIGH_MEMORY equals N_NORMAL_MEMORY - * so setting the node for N_NORMAL_MEMORY is enough. - */ - arg->status_change_nid_high = -1; -#endif + if (IS_ENABLED(CONFIG_HIGHMEM)) { + if (!node_state(nid, N_HIGH_MEMORY)) + arg->status_change_nid_high = nid; + } else + arg->status_change_nid_high = -1; + } /* - * 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 the node doesn't have memory before onlining it, we will need + * to set the node to node_states[N_MEMORY] after the memory + * gets onlined. */ if (!node_state(nid, N_MEMORY)) arg->status_change_nid = nid; From patchwork Wed Sep 19 10:08:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 10605587 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 6E6C1112B for ; Wed, 19 Sep 2018 10:08:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 607272B59D for ; Wed, 19 Sep 2018 10:08:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 54C5B2B5F2; Wed, 19 Sep 2018 10:08:56 +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 A92732B59D for ; Wed, 19 Sep 2018 10:08:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A9B698E0007; Wed, 19 Sep 2018 06:08:43 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9D8A68E0001; Wed, 19 Sep 2018 06:08:43 -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 7668F8E0007; Wed, 19 Sep 2018 06:08:43 -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 092EB8E0001 for ; Wed, 19 Sep 2018 06:08:43 -0400 (EDT) Received: by mail-wr1-f70.google.com with SMTP id g3-v6so2826680wrr.11 for ; Wed, 19 Sep 2018 03:08:42 -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=CPZ3SLz+vsImuE3JcnMjrOKHwubgJYYNz5KpnVll+6g=; b=Iwh3XdXTD1VMCyoBSXwH2ihuEXHzyAxaog69YsP71BaAFt6a+7cY/Alwv9R+HeIomg B4ssrnjI9p0m48bJjCRpQD2SnPAXU180D2Nmv6HgvJHmkKIq25Kf3QV4+is1G0L+bQQ7 ccL+ObTJxxUDvNEkKTF5HdSM9Mjz6NCWfnKMCY20cZJSugccRkIJLof8znNV1F9kuTiY oqttKHzvNodzsJkv1KqaOofC9cYU4XmK7jkHGtF9NAFjh+crksGrrvJKF6tcta6CFV6O PBu8faAwLtEJN4Yi1FXbHSbWwp1URVLZ9aT8OG//KtMo3Drf0EpJsr9396Hsfyc+4vou xKTg== 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: APzg51CmB4fA3zgoeNcoL2XiFBOiQmAWCVgDsgbrVd6E5c5Nh9RkJgI2 6WQ0RKoLVkF1ZsWz+dl7Qqv4DdvXodqTNh0InThiyzGdy3gKayonQ1a8zPO5axoyi2sUjwGWJix fvcRzRj5bk5tHGi2Oxsfy5bqIDAF6jqyQTjReLEPfgRSC3DV0bfc52qsW6W+ttwzMF8uIOeBcyL okVE8q7UuMN41ySkH1rLazrK7ZB9GQm6JUI3uzIyGlFxHVmznuof3t1vMZJEPAxvhekywlB/+TQ J+Votq7IYTJHEv54odM1FiLP5Bz46Lb6eqDU0wKb5XMnv37dB7SOppRusJGJoLGOC9Yg9isPtiy 9kxCoM49qN7K5EbN3fT69mug0oquiWuASdv/lh5fbyh49vGuEYrosVRKNHkry1NmsQVc1ecpyg= = X-Received: by 2002:a1c:d141:: with SMTP id i62-v6mr18508054wmg.113.1537351722549; Wed, 19 Sep 2018 03:08:42 -0700 (PDT) X-Received: by 2002:a1c:d141:: with SMTP id i62-v6mr18507980wmg.113.1537351721583; Wed, 19 Sep 2018 03:08:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537351721; cv=none; d=google.com; s=arc-20160816; b=hWB8mWPPP1lYbrlVpFsa5b7QUL3mx9gHuaHAp+zMuzjCDW0hN/3TFhLdjpfkrzGyMc hP4Shy+Dx8bNclSf1qhArNMtfPZRDF5YzQjK2nTC0uqjXs+6u96KiI9ygO7SdCQItDey FadxJGEt2L0AA1KEjGcRfz60gK7VQR1BYqHeRm6sQjD6bfurKDef4usANFMiHKaiCQzh FyIOXSIVK6Z8kekfSBYwUg1o2o5vcvHRB26rRTVmw41wf4bz5Fz7rOjPtZTtz14xnBTg IjsW0Qixj0wPKS8zqzftWruw3hofw5QitW85jTBZrSsPYH3umTWomjnC0afs0ndjRkPm GDKg== 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=CPZ3SLz+vsImuE3JcnMjrOKHwubgJYYNz5KpnVll+6g=; b=lqQDzmm0JmPwlTvria3gsA4AxnLtN8v5oqesYB1aUMyzCXSa9ddPueoYh14xLT2GyV QsrhaZ5/eW6a6co9mVHY0HS0KELD3+5L0gIX+4JPJjxmh8se7MsU72AYRVqilUklJ09s INRVADdwOZ0oXMDML0B/bji3rB3BRB+DvT0y/dGgUHoK7nVwzFSR9bUk6N0CqESeA3hZ dySexzCDosLWycarzo40+LhxKqY8tTg/+c0+UzHsmDso7C2RzCYWN04fSVmdrsRxXqMB Yu/LWrkN8JEPOzhezfvmruSa4fsLTWbOCCGglYEjVcX1TZsKpYpd5eEdQYeh68q83bX0 UrCQ== 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 g11-v6sor9504931wmg.19.2018.09.19.03.08.41 for (Google Transport Security); Wed, 19 Sep 2018 03:08:41 -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: ANB0VdZgJPGYpBQq2OBEkD7jNE2m2NRfhTGmiHgajHXDJ9aUNSIUIjDVoWBGrl/chuyhC9EF/bEBTw== X-Received: by 2002:a1c:9290:: with SMTP id u138-v6mr19088034wmd.52.1537351721295; Wed, 19 Sep 2018 03:08:41 -0700 (PDT) Received: from techadventures.net (techadventures.net. [62.201.165.239]) by smtp.gmail.com with ESMTPSA id v2-v6sm18364035wrs.54.2018.09.19.03.08.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Sep 2018 03:08:39 -0700 (PDT) Received: from d104.suse.de (charybdis-ext.suse.de [195.135.221.2]) by techadventures.net (Postfix) with ESMTPA id ACD641253C6; Wed, 19 Sep 2018 12:08:38 +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 5/5] mm/memory_hotplug: Clean up node_states_check_changes_offline Date: Wed, 19 Sep 2018 12:08:19 +0200 Message-Id: <20180919100819.25518-6-osalvador@techadventures.net> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180919100819.25518-1-osalvador@techadventures.net> References: <20180919100819.25518-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: Reviewed-by: Pavel Tatashin --- zone_last = ZONE_MOVABLE; /* * 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; --- In case the node gets empry, it must be removed from N_MEMORY. We already check N_HIGH_MEMORY a bit above within the CONFIG_HIGHMEM ifdef code. Not to say that status_change_nid is for N_MEMORY, and not for N_HIGH_MEMORY. So I re-wrote some of the comments to what I think is better. Signed-off-by: Oscar Salvador --- mm/memory_hotplug.c | 71 +++++++++++++++++++++-------------------------------- 1 file changed, 28 insertions(+), 43 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index ab3c1de18c5d..15ecf3d7a554 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1485,51 +1485,36 @@ 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. + * 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]. */ - if (N_MEMORY == N_NORMAL_MEMORY) - zone_last = ZONE_MOVABLE; - - /* - * 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]. - */ - 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; + zt = ZONE_HIGHMEM; + present_pages += pgdat->node_zones[zt].present_pages; - for (; zt <= zone_last; zt++) - present_pages += pgdat->node_zones[zt].present_pages; - if (zone_idx(zone) <= zone_last && nr_pages >= present_pages) + if (zone_idx(zone) <= zt && nr_pages >= present_pages) arg->status_change_nid_high = zone_to_nid(zone); else arg->status_change_nid_high = -1; @@ -1542,18 +1527,18 @@ static void node_states_check_changes_offline(unsigned long nr_pages, #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; + zt = ZONE_MOVABLE; + present_pages += pgdat->node_zones[zt].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