From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8E553C43334 for ; Fri, 1 Jul 2022 10:50:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 315B66B0073; Fri, 1 Jul 2022 06:50:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 29E996B0074; Fri, 1 Jul 2022 06:50:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 13FC76B0075; Fri, 1 Jul 2022 06:50:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 013A46B0073 for ; Fri, 1 Jul 2022 06:50:31 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id CB12C20EF7 for ; Fri, 1 Jul 2022 10:50:31 +0000 (UTC) X-FDA: 79638212262.05.977D97E Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) by imf13.hostedemail.com (Postfix) with ESMTP id 336272003E for ; Fri, 1 Jul 2022 10:50:30 +0000 (UTC) Received: by mail-wr1-f41.google.com with SMTP id d17so2610166wrc.10 for ; Fri, 01 Jul 2022 03:50:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wowsignal-io.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=RWZUVsXAPtGdLTMf1ubxvj12S/bNou+QA2yQm4CyNTY=; b=bRVeuQ28gU/Gcjqlmb7qAGoIdYClmEER/02v2qHKiFu93CKkrQdmR8sxcEsPoCu4za bAnqIbeiH9IJtj+tM432+nWeiT1W39Byped2d8o5rWIhgjQOFTedesSJgj9+I5o/eANb QlW2ZU2ivZxVsoqV9/AUD8OCyeXfqh3YipQAoAg2ItrE+8Gb1TcC8/VFV8MuAvjgKiT+ 75fZWoSHN8QcUk5QKU3tkieoVb2QynxMpHBpwQjFugIJVvWbpvOq+/TGZxOE5ocMFyrL 7hDif5N70UVDIGmUC0skusFHhguNRM+Zk3A2NGgVFTh1fc0nmfQ7pQIWwjtKMM+oCDL+ QggA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=RWZUVsXAPtGdLTMf1ubxvj12S/bNou+QA2yQm4CyNTY=; b=B8DctOOQJVWhQVLzr3T9SveiIPxfKcJSs4OSVL2IRUQd508HUeE1141h9Dv66GY6qU x2yyiR+SlCsG2b+Q0gfqDMMrlIsc7/AUphcOiM9F4uDV7ZhGQt/Hsd6ixEE1ejpab/3H WGShN62j0dDcys96yMVK7ozTlRWUuJzAXku1gOeFufQQdK/3ntEXqenOHfZU+HeoPL8A IDxy+XFjuRsSmXnzHR6RZWguAAe5wPX80l9uekwaA/21mthXVhY4J6HGJS5QhvpESQcn 8XLP5oZ9kyymuEjx69jX5II4txOBITkcie22UnZ2CcPuPPemjgDCNQi/tg5ex19VOCPJ /KHQ== X-Gm-Message-State: AJIora83zY4Rd69XqZ88wcjrzZ6LXz+GK714kbpqELUNOzofkr1ObPug YEg7SGNyV0ixFiIAFr+4qf70+A== X-Google-Smtp-Source: AGRyM1v5pFLZG6TZkJolF/HKBiQYOcGmna8LnoBiebTywMt/YFJWl5i0PsZ3SY7uZh9yADsAZB0/aQ== X-Received: by 2002:adf:ea91:0:b0:21a:3d15:ae17 with SMTP id s17-20020adfea91000000b0021a3d15ae17mr13693890wrm.486.1656672629611; Fri, 01 Jul 2022 03:50:29 -0700 (PDT) Received: from localhost (212-51-140-210.fiber7.init7.net. [212.51.140.210]) by smtp.gmail.com with ESMTPSA id s11-20020a5d4ecb000000b0020fe61acd09sm22507201wrv.12.2022.07.01.03.50.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Jul 2022 03:50:29 -0700 (PDT) Date: Fri, 1 Jul 2022 12:50:28 +0200 From: Adam Sindelar To: Andrew Morton Cc: linux-mm@kvack.org, Adam Sindelar , David Vernet , kernel-team@fb.com Subject: Re: [PATCH v5] selftests/vm: Only run 128TBswitch with 5-level paging Message-ID: References: <20220701104934.413146-1-adam@wowsignal.io> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220701104934.413146-1-adam@wowsignal.io> ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656672631; a=rsa-sha256; cv=none; b=gEw3QaYleEWT/+qwn0c9IABD3QPZkdQ/48PsVYL50uU7RbMnzUp8UBWyS25BvHn4NLROTS YPpnBml7th906nNcVbUaPyumsBYRjf40np8RY9c+YiNFlh9b7HPZ29GUnl3pyFrLtNuBi7 yhUPZLOmYyEEbaVEnffMQEf42dvK2iY= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=wowsignal-io.20210112.gappssmtp.com header.s=20210112 header.b=bRVeuQ28; dmarc=none; spf=none (imf13.hostedemail.com: domain of adam@wowsignal.io has no SPF policy when checking 209.85.221.41) smtp.mailfrom=adam@wowsignal.io ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656672631; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=RWZUVsXAPtGdLTMf1ubxvj12S/bNou+QA2yQm4CyNTY=; b=AsMpRqNanKcAnc3aqsG3LXyRjU1RPne1Bj1P1NbGhwTV5lUDF926wwSBdgALWSRW2EFPQG WkNfhMF+2b1T1QnQv5h5HDhiH1ebZGzansIw5cWgPuPwIOZ2kGtj7cY0zUS4v0QDTqHim8 DkPpKbsp5XWy80O2i+rLfU+VtmH5H7M= Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=wowsignal-io.20210112.gappssmtp.com header.s=20210112 header.b=bRVeuQ28; dmarc=none; spf=none (imf13.hostedemail.com: domain of adam@wowsignal.io has no SPF policy when checking 209.85.221.41) smtp.mailfrom=adam@wowsignal.io X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 336272003E X-Stat-Signature: byhuak1trfmhm9nuzifgp7c8hiswhkx4 X-Rspam-User: X-HE-Tag: 1656672630-39565 X-Bogosity: Ham, tests=bogofilter, spamicity=0.005609, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, Jul 01, 2022 at 12:49:34PM +0200, Adam Sindelar wrote: > The test va_128TBswitch.c expects to be able to pass mmap an address hint > and length that cross the address 1<<47. On x86_64, this is not possible > without 5-level page tables, so the test fails. > > The test is already only run on 64-bit powerpc and x86_64 archs, but this > patch adds an additional check on x86_64 that skips the test if PG_TABLE_LEVELS > < 5. There is precedent for checking /proc/config.gz in selftests, e.g. in > selftests/firmware. > > Running the tests produces the desired output: > > sudo make -C tools/testing/selftests TARGETS=vm run_tests > --------------------------- > running ./va_128TBswitch.sh > --------------------------- > ./va_128TBswitch.sh: PG_TABLE_LEVELS=4, must be >= 5 to run this test > [SKIP] > ------------------------------- > > Signed-off-by: Adam Sindelar > --- > V4 -> V5: Renamed "die" to "fail" (missed the review comment, sorry!) > V3 -> V4: Restrict the check to x86_64 > V2 -> V3: Clean up the commit message > V1 -> V2: Variables local, fixed Makefile typo, comment on gzip usage > > tools/testing/selftests/vm/Makefile | 1 + > tools/testing/selftests/vm/run_vmtests.sh | 2 +- > tools/testing/selftests/vm/va_128TBswitch.sh | 54 ++++++++++++++++++++ > 3 files changed, 56 insertions(+), 1 deletion(-) > create mode 100755 tools/testing/selftests/vm/va_128TBswitch.sh > > diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile > index 44f25acfbeca..6a34209379a4 100644 > --- a/tools/testing/selftests/vm/Makefile > +++ b/tools/testing/selftests/vm/Makefile > @@ -93,6 +93,7 @@ TEST_PROGS := run_vmtests.sh > > TEST_FILES := test_vmalloc.sh > TEST_FILES += test_hmm.sh > +TEST_FILES += va_128TBswitch.sh > > KSFT_KHDR_INSTALL := 1 > include ../lib.mk > diff --git a/tools/testing/selftests/vm/run_vmtests.sh b/tools/testing/selftests/vm/run_vmtests.sh > index 41fce8bea929..27c01c35c7a9 100755 > --- a/tools/testing/selftests/vm/run_vmtests.sh > +++ b/tools/testing/selftests/vm/run_vmtests.sh > @@ -151,7 +151,7 @@ if [ $VADDR64 -ne 0 ]; then > run_test ./virtual_address_range > > # virtual address 128TB switch test > - run_test ./va_128TBswitch > + run_test ./va_128TBswitch.sh > fi # VADDR64 > > # vmalloc stability smoke test > diff --git a/tools/testing/selftests/vm/va_128TBswitch.sh b/tools/testing/selftests/vm/va_128TBswitch.sh > new file mode 100755 > index 000000000000..334d12715ac3 > --- /dev/null > +++ b/tools/testing/selftests/vm/va_128TBswitch.sh > @@ -0,0 +1,54 @@ > +#!/bin/bash > +# SPDX-License-Identifier: GPL-2.0 > +# > +# Copyright (C) 2022 Adam Sindelar (Meta) > +# > +# This is a test for mmap behavior with 5-level paging. This script wraps the > +# real test to check that the kernel is configured to support at least 5 > +# pagetable levels. > + > +# 1 means the test failed > +exitcode=1 > + > +# Kselftest framework requirement - SKIP code is 4. > +ksft_skip=4 > + > +fail() > +{ > + echo "$1" > + exit $exitcode > +} > + > +check_supported_x86_64() > +{ > + local config="/proc/config.gz" > + [[ -f "${config}" ]] || config="/boot/config-$(uname -r)" > + [[ -f "${config}" ]] || fail "Cannot find kernel config in /proc or /boot" > + > + # gzip -dcfq automatically handles both compressed and plaintext input. > + # See man 1 gzip under '-f'. > + local pg_table_levels=$(gzip -dcfq "${config}" | grep PGTABLE_LEVELS | cut -d'=' -f 2) > + > + if [[ "${pg_table_levels}" -lt 5 ]]; then > + echo "$0: PGTABLE_LEVELS=${pg_table_levels}, must be >= 5 to run this test" > + exit $ksft_skip > + fi > +} > + > +check_test_requirements() > +{ > + # The test supports x86_64 and powerpc64. We currently have no useful > + # eligibility check for powerpc64, and the test itself will reject other > + # architectures. > + case `uname -m` in > + "x86_64") > + check_supported_x86_64 > + ;; > + *) > + return 0 > + ;; > + esac > +} > + > +check_test_requirements > +./va_128TBswitch > -- > 2.35.1 > Apologies for sending such a minor revision, but I'd realized I missed an earlier review comment and wanted to address it. -Adam