From patchwork Fri Sep 21 13:26:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 10610027 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 A16D3157B for ; Fri, 21 Sep 2018 13:26:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8779B2DB18 for ; Fri, 21 Sep 2018 13:26:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7A58D2DB1A; Fri, 21 Sep 2018 13:26:45 +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 0D8672DB18 for ; Fri, 21 Sep 2018 13:26:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A4BFF8E0002; Fri, 21 Sep 2018 09:26:43 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9FB748E0001; Fri, 21 Sep 2018 09:26: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 913278E0002; Fri, 21 Sep 2018 09:26:43 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by kanga.kvack.org (Postfix) with ESMTP id 390638E0001 for ; Fri, 21 Sep 2018 09:26:43 -0400 (EDT) Received: by mail-wm1-f72.google.com with SMTP id 199-v6so2450206wme.1 for ; Fri, 21 Sep 2018 06:26:43 -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; bh=1uKCZtawr6sx1VF67pqvvb8M6Rauyp4CSph0imxJ5Ao=; b=r8WJiAMjXNdPO0OmMpb3M9U4zqJKOPaL2sJHshTJbZylmk88ocqx1FmIfqg3IT9tC2 sKfD803WDqSLMnXJwtmk5WzSCmo0QpTXl2fiHoWXTxr4DOXo+yaZaXu3u3DP0T598ybo AkToJBJ2c5290W5w/dP11TRc8w7dxGUxmEUmj+41m+nx/WB0TjPXa0Q5J8uMk1/1c14l HFd+g0IzefczSPQMxrO5o1e/LOLuFn1VVtL9LH0cPEfrakEDYubGSRmmf/PtwRgVrVqe b+txRhfS+WxWE7hGwdrKXYYuq6kAbtoqT3Dg5aOOB1rs+luRaMl34rRuHv7+AIJc9WhL 4oDA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of osalvador.vilardaga@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=osalvador.vilardaga@gmail.com X-Gm-Message-State: APzg51BMQ5c3Kaq/q+KQl4tEXLpqrX/m7+nEevZNnKjmMf/G24ybzMlt vF3WD8bKiALeU8tSDKamMLkW3UI5DWZQCQNEAzJpsDeQ8n42jN+aB7cIP49Qqtg5zxg7LaFd+Od 10nldxSmyYbkiLIc2Ay9Ylnc1rLosuTkUfP/HarKKxBWZIHhpTJFJMbTPxyRCJttddCWkR6g1wB 4fdHMj+dNoJICIqnLMJcS1Pf4KcLdj8b5KRJrvi9ykSifWZrGesKzbfOzh3eS4ScRwvwuQjLbCH l3lpprN3Cy0hml252XCbitAuJotifZtsQw7Mmo7ufSDGObtf3QXdHuMqZq69JpMVnZq6ZFv6zTQ ez5rRBpjac+zdPBb10iJCu8M5mz9ZtqHCF4b1z8TL4SuFvY1VZNZ++doEiD5NJq0Nm1sqLPz2w= = X-Received: by 2002:adf:ea92:: with SMTP id s18-v6mr36769274wrm.284.1537536402722; Fri, 21 Sep 2018 06:26:42 -0700 (PDT) X-Received: by 2002:adf:ea92:: with SMTP id s18-v6mr36769227wrm.284.1537536401869; Fri, 21 Sep 2018 06:26:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537536401; cv=none; d=google.com; s=arc-20160816; b=G2MCykCn6Wjx6NJcIbfmxHhhqmcFkHbAZmWAS+CdNVyf6GBj8dPUVr5Ncpx+WD+Maf OVNrIEKcBktp8jsl8RJ8LbF/brSHtUFXXGbg9BSA5P4EmKO+nzIm9AzHy6sAifpCC298 AP5I6zfJSX6EFIKno0f/xhwYA3bCFJdQURK13PGvEIyZrzJgr6AonnM3LXyfcMjHAint PmsPVOQjs5jU5665b9oMk3Sinq+z2M0+2GlBLwep0b3UkxzhjlphPX+5eYt3nMwouZkG D18S+zkSrj+xy1ICmc2nkM8UpP/Tn7WAB9z2hKoqrDUNlsbwaIF5BD7+BvJO+7NXQG+d jQUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from; bh=1uKCZtawr6sx1VF67pqvvb8M6Rauyp4CSph0imxJ5Ao=; b=0Q24rd+76ZHmAJsHH4uJBsa4PU4ZF9erAqnmS1zkXZ+uS1IqyvcVWEK29agflZQlTe XTQ3W55z9OpwbaIQoXlZ7rVoupvKZV/4tJeXJJGHaFyYvubvV/6xVFwZpAWZDAPT077C SPtZW5m1FoFaSvwXWT1NxWklbgMwKnEyDMinoEumP/cl/7rpSh3+8iDboh2IFHUYlU9j +LbNI0cWsgtfPANsiT9nwxrLnAfBBGbcqsthOp7udoqVArm9x51BqVxmvPASfCiMZDsA VKAuc91TaBfWGj+yb6jszJeO7CPkc74FkumDruIcQdCe613Pz+XIP6fv7pU73O0nRJyR UcNA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of osalvador.vilardaga@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=osalvador.vilardaga@gmail.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id e14-v6sor20062277wrv.6.2018.09.21.06.26.41 for (Google Transport Security); Fri, 21 Sep 2018 06:26:41 -0700 (PDT) Received-SPF: pass (google.com: domain of osalvador.vilardaga@gmail.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; spf=pass (google.com: domain of osalvador.vilardaga@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=osalvador.vilardaga@gmail.com X-Google-Smtp-Source: ANB0VdaVJa74kMPkh47W1eZR1xPt5lfIMMNXIpuzjoLxYy9WyfaycvtUv6Q/YzZmUC1I80AWBOSLUg== X-Received: by 2002:adf:e44e:: with SMTP id t14-v6mr37268082wrm.96.1537536401315; Fri, 21 Sep 2018 06:26:41 -0700 (PDT) Received: from techadventures.net (techadventures.net. [62.201.165.239]) by smtp.gmail.com with ESMTPSA id y5-v6sm30937834wrd.5.2018.09.21.06.26.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Sep 2018 06:26:40 -0700 (PDT) Received: from d104.suse.de (nat.nue.novell.com [195.135.221.2]) by techadventures.net (Postfix) with ESMTPA id C3A0D1252A7; Fri, 21 Sep 2018 15:26:39 +0200 (CEST) From: Oscar Salvador To: akpm@linux-foundation.org Cc: mhocko@suse.com, dan.j.williams@intel.com, david@redhat.com, Pavel.Tatashin@microsoft.com, Jonathan.Cameron@huawei.com, yasu.isimatu@gmail.com, malat@debian.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Oscar Salvador Subject: [PATCH v2 0/4] Refactor node_states_check_changes_online/offline Date: Fri, 21 Sep 2018 15:26:30 +0200 Message-Id: <20180921132634.10103-1-osalvador@techadventures.net> X-Mailer: git-send-email 2.13.6 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 v1 -> v2: - Address feedback from Pavel - Re-write patch4 his way, as it is better - Add Reviewed-by from Pavel --- 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 (4): mm/memory_hotplug: Spare unnecessary calls to node_set_state 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 | 146 ++++++++++++++-------------------------------------- 1 file changed, 40 insertions(+), 106 deletions(-)