From patchwork Fri Sep 29 09:53:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Leizhen \(ThunderTown\)" X-Patchwork-Id: 114503 Delivered-To: patch@linaro.org Received: by 10.140.104.133 with SMTP id a5csp597308qgf; Fri, 29 Sep 2017 02:57:56 -0700 (PDT) X-Google-Smtp-Source: AOwi7QAwQKzwEtyGuuYqeoR8+t/YCO1UGQgklhp+GHcBsFwcmJVvZnNvJxBxbTvZQw415jGcTCwN X-Received: by 10.99.181.23 with SMTP id y23mr6772775pge.189.1506679076086; Fri, 29 Sep 2017 02:57:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506679076; cv=none; d=google.com; s=arc-20160816; b=H7okvwes3yPbxmSUUijw5FDIhtb+Q8JOjI37ytH6yyMMrLMEb3tF9tkx1R43RAKE0H irdMNPVtzWBvOZpYPzkktiHjBk1+QU4CyWBP/sP15ejTuguIqtUi/98HgeU3UKMtb3WQ UY9LzMayCap6+drEiq1iU+0HUpzd1RIdCuu/ZHSp4Nr8GLbG22M1O9NG3fkjRo58N7y3 VeKV/+yiyCuZLIOgZcA1ryKkAbIIo+eeVn5f1aqCckDHUWchi1GVRpMAW5MeP5RpmWDj 3KJMCiVQ9r9sUdZaxBiQOfmxowXH+exLCEiJVq0fBkn45NhZ9Q7SYL6nF/XaCmwYyZXL benQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=is8VIDA9OCJLnP4C8QcH5Bj4H/vJhxoCmfgSTmBGpbw=; b=ghVJBXkGaYmQDEXJWqhQecIixC5JjIpXT4ESdU/2yYSWL7kliL8gAD8kvtil4KX6wm nR+/u1tcYuqOEtvNnkvSlCvLsKPX1HG1IvliFRfQQ9M6R3kNeEm4W5n62VdgYe88Yzfk 4RUhJ4KVENjRGy08OQCdriqCa8amhRDLUtIqTB+5Oh1iFpW7XhD8I51pCMLPbIBiISxi 0DH9c1bT5WB5eKYbu5lY5Uf/Dk9fKL+Iev9CbG1hXm4j1khlNFN08Ti9bNscZChh53bd kOb5TnyJSH1tRo34pPr+2YelDDx8qpCyohzEbsbQSFUbEk5+NBoFgm2C7Nc510jR+fV3 D/jg== 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 k16si961834pli.801.2017.09.29.02.57.55; Fri, 29 Sep 2017 02:57:56 -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 S1751984AbdI2J5v (ORCPT + 26 others); Fri, 29 Sep 2017 05:57:51 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:7471 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750926AbdI2J5t (ORCPT ); Fri, 29 Sep 2017 05:57:49 -0400 Received: from 172.30.72.58 (EHLO DGGEMS410-HUB.china.huawei.com) ([172.30.72.58]) by dggrg04-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id DIE35015; Fri, 29 Sep 2017 17:54:20 +0800 (CST) Received: from localhost (10.177.23.164) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.301.0; Fri, 29 Sep 2017 17:54:12 +0800 From: Zhen Lei To: Catalin Marinas , Will Deacon , linux-kernel , linux-api , Greg Kroah-Hartman , Michal Hocko , linux-mm CC: Tianhong Ding , Hanjun Guo , Libin , Kefeng Wang , Zhen Lei Subject: [PATCH v2 1/1] mm: only dispaly online cpus of the numa node Date: Fri, 29 Sep 2017 17:53:25 +0800 Message-ID: <1506678805-15392-2-git-send-email-thunder.leizhen@huawei.com> X-Mailer: git-send-email 1.9.5.msysgit.0 In-Reply-To: <1506678805-15392-1-git-send-email-thunder.leizhen@huawei.com> References: <1506678805-15392-1-git-send-email-thunder.leizhen@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.23.164] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A010205.59CE184D.0041, 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: e81be22d7ec363d8f77670df3133b8ff Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When I executed numactl -H(which read /sys/devices/system/node/nodeX/cpumap and display cpumask_of_node for each node), but 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. Unfortunately, both Linux documentation and numactl manual have not described it clear. I sent a mail to ask for help, and Michal Hocko replied that he preferred to print online cpus because it doesn't really make much sense to bind anything on offline nodes. Signed-off-by: Zhen Lei Acked-by: Michal Hocko --- drivers/base/node.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) -- 2.5.0 diff --git a/drivers/base/node.c b/drivers/base/node.c index 3855902..aae2402 100644 --- a/drivers/base/node.c +++ b/drivers/base/node.c @@ -27,13 +27,21 @@ static struct bus_type node_subsys = { static ssize_t node_read_cpumap(struct device *dev, bool list, char *buf) { + ssize_t n; + cpumask_var_t mask; struct node *node_dev = to_node(dev); - const struct cpumask *mask = cpumask_of_node(node_dev->dev.id); /* 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); + if (!alloc_cpumask_var(&mask, GFP_KERNEL)) + return 0; + + cpumask_and(mask, cpumask_of_node(node_dev->dev.id), cpu_online_mask); + n = cpumap_print_to_pagebuf(list, buf, mask); + free_cpumask_var(mask); + + return n; } static inline ssize_t node_read_cpumask(struct device *dev,