Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1293303imm; Wed, 20 Jun 2018 15:19:38 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKfpQ6kbOtNyrREhabeyVuKYmUFXxoy9RmC+6mhThkgsjGJ6oeqFTbn+YwpkAr8lrVtBaK1 X-Received: by 2002:a62:c16:: with SMTP id u22-v6mr24518470pfi.177.1529533178054; Wed, 20 Jun 2018 15:19:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529533178; cv=none; d=google.com; s=arc-20160816; b=iKaXYp+8773MGcYWPa4n3aTfYi7BHAz9GMFURbDUQ3J34JBX3dW0VsiRFkxzZl4a18 5fRpvxlU1GZf/p7al7zd072zlmn50VyKvaZAUf3VcXCfh60BbN150+63bE7T75Oe3YVc 32bjvnAoFRehnEJp6jgOMpwRTH0mGhjMWh8D/cdTzqJPshgF4eHuqAv0VDVGBBQo1yGF zTxsqXX6MuiAzFLCzc7bzy7Y0cWHl7ui8b3IlETN/kkwH2TwgZHZHg2+sJlPS2SNHPC0 tuunEQ18eb8ms2icxkMiUS/UZPLSfBhSsT1ZBkj5RuT8PTKn3aJb6TGFC1NI4BOi45d0 T0+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :arc-authentication-results; bh=D7wnnb1mvuSOvUxEYsLQLvRHYBmHIAiyct3YtQgb4OU=; b=ANI/9ZifJPFM3HTT8lEDD4Nm7EVGft8BMkSX5ryCtI4LY+0wUbXLQJtIWh6ha8Us9s dnbBAdpJZwMHDnBspH/ocLv1fNHmERlR8yS7i26VNmCs+aEB7AUwLnrfzevA6dQTlqdh ni1zvnkEdnPKHFuKp4Ii30bz/2VYBQlK5XCYWiITTM3/KjOZFwlRvSYMtYSUnhdoPWiS 1LjIOz1XOP+9pxsLM2PIcwI+7WmUO3wkvHIoqnZtGYsDLb4ZnjGXvgC5rAOQEH3vYrWD 3y5XRVhZzGbLgcMDeE58vAnqvCh5qH7/PPtLrxqnBycB3pY5BVIeB7bUwP8Olm4xh+rZ WcPg== 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 v7-v6si3305480plz.86.2018.06.20.15.19.23; Wed, 20 Jun 2018 15:19:38 -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 S933653AbeFTWSV (ORCPT + 99 others); Wed, 20 Jun 2018 18:18:21 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:36312 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933308AbeFTWSU (ORCPT ); Wed, 20 Jun 2018 18:18:20 -0400 Received: from akpm3.svl.corp.google.com (unknown [104.133.9.92]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 1B06EC8A; Wed, 20 Jun 2018 22:18:20 +0000 (UTC) Date: Wed, 20 Jun 2018 15:18:19 -0700 From: Andrew Morton To: osalvador@techadventures.net Cc: mhocko@suse.com, vbabka@suse.cz, pasha.tatashin@oracle.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Oscar Salvador Subject: Re: [PATCH 1/4] mm/memory_hotplug: Make add_memory_resource use __try_online_node Message-Id: <20180620151819.3f39226998bd80f7161fcea5@linux-foundation.org> In-Reply-To: <20180601125321.30652-2-osalvador@techadventures.net> References: <20180601125321.30652-1-osalvador@techadventures.net> <20180601125321.30652-2-osalvador@techadventures.net> X-Mailer: Sylpheed 3.6.0 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 1 Jun 2018 14:53:18 +0200 osalvador@techadventures.net wrote: > From: Oscar Salvador > > add_memory_resource() contains code to allocate a new node in case > it is necessary. > Since try_online_node() also hast some code for this purpose, > let us make use of that and remove duplicate code. > > This introduces __try_online_node(), which is called by add_memory_resource() > and try_online_node(). > __try_online_node() has two new parameters, start_addr of the node, > and if the node should be onlined and registered right away. > This is always wanted if we are calling from do_cpu_up(), but not > when we are calling from memhotplug code. > Nothing changes from the point of view of the users of try_online_node(), > since try_online_node passes start_addr=0 and online_node=true to > __try_online_node(). > > ... > > @@ -1126,17 +1136,14 @@ int __ref add_memory_resource(int nid, struct resource *res, bool online) > */ > memblock_add_node(start, size, nid); > > - new_node = !node_online(nid); > - if (new_node) { > - pgdat = hotadd_new_pgdat(nid, start); > - ret = -ENOMEM; > - if (!pgdat) > - goto error; > - } > + ret = __try_online_node (nid, start, false); > + new_node = !!(ret > 0); I don't think __try_online_node() will ever return a value greater than zero. I assume what was meant was new_node = !!(ret >= 0); which may as well be new_node = (ret >= 0); since both sides have bool type. The fact that testing didn't detect this is worrisome.... > + if (ret < 0) > + goto error; > + > > /* call arch's memory hotadd */ > ret = arch_add_memory(nid, start, size, NULL, true); > - > if (ret < 0) > goto error; > > > ... >