Received: by 10.223.185.116 with SMTP id b49csp8220652wrg; Thu, 1 Mar 2018 20:19:39 -0800 (PST) X-Google-Smtp-Source: AG47ELvjS6Xo8QxVBfV5qJE9DAYSsUQNIuMN3+PvY6VNC9mgaHcjxovPiLMEAVu6eWdIbuE6Yw8c X-Received: by 10.99.97.205 with SMTP id v196mr3477376pgb.319.1519964378985; Thu, 01 Mar 2018 20:19:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519964378; cv=none; d=google.com; s=arc-20160816; b=RXToeBVaSPmhMXHkRkCaskjVZ4ry5quUlxDxHHGXoB7ncmbEf0kzsjJEVCcPitC8sn wgJ5J80Gqi8S6eJPHCJ8M+Ah65zKjtpzJY6YujxRgBjMEJ2em4vmPyngyZYKTw15Toos mqXOU1IBsEdNWf6SdEGnIqetzj87Fa+KSUKfe16uqdvoqNojer4ScWugAICQgYPZw4cY 2G9BdcE3ea6hnvl/MHKf8fQQu7hBAArm6ZIMoCQoSag9ROx4N3kpWhAOmO5Kwclc+A0+ CQeZowloAcYs05aF+DbdmJGpkHTTjBfEioxZtbpsqRBd4CH+lV168HuPTcGUnaiGV46d RTDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=Ou+YLzw0cV3TjsD/89wNZtwJASwJ8igKjee2mHA3kSE=; b=yvwwD4SseX29oIeG+QQN1P7+vsqHyguFDL8nZB3ZXGZsg2+1ONxUhIkZAiJUb1ReYk 2C+gytqoDeWMADJfWF0z0T2Er4fsw9jyyvvA9/oxmxJqhad3qtoeGT3FCt90TI2VPwuS wOjgj4zvmx/jriHTu78uLhGzaeMu9tcKHl9gGbscn3fHRWB56sMY+0gTbIw377V6oaI2 34RKwIvHOYKHAxygBAUS+ruJX5KefGFkHliwDbzTyyf8fMhEWwm/MfW5RwGQStHessUr hdKfsCBPrxGoILQWuUjYrtJtHdomJFoleU46Dx30EH5eKtcLXHc7qCZZAnYZiWYH/YTC H5gg== 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 x14si3433381pgq.614.2018.03.01.20.19.24; Thu, 01 Mar 2018 20:19:38 -0800 (PST) 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 S1164417AbeCBCoD (ORCPT + 99 others); Thu, 1 Mar 2018 21:44:03 -0500 Received: from mga06.intel.com ([134.134.136.31]:51067 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1164256AbeCBCoB (ORCPT ); Thu, 1 Mar 2018 21:44:01 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Mar 2018 18:44:00 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,409,1515484800"; d="scan'208";a="34866274" Received: from bee.sh.intel.com (HELO inn.lkp.intel.com) ([10.239.97.14]) by fmsmga001.fm.intel.com with ESMTP; 01 Mar 2018 18:43:58 -0800 From: Li Zhijian To: shuah@kernel.org, akpm@linux-foundation.org, sj38.park@gmail.com, pombredanne@nexb.com, aneesh.kumar@linux.vnet.ibm.com, linux-kselftest@vger.kernel.org Cc: linux-kernel@vger.kernel.org, lizhijian@cn.fujitsu.com, Li Zhijian Subject: [PATCH] selftests/vm/run_vmtests: adjust hugetlb size accroding to nr_cpus Date: Fri, 2 Mar 2018 10:43:56 +0800 Message-Id: <20180302024356.83359-1-zhijianx.li@intel.com> X-Mailer: git-send-email 2.11.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org this patch is to fix running userfaultfd_hugetlb failed on the host which has more than 64 cpus --------------------------- running userfaultfd_hugetlb --------------------------- invalid MiB Usage: [FAIL] From userfaultfd.c we can know, hugetlb_size need to meet hugetlb_size >= nr_cpus * hugepage_size hugepage_size is often 2M, so when host cpus > 64, it requires more than 128M. Signed-off-by: Li Zhijian --- tools/testing/selftests/vm/run_vmtests | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/vm/run_vmtests b/tools/testing/selftests/vm/run_vmtests index d2561895a021a..c440fb972afe9 100755 --- a/tools/testing/selftests/vm/run_vmtests +++ b/tools/testing/selftests/vm/run_vmtests @@ -2,8 +2,6 @@ # SPDX-License-Identifier: GPL-2.0 #please run as root -#we need 256M, below is the size in kB -needmem=262144 mnt=./huge exitcode=0 @@ -17,6 +15,13 @@ while read name size unit; do fi done < /proc/meminfo +nr_cpus=$(nproc) +pgsize_MB=$((pgsize/1024)) +# rule: nr_cpus * pgsize_MB <= hugetlb_size(round to 128M for testing) +hugetlb_size=$((((nr_cpus*pgsize_MB+127)/128)*128)) +# needmem depends on the nr_cpus, below is the size in kB +needmem=$((hugetlb_size*2*1024)) + #set proper nr_hugepages if [ -n "$freepgs" ] && [ -n "$pgsize" ]; then nr_hugepgs=`cat /proc/sys/vm/nr_hugepages` @@ -107,8 +112,8 @@ fi echo "---------------------------" echo "running userfaultfd_hugetlb" echo "---------------------------" -# 256MB total huge pages == 128MB src and 128MB dst -./userfaultfd hugetlb 128 32 $mnt/ufd_test_file +# 256MB total huge pages == 128MB src and 128MB dst when nr_cpus <= 64 +./userfaultfd hugetlb $hugetlb_size 32 $mnt/ufd_test_file if [ $? -ne 0 ]; then echo "[FAIL]" exitcode=1 -- 2.11.0