From patchwork Fri Oct 28 13:26:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Savitz X-Patchwork-Id: 12271 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp835474wru; Fri, 28 Oct 2022 06:36:14 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7rT4i9xcBeoIA++O1gm3NY3nHb6PdF0dZ1xN5Zi7A7l1rbXS5yPIfSjAfBh/Z0ljWxXb8f X-Received: by 2002:a17:907:2d8a:b0:78d:4448:e96c with SMTP id gt10-20020a1709072d8a00b0078d4448e96cmr46477681ejc.199.1666964174203; Fri, 28 Oct 2022 06:36:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666964174; cv=none; d=google.com; s=arc-20160816; b=UCCPal+L6ZGJcF6KjnICaX3b7Uv1xgtJsUfBnKcefz8I4k1B4WoabXUF8RxnVgsJgn 06bj/EaR6B/snr5tH3JCjAE5fXsZ63BQlMpLu/G3c58JmbT0oaGXk9vgIbMNsBYLDN20 6MzirS2vFs0DjR0PIkb19fNkZWhKxIdBVKOw/jE9Xm2qFOyAx+wuvRHVypIwpBuTXE0e WV/tuVts8ESKMepPtt0+9Oh6Gjkk8yinNx7Kil4G28/6ojdrtIAZsa2+5GT4ivPG6Fgq lF4rm6L2RBygXB9enLNf4c+s8mbmNBfYRPG1KJolzpzlzopGxDVitWRpfAaeJXi2Zerz T+7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=nMEqJ+SJX81wA4F4D8VcQ1oWVGj7/HJA80MojM8MPSQ=; b=YDSAG3HRo0p61z/J7R9HDIi1TTo3NvtIL4ARZLY/+l3z1IGMZGCOntghHWKaF8auz4 2qZ6azqxwx1YtuHbycdx5xRi1F3KdFCmO2NYgQFdaCoEVC22cRv1m5QEEUxknIWUo7GA J220fBGx+7HPgAwrB8ux2A8Aouno1V8wimZOVIIaxw8f/ucObychQvciIQfN46+zlMIu oF/8czUbH3pNhlfJlB7C084riRVOh5E+bOHJIFu8S7/JEyGFdnxlwOULqUsoZWQWjSpC YPOHT+Dmx5KKh8offzNnS24z2ME7IS3HkeYLlfVUYqcPShfnubdVfUtJgEbugq/1/uVR zvKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Txwkx/3Q"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h11-20020a05640250cb00b0045cca8f9a0asi5135859edb.580.2022.10.28.06.35.50; Fri, 28 Oct 2022 06:36:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Txwkx/3Q"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229450AbiJ1N2K (ORCPT + 99 others); Fri, 28 Oct 2022 09:28:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230416AbiJ1N17 (ORCPT ); Fri, 28 Oct 2022 09:27:59 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E5BA1CB52E for ; Fri, 28 Oct 2022 06:27:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666963619; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=nMEqJ+SJX81wA4F4D8VcQ1oWVGj7/HJA80MojM8MPSQ=; b=Txwkx/3QgMEfCouQ6A8W9Wh+PTr2AYsEVZtRGV0mfhDFiBCMS9MpLOAEu7r8ZS5y0bRtpB 5SXuKAYMoE7ZH8gFkoVY1IX3mk6vnq0EsEFVYDCIPx8i2Q+ddJMzYZPOuJSx2LXkpz9EYN fccZGHEtdWhopRTZKVMHDriGWvDGcd8= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-170-eXGXvRW4NzCQ6fMIzMAqUA-1; Fri, 28 Oct 2022 09:26:56 -0400 X-MC-Unique: eXGXvRW4NzCQ6fMIzMAqUA-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DDD8484ACA0; Fri, 28 Oct 2022 13:26:55 +0000 (UTC) Received: from jsavitz-csb.redhat.com (unknown [10.22.16.249]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1F9CE492B06; Fri, 28 Oct 2022 13:26:53 +0000 (UTC) From: Joel Savitz To: linux-kernel@vger.kernel.org Cc: Joel Savitz , Andrew Morton , Shuah Khan , David Hildenbrand , Nico Pache , linux-mm@kvack.org, linux-kselftest@vger.kernel.org Subject: [PATCH linux-next] selftests/vm: calculate variables in correct order Date: Fri, 28 Oct 2022 09:26:40 -0400 Message-Id: <20221028132640.2791026-1-jsavitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747938625933569163?= X-GMAIL-MSGID: =?utf-8?q?1747938625933569163?= commit b5ba705c2608 ("selftests/vm: enable running select groups of tests") unintentionally reversed the ordering of some of the lines of run_vmtests.sh that calculate values based on system configuration. Importantly, $hpgsize_MB is determined from $hpgsize_KB, but this later value is not read from /proc/meminfo until later, causing userfaultfd tests to incorrectly fail since $half_ufd_size_MB will always be 0. Switch these statements around into proper order to fix the invocation of the userfaultfd tests that use $half_ufd_size_MB. Suggested-by: Nico Pache Signed-off-by: Joel Savitz Acked-by: Mike Kravetz --- tools/testing/selftests/vm/run_vmtests.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tools/testing/selftests/vm/run_vmtests.sh b/tools/testing/selftests/vm/run_vmtests.sh index fff00bb77086..ce52e4f5ff21 100755 --- a/tools/testing/selftests/vm/run_vmtests.sh +++ b/tools/testing/selftests/vm/run_vmtests.sh @@ -82,16 +82,6 @@ test_selected() { fi } -# Simple hugetlbfs tests have a hardcoded minimum requirement of -# huge pages totaling 256MB (262144KB) in size. The userfaultfd -# hugetlb test requires a minimum of 2 * nr_cpus huge pages. Take -# both of these requirements into account and attempt to increase -# number of huge pages available. -nr_cpus=$(nproc) -hpgsize_MB=$((hpgsize_KB / 1024)) -half_ufd_size_MB=$((((nr_cpus * hpgsize_MB + 127) / 128) * 128)) -needmem_KB=$((half_ufd_size_MB * 2 * 1024)) - # get huge pagesize and freepages from /proc/meminfo while read -r name size unit; do if [ "$name" = "HugePages_Free:" ]; then @@ -102,6 +92,16 @@ while read -r name size unit; do fi done < /proc/meminfo +# Simple hugetlbfs tests have a hardcoded minimum requirement of +# huge pages totaling 256MB (262144KB) in size. The userfaultfd +# hugetlb test requires a minimum of 2 * nr_cpus huge pages. Take +# both of these requirements into account and attempt to increase +# number of huge pages available. +nr_cpus=$(nproc) +hpgsize_MB=$((hpgsize_KB / 1024)) +half_ufd_size_MB=$((((nr_cpus * hpgsize_MB + 127) / 128) * 128)) +needmem_KB=$((half_ufd_size_MB * 2 * 1024)) + # set proper nr_hugepages if [ -n "$freepgs" ] && [ -n "$hpgsize_KB" ]; then nr_hugepgs=$(cat /proc/sys/vm/nr_hugepages)