From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 762B1C433F5 for ; Sat, 7 May 2022 08:47:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EA55D6B0082; Sat, 7 May 2022 04:47:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E558F6B0083; Sat, 7 May 2022 04:47:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D1BB96B0085; Sat, 7 May 2022 04:47:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id C35136B0082 for ; Sat, 7 May 2022 04:47:50 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 8D733806B2 for ; Sat, 7 May 2022 08:47:50 +0000 (UTC) X-FDA: 79438319100.03.18B6EE3 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf30.hostedemail.com (Postfix) with ESMTP id 810108001C for ; Sat, 7 May 2022 08:47:34 +0000 (UTC) Received: from kwepemi500017.china.huawei.com (unknown [172.30.72.53]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4KwLYK4g5mzXdkZ; Sat, 7 May 2022 16:43:01 +0800 (CST) Received: from kwepemm600017.china.huawei.com (7.193.23.234) by kwepemi500017.china.huawei.com (7.221.188.110) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Sat, 7 May 2022 16:47:44 +0800 Received: from [10.174.179.19] (10.174.179.19) by kwepemm600017.china.huawei.com (7.193.23.234) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Sat, 7 May 2022 16:47:42 +0800 Content-Type: multipart/alternative; boundary="------------sdqAK1DJzJ74g8LFFrXAE2lG" Message-ID: <68447b2a-31d7-4150-dbff-b06b0fd648a3@huawei.com> Date: Sat, 7 May 2022 16:47:42 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 Subject: Re: [PATCH 1/2] include/linux/nodemask.h: create node_available() helper Content-Language: en-US To: Bjorn Helgaas CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , References: <20220506172348.GA543299@bhelgaas> From: "liupeng (DM)" In-Reply-To: <20220506172348.GA543299@bhelgaas> X-Originating-IP: [10.174.179.19] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemm600017.china.huawei.com (7.193.23.234) X-CFilter-Loop: Reflected X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 810108001C Authentication-Results: imf30.hostedemail.com; dkim=none; spf=pass (imf30.hostedemail.com: domain of liupeng256@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=liupeng256@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Rspam-User: X-Stat-Signature: 96f7t9zzih9igz1b8xwf7w3wdkikm38j X-HE-Tag: 1651913254-153104 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: --------------sdqAK1DJzJ74g8LFFrXAE2lG Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit On 2022/5/7 1:23, Bjorn Helgaas wrote: > Subject line convention looks like "numa: ..." > > On Fri, May 06, 2022 at 01:58:00AM +0000, Peng Liu wrote: >> Lots of code dose > does > >> node != NUMA_NO_NODE && !node_online(node) >> or >> node == NUMA_NO_NODE || node_online(node) >> so create node_available to do this to simplify code. > node_available() Thanks. > I'm not really sure what meaning "node_available" conveys, though. > Probably just because I don't understand NUMA. > > Should the test for NUMA_NO_NODE be folded into node_state() or > node_online() directly instead of adding a new node_available() > interface? > > NUMA_NO_NODE is -1. It's not clear to me that node_state()/ > node_isset()/test_bit() would do the right thing given -1. I doubt > all node_online() callers ensure they don't pass NUMA_NO_NODE. I have tested node_online(NUMA_NO_NODE) on x86_64, arm64, arm32, the results are: arch node_online(NUMA_NO_NODE) ------------------------------------------ x86_64 0 arm64 1 arm32 0 . Hence, I think the behavior of node_state(NUMA_NO_NODE) is undefined which is due to test_bit(NUMA_NO_NODE) is different between different arches. For many times, callers could ensure they don't pass NUMA_NO_NODE, for example "nid < 0" is checked before node_online() or some code only used in NUMA has node. So, it is not suitable to test NUMA_NO_NODE in node_state() or node_online(). Unfortunately, there are actually some cases that test for NUMA_NO_NODE is needed but ignored. Related issue: ab31c7fd2d37 ("sched/numa: Fix boot crash on arm64 systems") >> --- a/include/linux/nodemask.h >> +++ b/include/linux/nodemask.h >> @@ -70,6 +70,7 @@ >> * >> * int node_online(node) Is some node online? >> * int node_possible(node) Is some node possible? >> + * int node_available(node) Is some node available(online or NUMA_NO_NODE)? > Existing file generally fits in 80 columns; follow that lead unless > you have a really good reason. E.g., maybe this? > > + * int node_available(node) Node online or NUMA_NO_NODE > . Thank you for your suggestion, I will send a revised patch with modified comments later. --------------sdqAK1DJzJ74g8LFFrXAE2lG Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: 7bit
On 2022/5/7 1:23, Bjorn Helgaas wrote:
Subject line convention looks like "numa: ..."

On Fri, May 06, 2022 at 01:58:00AM +0000, Peng Liu wrote:
Lots of code dose
               does

	node != NUMA_NO_NODE && !node_online(node)
or
	node == NUMA_NO_NODE || node_online(node)
so create node_available to do this to simplify code.
            node_available()
Thanks.
I'm not really sure what meaning "node_available" conveys, though.
Probably just because I don't understand NUMA.

Should the test for NUMA_NO_NODE be folded into node_state() or
node_online() directly instead of adding a new node_available()
interface?

NUMA_NO_NODE is -1.  It's not clear to me that node_state()/
node_isset()/test_bit() would do the right thing given -1.  I doubt
all node_online() callers ensure they don't pass NUMA_NO_NODE.
I have tested node_online(NUMA_NO_NODE) on x86_64, arm64, arm32, the results are:

arch		node_online(NUMA_NO_NODE)
------------------------------------------
x86_64		0
arm64		1
arm32		0
.

Hence, I think the behavior of node_state(NUMA_NO_NODE) is undefined which is due to 
test_bit(NUMA_NO_NODE) is different between different arches.

For many times, callers could ensure they don't pass NUMA_NO_NODE, for example "nid < 0" is
checked before node_online() or some code only used in NUMA has node. So, it is not
suitable to test NUMA_NO_NODE in node_state() or node_online().

Unfortunately, there are actually some cases that test for NUMA_NO_NODE is needed but ignored.
Related issue: ab31c7fd2d37 ("sched/numa: Fix boot crash on arm64 systems")
--- a/include/linux/nodemask.h
+++ b/include/linux/nodemask.h
@@ -70,6 +70,7 @@
  *
  * int node_online(node)		Is some node online?
  * int node_possible(node)		Is some node possible?
+ * int node_available(node)		Is some node available(online or NUMA_NO_NODE)?
Existing file generally fits in 80 columns; follow that lead unless
you have a really good reason.  E.g., maybe this?

  + * int node_available(node)		Node online or NUMA_NO_NODE
.
Thank you for your suggestion, I will send a revised patch with modified comments later.
--------------sdqAK1DJzJ74g8LFFrXAE2lG--