From patchwork Fri Jan 10 13:05:50 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13934560 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 30B16E77188 for ; Fri, 10 Jan 2025 13:06:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AAA4C6B009E; Fri, 10 Jan 2025 08:06:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A58FD6B00A0; Fri, 10 Jan 2025 08:06:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8D0D36B00A7; Fri, 10 Jan 2025 08:06:19 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 70A066B009E for ; Fri, 10 Jan 2025 08:06:19 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 1E468160A4B for ; Fri, 10 Jan 2025 13:06:19 +0000 (UTC) X-FDA: 82991565678.15.B420F72 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by imf15.hostedemail.com (Postfix) with ESMTP id 28B31A000F for ; Fri, 10 Jan 2025 13:06:16 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=kA+S8SXB; dkim=pass header.d=linutronix.de header.s=2020e header.b=5KZkRKHk; spf=pass (imf15.hostedemail.com: domain of t-8ch@linutronix.de designates 193.142.43.55 as permitted sender) smtp.mailfrom=t-8ch@linutronix.de; dmarc=pass (policy=none) header.from=linutronix.de ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736514377; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=rvleoViXEKAiJTVXtrq0/ICXhKzDLpaWFsIO95ioPJE=; b=nDcXMRUtrI0pCOT6buNolZAzDmqICHU9XSjUseGNEVw09IAVBheJLHt1tEXUu1juvtWLcW Cjy4nyW8026eNPJyOpJhSKiy08u3n6qv0iMPZZGhp/PBxnM2NJ2VW8fHjleLuHwY3nPbH5 gEg8xY8ZDnW467Uj5HtvbpHR7Ci2Cc0= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=kA+S8SXB; dkim=pass header.d=linutronix.de header.s=2020e header.b=5KZkRKHk; spf=pass (imf15.hostedemail.com: domain of t-8ch@linutronix.de designates 193.142.43.55 as permitted sender) smtp.mailfrom=t-8ch@linutronix.de; dmarc=pass (policy=none) header.from=linutronix.de ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736514377; a=rsa-sha256; cv=none; b=aS25VPzyQNlHcye0IlfSPMhwneMW8g5eGdb6FWUcObyBDpDrR00OeoRNdKmtHqkgwCASho i/4v4MDbZWu7yCnnnBw6IKQi022f9SWoIed74S+tFwUyrFWy0DPo9CROyjHj3LOi2sYkMa CPunNeGV5Bio4W0CopRm+y6UrtiXiNw= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1736514375; h=from:from: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rvleoViXEKAiJTVXtrq0/ICXhKzDLpaWFsIO95ioPJE=; b=kA+S8SXBPARb8/LLqo0nfKGrPw7rdKWdDmGS2CbReD3UmVTIQQskSvD3RaWBL93kyST6L9 PsHFEZqYEro6lVdcsTGBAw2OEuWu6/NQixUPXpAxkpeQOj0Gj1sS7Qmps6jUqISOAOPscj J4JDbtS7rOZZV9TurTDXICTLNe6BWu5xsr4cmjNppwduyJDK/ief8slr8ViWYefVI5crLN 8OltyuL8hhe48ezTMJra2ESijyzKBCc14D8GstA+D5PU3hMtbQGu18gh/Hpi6IldVe7ZgK XHuDv3nt/6TFjUHpbRZ8PP1Hoqrek4EY71BUqqybuaVVD2/t9vdau5pjUO1mgg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1736514375; h=from:from: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rvleoViXEKAiJTVXtrq0/ICXhKzDLpaWFsIO95ioPJE=; b=5KZkRKHkwyWQDbmLNGda8RdT9cAqgyA7/oTQynMbpe46hd4sDQU1p09idFSqW8ElHooX/B Gw4DHIjstVF/o6CQ== Date: Fri, 10 Jan 2025 14:05:50 +0100 Subject: [PATCH v2 1/3] selftests/mm: virtual_address_range: mmap() without PROT_WRITE MIME-Version: 1.0 Message-Id: <20250110-virtual_address_range-tests-v2-1-262a2bf3c3d0@linutronix.de> References: <20250110-virtual_address_range-tests-v2-0-262a2bf3c3d0@linutronix.de> In-Reply-To: <20250110-virtual_address_range-tests-v2-0-262a2bf3c3d0@linutronix.de> To: Andrew Morton , Shuah Khan , Dev Jain , Thomas Gleixner , David Hildenbrand Cc: linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1736514373; l=1736; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=6Y4AYnLMO6bZ4JZYH4ZHiDJ17RsT8q+tecRlw111Dgw=; b=x/1Tr/J0h4P+MXP4+Hne/MFcUXBC2su4aDXFajOeQYUQnctX6GGFfB8m0I5tB3Rhc4XdY+xHO VpnjsHoiQtVDIsaAjowbqM8fe55VK5GfURLdBwupuLvfHlnMEtMxNGB X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 28B31A000F X-Rspam-User: X-Stat-Signature: wixutbu1m7qgu4we5ppm5xqxzxtd5jta X-HE-Tag: 1736514376-124931 X-HE-Meta: U2FsdGVkX1/Q8ID8WOTQEGtZ18A10IGfCs0Sodjy7xxK5bBSV25IckUmbzzS1ti/C16hXR3MaZoK1gDHFLekFfoNGmjO0G+ZgbDyZOhlG1Yz6CwuZo6zV6HQ+B77SlFowBrdo81nwSrpyooSw6CDo/L0pA0yqBaE2+/78Oq50QvnnSoMTemTIVwVlsNErc8UcA1/g/fdI5fu3DACmpYecAKyJcHbcPysFAkY9Q/gUnwHPagpQK2G3/vzmG737afTDSgTeT8NAj0OF4IVa1ZFYlOVpgXCN+CW9LwPBq2fd89irKJg5rGqM3zyQs8NeqbM6ShdQpPBW0yD3sGbWsKAabxz89ouJkB1KF1KkGLFebJ1ecnCNaOUonqGXebPQ+nwg+Ro9n8XxLpHsQd1ynPi+TkGBdjFk7874XMvAkwqXMLZLLPFfcmksl9mj/idByd7Fdbxy7U5xZkYzV7A3LHcL3LsEBlg1ITJohDMcdAtALM4kZzpyfdriMft/sf/FwCzHXb3g5//28BPIbjld+NdvWqKTgnKuwBrjqYdC/xBpGxMsgTNAy+5l3rVza2DOEVtIwSFqETONXP7CumxnY4DR7gunJD94FQeIErEOloae3iqKnGS4lC4NoAF+XE0Gd/oq7z4mt6YXwSSjdAD7m45XhvAfJHg1E+0lRQyqjlj3FCS8DDma9UC0vgzk+xy2vzYUkqh1Hl+7LgBJ7OH/kz8UkjFZO79Q3QQNhHsfXhffzeCutH+jkXd7rzG00qiwf0w856MgT6JZnqTu7VNqNLfI1YHgk02mWVxmq4WkiuB56b+jbv8/66TAMk0djoSqFDhlLQqGeNGOXZ06ZAcYAJmkfkeSd8UDbL/61W7KbkF92HtQZh1rxxcXJQVoLdXfd0iAtOaGy2BulUd4rhbIO3etHXGbL8tLQI5WrC9TWeQTZgZgGBXiEbbve8ToCRiarHe1UIoAH3X8SQ4LrjCRNI UtbZBPn/ 4Z7AM5h6gA0XNwUCrXKaX5cySfwi/pP+DGJrHqxCn176HneIMZ0Jmt6lMd651nw40mZZrq1zGQYETuJhjb/YSI6wNsZkUmTbK7O/R1msZwvWbnCjLvpzgRAJHTYbVOozt04+ma+W+xebG+9hPe6xwIpvrdFdNN3HpHGaj+ZIC6MKhbW1LVv9t1m+1bpAksu2mRi9EajVbgE0I2jn+NBLj2ORHRYLu2ZP6MI/yNEzrFGXUbbGhkXvrKTfJGpk75A8k0kkiW4OhKtjhZfCkJghGLJkw0Jt9xqAOEdZrrnZ4pfMs1/rvSbL/Hf7+cq7RoxLoaWLt0MLnQsGdPHKNyuV+sJO8HX6LZ/Cl0V0I9DZi3dw5HT2RSm3EM9YRBb1/fSLfSyJdGHu5wN16XgjQ+7RuLx1g7YLyrgTNGdZM1OFvB0OiQ5SoIuu4/8KYhyTuMaZF6cPa 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: List-Subscribe: List-Unsubscribe: When mapping a larger chunk than physical memory is available with PROT_WRITE and overcommit is disabled, the mapping will fail. This will prevent the test from running on systems with less then ~1GiB of memory and triggering an inscrutinable test failure. As the mappings are never written to anyways, the flag can be removed. Fixes: 010409649885 ("selftests/mm: confirm VA exhaustion without reliance on correctness of mmap()") Signed-off-by: Thomas Weißschuh Acked-by: David Hildenbrand Acked-by: Dev Jain --- I went with dropping PROT_WRITE instead of adding MAP_NORESERVE as this works even in the face of OVERCOMMIT_NEVER. --- tools/testing/selftests/mm/virtual_address_range.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/mm/virtual_address_range.c b/tools/testing/selftests/mm/virtual_address_range.c index 2a2b69e91950a37999f606847c9c8328d79890c2..ea6ccf49ef4c552f26317c2a40b09bca1a677f8f 100644 --- a/tools/testing/selftests/mm/virtual_address_range.c +++ b/tools/testing/selftests/mm/virtual_address_range.c @@ -166,7 +166,7 @@ int main(int argc, char *argv[]) ksft_set_plan(1); for (i = 0; i < NR_CHUNKS_LOW; i++) { - ptr[i] = mmap(NULL, MAP_CHUNK_SIZE, PROT_READ | PROT_WRITE, + ptr[i] = mmap(NULL, MAP_CHUNK_SIZE, PROT_READ, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (ptr[i] == MAP_FAILED) { @@ -186,7 +186,7 @@ int main(int argc, char *argv[]) for (i = 0; i < NR_CHUNKS_HIGH; i++) { hint = hint_addr(); - hptr[i] = mmap(hint, MAP_CHUNK_SIZE, PROT_READ | PROT_WRITE, + hptr[i] = mmap(hint, MAP_CHUNK_SIZE, PROT_READ, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (hptr[i] == MAP_FAILED)