From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Leizhen (ThunderTown)" Subject: Re: [Question or BUG] [NUMA]: I feel puzzled at the function cpumask_of_node Date: Thu, 15 Jun 2017 10:00:25 +0800 Message-ID: <5941EA39.8090501@huawei.com> References: <5937C608.7010905@huawei.com> <20170608141214.GJ19866@dhcp22.suse.cz> Mime-Version: 1.0 Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20170608141214.GJ19866-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org> Sender: linux-api-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Michal Hocko Cc: Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Catalin Marinas , Will Deacon , linux-arm-kernel , linux-mm , linux-kernel , chenchunxiao , x86l , linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-Id: linux-api@vger.kernel.org On 2017/6/8 22:12, Michal Hocko wrote: > [CC linux-api] > > On Wed 07-06-17 17:23:20, Leizhen (ThunderTown) wrote: >> When I executed numactl -H(print cpumask_of_node for each node), I got >> different result on X86 and ARM64. For each numa node, the former >> only displayed online CPUs, and the latter displayed all possible >> CPUs. Actually, all other ARCHs is the same to ARM64. >> >> So, my question is: Which case(online or possible) should function >> cpumask_of_node be? Or there is no matter about it? > > Unfortunatelly the documentation is quite unclear > What: /sys/devices/system/node/nodeX/cpumap > Date: October 2002 > Contact: Linux Memory Management list > Description: > The node's cpumap. > > not really helpeful, is it? Semantically I _think_ printing online cpus > makes more sense because it doesn't really make much sense to bind > anything on offline nodes. Generic implementtion of cpumask_of_node > indeed provides only online cpus. I haven't checked specific > implementations of arch specific code but listing offline cpus sounds > confusing to me. > OK, thank you very much. So, how about we directly add "cpumask_and with cpu_online_mask", as below: diff --git a/drivers/base/node.c b/drivers/base/node.c index b10479c..199723d 100644 --- a/drivers/base/node.c +++ b/drivers/base/node.c @@ -28,12 +28,14 @@ static struct bus_type node_subsys = { static ssize_t node_read_cpumap(struct device *dev, bool list, char *buf) { struct node *node_dev = to_node(dev); - const struct cpumask *mask = cpumask_of_node(node_dev->dev.id); + struct cpumask mask; + + cpumask_and(&mask, cpumask_of_node(node_dev->dev.id), cpu_online_mask); /* 2008/04/07: buf currently PAGE_SIZE, need 9 chars per 32 bits. */ BUILD_BUG_ON((NR_CPUS/32 * 9) > (PAGE_SIZE-1)); - return cpumap_print_to_pagebuf(list, buf, mask); + return cpumap_print_to_pagebuf(list, buf, &mask); } static inline ssize_t node_read_cpumask(struct device *dev, -- Thanks! BestRegards From mboxrd@z Thu Jan 1 00:00:00 1970 From: thunder.leizhen@huawei.com (Leizhen (ThunderTown)) Date: Thu, 15 Jun 2017 10:00:25 +0800 Subject: [Question or BUG] [NUMA]: I feel puzzled at the function cpumask_of_node In-Reply-To: <20170608141214.GJ19866@dhcp22.suse.cz> References: <5937C608.7010905@huawei.com> <20170608141214.GJ19866@dhcp22.suse.cz> Message-ID: <5941EA39.8090501@huawei.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On 2017/6/8 22:12, Michal Hocko wrote: > [CC linux-api] > > On Wed 07-06-17 17:23:20, Leizhen (ThunderTown) wrote: >> When I executed numactl -H(print cpumask_of_node for each node), I got >> different result on X86 and ARM64. For each numa node, the former >> only displayed online CPUs, and the latter displayed all possible >> CPUs. Actually, all other ARCHs is the same to ARM64. >> >> So, my question is: Which case(online or possible) should function >> cpumask_of_node be? Or there is no matter about it? > > Unfortunatelly the documentation is quite unclear > What: /sys/devices/system/node/nodeX/cpumap > Date: October 2002 > Contact: Linux Memory Management list > Description: > The node's cpumap. > > not really helpeful, is it? Semantically I _think_ printing online cpus > makes more sense because it doesn't really make much sense to bind > anything on offline nodes. Generic implementtion of cpumask_of_node > indeed provides only online cpus. I haven't checked specific > implementations of arch specific code but listing offline cpus sounds > confusing to me. > OK, thank you very much. So, how about we directly add "cpumask_and with cpu_online_mask", as below: diff --git a/drivers/base/node.c b/drivers/base/node.c index b10479c..199723d 100644 --- a/drivers/base/node.c +++ b/drivers/base/node.c @@ -28,12 +28,14 @@ static struct bus_type node_subsys = { static ssize_t node_read_cpumap(struct device *dev, bool list, char *buf) { struct node *node_dev = to_node(dev); - const struct cpumask *mask = cpumask_of_node(node_dev->dev.id); + struct cpumask mask; + + cpumask_and(&mask, cpumask_of_node(node_dev->dev.id), cpu_online_mask); /* 2008/04/07: buf currently PAGE_SIZE, need 9 chars per 32 bits. */ BUILD_BUG_ON((NR_CPUS/32 * 9) > (PAGE_SIZE-1)); - return cpumap_print_to_pagebuf(list, buf, mask); + return cpumap_print_to_pagebuf(list, buf, &mask); } static inline ssize_t node_read_cpumask(struct device *dev, -- Thanks! BestRegards From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f199.google.com (mail-pf0-f199.google.com [209.85.192.199]) by kanga.kvack.org (Postfix) with ESMTP id A40416B0279 for ; Wed, 14 Jun 2017 22:02:21 -0400 (EDT) Received: by mail-pf0-f199.google.com with SMTP id r70so843888pfb.7 for ; Wed, 14 Jun 2017 19:02:21 -0700 (PDT) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com. [45.249.212.188]) by mx.google.com with ESMTPS id c24si1175711pfl.259.2017.06.14.19.02.20 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 14 Jun 2017 19:02:20 -0700 (PDT) Subject: Re: [Question or BUG] [NUMA]: I feel puzzled at the function cpumask_of_node References: <5937C608.7010905@huawei.com> <20170608141214.GJ19866@dhcp22.suse.cz> From: "Leizhen (ThunderTown)" Message-ID: <5941EA39.8090501@huawei.com> Date: Thu, 15 Jun 2017 10:00:25 +0800 MIME-Version: 1.0 In-Reply-To: <20170608141214.GJ19866@dhcp22.suse.cz> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Michal Hocko Cc: Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Catalin Marinas , Will Deacon , linux-arm-kernel , linux-mm , linux-kernel , chenchunxiao , x86l , linux-api@vger.kernel.org On 2017/6/8 22:12, Michal Hocko wrote: > [CC linux-api] > > On Wed 07-06-17 17:23:20, Leizhen (ThunderTown) wrote: >> When I executed numactl -H(print cpumask_of_node for each node), I got >> different result on X86 and ARM64. For each numa node, the former >> only displayed online CPUs, and the latter displayed all possible >> CPUs. Actually, all other ARCHs is the same to ARM64. >> >> So, my question is: Which case(online or possible) should function >> cpumask_of_node be? Or there is no matter about it? > > Unfortunatelly the documentation is quite unclear > What: /sys/devices/system/node/nodeX/cpumap > Date: October 2002 > Contact: Linux Memory Management list > Description: > The node's cpumap. > > not really helpeful, is it? Semantically I _think_ printing online cpus > makes more sense because it doesn't really make much sense to bind > anything on offline nodes. Generic implementtion of cpumask_of_node > indeed provides only online cpus. I haven't checked specific > implementations of arch specific code but listing offline cpus sounds > confusing to me. > OK, thank you very much. So, how about we directly add "cpumask_and with cpu_online_mask", as below: diff --git a/drivers/base/node.c b/drivers/base/node.c index b10479c..199723d 100644 --- a/drivers/base/node.c +++ b/drivers/base/node.c @@ -28,12 +28,14 @@ static struct bus_type node_subsys = { static ssize_t node_read_cpumap(struct device *dev, bool list, char *buf) { struct node *node_dev = to_node(dev); - const struct cpumask *mask = cpumask_of_node(node_dev->dev.id); + struct cpumask mask; + + cpumask_and(&mask, cpumask_of_node(node_dev->dev.id), cpu_online_mask); /* 2008/04/07: buf currently PAGE_SIZE, need 9 chars per 32 bits. */ BUILD_BUG_ON((NR_CPUS/32 * 9) > (PAGE_SIZE-1)); - return cpumap_print_to_pagebuf(list, buf, mask); + return cpumap_print_to_pagebuf(list, buf, &mask); } static inline ssize_t node_read_cpumask(struct device *dev, -- Thanks! BestRegards -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752030AbdFOCBr (ORCPT ); Wed, 14 Jun 2017 22:01:47 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:7874 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750768AbdFOCBq (ORCPT ); Wed, 14 Jun 2017 22:01:46 -0400 Subject: Re: [Question or BUG] [NUMA]: I feel puzzled at the function cpumask_of_node To: Michal Hocko References: <5937C608.7010905@huawei.com> <20170608141214.GJ19866@dhcp22.suse.cz> CC: Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Catalin Marinas , "Will Deacon" , linux-arm-kernel , linux-mm , linux-kernel , chenchunxiao , x86l , From: "Leizhen (ThunderTown)" Message-ID: <5941EA39.8090501@huawei.com> Date: Thu, 15 Jun 2017 10:00:25 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <20170608141214.GJ19866@dhcp22.suse.cz> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.23.164] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020206.5941EA40.01A2,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 2846f3b0ff33d00436c54ad0f66a1dba Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2017/6/8 22:12, Michal Hocko wrote: > [CC linux-api] > > On Wed 07-06-17 17:23:20, Leizhen (ThunderTown) wrote: >> When I executed numactl -H(print cpumask_of_node for each node), I got >> different result on X86 and ARM64. For each numa node, the former >> only displayed online CPUs, and the latter displayed all possible >> CPUs. Actually, all other ARCHs is the same to ARM64. >> >> So, my question is: Which case(online or possible) should function >> cpumask_of_node be? Or there is no matter about it? > > Unfortunatelly the documentation is quite unclear > What: /sys/devices/system/node/nodeX/cpumap > Date: October 2002 > Contact: Linux Memory Management list > Description: > The node's cpumap. > > not really helpeful, is it? Semantically I _think_ printing online cpus > makes more sense because it doesn't really make much sense to bind > anything on offline nodes. Generic implementtion of cpumask_of_node > indeed provides only online cpus. I haven't checked specific > implementations of arch specific code but listing offline cpus sounds > confusing to me. > OK, thank you very much. So, how about we directly add "cpumask_and with cpu_online_mask", as below: diff --git a/drivers/base/node.c b/drivers/base/node.c index b10479c..199723d 100644 --- a/drivers/base/node.c +++ b/drivers/base/node.c @@ -28,12 +28,14 @@ static struct bus_type node_subsys = { static ssize_t node_read_cpumap(struct device *dev, bool list, char *buf) { struct node *node_dev = to_node(dev); - const struct cpumask *mask = cpumask_of_node(node_dev->dev.id); + struct cpumask mask; + + cpumask_and(&mask, cpumask_of_node(node_dev->dev.id), cpu_online_mask); /* 2008/04/07: buf currently PAGE_SIZE, need 9 chars per 32 bits. */ BUILD_BUG_ON((NR_CPUS/32 * 9) > (PAGE_SIZE-1)); - return cpumap_print_to_pagebuf(list, buf, mask); + return cpumap_print_to_pagebuf(list, buf, &mask); } static inline ssize_t node_read_cpumask(struct device *dev, -- Thanks! BestRegards