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 F2B07C43334 for ; Tue, 28 Jun 2022 15:24:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6739F8E0001; Tue, 28 Jun 2022 11:24:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 623196B0072; Tue, 28 Jun 2022 11:24:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4EAD88E0001; Tue, 28 Jun 2022 11:24:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 40BF16B0071 for ; Tue, 28 Jun 2022 11:24:23 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 0E50820A61 for ; Tue, 28 Jun 2022 15:24:23 +0000 (UTC) X-FDA: 79628016006.29.CE991B0 Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) by imf08.hostedemail.com (Postfix) with ESMTP id 4938B160034 for ; Tue, 28 Jun 2022 15:24:22 +0000 (UTC) Received: by mail-wr1-f42.google.com with SMTP id i25so12699010wrc.13 for ; Tue, 28 Jun 2022 08:24:22 -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=WSSq3lrsxOAtBEKRUyszSwx1pmNzhKrE4XnbixckSsM=; b=WZZVLWPTdGbDKX3iRWmzLR6o9Og+wHTW3u/m7LRBjBKByUWQ4+DDSN1Q6qPKuq8Tn7 HjnNHFFHyAWCwWMR68uLym1f1X4xYo6//G3fGTmffTPHhtL4YkuTuYBYBdq1Kh5NRvOn DW6MRjcQRKbZXaq66g/ifDOTGl4XpucA/LFJjSUQd3AkPOePC4sCAFo5scv78Dzy/NlW cNhqkoXo1WSs7F7l+V1G1p4fPcUU1lMPdWnfQeMx3CgCalYTYRaEzE2smj+D8ZAyKvXc fD5U4PfDyDNNIlnQphPjJDSWxVZTW3FOa+a6qQDeFuYu/UBlFYIyc/hO/IN6quRl79YD lqiQ== 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=WSSq3lrsxOAtBEKRUyszSwx1pmNzhKrE4XnbixckSsM=; b=rbSrnmu8uZK/Cq01jEuXDIuI5ld9812TV/wkqV4tdChhVuWTryoGOyLfJ5R6AJMLUa Bfkvv4hcECXxqnl7C23mcQoh2Pd6O/SB0tbXiV/g9jAPTzNUOVfME5BqdoFn6rQIWLZN +R5b7YOEtS7UPeSTn6owK192SR2M+/UbRUjGetutgxo3EEgPifVhtgN75pUAdWvGtaZw 3lRBFebiDc8vS4AJDBSIL7rIJQxxgaDQcPrWKVIIa5IwwLnkMO5V+//UXbkwq/LxFyaY tydEomATrXL44eejD0QRR/zvLuBrW0Gw/N9p/+93plkTY1vQJ+V/LPVDD18LKF1mU+Ha LT+A== X-Gm-Message-State: AJIora9yaFHeMZ4bY8CMtLa7nL33U38/4k/72tlKu2fAFPyWQRZ/2J+H zc5klYNuFLSt4+hxVi8+iqCy8w== X-Google-Smtp-Source: AGRyM1uqcKVYr7mOOgYozMpNBmRDkYjTIsiungyGvSvf83dr2jFaQcH7ZsHMtBW6SNhQgK+jMEQppw== X-Received: by 2002:a5d:43c7:0:b0:21d:1e01:e9ac with SMTP id v7-20020a5d43c7000000b0021d1e01e9acmr3800930wrr.187.1656429860747; Tue, 28 Jun 2022 08:24:20 -0700 (PDT) Received: from localhost (212-51-140-210.fiber7.init7.net. [212.51.140.210]) by smtp.gmail.com with ESMTPSA id e9-20020a5d4e89000000b0021a3a87fda9sm14049925wru.47.2022.06.28.08.24.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jun 2022 08:24:20 -0700 (PDT) Date: Tue, 28 Jun 2022 17:24:17 +0200 From: Adam Sindelar To: "Aneesh Kumar K.V" Cc: Andrew Morton , linux-mm@kvack.org, Adam Sindelar , David Vernet , kernel-team@fb.com Subject: Re: [PATCH v3] selftests/vm: Only run 128TBswitch with 5-level paging Message-ID: References: <20220627163912.5581-1-adam@wowsignal.io> <874k04hl2p.fsf@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <874k04hl2p.fsf@linux.ibm.com> ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656429862; a=rsa-sha256; cv=none; b=zzoBfKrvgc6OL+IE3yfbpiCfai/k2GirpntTmDwWWZ7GAsvPdntASpjQuroh18sXrFkqfW qtAXdatzI2fRoDlOhldp5NME1eb9nG7VjXP/bPtmzOiMKGsQ6EdI+C5THJxIkcjKVTSt26 WMH44SwZ5azxytmpEhL94k2nqlEqBAw= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=wowsignal-io.20210112.gappssmtp.com header.s=20210112 header.b=WZZVLWPT; spf=none (imf08.hostedemail.com: domain of adam@wowsignal.io has no SPF policy when checking 209.85.221.42) smtp.mailfrom=adam@wowsignal.io; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656429862; 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=WSSq3lrsxOAtBEKRUyszSwx1pmNzhKrE4XnbixckSsM=; b=zsrpi13M+Ajy2pryVCKTRxE7z9y5XE53esZ7gjs4nNy3kUBaJmhYev81/p1Y9aNE1pvM5x 50hyQ0JvMudFi8zCUGnMYlthIcBxnDDWuvS+1iA/0wYF952yNXMCwtUlioQJoaHDKTxKms /WenwOPcv4djAX50ZSafrNwp47eQQTk= X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 4938B160034 X-Rspam-User: X-Stat-Signature: qciq63mgmo9n3dqy9a3bg4fc1ut1sycw Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=wowsignal-io.20210112.gappssmtp.com header.s=20210112 header.b=WZZVLWPT; spf=none (imf08.hostedemail.com: domain of adam@wowsignal.io has no SPF policy when checking 209.85.221.42) smtp.mailfrom=adam@wowsignal.io; dmarc=none X-HE-Tag: 1656429862-692593 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, Jun 28, 2022 at 08:49:42PM +0530, Aneesh Kumar K.V wrote: > Adam Sindelar writes: > > > The test va_128TBswitch.c expects to be able to pass mmap an address hint > > and length that cross the address 1<<47. 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 archs, but this > > patch adds an additional check 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 > > --- > > 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 | 39 ++++++++++++++++++++ > > 3 files changed, 41 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 c45e535ff4b8..7860d0969888 100644 > > --- a/tools/testing/selftests/vm/Makefile > > +++ b/tools/testing/selftests/vm/Makefile > > @@ -91,6 +91,7 @@ endif > > TEST_PROGS := run_vmtests.sh > > > > TEST_FILES := test_vmalloc.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 a2302b5faaf2..edda7350ccca 100755 > > --- a/tools/testing/selftests/vm/run_vmtests.sh > > +++ b/tools/testing/selftests/vm/run_vmtests.sh > > @@ -149,7 +149,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..767a6465b5d2 > > --- /dev/null > > +++ b/tools/testing/selftests/vm/va_128TBswitch.sh > > @@ -0,0 +1,39 @@ > > +#!/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 > > + > > +die() > > +{ > > + echo "$1" > > + exit $exitcode > > +} > > + > > +check_test_requirements() > > +{ > > + local config="/proc/config.gz" > > + [[ -f "${config}" ]] || config="/boot/config-$(uname -r)" > > + [[ -f "${config}" ]] || die "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: PG_TABLE_LEVELS=${pg_table_levels}, must be >= 5 to run this test" > > + exit $ksft_skip > > + fi > > +} > > This prevent the test from running on powerpc architecture. > > $bash -x ./va_128TBswitch.sh > + exitcode=1 > + ksft_skip=4 > + check_test_requirements > + local config=/proc/config.gz > + [[ -f /proc/config.gz ]] > + [[ -f /proc/config.gz ]] > ++ gzip -dcfq /proc/config.gz > ++ grep PGTABLE_LEVELS > ++ cut -d= -f 2 > + local pg_table_levels=4 > + [[ 4 -lt 5 ]] > + echo './va_128TBswitch.sh: PG_TABLE_LEVELS=4, must be >= 5 to run this test' > ./va_128TBswitch.sh: PG_TABLE_LEVELS=4, must be >= 5 to run this test > + exit 4 > > Without the patch > > :src/linux/tools/testing/selftests/vm$ ./va_128TBswitch > mmap(ADDR_SWITCH_HINT - PAGE_SIZE, PAGE_SIZE): 0x7fffffff0000 - OK > mmap(ADDR_SWITCH_HINT - PAGE_SIZE, (2 * PAGE_SIZE)): 0x763910f30000 - OK > mmap(ADDR_SWITCH_HINT, PAGE_SIZE): 0x763910f40000 - OK > mmap(ADDR_SWITCH_HINT, 2 * PAGE_SIZE, MAP_FIXED): 0x800000000000 - OK > mmap(NULL): 0x763910f20000 - OK > mmap(LOW_ADDR): 0x40000000 - OK > mmap(HIGH_ADDR): 0x1000000000000 - OK > mmap(HIGH_ADDR) again: 0xff63910fc0000 - OK > mmap(HIGH_ADDR, MAP_FIXED): 0x1000000000000 - OK > mmap(-1): 0xff63910fa0000 - OK > mmap(-1) again: 0xff63910f80000 - OK > mmap(ADDR_SWITCH_HINT - PAGE_SIZE, PAGE_SIZE): 0x7fffffff0000 - OK > mmap(ADDR_SWITCH_HINT - PAGE_SIZE, 2 * PAGE_SIZE): 0x763910f20000 - OK > mmap(ADDR_SWITCH_HINT - PAGE_SIZE/2 , 2 * PAGE_SIZE): 0x763910f00000 - OK > mmap(ADDR_SWITCH_HINT, PAGE_SIZE): 0x763910ef0000 - OK > mmap(ADDR_SWITCH_HINT, 2 * PAGE_SIZE, MAP_FIXED): 0x800000000000 - OK > > + > > +check_test_requirements > > +./va_128TBswitch > > -- > > 2.35.1 My bad, sorry. Let me fix it in v4.