From patchwork Fri Sep 21 13:26:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 10610031 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 19503157B for ; Fri, 21 Sep 2018 13:26:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0949B2DB18 for ; Fri, 21 Sep 2018 13:26:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F1ADA2DB1A; Fri, 21 Sep 2018 13:26:51 +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 EBC912DB18 for ; Fri, 21 Sep 2018 13:26:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C9AE68E0004; Fri, 21 Sep 2018 09:26:45 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C1FDA8E0001; Fri, 21 Sep 2018 09:26:45 -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 AE86C8E0004; Fri, 21 Sep 2018 09:26:45 -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 516378E0001 for ; Fri, 21 Sep 2018 09:26:45 -0400 (EDT) Received: by mail-wm1-f70.google.com with SMTP id v1-v6so2457679wmh.4 for ; Fri, 21 Sep 2018 06:26:45 -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=RCTTXVkL71qkxGQmeRTBKaL8TjPr8oGCumoctB9DgDA=; b=EqVIF8pbKBa6UsIQe2IF6ORoF4dOw7WngdeOzQqpRuzp1GoPC8Wd8uAD2llvGkTjoS VlzcXThsh9UJ1PHlmAI602oFKg0pLqimuDRZzetLc2uh8BXgy02/pwZTEgl+6G8AjYPZ 3KEbCNNMRUffFC45WoItJ2v1YbMmVj+9z4ESUdZNr9DohowQc0Xxnj8GLe29F6teZlni 0gpW4yEUJ5T2iJFrqt/FeyAsCRVhZNNd+ROWIsDZxTn9V0AWi7caGqjNaT2qz/W5p3D9 4s3JQv2iJ24ihfDOXO2yXLAk6VcSj/VOLGHAyU+AlX7VmtL/MnRnmfv3w/FiqvkACZk6 l7og== 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: ABuFfojRDwcjB1CBKxm9dmgdvNv/q0GK2qN2KgStuJsyQ68KX1jsVc5a wbaiHUNZn5jRyTrHgeyG2smVLbIlmXfUsdSNXO9iB128COWoxaaH9Ut1CFpvTJ5oE4D/8X4A+QX kPcWCyPM87BbqiUVOvyE4glngoK5bbrQyAQi8tOj3noRH8sTXasKL4QKnJRhHPZbqjE601krwL8 KsID16TrvTLTFHwLT6/3yo6oWla+5iHOYzpTGWD46gobvl7vDB20XPWOZX91TePWiKIM7LLbdzO 6+AHZbJmPInVWLv84y17evv5GK0SvvqNna8rcZxLScg9NuedvCPRXQskYqtqoiu2ho6IntDJTOZ 7Mqo0yNZfAsieelCi3LMKj9dHJIqCx1ma6IBtDAibeaSJnIDQF24VRFRbyBzOfAAPf0CLs1fzg= = X-Received: by 2002:a1c:2108:: with SMTP id h8-v6mr7036875wmh.108.1537536404781; Fri, 21 Sep 2018 06:26:44 -0700 (PDT) X-Received: by 2002:a1c:2108:: with SMTP id h8-v6mr7036815wmh.108.1537536403869; Fri, 21 Sep 2018 06:26:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537536403; cv=none; d=google.com; s=arc-20160816; b=CTMOV+LidHueLg0Hhx2/w8vpu22e3cgDSCoGjlh2U9Ooo7kpXIvV8MLNz51Abw40wV 8bgTXrSe5PJB1zO1POpmtl0PTyBHEOkQMieaAR/byw9IR3BQJxaE0MF+1z/bprJ/3e0W q9q4bWz9IzrTcEdDJnK4+spxkVlc/qDyreOOxjs6goHje7WNhet/ZJcz0eKKBf9raftm DwoEBu+lREta5J6COJSG4r3HiBcOa46LDRuOfxrWGR9Q8LzjQiqd0nu1hJrW0Ib0SKZK G7uc1io6DOeTH9kHIsLpeeEmKcUl7HxvyAvo58yOS/ZTNZKK7r5Jx+po0BxB6L+DR2kE 1kxw== 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=RCTTXVkL71qkxGQmeRTBKaL8TjPr8oGCumoctB9DgDA=; b=ibVlWSeIJ60cgRAnAE9rENaE1YS6mZkgjXK7jRBWNUUYGieKFeVXwWqzd2XHsyCh/0 bCyK3PkmmpSs1v6vHJv6SiWeXSekjq637JovkiViyEjP5irywtuPNLtu3ilwrMbiGJUX t/Zbj0DRSiawmmNYszfx+1LTx79VEHoE3n0E+xEYgy0UpR9H/emWwpRhPJzDR1CSXhMI FIW2ErFY9V7xJy6vMGhWfTGYWEL4Fb8Wj+YQY7mX9qnhygUP1txAmXfKnTnliNdBCCyK fTRJtNSbS5gK78X46RK3v0llCOkLGmBwDui0cO7BzRCcynba6x3P4CSjUctut6f/OQa4 pQEg== 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 i8-v6sor10922075wrs.28.2018.09.21.06.26.43 for (Google Transport Security); Fri, 21 Sep 2018 06:26:43 -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: ANB0VdbdQH2QGULdBiqI2bwJ+Av8EaBk4PfgnTPNz4WhXo+tilr8wkafVPnOGz47MIFZJcrZPhzqNA== X-Received: by 2002:adf:fc44:: with SMTP id e4-v6mr11704736wrs.9.1537536403548; Fri, 21 Sep 2018 06:26:43 -0700 (PDT) Received: from techadventures.net (techadventures.net. [62.201.165.239]) by smtp.gmail.com with ESMTPSA id y17-v6sm23774170wrh.49.2018.09.21.06.26.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Sep 2018 06:26:42 -0700 (PDT) Received: from d104.suse.de (nat.nue.novell.com [195.135.221.2]) by techadventures.net (Postfix) with ESMTPA id C655E12533E; Fri, 21 Sep 2018 15:26:40 +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 3/4] mm/memory_hotplug: Simplify node_states_check_changes_online Date: Fri, 21 Sep 2018 15:26:33 +0200 Message-Id: <20180921132634.10103-4-osalvador@techadventures.net> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180921132634.10103-1-osalvador@techadventures.net> References: <20180921132634.10103-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 Suggested-by: Pavel Tatashin Reviewed-by: Pavel Tatashin --- mm/memory_hotplug.c | 57 +++++++---------------------------------------------- 1 file changed, 7 insertions(+), 50 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 561c44761f95..eadd149eb7bc 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -687,62 +687,19 @@ 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; + arg->status_change_nid = -1; + arg->status_change_nid_normal = -1; + arg->status_change_nid_high = -1; - /* - * 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)) + if (!node_state(nid, N_MEMORY)) + arg->status_change_nid = nid; + 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. - */ - 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) <= N_HIGH_MEMORY && !node_state(nid, N_HIGH_MEMORY)) arg->status_change_nid_high = nid; - else - arg->status_change_nid_high = -1; -#else - arg->status_change_nid_high = arg->status_change_nid_normal; #endif - - /* - * 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 (!node_state(nid, N_MEMORY)) - arg->status_change_nid = nid; - else - arg->status_change_nid = -1; } static void node_states_set_node(int node, struct memory_notify *arg)