Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp543040imm; Wed, 19 Sep 2018 03:10:26 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYi3Nc+klSANEgGjebpqWKLcHzl8UWCoHW7yMX1WNwZtk78RP7xk/IrF3ILH38QyxXio5sp X-Received: by 2002:a63:3741:: with SMTP id g1-v6mr155841pgn.59.1537351826740; Wed, 19 Sep 2018 03:10:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537351826; cv=none; d=google.com; s=arc-20160816; b=niZb27VRV+IrLlHc3TNLfMU0F+YTgstY25jHLfKd8KOttMfq9Szl+nMXxTzHpjdQX1 ZGd0Xdh5KVrhl0n7rrIeEkL6Zegr3413uX2d65mGGNcFkse/JWFNAoeoqQI0U6U8fzAE teF0hQ52P7vCW/9aYA4Hiu1qlxj2lI1FdU6tm/LOq44IxAcUg5MkdKKr2KRsnZj0ILmd 5zSlCQHl2NQ7hXDgFqbvgh/K3ok6YsxcOQ339O40uy6lSXuIoYgNjNkBjXHWHeZ9sDng zf/o5qnFC3+sJL+02Ct1QDBKZeAlkMMbTYAtWuSLAe6pbv8ID/wNhEDB9VxGsEmGPN3q O3ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=/RrOOYn9/i5abI8jQPJ0P3dbfJeu7mgxvohT+QHErjI=; b=H1UoqBxXlYnOSsT0f9kkwTt6HlTGc/zz4v29xfQA8dEG41BXd6PJO7JpP/dR89p01F bLjOH+RQfx7UZtLgo3i7u9L4iezYvkASk/SJ9Sgd89W430XYJHOBnQT2RxY6mQXbBvCp xZAoCtWWFpgWBXef6gwaxOvNNXr9M8vIQT0m/JvCouj4Ad6IYJ0XEeoLOf7ANPkrjie7 KQvFH29plokLw5l67NOYDZkr7pICi5iCMTJunS9JzNfc/UMi5Un040mS5eTZRhcQnKAD WKQ5nO64B0+TCP7hmp1K5YOmm/FmkC9IGwfaxoZoYCX1O8VTtG3iXzLpR/tj7Yo6WXbq /AKQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e1-v6si20271191plt.325.2018.09.19.03.10.11; Wed, 19 Sep 2018 03:10:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731179AbeISPpw (ORCPT + 99 others); Wed, 19 Sep 2018 11:45:52 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:34383 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727605AbeISPpv (ORCPT ); Wed, 19 Sep 2018 11:45:51 -0400 Received: by mail-wm1-f66.google.com with SMTP id j25-v6so9072378wmc.1 for ; Wed, 19 Sep 2018 03:08:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=/RrOOYn9/i5abI8jQPJ0P3dbfJeu7mgxvohT+QHErjI=; b=H7S4Z0mRBTa9o6O+EdZYg3XxuY5v/E1OS/26JoCg/6mZaI43Rj4V9LXurMbFfDdYtK j1Isy/QECYmDuT+aJpnznZUrYqkNI5k5tiNNVtu1dguekSSI8b7Uo6YANzgXiwwsgaET xkTokDnQKF4drR49AtWtM/3OATLgTYgXhEUCQ0Weyqaq8ZXqTZ4wQ4JCmr5LUEtca9oG 3jQY+EzJcNR21MdkyU9UlfxYe6eKau0Ekk1cz/Jw0l+hoJeyhyCyIXM2ZxP+J82wM545 Ludcclitu1o7sQXBuMNvu3BCRnnP/6knCbn9TJ9IoEqaDoon52v/1+/Y0Jw7Ui/KxmRm jWMg== X-Gm-Message-State: APzg51A2elGI9jKHRTME4suDYdW3BIV9yFVXBP8gEpuLEwQsF1yfIopM MSP7X8k//+2TB8Xe4h9Moao= X-Received: by 2002:a1c:dd05:: with SMTP id u5-v6mr19916494wmg.107.1537351718758; Wed, 19 Sep 2018 03:08:38 -0700 (PDT) Received: from techadventures.net (techadventures.net. [62.201.165.239]) by smtp.gmail.com with ESMTPSA id x16-v6sm21265497wrm.69.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 6C020125379; 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 0/5] Refactor node_states_check_changes_online/offline Date: Wed, 19 Sep 2018 12:08:14 +0200 Message-Id: <20180919100819.25518-1-osalvador@techadventures.net> X-Mailer: git-send-email 2.13.6 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Oscar Salvador This patchset refactors/clean ups node_states_check_changes_online/offline functions together with node_states_set/clear_node. The main reason behind this patchset is that currently, these functions are suboptimal and confusing. For example, they contain wrong statements like: if (N_MEMORY == N_NORMAL_MEMORY) if (N_MEMORY =! N_NORMAL_MEMORY) if (N_MEMORY != N_HIGH_MEMORY) if (N_MEMORY == N_HIGH_MEMORY) These comparasions are wrong, as N_MEMORY will never be equal to either N_NORMAL_MEMORY or N_HIGH_MEMORY. Although the statements do not "affect" the flow because in the way they are placed, they are completely wrong and confusing. I caught another misuse of this in [1]. Another thing that this patchset addresses is the fact that some functions get called twice, or even unconditionally, without any need. Examples of this are: - node_states_set_node()->node_set_state(node, N_MEMORY) * node_states_set_node() gets called whenever we online pages, so we end up calling node_set_state(node, N_MEMORY) everytime. To avoid this, we should check if the node is already in node_state[N_MEMORY]. - node_states_set_node()->node_set_state(node, N_HIGH_MEMORY) * On !CONFIG_HIGH_MEMORY, N_HIGH_MEMORY == N_NORMAL_MEMORY, but the current code sets: status_change_nid_high = status_change_nid_normal This means that we will call node_set_state(node, N_NORMAL_MEMORY) twice. The fix here is to set status_change_nid_normal = -1 on such systems, so we skip the second call. [1] https://patchwork.kernel.org/patch/10579155/ Oscar Salvador (5): mm/memory_hotplug: Spare unnecessary calls to node_set_state mm/memory_hotplug: Avoid node_set/clear_state(N_HIGH_MEMORY) when !CONFIG_HIGHMEM mm/memory_hotplug: Tidy up node_states_clear_node mm/memory_hotplug: Simplify node_states_check_changes_online mm/memory_hotplug: Clean up node_states_check_changes_offline mm/memory_hotplug.c | 153 +++++++++++++++++++++------------------------------- 1 file changed, 60 insertions(+), 93 deletions(-) -- 2.13.6