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 079F1C433EF for ; Tue, 28 Jun 2022 15:19:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 734FA8E0001; Tue, 28 Jun 2022 11:19:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6E40F6B0072; Tue, 28 Jun 2022 11:19:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 583868E0001; Tue, 28 Jun 2022 11:19:57 -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 494B56B0071 for ; Tue, 28 Jun 2022 11:19:57 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id 121F86097C for ; Tue, 28 Jun 2022 15:19:57 +0000 (UTC) X-FDA: 79628004834.15.14E9B74 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf10.hostedemail.com (Postfix) with ESMTP id 75A03C0039 for ; Tue, 28 Jun 2022 15:19:51 +0000 (UTC) Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25SEimiS020823; Tue, 28 Jun 2022 15:19:48 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : in-reply-to : references : date : message-id : mime-version : content-type; s=pp1; bh=IluW8F7kKQ70rjMZ5rK+1XS1nk2kCXfhYcUN6KjQFXU=; b=cfahT1WnwYXdItdu1uMQ4EOKNKygmiIR3Yv/XRXxH5w8AXchwYNnN7aM4cnNC3uGOTya eWtn5UCebOUzr6FNWZHDWyJ9d3xWXHIfQTYHwefPGLgSmxTYGc71pY7BbaXl3usT3ozX bnDL3EFxLjk4euMaWt/6kw1DhqtH5zL4IVnpa+LcPQKjQclj8zkdVyjLxfFRZlOR7I4S jN1oexMVMtqEZ85AV+wLEfLou0AbNtlx05BKVzTulJN1GPX6D42EigFT6+oGq01u5AOl vb1Ekbomuv4TcyI5ScR+p8c0gSPknlY1onFn6mDAGIsyBLqkMf22NNm+PmzpVOGetQ6V DA== Received: from ppma05wdc.us.ibm.com (1b.90.2fa9.ip4.static.sl-reverse.com [169.47.144.27]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3h03nyhjdd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 28 Jun 2022 15:19:48 +0000 Received: from pps.filterd (ppma05wdc.us.ibm.com [127.0.0.1]) by ppma05wdc.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 25SF824k026752; Tue, 28 Jun 2022 15:19:48 GMT Received: from b01cxnp22033.gho.pok.ibm.com (b01cxnp22033.gho.pok.ibm.com [9.57.198.23]) by ppma05wdc.us.ibm.com with ESMTP id 3gwt09x89b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 28 Jun 2022 15:19:48 +0000 Received: from b01ledav005.gho.pok.ibm.com (b01ledav005.gho.pok.ibm.com [9.57.199.110]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 25SFJlQE32571850 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 28 Jun 2022 15:19:47 GMT Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9864BAE060; Tue, 28 Jun 2022 15:19:47 +0000 (GMT) Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 27FCBAE05C; Tue, 28 Jun 2022 15:19:45 +0000 (GMT) Received: from skywalker.linux.ibm.com (unknown [9.43.29.251]) by b01ledav005.gho.pok.ibm.com (Postfix) with ESMTP; Tue, 28 Jun 2022 15:19:44 +0000 (GMT) X-Mailer: emacs 29.0.50 (via feedmail 11-beta-1 I) From: "Aneesh Kumar K.V" To: Adam Sindelar , Andrew Morton Cc: linux-mm@kvack.org, Adam Sindelar , Adam Sindelar , David Vernet , kernel-team@fb.com Subject: Re: [PATCH v3] selftests/vm: Only run 128TBswitch with 5-level paging In-Reply-To: <20220627163912.5581-1-adam@wowsignal.io> References: <20220627163912.5581-1-adam@wowsignal.io> Date: Tue, 28 Jun 2022 20:49:42 +0530 Message-ID: <874k04hl2p.fsf@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: hRiVQ5Ni_a67Bs5kDmsbPekjhHYQD-Mq X-Proofpoint-GUID: hRiVQ5Ni_a67Bs5kDmsbPekjhHYQD-Mq X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-06-28_08,2022-06-28_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 impostorscore=0 suspectscore=0 adultscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 mlxscore=0 priorityscore=1501 clxscore=1011 spamscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206280062 ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=cfahT1Wn; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf10.hostedemail.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656429591; a=rsa-sha256; cv=none; b=VH6XJuh9QGDtRsCxx1QWXNP3EQSoY3LY+X5KJ37K0KBt0g6fkjkAETRIvbIjkPchrwvZ2I dWTGkmzeCzxUbovrU0QyJSeZ/8kHjgp8golinAV0NClQ0Omb9wHaBrpmf1N9vHEMsJRb3D hkG5GAd2ylXkQ4C3UN49gZx7iFjALMA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656429591; 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=IluW8F7kKQ70rjMZ5rK+1XS1nk2kCXfhYcUN6KjQFXU=; b=BMT3+VfYrEoRpJ4wOU72tskN/JtViiZA78MpuLFsekYg6hx3iNVJIm8LEChckV5lFtYe79 yBL+xrNtgRBtG+XOfSkSeCOycQIPmJ10Gbm74K2i75vucmoyhglE8yhuRQ+XEm/bFblKl6 XLvsjC4SBviMb0yOmfrsv4zKaHmRasA= X-Stat-Signature: xhzxdfcf5rnuzjpnfn7gehdzar5j7ixt X-Rspamd-Server: rspam08 X-Rspam-User: X-Rspamd-Queue-Id: 75A03C0039 Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=cfahT1Wn; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf10.hostedemail.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com X-HE-Tag: 1656429591-530601 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: 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