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 D0852C433EF for ; Mon, 27 Jun 2022 15:52:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2674B6B0071; Mon, 27 Jun 2022 11:52:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 217878E0002; Mon, 27 Jun 2022 11:52:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0DF038E0001; Mon, 27 Jun 2022 11:52:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 00A986B0071 for ; Mon, 27 Jun 2022 11:52:39 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id C4A1880375 for ; Mon, 27 Jun 2022 15:52:39 +0000 (UTC) X-FDA: 79624458438.13.4F937C5 Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) by imf16.hostedemail.com (Postfix) with ESMTP id 5D1D118003C for ; Mon, 27 Jun 2022 15:52:39 +0000 (UTC) Received: by mail-wr1-f42.google.com with SMTP id n1so13657386wrg.12 for ; Mon, 27 Jun 2022 08:52:39 -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=N3B1VxUUWsydIz5RSxnnPaDsYNgL0hGvKhwpl8rOdwM=; b=m8xiaZprME/p77BCRlbffc/wyl5Jg1ekT6TLevFu5z80gfC6gRyI4u2I/DUCdVa1Vy zEC4ku3dRqDUFA/73YCMzloF3m2uHo1Sls/UK5lrIGt5HZta0QemwzcVhGsMXLiGOU24 92K0lGdvh6YuNjT5cf/WKbs7oEOapekSwIZ7+rNQf4EuAeb+QhPtpmwc5NTaCfJ5lY7H htBkJ4vpWY9BIi8J7/TFsjUrSeSV1iYzVTDUPmvtZs8YblVJBbrAwIhvz0Zv0YoNldyP WUE3rJoI0NQyuek1XKHaqsqYLhPvB/pDcbUE0/svUVYE/h0ksIa8FTT6hTylbMRIvb/K blzQ== 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=N3B1VxUUWsydIz5RSxnnPaDsYNgL0hGvKhwpl8rOdwM=; b=GJ4CG3tUHZ/jlPeYkW0j90+WjiqKmetqHG5AyInYtrGY54Ev3WEodn92+CW6wLUo39 5t8tgtsTkGkqw3dnLwS/EAqfGRaneKqs8PoJkJV4NB26/ghQ/O5UXh7w03+r7KhJAkSr UqXrNO9uVnBiWDh4OkNZ99oLfgS3EmZCpvpBJ5Bk9K0KWq+S9jc/FJpLFxR0lYrsxc3y +CZ9BYYRkSQzJaiKZt5KulwaCmI6P4Zb/qZtcHjTEibT/SqgY2lTFMrvB3m0F/JUm8I/ 6I3Q/eFfsZBud0zjwJlgOveZkTpSxbpFYhI9jdiRykwKHiW35o9lhG8GbZKrf0i6S9Z5 Kw7Q== X-Gm-Message-State: AJIora9cYDTB8Awa5++/BcgWyZh7wHoh6D7ab8YgGowBquB7XxirSr6d Xo32Eqg4kJy3BZstoapFaUQFRw== X-Google-Smtp-Source: AGRyM1vZF/YJ3xnufGLMjmdAZoWP5yf7K53JVm3CRjW0mtq4f5Wjr58+r12+FwDUH9fkCzuLwPS5nQ== X-Received: by 2002:a5d:664d:0:b0:21a:3b82:6bb2 with SMTP id f13-20020a5d664d000000b0021a3b826bb2mr13143074wrw.534.1656345157890; Mon, 27 Jun 2022 08:52:37 -0700 (PDT) Received: from localhost ([2620:10d:c093:500::1:e511]) by smtp.gmail.com with ESMTPSA id t7-20020a05600001c700b002167efdd549sm10807700wrx.38.2022.06.27.08.52.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jun 2022 08:52:37 -0700 (PDT) Date: Mon, 27 Jun 2022 16:51:56 +0100 From: Adam Sindelar To: David Vernet Cc: Andrew Morton , linux-mm@kvack.org, Adam Sindelar , kernel-team@fb.com Subject: Re: [PATCH] selftests/vm: Only run 128TBswitch with 5-level paging Message-ID: References: <20220627123106.3798-1-adam@wowsignal.io> <20220627143837.mjln2g34xkbvkj2b@dev0025.ash9.facebook.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220627143837.mjln2g34xkbvkj2b@dev0025.ash9.facebook.com> ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656345159; a=rsa-sha256; cv=none; b=bg8DN6nRHlS1C/yikgV2hKctfwo3eDpxcGyFLdNFdpsBiTm+wsi3ZHAP3BN00ZO/g315RT eNlh0XWd/Ul9XZheuFg3UFgxx8VjhvSuXp1YzOMJEpTgqUjyXDUMmxHAZmmsyP/u48k1xf 6KpVr8y2gjL7ym9Ebky4i5w5xTHFzSg= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=wowsignal-io.20210112.gappssmtp.com header.s=20210112 header.b=m8xiaZpr; dmarc=none; spf=none (imf16.hostedemail.com: domain of adam@wowsignal.io has no SPF policy when checking 209.85.221.42) smtp.mailfrom=adam@wowsignal.io ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656345159; 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=N3B1VxUUWsydIz5RSxnnPaDsYNgL0hGvKhwpl8rOdwM=; b=Le14KeC3xLtteIu7LpT7n5LC/rVJml0wO2RaUujNLsr83Ywtn5yY2kRYfJMHdIoa+FyTuT 31LNy7k/XyOwqvmQz66v2TeC5d/TuhMcpoSZkqaGJEkShePPdr+NKnAAaO7L7j8LM3TD4y PvS8sQLKKxmebW1C5OK8KzqmLLyRs1Y= X-Stat-Signature: c89jrcmxayi8ofizam5hd5s9c3unxuw1 X-Rspam-User: X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 5D1D118003C Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=wowsignal-io.20210112.gappssmtp.com header.s=20210112 header.b=m8xiaZpr; dmarc=none; spf=none (imf16.hostedemail.com: domain of adam@wowsignal.io has no SPF policy when checking 209.85.221.42) smtp.mailfrom=adam@wowsignal.io X-HE-Tag: 1656345159-298076 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000064, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon, Jun 27, 2022 at 07:38:37AM -0700, David Vernet wrote: > On Mon, Jun 27, 2022 at 02:31:06PM +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. 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. > > > > Signed-off-by: Adam Sindelar > > Hi Adam, > > Thanks for the patch. This is a great start -- left a few comments and > questions. > > > --- > > tools/testing/selftests/vm/Makefile | 1 + > > tools/testing/selftests/vm/run_vmtests.sh | 2 +- > > tools/testing/selftests/vm/va_128TBswitch.sh | 37 ++++++++++++++++++++ > > 3 files changed, 39 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..74390f498859 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 > > s/TEST_FILEs/TEST_FILES > > I recommend verifying that the installation worked as expected by running: > > $ make -C tools/testing/selftests TARGETS=vm install > > and ensuring that the shell script is output into > tools/testing/selftests/kselftest_install/vm > Done - I think it runs and installs correctly. (All the files are where I expect them to be, but I don't usually install selftests.) Typo fixed in v2. > > 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..269cc674fe9e > > --- /dev/null > > +++ b/tools/testing/selftests/vm/va_128TBswitch.sh > > @@ -0,0 +1,37 @@ > > +#!/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 > > Should we change this to ksft_fail to match ksft_skip? > The convention seems to be to use exitcode in selftests/vm. (ksft_fail is used in selftets/bpf.) I wanted to match the surrounding code. > > + > > +# Kselftest framework requirement - SKIP code is 4. > > +ksft_skip=4 > > + > > +die() > > +{ > > + echo "$1" > > + exit $exitcode > > +} > > + > > +check_test_requirements() > > +{ > > + config="/proc/config.gz" > > Can you make this variable local? > Done in v2, thanks. > > + [[ -f "${config}" ]] || config="/boot/config-$(uname -r)" > > + [[ -f "${config}" ]] || die "Cannot find kernel config in /proc or /boot" > > + > > + pg_table_levels=$(gzip -dcfq "${config}" | grep PGTABLE_LEVELS | cut -d'=' -f 2) > > Same here r.e. making it local. > > Also, does this work if we end up having to pull config from /boot where > it's not gzipped? Perhaps we should create a variable called something like > 'configs' which stores the output as either: > > $ local configs="$(zcat /proc/config.gz)" > > or > > $ local configs="$(cat /boot/config-$(uname -r))" > > Also, to the point above, just using zcat might be a bit simpler than > invoking gzip -dcfq. > Variable made local in v2. I added a comment calling out '-f' from man 1 gzip - it's intended to be a passthrough for plaintext, while decompressing gzip. (zcat does not work that way) > > + 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 > > +} > > + > > +check_test_requirements > > +./va_128TBswitch > > -- > > 2.35.1 > > > > Thanks, > David Thank you for reading! -Adam