From patchwork Wed Aug 22 09:32:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 10572773 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 1C6B9112E for ; Wed, 22 Aug 2018 09:32:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0F4AF2AA30 for ; Wed, 22 Aug 2018 09:32:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 03399298D3; Wed, 22 Aug 2018 09:32:37 +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 920D1298D3 for ; Wed, 22 Aug 2018 09:32:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4855E6B23AD; Wed, 22 Aug 2018 05:32:35 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3A06B6B23AE; Wed, 22 Aug 2018 05:32:35 -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 0DCF56B23AE; Wed, 22 Aug 2018 05:32:34 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wm0-f71.google.com (mail-wm0-f71.google.com [74.125.82.71]) by kanga.kvack.org (Postfix) with ESMTP id 9550B6B23AC for ; Wed, 22 Aug 2018 05:32:34 -0400 (EDT) Received: by mail-wm0-f71.google.com with SMTP id v24-v6so1324387wmh.5 for ; Wed, 22 Aug 2018 02:32:34 -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=zqnYEmFfSStfubGMhFL+km+dqzq3LfNEkBqGNnMeElQ=; b=grfsZcxrbucLJ5piA98Df107SArR5tR8ZSKhE0QyNW5mLKzMeCzn2rKbW/6+mJwZN+ edhjGAg04txqhy8dbW0Ql9mgmWCvPucFhALI4OE1Fa2bA6SKFMYLpe8Jy/NqHsTlcM/F TfAJ2OPSPGVRHOYFu0Gs4o7X6OIFbee6ZQdWjuEkSB+1F/X7KHgsmCvBQiRN4m41+TqJ T/mBzQNLMKCFbgtsFIDPKzHNQlV7BaaHypSt7P4AVSdghEKXyoIhtos9AHtnJvypPoRp bTrikGKb5kiUN+aliYriQjJU0miaqzoGbrcNxiwh8+JnAfuNdryHuVBHmVc1m2GaUJSO BMlg== 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: APzg51B7o2V8Ctf2Qii7OXcIi8XOJvBTUCP6PQi4uibIzXSmCVW2KHtG uQsXcTAEf0oF3399+dl8pxvtj5WxepUKOyeb8OkDLaP/qrWC6w4P1WJRL7ZzIpKVKH4p7mkftU3 a2w0TB7HJJB5vftahGfBqgiSpQZB8zhhG9W57iTuxPO0oXlqKgPNPbr9w0OG61J+eK15aNXOxHG XB4qpahnNdPMwveEGG/4s+p4CQsML24v8Umo3IMdSr22kOoQaPn9S63wJb5zySbNKVNJDK9rEGR s58QLuv7gcAruptWHAsf4BdB6D1avQw1wHP72UWvRujRcDHED4GPCQziN0azUBQV0j/X4TToZ3X sJhgXDigG2lz3iKjBkI9vmVms/1RvHh0LI21HZTZlwaYjiOx6v3hc/vml0Kki4mcr0dnwfNZRw= = X-Received: by 2002:a1c:4405:: with SMTP id r5-v6mr1742118wma.4.1534930354105; Wed, 22 Aug 2018 02:32:34 -0700 (PDT) X-Received: by 2002:a1c:4405:: with SMTP id r5-v6mr1742092wma.4.1534930353295; Wed, 22 Aug 2018 02:32:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534930353; cv=none; d=google.com; s=arc-20160816; b=uzjN3utTvFmS23NW7O+Z0ivQUQb215JrPsQpKlueJe0RXOD8im9bfmLgfCWs+iIFCm vKB2vikbj2IOZB/KT2DxBdAni3TiQtmRk1oBtB7T242bLLVGKdebYCx1a+gjkKBPNpIT X0Om5YPa4sxYKx1giCBk8Jk3zGdGyZHQPk6RRy6YKCWUDxpxqNILMNnMHv4KPiiZQHMG zXonzZqmll0Eb2tVjoZ6ZptQtraPFsVzjgA1gXGEZCeehMVPS/rfEcPAd7ckxQcj3Rf7 eg5/M/BbL54Erb1Fxy1CZfmQZSEvFrDd5tLh63+xik90+dzRpN9NSFajEnq8efxTA7x7 94Fg== 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 :arc-authentication-results; bh=zqnYEmFfSStfubGMhFL+km+dqzq3LfNEkBqGNnMeElQ=; b=mbR25rUABmzajzZ0h9D5E+B0+fDUM4C6BvZmnhqXP0aveqXzyAO6FAmaOI8zGbq0zC Ui/DZFLdCGCH5L9RZVcn14J9LAwtbJj5TpgxRSoT5KY8wNlhjd0YLuhBjW3v/I5CvO5t URISAgO2B0yxkV0TDuSoBSI69OER1kpcsDm3ZuPM5osOFbgAZgK9V/h8BWezqiznpmVR QuZqkebFfTeo7EAXBLVMFNqC5YIHnO5PbSJBUV8PlfbeNaPA7ZifoBM5bGmX4Q+D2wji 5GUH5oRk5qPJr9d+yYKXJ9wj9WB92cubtywHygLQ08jRo4yB9s2ZmoOHYQpxUMmT3tEv r1HQ== 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 v7-v6sor394537wrn.87.2018.08.22.02.32.33 for (Google Transport Security); Wed, 22 Aug 2018 02:32:33 -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: ANB0VdaMqTgfSCWdBjDRWYuv35U7h8b01944NhHcAT1EEOisqVc/6/il5v1eAiDgMt/VUXU7oa0A+A== X-Received: by 2002:adf:9101:: with SMTP id j1-v6mr10482285wrj.3.1534930353055; Wed, 22 Aug 2018 02:32:33 -0700 (PDT) Received: from techadventures.net (techadventures.net. [62.201.165.239]) by smtp.gmail.com with ESMTPSA id q3-v6sm1148938wmf.21.2018.08.22.02.32.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Aug 2018 02:32:32 -0700 (PDT) Received: from d104.suse.de (nat.nue.novell.com [195.135.221.2]) by techadventures.net (Postfix) with ESMTPA id E69A3124A13; Wed, 22 Aug 2018 11:32:30 +0200 (CEST) From: Oscar Salvador To: akpm@linux-foundation.org Cc: mhocko@suse.com, dan.j.williams@intel.com, malat@debian.org, david@redhat.com, Pavel.Tatashin@microsoft.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Oscar Salvador Subject: [RFC PATCH 1/5] mm/memory_hotplug: Spare unnecessary calls to node_set_state Date: Wed, 22 Aug 2018 11:32:22 +0200 Message-Id: <20180822093226.25987-2-osalvador@techadventures.net> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180822093226.25987-1-osalvador@techadventures.net> References: <20180822093226.25987-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 will 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. Signed-off-by: Oscar Salvador --- 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 60b67f09956e..4a89915e1467 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -746,7 +746,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 Aug 22 09:32:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 10572775 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 2CFD8112E for ; Wed, 22 Aug 2018 09:32:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 20656298D3 for ; Wed, 22 Aug 2018 09:32:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 14FD92AAEC; Wed, 22 Aug 2018 09:32:41 +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 EC267298D3 for ; Wed, 22 Aug 2018 09:32:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BACEA6B23AF; Wed, 22 Aug 2018 05:32:35 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B324B6B23B1; Wed, 22 Aug 2018 05:32:35 -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 911D56B23AF; Wed, 22 Aug 2018 05:32:35 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wm0-f70.google.com (mail-wm0-f70.google.com [74.125.82.70]) by kanga.kvack.org (Postfix) with ESMTP id 2D5576B23AC for ; Wed, 22 Aug 2018 05:32:35 -0400 (EDT) Received: by mail-wm0-f70.google.com with SMTP id s18-v6so1390180wmc.5 for ; Wed, 22 Aug 2018 02:32:35 -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=Wz8/ynznSqcf8dsCpQK0BPCP5e0b9FrI7V6UJn+hlEA=; b=Tg2mvuz6xCfuWSVjzN1/+WZFTf5DJr9YIi3te2qAVZ6PQcooPX/MBfzZ4zyGQ7eSHz XMJnDG2M/3QfHhmxLrvsQTMjFl9xlTNZO1H0+szPObd2GAprksQkE6hM43ylCjpdiY71 Tf/ykZUS4q5mF9deS3z+gkJslctDiLlc1guLazqb74A2xKLLskDEMaFHVdSOkSY4zGWh 1e1wrAHDh7nBP4kVDeS0ld/RWyjbT3ocxM5OQJ5K0trflDT0rJTuZLxLrE/QQbcJjw6F tucx/cwlT1oMzvcmWYz6Acq78IH/flD6K5R8TFHIZSkoBI2Qcbut+3+OlNkXbMkFJ6Qa 7Uww== 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: APzg51DioyXIf7tQiolOrCABDIdwrX89kVqIU7hMnIrsGSvZDP67mDgx sU296iOWIqM3jVG2+rl6/9xKeZbsVcrmHaZ42EAx3+1jz7455TrngP7zLpxYrBKw5A4XMH1TUAf ci7/u7WjRxNy38KZ1LhUY/Z4pGfNd11ksvMGmd3YvkCZVIfjrGaPzs1+008qhoXuR4rr9NfZ/AV F5aFp5SuZ9emzsdBcgdoPQQJj0MERZAPL6UWSIS/bA/72J3HhMtRjNIbKYDU64p5yWUo5GFFXUx ai5ZkI/XqlW6rTqwQ3KDRfC6cwJeWl/XW3GUjOKN6XciXmUTKJobZ4il+CAAF1wcgIP3nP+rxYy oA27hmF8T1g4YoHxj/uDyD7oD2k1+v8eARs0Qc4jVDDAgnKxJSmbVE5ke/mvNpd5DYCD+9uEvQ= = X-Received: by 2002:a1c:3314:: with SMTP id z20-v6mr1745033wmz.95.1534930354636; Wed, 22 Aug 2018 02:32:34 -0700 (PDT) X-Received: by 2002:a1c:3314:: with SMTP id z20-v6mr1745003wmz.95.1534930353828; Wed, 22 Aug 2018 02:32:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534930353; cv=none; d=google.com; s=arc-20160816; b=MLa7PVQQB3qZ2rgZT4HorZPmXpMKjTbZGY2apnaoDWyccmfhBiwnNa7A8Dqn83nI/5 bTt6DN+I5h7BpVMxg4+prLITC1adXwirizvK1Rr2vBUOakRSigFhGoGMHMECrjY81XOW yC/LJluz5mlgRW7axOnYyVZHNrTP2NiWxcoh/Abg4Ln1UUvgsZg2cdUjmf6h5qo28ZZs EIoYCKhGzq7T8n6VXsRsEoKMpKN4Xp2QvcxenYeiQJ+ahoSitnRhW/t+4NOPeubZaMTe YFdGdwRW9gRHPbn5OpW/th0bo0u2wWdzchyhL2eGJ4QsztucLoooXcK0nsK+Hk2gUSWo s9GQ== 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 :arc-authentication-results; bh=Wz8/ynznSqcf8dsCpQK0BPCP5e0b9FrI7V6UJn+hlEA=; b=ZbFV3xrx15ZQIuXwHvy3RPsj4Hw3Lti9nsvcqsOWZgTpQedoEnNsOTLzXHkBgGANIz 97/B3U0HXQ+JwurXwNPo5crxe6/ups/GV5yy8MSP606+IZwxAQ4ecPYKqj/R54sWItSr 28FC+Ne+/83kgCRZQrI0vQnIJSKf+MQzLk+zxh3bwA6+40I4E91K+SjLz9zc+e9/z8Rp NnP/Q30s1MLWJUSgIWqNe+8TenaQOAZMy1qZ19iOHipmslM5d+1mNYcxbpxxM4owiEda k3InxcaOfA5Gdv73zOaMkIjH2jqSoN3fH+9UZsaWZPiAzIPGrWn+eG9jR/3bJ8nDrnTs tpTw== 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 g5-v6sor338492wme.55.2018.08.22.02.32.33 for (Google Transport Security); Wed, 22 Aug 2018 02:32:33 -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: ANB0VdbHrwXHXSCrKU8pWVOCF9UhkYpALTex3Krz0ZWw3HwbSHiQkxhOSXexVU1R2czef+JwNwC86g== X-Received: by 2002:a1c:6f8b:: with SMTP id c11-v6mr1937798wmi.138.1534930353518; Wed, 22 Aug 2018 02:32:33 -0700 (PDT) Received: from techadventures.net (techadventures.net. [62.201.165.239]) by smtp.gmail.com with ESMTPSA id t13-v6sm940418wrr.74.2018.08.22.02.32.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Aug 2018 02:32:32 -0700 (PDT) Received: from d104.suse.de (nat.nue.novell.com [195.135.221.2]) by techadventures.net (Postfix) with ESMTPA id 2DF57124A14; Wed, 22 Aug 2018 11:32:31 +0200 (CEST) From: Oscar Salvador To: akpm@linux-foundation.org Cc: mhocko@suse.com, dan.j.williams@intel.com, malat@debian.org, david@redhat.com, Pavel.Tatashin@microsoft.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Oscar Salvador Subject: [RFC PATCH 2/5] mm/memory_hotplug: Avoid node_set/clear_state(N_HIGH_MEMORY) when !CONFIG_HIGHMEM Date: Wed, 22 Aug 2018 11:32:23 +0200 Message-Id: <20180822093226.25987-3-osalvador@techadventures.net> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180822093226.25987-1-osalvador@techadventures.net> References: <20180822093226.25987-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 Currently, when !CONFIG_HIGHMEM, status_change_nid_high is being set to status_change_nid_normal, but on such systems, N_HIGH_MEMORY equals 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 --- 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 4a89915e1467..1cfd0b5a9cc7 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -724,7 +724,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 /* @@ -1547,7 +1551,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 Aug 22 09:32:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 10572777 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 C155D112E for ; Wed, 22 Aug 2018 09:32:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B2FC5298D3 for ; Wed, 22 Aug 2018 09:32:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A70D62AAEC; Wed, 22 Aug 2018 09:32:42 +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 20BC9298D3 for ; Wed, 22 Aug 2018 09:32:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4596E6B23AE; Wed, 22 Aug 2018 05:32:36 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3BD6B6B23B0; Wed, 22 Aug 2018 05:32:36 -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 1E8746B23B1; Wed, 22 Aug 2018 05:32:36 -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 ADC8E6B23AE for ; Wed, 22 Aug 2018 05:32:35 -0400 (EDT) Received: by mail-wr1-f70.google.com with SMTP id v11-v6so733186wrn.19 for ; Wed, 22 Aug 2018 02:32:35 -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=jYkTykqTIEVYyBeQj0aD08ILz0lDkebKvUInR6uiJsg=; b=AfdzSlhYV98XuWPoHex8Ui22xklUafDoHOPQoSM7wKt5UjpVzotoXSLN47DQh6cCG5 tdA9BhUi0JqD1XtA+5SNbzJsrLl3RPq8yAnjtaCeUSURrBWPvhEdIxfW9/7sX74EVvBi 7yYW+AJsfJRBvXNlw+f+fRnS/4yjnMc17HWzrh841SOMVTterphGX6Y+7KDks4WKl8Mu XvALqexRrQwlLpXLUTMHE7/im9QYpeLyygYu7Enyitm81NpONi954a64yJnib77dtmB2 GDRNYTbL06tvwubf0iHehUONyLJobf3ww2S0757eXb4GJUyuQ6bwgxPZ0HTxdfWpr/70 1wNA== 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: APzg51C+OBuA4N00LqjFWfG5o4est8NvqYJ0opvbwb55gHdYt3hu1xon WXkrzgN5Dr4BXaQo31nfBThuGkILRXEcWZzeMXietJULgL1s16I4/sfDANbiJmigrU2ipCVQfKP J7B9fT4V3TMwk2XaVrcl+qNlub5u7/6c0t1Ov5XmJDqQDCcfST5Vtff1Q+n+XF3CSY9HUYcukTg z5XMLoFkS9IqVE5ANPWHiRZlzA/coqPOH7xvYWS2dnDWBU+3X0Xp/LefN+1nENTFs0s6T3z7Qm3 NQguchBy3maT0zlm2ro+fpntFxfq44PRz62oyhAihwxelHVFz4J5E18tmDRmpyM3xIeKfmPKJjb YEufFefz0ajxf18xbXuHE4S/cgSl32dwOqwSM0PmUS6nNTuJ8EVro2DOVEyyWA3vZ3DzymKcew= = X-Received: by 2002:a1c:b406:: with SMTP id d6-v6mr1849250wmf.126.1534930355222; Wed, 22 Aug 2018 02:32:35 -0700 (PDT) X-Received: by 2002:a1c:b406:: with SMTP id d6-v6mr1849217wmf.126.1534930354332; Wed, 22 Aug 2018 02:32:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534930354; cv=none; d=google.com; s=arc-20160816; b=t1wX96ZJ2anHsbJ8Og+6+G+lZeFUbV4s+0qK0fc58XozcNRRTvylA7Map31z0cggd+ fMmD9WNGB/WLgEOidlfY5LVXjJO89MhWu6hH0zxp3cK+eD1DTZsxZWMghc6VsFt3CYW3 s1jf+Wuz3wKOkunX62gYzs3QZKFKU925EmPvL9Tl9Ta96Ly2tHpAJOAdeH5NXInw2iB6 vZQr1Q3I6IbOyASZxq08Za0Yf/KuX9omOJyDssV+PqsEiaB0XoaaQHqQTDhtkRKj5m94 FTxGol2cf6oUO7p4ad8X8H6MJNgKsQGtF//FHBo0gQ2vr7T90neTmjFaqk6ngGg1Boq0 hgxA== 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 :arc-authentication-results; bh=jYkTykqTIEVYyBeQj0aD08ILz0lDkebKvUInR6uiJsg=; b=cO1A8PNNMG3o+qKyIQejXxZ8a35mDribwbJIvr/AX447j6O2IAo9JlMI1ueeLkqXxJ 6q34AYHXTHxzokHBiMU5Y1/i0BuQyuU+08QtJzHmgQQzmXbas/i324amuAsEb8TJnHuG MxSkKRrSsKtEo+V4vnWDjZ5Po3S9sHciAXk7wnau72066lLXOHxFQK1ZisUxpq2xz/cP CuwQJBBN6w/UlH0Na1T94pzg49y8pqHg2O7xqh6cE1dftOK0Se2/uyVkkBtVWOuXQV8o uIYooRdBAkroL7/nvVrvf0riq7A8SVtFqdBUybBa4jdNhU+YwQBlkEZ9XGwGVEtUtYs5 ZDfw== 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 h19-v6sor299891wmb.88.2018.08.22.02.32.34 for (Google Transport Security); Wed, 22 Aug 2018 02:32:34 -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: ANB0VdaUAKPFzkNQNeYtkQHN9lzSGtEOWGUbTss5CpGcInT9fj+ZMgr64iQyCVEGHsbK+DSdocUFSA== X-Received: by 2002:a1c:a401:: with SMTP id n1-v6mr1926217wme.125.1534930353964; Wed, 22 Aug 2018 02:32:33 -0700 (PDT) Received: from techadventures.net (techadventures.net. [62.201.165.239]) by smtp.gmail.com with ESMTPSA id f132-v6sm1260349wme.24.2018.08.22.02.32.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Aug 2018 02:32:32 -0700 (PDT) Received: from d104.suse.de (nat.nue.novell.com [195.135.221.2]) by techadventures.net (Postfix) with ESMTPA id 65EE8124A15; Wed, 22 Aug 2018 11:32:31 +0200 (CEST) From: Oscar Salvador To: akpm@linux-foundation.org Cc: mhocko@suse.com, dan.j.williams@intel.com, malat@debian.org, david@redhat.com, Pavel.Tatashin@microsoft.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Oscar Salvador Subject: [RFC PATCH 3/5] mm/memory_hotplug: Simplify node_states_check_changes_online Date: Wed, 22 Aug 2018 11:32:24 +0200 Message-Id: <20180822093226.25987-4-osalvador@techadventures.net> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180822093226.25987-1-osalvador@techadventures.net> References: <20180822093226.25987-1-osalvador@techadventures.net> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000002, 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 saw some confusing things I am not sure how it was supposed to work. Right after entering the function, we find this: if (N_MEMORY == N_NORMAL_MEMORY) zone_last = ZONE_MOVABLE; This, unless I am missing something really obvious, 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_HICHMEM block, we have: if (N_MEMORY == N_HIGH_MEMORY) zone_last = ZONE_MOVABLE; This is also wrong, and will never be evaluated to true. The thing is that besides this, the function can be simplified a bit. - If the zone is whithin (0..ZONE_NORMAL], we need to set the node for node_state[N_NORMAL_MEMORY] - If we have CONFIG_HIGHMEM, and the zone is within (0..ZONE_NORMAL], we need to set the node for node_state[N_HIGH_MEMORY], as N_HIGH_MEMORY stands for regular or high memory. - Finally, we set the node for node_states[N_MEMORY]. ZONE_MOVABLE ends up there. Signed-off-by: Oscar Salvador --- mm/memory_hotplug.c | 44 +++++++++++++------------------------------- 1 file changed, 13 insertions(+), 31 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 1cfd0b5a9cc7..0f2cf6941224 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -680,46 +680,28 @@ 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; - - /* - * 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. + * node_states[N_NORMAL_MEMORY] contains nodes which have + * zones from (0..ZONE_NORMAL] + * We can start checking if the current zone is in that range + * and if so, if the node needs to be set to node_states[N_NORMAL_MEMORY] + * after memory is online. */ - if (zone_idx(zone) <= zone_last && !node_state(nid, N_NORMAL_MEMORY)) + 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. + * The current zone cannot be ZONE_HIGHMEM, as zone_for_pfn_range + * can only return (0..ZONE_NORMAL] or ZONE_MOVABLE. + * N_HIGH_MEMORY stands for regular or high memory, so if the zone + * is within the range (0..ZONE_NORMAL], we have to set the node + * for N_HIGH_MEMORY as well. */ - 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) < ZONE_HIGHMEM && !node_state(nid, N_HIGH_MEMORY)) arg->status_change_nid_high = nid; else arg->status_change_nid_high = -1; @@ -732,7 +714,7 @@ static void node_states_check_changes_online(unsigned long nr_pages, #endif /* - * if the node don't have memory befor online, we will need to + * if the node don't have memory before online, we will need to * set the node to node_states[N_MEMORY] after the memory * is online. */ From patchwork Wed Aug 22 09:32:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 10572779 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 F2DAE112E for ; Wed, 22 Aug 2018 09:32:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E5C9D298D3 for ; Wed, 22 Aug 2018 09:32:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D95C52AAEC; Wed, 22 Aug 2018 09:32: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 79DA8298D3 for ; Wed, 22 Aug 2018 09:32:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E67916B23B1; Wed, 22 Aug 2018 05:32:36 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DF9BA6B23B3; Wed, 22 Aug 2018 05:32:36 -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 AEABC6B23B2; Wed, 22 Aug 2018 05:32:36 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wm0-f71.google.com (mail-wm0-f71.google.com [74.125.82.71]) by kanga.kvack.org (Postfix) with ESMTP id 411B86B23B1 for ; Wed, 22 Aug 2018 05:32:36 -0400 (EDT) Received: by mail-wm0-f71.google.com with SMTP id s18-v6so1401802wmh.0 for ; Wed, 22 Aug 2018 02:32:36 -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=nxUagGrg5D666cpnIjgBZsQJk+sz7QTKW02cy3LKoaE=; b=W8XGLoWqilejIDGGUDtdYarW6hHOXNE8GSFN4H5Vi0e6ZcBXBESdKKh544Agg/UT9i EtHr4LGb/nOW2UG8d/XnVsqO9795SY8HfGE44VIKzm7CSynosk1BkUy7npt5026zXsnL x47yMNwmezk+XHcMB+yGq3aoz/JUSFpdlAdJTJ3cy3hJoixCiJ1Cz1TGh2ycdgVva15d vGuDKHYgai+aGL6QyCsKhxQZq7jpHIdh8tQ46TexK4D9We1xvzoQQFyZ0QZPM5IgBjNI AJcP3/xhuy1uMEFA0akUmjYtmV5gEbg9okX+0Z3ncghNNHtyuxE6wcT9QAgVEtCxernH ZMEw== 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: APzg51BBfQvWxMpBhRH6O5L7jbDmszAZgeIJv/nHUFiG2S3aTrQ4NgrX a2z9Wtz9bXLArlsoQ1gbagL5hreLJavRzvFSwodIMKCBYHS+9Ac82Cg4eZcQaxOTuFq9881LYkq j3RQVLtot+z2eZRXqYco4G26vuVhILw1tVLoAWUfF/N0zIIAK4AnP5C43q+jlR3xBGe55vxJL60 JUmoxYD4z4LqBgez6JzbO8Xjtk3rGCi9WXU3QeIXdzdGG1nYBdS6F8fvJWE3hiR8az3RcHLiH5B 86GaUX3zYIAgn1vqYVUMBGng+6NYcsAkOLHe8Eq+2OAfiKqKmCkUTjSnML7YejGWdkM9q3Zi0Mh x2UjFQsbp0xYcuyEIz/Y/W/xS8Ut492/R33jxNIQJYqahUN2TnSpablx4gXCG1jMQRFD2A+/fw= = X-Received: by 2002:a1c:cc1a:: with SMTP id h26-v6mr1953489wmb.112.1534930355795; Wed, 22 Aug 2018 02:32:35 -0700 (PDT) X-Received: by 2002:a1c:cc1a:: with SMTP id h26-v6mr1953461wmb.112.1534930354912; Wed, 22 Aug 2018 02:32:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534930354; cv=none; d=google.com; s=arc-20160816; b=uREf5sEhkBaIQwbhGNjeqEiTkUD0LSk/+1+nLdZxcxqf1CRkLRQzxy2s+GwzcSf20l 2kJ+KqKpZZKaQAv+FWAHALYaZQ84qkgbaCpThpfppeOGVot2eeffKu0XUpfClKWgpk3a ZhNKBgls6fWhgfOeAsVFXnDHbsdbs+SHgK454qZzcVnuw6hjCtAvzkQLeFuYubsDsvqy /0FSxXGzHareZIeV2TlcqtkeTwFnekD0iBfuneBQhim/paVX5xNgOhZt7fvj6h/ErSfk JIk35GP54ynD8oHngtwIQ72g2TXsQfDFBmLZAKvziRs7oP+1H5ioXh9JxR9uZKowmRYO flVQ== 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 :arc-authentication-results; bh=nxUagGrg5D666cpnIjgBZsQJk+sz7QTKW02cy3LKoaE=; b=X0ARXfo29QYTLUwqoetNRnebwHM2mPKDMpTd5kdPrav+8LVa5coG3BUtdBF17clNW/ WUE9eiMzVlRvEGlQ5zRapwf7SCnjzA+rReO7RO3P2smb8Kj0/b1Q/ZuI7NCjUmlXjowH UGdZ1Rs34fnA8TaGcA9iC0YZuo5JGAZJczQTeLEKLOOO7ojZEscguyuzaifNkwFrdBYE eoOIAt3u/EAH245lFzvLQfHHBmThmAZHdGYAex3ohzLY3im7pXWWQopCcIPUNl0ZoYzX voedheB03uuPVKnmUw8Q2j6qJk5fX8llw9TiJi0lHwCOTbuoEyKbHVCooVxNpCuJObpB lcWw== 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 g40-v6sor393760wrd.15.2018.08.22.02.32.34 for (Google Transport Security); Wed, 22 Aug 2018 02:32:34 -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: ANB0VdYF/NAGu5c3hvht6sSSFszgiUORPgrM7HTAMBTHGwg8K6Fg51jSrRQF6DXfaHH3XTD2dxlrKA== X-Received: by 2002:adf:b609:: with SMTP id f9-v6mr6051323wre.14.1534930354670; Wed, 22 Aug 2018 02:32:34 -0700 (PDT) Received: from techadventures.net (techadventures.net. [62.201.165.239]) by smtp.gmail.com with ESMTPSA id 144-v6sm2290164wma.19.2018.08.22.02.32.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Aug 2018 02:32:33 -0700 (PDT) Received: from d104.suse.de (nat.nue.novell.com [195.135.221.2]) by techadventures.net (Postfix) with ESMTPA id 992EF124A16; Wed, 22 Aug 2018 11:32:31 +0200 (CEST) From: Oscar Salvador To: akpm@linux-foundation.org Cc: mhocko@suse.com, dan.j.williams@intel.com, malat@debian.org, david@redhat.com, Pavel.Tatashin@microsoft.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Oscar Salvador Subject: [RFC PATCH 4/5] mm/memory_hotplug: Tidy up node_states_clear_node Date: Wed, 22 Aug 2018 11:32:25 +0200 Message-Id: <20180822093226.25987-5-osalvador@techadventures.net> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180822093226.25987-1-osalvador@techadventures.net> References: <20180822093226.25987-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. This is wrong, so let us get rid of it. Signed-off-by: Oscar Salvador --- 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 0f2cf6941224..006a7b817724 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1564,12 +1564,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 Aug 22 09:32:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 10572781 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 BC45A139B for ; Wed, 22 Aug 2018 09:32:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AD60D298D3 for ; Wed, 22 Aug 2018 09:32:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A03852AAEC; Wed, 22 Aug 2018 09:32: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 1701C298D3 for ; Wed, 22 Aug 2018 09:32:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5DBE06B23B0; Wed, 22 Aug 2018 05:32:37 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 566C06B23B2; Wed, 22 Aug 2018 05:32:37 -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 412166B23B3; Wed, 22 Aug 2018 05:32:37 -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 BB5D46B23B0 for ; Wed, 22 Aug 2018 05:32:36 -0400 (EDT) Received: by mail-wr1-f69.google.com with SMTP id v11-v6so733243wrn.19 for ; Wed, 22 Aug 2018 02:32:36 -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=Pr2O40TB9sxq7YnJMaW3tfAKxlcOinscuFYdiw5J9bo=; b=lm3OM0f3yMYoHFghtc/6hTUnW7xy8fPxgBkXZIKn0alBPkRqogyGboKtslBJWR+k5p /rW7ZoXCdYtMOS314CouMGrMAUyyNsB/n3ZCZRAz2cqIA+30bqoQVDRTUqtrOzr6qzCR j6obAJHbIldS2aAL1qg4by/DNQoRyfWGPROLRssn23S3z3Uery7QE+5c/UlqQYm9TGPi Yr9wDLqu9eoBnj21N6I/1FQ2PGiYToSIZINLto/pIpWJh8ZKerZA085vXqkwHYshYA7k XfCC8NSHkr+odgRYoI0NuMm2ejFEGY934RnkU4a/0jXhjUftUjWbGkW7bnjoRwTSCCbB s8Fw== 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: APzg51CcJ84O+xVsHCKcSAdu048BWkle1asFBVUC1n8OJlmErVavl7/U qEm/6IRXcOd0iV4oIwxMBrQf9mdzvRpKFEDKBITgv+B5lux1FEki3AAFGFDP/awzCd3h3SV/Q8h NfYEK+WCiE+W76tIgevSm5W9Wt9IpvAGCyshbDl4SNXwrpXSQzhQQDsw8/sSkFDOJk731FXR5TJ xmZV5kDHhAXeVXGjpj7JlM7dX+7wYcTq3XjK8PEzzQebWCq4GnLhFWDxrLvVFksgM1PkoILAtZJ Bsx/0xFyKJ0kHCyWkkTEFG9YFJxljDn0NMxAyyaaaLvrfL02BzAPYhAHer1pkETw9/wxxNMYs0l wVwXjwG32TPcuGTSlNzIKYlJk0pgfE91XyEL2irQYSBDegGunL3AJ/Dv/Q9fFcJUdJK8KNfMGw= = X-Received: by 2002:a1c:b143:: with SMTP id a64-v6mr1985701wmf.114.1534930356288; Wed, 22 Aug 2018 02:32:36 -0700 (PDT) X-Received: by 2002:a1c:b143:: with SMTP id a64-v6mr1985668wmf.114.1534930355404; Wed, 22 Aug 2018 02:32:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534930355; cv=none; d=google.com; s=arc-20160816; b=ozI65h4EDRhbdeEsFUfx0MVIOP0d9NQ21OjD9WeYciIYHOgOURAP7xcoD/m5Da/1yN Cy1WYwQvQezyo1xtuJhY+/Yvo0Y89giBys0Y2/CsLGV3So4e0v9UY9UMjI8rDGCBMTcO Px5Yb9BruXm16xF9U7zd0zzRiRs6a8om9/y7v9QJybPi/6DEv0OVnYNeEpNrdYp7jxf7 mQC9ig3zFTX3dyQMtU/ItIWTW8R9CHSKEWCzk3aJDjhflATyv3JcOLK240q6xxxr8RxU zZbSqjeTbIz0tkCdHZjTh5NuXec3i5/D2PUDIHG75MILwu6pnr5bPdj+XGnkmFJjdN8b e2lA== 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 :arc-authentication-results; bh=Pr2O40TB9sxq7YnJMaW3tfAKxlcOinscuFYdiw5J9bo=; b=p5ER+SmjUrB9rAA2DVA5Vas5Y4KPkYHcI9LRe8V97JsG+WCJy7omqCZcNEXaf4KF5O XjX/seiHIkLNH6VX3W5iuxJ1iQztUnNXQmQaKjGUwPG9glpzFSLV/2XJUJlMRn6qCDyz Ks2MlRl9z5G83dNwc5hhPiU4HQV5XOH+THe7U8xUdaKtAldmwMDJz1cQO8wTESWny2Bj wW9DVEk1irw8OkJ4jC6eV1cqcfGJw1ZrmFRibw6a4VSXTRQ956cHtg7EIKAu8rBfu60h xz61cdoCeS4ZqgnySS/cHDQ0t6Qi3hCLM7qqi3/nBzlII/mjmd6nHy0XvSam9I+rSVfI FHJQ== 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 b190-v6sor341566wma.69.2018.08.22.02.32.35 for (Google Transport Security); Wed, 22 Aug 2018 02:32:35 -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: ANB0VdYEvE1cm5Z7++E5F9Lg9empOICLxh/N6KJ06RqF1VehZVmu68vt1tdFj0Io/1zvFd2xctnlmQ== X-Received: by 2002:a1c:3663:: with SMTP id d96-v6mr672209wma.92.1534930355096; Wed, 22 Aug 2018 02:32:35 -0700 (PDT) Received: from techadventures.net (techadventures.net. [62.201.165.239]) by smtp.gmail.com with ESMTPSA id q5-v6sm2363469wmd.29.2018.08.22.02.32.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Aug 2018 02:32:34 -0700 (PDT) Received: from d104.suse.de (nat.nue.novell.com [195.135.221.2]) by techadventures.net (Postfix) with ESMTPA id D506A124A17; Wed, 22 Aug 2018 11:32:31 +0200 (CEST) From: Oscar Salvador To: akpm@linux-foundation.org Cc: mhocko@suse.com, dan.j.williams@intel.com, malat@debian.org, david@redhat.com, Pavel.Tatashin@microsoft.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Oscar Salvador Subject: [RFC PATCH 5/5] mm/memory_hotplug: Simplify node_states_check_changes_offline Date: Wed, 22 Aug 2018 11:32:26 +0200 Message-Id: <20180822093226.25987-6-osalvador@techadventures.net> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180822093226.25987-1-osalvador@techadventures.net> References: <20180822093226.25987-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 tries to simplify node_states_check_changes_offline and make the code more understandable by: - Removing the if (N_MEMORY == N_NORMAL_MEMORY) wrong statement - Removing the if (N_MEMORY == N_HIGH_MEMORY) wrong statement - Re-structure the code a bit - Removing confusing comments Signed-off-by: Oscar Salvador --- mm/memory_hotplug.c | 81 ++++++++++++++++++++++------------------------------- 1 file changed, 33 insertions(+), 48 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 006a7b817724..b45bc681e6db 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1487,51 +1487,40 @@ static void node_states_check_changes_offline(unsigned long nr_pages, enum zone_type zt, 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 the current zone is whithin (0..ZONE_NORMAL], + * check if the amount of pages that are going to be + * offlined is above or equal to the sum of the present + * pages of these zones. + * If that happens, we need to take this node out of + * node_state[N_NORMAL_MEMORY] */ - if (N_MEMORY == N_NORMAL_MEMORY) - zone_last = ZONE_MOVABLE; + if (zone_idx(zone) <= zone_last) { + for (zt = 0; zt <= zone_last; zt++) + present_pages += pgdat->node_zones[zt].present_pages; - /* - * 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++) - present_pages += pgdat->node_zones[zt].present_pages; - if (zone_idx(zone) <= zone_last && nr_pages >= present_pages) - arg->status_change_nid_normal = zone_to_nid(zone); - else - arg->status_change_nid_normal = -1; + if (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. + * If the current zone is whithin (0..ZONE_HIGHMEM], check if + * the amount of pages that are going to be offlined is above + * or equal to the sum of the present pages of these zones. + * If that happens, we need to take this node out of + * node_state[N_HIGH_MEMORY] */ - zone_last = ZONE_HIGHMEM; - if (N_MEMORY == N_HIGH_MEMORY) - zone_last = ZONE_MOVABLE; - - for (; zt <= zone_last; zt++) + if (zone_idx(zone) <= ZONE_HIGHMEM) { + zt = ZONE_HIGHMEM; present_pages += pgdat->node_zones[zt].present_pages; - if (zone_idx(zone) <= zone_last && nr_pages >= present_pages) - arg->status_change_nid_high = zone_to_nid(zone); - else - arg->status_change_nid_high = -1; + + if (nr_pages >= present_pages) + arg->status_change_nid_high = zone_to_nid(zone); + else + arg->status_change_nid_high = -1; + } #else /* * When !CONFIG_HIGHMEM, N_HIGH_MEMORY equals N_NORMAL_MEMORY @@ -1541,18 +1530,14 @@ static void node_states_check_changes_offline(unsigned long nr_pages, #endif /* - * node_states[N_HIGH_MEMORY] contains nodes which have 0...ZONE_MOVABLE + * Count pages from ZONE_MOVABLE as well. + * If the amount of pages that are going to be offlined is above + * or equal the sum of the present pages of all zones, we need + * to remove this node from node_state[N_MEMORY] */ - 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