Received: by 2002:a25:b323:0:0:0:0:0 with SMTP id l35csp1254975ybj; Fri, 20 Sep 2019 07:35:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqyNxE33BSP4pSdXQawWDOE9+aDPSuQTZ5jrPcdQWreIUH3tXxzNlJibxzNtzLAnTK6QVNFF X-Received: by 2002:a50:fd10:: with SMTP id i16mr19957819eds.239.1568990124820; Fri, 20 Sep 2019 07:35:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568990124; cv=none; d=google.com; s=arc-20160816; b=esmhWN4eEoWf5RhCIqrmxH88j7JVYxgsgocgFvx+00CQkryG54r7ORIXQdYK/pceVS 4E8sc0yln7kTQdMm+YMxa+AFgaQPuUZt67HjinsdSl0z648x3puqYufWdW2C3FWo8WBE ZXKuuKs3YJD/FY/PsKh/XO2pDEUEOR8c2cZEHi7I5bUNPPHjiRMoFZQDLvCa/YTb+D9a 0M55t/KC/Ew/uQFRLAuWc/aF5WoGLkrpypU0/NCo3gDeZnWlBYrEoE77fU3WeYVxOSG3 IM1Ms1XyEqcsCkVkN9BrC7bhYDzVQGzaSImS+V1x2dpE5IHy0SaHFXndu9vtCly3wZSp TbSw== 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 :message-id:date:subject:to:from; bh=zSrTMq2zHDT90tmv/vIGPVmT07ig9nWFq7lD0beVv6U=; b=KnZ0QXheDP2yZwaHmJWCL0tZpZP6rsV7/b58u9uVGA1YZkRzk4ZBAizgwyf24F9Wrg NdDG2XG1yxNZxc0x8wklHA+VYFd8LXK3IdEV/uzkFHyQ8ILBPltEdDkLRyegWG1UP6Dd ldtlEFIYd7pj+NRpjr1HzGoqBGhY17Y92JtNuNdAop+/t4pB7EtJzK1DZkJsDw4mfLSI esXVvpWVx8GicIiU66rjyOLRPF5OTFsaVX2tJWsLFYNWcFES2CSK2qeAgwFN2kTImO+S 5Gzi3jfvaL6ebnTlS7TUT/Nv4HV/u5M55Ws7WqFCY2F1aJeBr3T7sJQYczWx8rLtj1IB nwgA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-numa-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-numa-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 z16si1505177edb.420.2019.09.20.07.35.02; Fri, 20 Sep 2019 07:35:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-numa-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-numa-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-numa-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389764AbfITCek (ORCPT + 72 others); Thu, 19 Sep 2019 22:34:40 -0400 Received: from mail.windriver.com ([147.11.1.11]:63721 "EHLO mail.windriver.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389457AbfITCek (ORCPT ); Thu, 19 Sep 2019 22:34:40 -0400 Received: from ALA-HCA.corp.ad.wrs.com ([147.11.189.40]) by mail.windriver.com (8.15.2/8.15.1) with ESMTPS id x8K2YXq6024910 (version=TLSv1 cipher=AES128-SHA bits=128 verify=FAIL); Thu, 19 Sep 2019 19:34:33 -0700 (PDT) Received: from ala-lpggp2.wrs.com (147.11.105.123) by ALA-HCA.corp.ad.wrs.com (147.11.189.40) with Microsoft SMTP Server id 14.3.468.0; Thu, 19 Sep 2019 19:34:33 -0700 From: "Hongzhi.Song" To: , , Subject: [PATCH] numademo: fix error on 32bit system Date: Thu, 19 Sep 2019 19:34:33 -0700 Message-ID: <20190920023433.88771-1-hongzhi.song@windriver.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII Sender: linux-numa-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-numa@vger.kernel.org Error Info on 32bit: root@intel-x86:~# numademo -t -e 1M Configured Nodes does not match available memory nodes That's because sizeof(long)=4Word, but sizeof(long long)=8Word on 32bit. So (long long) assigning to (long) maybe cause overflow. long numa_node_size(int node, long *freep) { ... long sz = numa_node_size64_int(node, &f2); return sz; ... } long long numa_node_size64(int node, long long *freep) { ... } Signed-off-by: Hongzhi.Song --- libnuma.c | 4 ++-- numa.h | 2 +- numademo.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libnuma.c b/libnuma.c index cac8851..8b5c6aa 100644 --- a/libnuma.c +++ b/libnuma.c @@ -791,10 +791,10 @@ long long numa_node_size64(int node, long long *freep) make_internal_alias(numa_node_size64); -long numa_node_size(int node, long *freep) +long long numa_node_size(int node, long long *freep) { long long f2; - long sz = numa_node_size64_int(node, &f2); + long long sz = numa_node_size64_int(node, &f2); if (freep) *freep = f2; return sz; diff --git a/numa.h b/numa.h index 3a8c543..268fb1d 100644 --- a/numa.h +++ b/numa.h @@ -143,7 +143,7 @@ int numa_preferred(void); /* Return node size and free memory */ long long numa_node_size64(int node, long long *freep); -long numa_node_size(int node, long *freep); +long long numa_node_size(int node, long long *freep); int numa_pagesize(void); diff --git a/numademo.c b/numademo.c index a720db0..8c56da8 100644 --- a/numademo.c +++ b/numademo.c @@ -301,7 +301,7 @@ int max_node, numnodes; int get_node_list(void) { int a, got_nodes = 0; - long free_node_sizes; + long long free_node_sizes; numnodes = numa_num_configured_nodes(); node_to_use = (int *)malloc(numnodes * sizeof(int)); -- 2.23.0