From patchwork Wed Sep 19 10:08:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 10605577 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 62309112B for ; Wed, 19 Sep 2018 10:08:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5508A2B59D for ; Wed, 19 Sep 2018 10:08:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 47BE42B5F2; Wed, 19 Sep 2018 10:08: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 D49412B59D for ; Wed, 19 Sep 2018 10:08:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D5AFF8E0002; Wed, 19 Sep 2018 06:08:40 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id CE4C68E0001; Wed, 19 Sep 2018 06:08:40 -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 B85768E0002; Wed, 19 Sep 2018 06:08:40 -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 5D8948E0001 for ; Wed, 19 Sep 2018 06:08:40 -0400 (EDT) Received: by mail-wr1-f70.google.com with SMTP id a37-v6so5293357wrc.5 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; bh=/RrOOYn9/i5abI8jQPJ0P3dbfJeu7mgxvohT+QHErjI=; b=tqqGKJqoLm5qL7/TBPpnTHwfLjIjpsB8RHT7JWB1tCWAGLVBv55Dgxn6y5uyeZFruz vbvyWd1yduxfvUUek9xOUvLPV9VaRasMb24yI6PR8wOYBBq1tcdiDlURGKlZd+Q4A9GP +n/nkyxkXEw0by+QSK6EKE7fS76FTTeStZpjb5jKba3tmr/D6TFhZt5eH9iWR/561JKO GflPwfmFxNiCQ9xrq5shpOGvxkOUBASPwxDDbElNOpsspov5BDDsMG+3PB4hTNjCcUyV VD6sjruNjbUFhGt/Byc36Lnla/hik72IYT33yhFWAssLQmcl21shfr732ggAt+dFtccV S6ow== 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: APzg51ATyCo3rXf4i/CijlXKIA2qQ2y3u6p8HHkBl/ty+3SiRV95TJTS j4d0pe6c4dCQgp/wGXapUmPUO63Rd+vXKyGBq8GU7LIWVMmXGZrvGWoT7xvpz30EDfLL8DHojhq iSAG9UbFfS156yJWZ/6O5+OZLl59gFLe8tzbhJwGyMYJdrP6qhA85Jvt26+rv1T5tgpsGNWdr4i rwNhEo5+BUVpi5hxHNutsgfvLEA3czF5lM4XqL9X8eBWi1AwqnXSVI3L0Za+awhnS63EC+lUUUe 9S2dx3zIDWEXPuajW+tH/V4YbFI6f05VZeszi4RK1Msg43zUlRJZhXXzdKKd8KtFNNMbbmzypBO jO3YtqvxruVz7PY+qBerpmetCtw9hcsju5Qe2LxKWnqbor12lkxJi6hcuOnajnSelTXcSLmj+g= = X-Received: by 2002:a1c:9cd3:: with SMTP id f202-v6mr19440496wme.148.1537351719892; Wed, 19 Sep 2018 03:08:39 -0700 (PDT) X-Received: by 2002:a1c:9cd3:: with SMTP id f202-v6mr19440443wme.148.1537351719125; 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=wL4PvyDyH/Pr2aVb0fCjmUUz5Z0VYFfrTpl09Mb7G633I+b3ggGMEPE/ZPPXKEdrOb e/9N5wtNoNvx2hSeKXq0aO/GcLW2QnkM0I0DiPDN4LK5VuWZc0gp2ZJCMHw/xRMqpkZs uqtwKXXEmn2vJFUCL55sJnld4kv/yklP4lbBvo0SZfkEiYhZs9B3+IE2cjTkq116/rg6 pLB5aOSSeuDBE1Tep9Og86j/HxpJ+liyFKxOBNWuSNSfiSGXW0UPepElPH2PslbmY88I aW0gYjQhYyUdyj/wB/Vf9nxpSO8kRJada1OiXYNhmpTA2BzAxI6DfGp0Qtg2a6r+rjNI WYRw== 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=/RrOOYn9/i5abI8jQPJ0P3dbfJeu7mgxvohT+QHErjI=; b=hx+7goMqBDmNWYe9pBdU18FIirFu1FGPoWG43FNChiPi6SWrjAfcw9+/jCzWQcsisc URvTnOZsTcAgIvofAXRlIuDsv1OX8RGJcCFexmYnfeuWid7aQ+2YVqphgdBgE99W/Pfk rkCiN3yodh0g0dgKim0VT9v9TECKPkpTLEsAvVAUo3xufWhiYBwNq5wkq9dITVU2Hyza 2pO1LAONPowCQ8kiOWRIADMdWsf8Fs2P8i7r3v5u4tzjJBnbTptghbMOQ2vdNSsgZq5V 5PRIpSgaRyW6EqXwp9qdxSCvH4bV3PBbwoZmsS+8I4TkPsIE/PfUj/x4rjtFs5zjL+Hs 7FAA== 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 x10-v6sor9412482wmg.17.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: ANB0VdYIIP2/SqUr3iuQp8wP7YHC3y/FrjzF55lVh4KkGFw61Fb+t51/ZCfEUMtO2MpP9pCqi0RzXA== 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 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, 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 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(-)