From patchwork Thu Aug 29 07:16:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charlie Jenkins X-Patchwork-Id: 1978262 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=cQxJbtU5; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=Rr5v86wT; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WvXdY3GHnz1yZ9 for ; Thu, 29 Aug 2024 17:16:33 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Al0cwYFsp8j2tDiE9NgbVR6nxJhpI4UXZ2IVx/Ujua4=; b=cQxJbtU5UhZky3 kMvIVHPgoE8Siq5Kt8ML+qcwyD6z+lvOvrKsLp0Fkb0SLWkkXDGUb3IJpktTKW8H8u4Yj0ESrZA4e CQbAYMDs4cmzjuSw7mSDEjlRAmgJvrGHcAneuPWQqxquoxlAvAgVWqcrrQl7z2Wf+iw+T++NP8cPp VRLELd35RhGkhRfjT4uqx2ixxKEgpQN5dJ1y3EEC6CwBFQraX2U94gEA+3YRGqgCYLBzKEXL/nWXn V8bKEtIHVkxjFas+JBfKzAvUtsf9jZig1YDCuQdpHwFv0ZpM74EGRMCgA0GnanvitHDtC9UjDmPX6 FxvmS5msVmIiaY6SBJ0w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sjZOS-00000000uOT-11jP; Thu, 29 Aug 2024 07:16:32 +0000 Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sjZON-00000000uKE-3vyY for linux-snps-arc@lists.infradead.org; Thu, 29 Aug 2024 07:16:29 +0000 Received: by mail-pg1-x52b.google.com with SMTP id 41be03b00d2f7-7ae3d7222d4so204922a12.3 for ; Thu, 29 Aug 2024 00:16:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1724915787; x=1725520587; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=9klKwS2bfsiGNUk5X0TeI2il7xQjjU59nEcVHrUHGMg=; b=Rr5v86wTd3s/E7SPv+FfAaX51KMgbLbhq0O2nrdTsLWV1FmY4WYqe0Vs/S45pXCsZ4 T026z1LQ0uO1xQJugKphegG7qKWf9BcB5I6mfQnStwjaqE+lW1Ra4BJT6tJtV9H6Adp6 Jn0kmRwIDPoUSzYsha9fNh86hDWEQX003t6JQWhvuabERXqmgKQlIINPtZbKU7aH8p2s qooD5dkGmR05UeSmagmOsWbvqPBn4YAEOI/nfxH8P/pxSlDFQN2OaPW2NLy2v1C1nTtL LbTPqyKlOl8ciIaa0/deL4PwXgTKSD6Oho5t4la7G0SsvKrNeOgLidjS86iDG2B1U4iY nUsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724915787; x=1725520587; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9klKwS2bfsiGNUk5X0TeI2il7xQjjU59nEcVHrUHGMg=; b=k3pHPoAWFj3Ws0iwPVmefUKJKEWWSYY12jUwfq2W7Yyg5X1oq2wDCRSUh3/rI++jXS KCIwZo1CLCQ9OF88lLrOHSF81lv0I/Z4vKgW5fAUrhkFqooSU4ExAo4u3OUGf7OsxFMG VznVJ0oE+/nHUwBbqYkw9lpOWGT6RIT/Y+YYalmiPVmQj2cwE975Jm997Oz8xlkyUA4D TtYxLX+QGto6K/Rp9VmMFBwmlCYRkSc22FzQmlT+DCX7+2QgaG1euYE3ifCCn3Yza/+y /JFRueolqDRvBM6Lebn+QaXeKGgKTNKgcVIFXD6yuRI2UFEJZh2oO0LesGzqN+Nww1bj T+rw== X-Forwarded-Encrypted: i=1; AJvYcCWkde4DBfYNEy4ECPcQ1ahpGf/glNZwaMqsSsxWpwxpJM1jQM3u2aZfK8H2QtJo9KxCzY6pbB/I+7h7LsI2WA==@lists.infradead.org X-Gm-Message-State: AOJu0YzwfrpL17STwnXhCTFq+8zcoX7/CPtUb2Fqu4WVlC9GribXuYS1 CaNIvOp/IqCM9PZ8LEPQGCF4EFeGpqaEUMfkTth/Tx0QIR83vMgKWVCB0mRVk1Q= X-Google-Smtp-Source: AGHT+IF3t2cjexZNLvhhEG5lVGM8VXbW+pDj1JAzDu87zeFwskGcSX3PJG32Vb5o0zHIzYY5Gmbt2A== X-Received: by 2002:a05:6a20:e196:b0:1be:c4bb:6f31 with SMTP id adf61e73a8af0-1cce1011dd6mr2308343637.18.1724915786799; Thu, 29 Aug 2024 00:16:26 -0700 (PDT) Received: from charlie.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7d22e9bef08sm581976a12.58.2024.08.29.00.16.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2024 00:16:26 -0700 (PDT) From: Charlie Jenkins Date: Thu, 29 Aug 2024 00:16:01 -0700 Subject: [PATCH RFC v2 4/4] selftests/mm: Create MAP_BELOW_HINT test MIME-Version: 1.0 Message-Id: <20240829-patches-below_hint_mmap-v2-4-638a28d9eae0@rivosinc.com> References: <20240829-patches-below_hint_mmap-v2-0-638a28d9eae0@rivosinc.com> In-Reply-To: <20240829-patches-below_hint_mmap-v2-0-638a28d9eae0@rivosinc.com> To: Arnd Bergmann , Richard Henderson , Ivan Kokshaysky , Matt Turner , Vineet Gupta , Russell King , Guo Ren , Huacai Chen , WANG Xuerui , Thomas Bogendoerfer , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Naveen N Rao , Alexander Gordeev , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Sven Schnelle , Yoshinori Sato , Rich Felker , John Paul Adrian Glaubitz , "David S. Miller" , Andreas Larsson , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Andy Lutomirski , Peter Zijlstra , Muchun Song , Andrew Morton , "Liam R. Howlett" , Vlastimil Babka , Lorenzo Stoakes , Shuah Khan Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-alpha@vger.kernel.org, linux-snps-arc@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-csky@vger.kernel.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, Charlie Jenkins X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1995; i=charlie@rivosinc.com; h=from:subject:message-id; bh=s/V5Z34t4dT0xkb/r9QmO4zmTWyR+OmvwZt8Wf5I9yo=; b=owGbwMvMwCHWx5hUnlvL8Y3xtFoSQ9oFBcsP6+L/Tm5SuNTuoL5vd1CHFePmle9+1/Le0d5Yp 3hVY8XNjlIWBjEOBlkxRRaeaw3MrXf0y46Klk2AmcPKBDKEgYtTACYikcjwz6bDSmrzHWPjp6+e zUhZGF3tGZgzRbFMebrXzej5O9YXpDH8j7Z7ceLNKc+79Xs9s7LbGbZefbF4gvgksf23zjP3/b/ +jhkA X-Developer-Key: i=charlie@rivosinc.com; a=openpgp; fpr=7D834FF11B1D8387E61C776FFB10D1F27D6B1354 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240829_001628_028874_840482CD X-CRM114-Status: GOOD ( 14.46 ) X-Spam-Score: -1.9 (-) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Add a selftest for MAP_BELOW_HINT that maps until it runs out of space below the hint address. Signed-off-by: Charlie Jenkins --- tools/testing/selftests/mm/Makefile | 1 + tools/testing/selftests/mm/map_below_hint.c | 32 +++++++++++++++++++++++++++++ 2 files changed, 33 i [...] Content analysis details: (-1.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:52b listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 T_SCC_BODY_TEXT_LINE No description available. X-BeenThere: linux-snps-arc@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux on Synopsys ARC Processors List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-snps-arc" Errors-To: linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Add a selftest for MAP_BELOW_HINT that maps until it runs out of space below the hint address. Signed-off-by: Charlie Jenkins --- tools/testing/selftests/mm/Makefile | 1 + tools/testing/selftests/mm/map_below_hint.c | 32 +++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/tools/testing/selftests/mm/Makefile b/tools/testing/selftests/mm/Makefile index cfad627e8d94..4e2de85267b5 100644 --- a/tools/testing/selftests/mm/Makefile +++ b/tools/testing/selftests/mm/Makefile @@ -50,6 +50,7 @@ TEST_GEN_FILES += hugepage-shm TEST_GEN_FILES += hugepage-vmemmap TEST_GEN_FILES += khugepaged TEST_GEN_FILES += madv_populate +TEST_GEN_FILES += map_below_hint TEST_GEN_FILES += map_fixed_noreplace TEST_GEN_FILES += map_hugetlb TEST_GEN_FILES += map_populate diff --git a/tools/testing/selftests/mm/map_below_hint.c b/tools/testing/selftests/mm/map_below_hint.c new file mode 100644 index 000000000000..55d6cbf90645 --- /dev/null +++ b/tools/testing/selftests/mm/map_below_hint.c @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Test the MAP_BELOW_HINT mmap flag. + */ +#include +#include +#include "../kselftest.h" + +#define ADDR (1 << 20) +#define LENGTH (ADDR / 10000) + +#define MAP_BELOW_HINT 0x8000000 /* Not defined in all libc */ + +/* + * Map memory with MAP_BELOW_HINT until no memory left. Ensure that all returned + * addresses are below the hint. + */ +int main(int argc, char **argv) +{ + void *addr; + + do { + addr = mmap((void *)ADDR, LENGTH, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS | MAP_BELOW_HINT, -1, 0); + } while (addr != MAP_FAILED && (unsigned long)addr <= ADDR); + + if (errno == ENOMEM) + ksft_test_result_pass("MAP_BELOW_HINT works\n"); + else + ksft_test_result_fail("mmap returned address above hint with MAP_BELOW_HINT with error: %s\n", + strerror(errno)); +}