From patchwork Tue Jan 7 15:14:45 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: 13929148 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 87897E77199 for ; Tue, 7 Jan 2025 15:15:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D2CBC6B00AA; Tue, 7 Jan 2025 10:14:59 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CC3DB6B00B3; Tue, 7 Jan 2025 10:14:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A1B466B00AE; Tue, 7 Jan 2025 10:14:59 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 6BDB86B00A8 for ; Tue, 7 Jan 2025 10:14:59 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id BEE691A0A2A for ; Tue, 7 Jan 2025 15:14:58 +0000 (UTC) X-FDA: 82981003476.25.0E5BE5C Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by imf16.hostedemail.com (Postfix) with ESMTP id D660B180002 for ; Tue, 7 Jan 2025 15:14:56 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=xEDYdNyQ; dkim=pass header.d=linutronix.de header.s=2020e header.b=gvC+B3rW; spf=pass (imf16.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=1736262897; a=rsa-sha256; cv=none; b=8bfbtQV1EsMA3VW3KtBssUPQMGo8axzDNRbwuhqDbXiNZDZIs7HKMtmktC3P4ZtWmP80fw 5fbyNvZnx+tyHO017MT6kwr8nQ27u9Dzd+5aGULkurs/zTJmV0e/XwcgLei0m0QjKPw/US +ee000aUWwmVuPEYGSDof4hPrc7lH30= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=xEDYdNyQ; dkim=pass header.d=linutronix.de header.s=2020e header.b=gvC+B3rW; spf=pass (imf16.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=1736262897; 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=8MKnoaEM2eqbdSEIwek8NUSxcpZg/joWFCsMXcOwV8g=; b=2sHc57b6APEEzHJ8McHv9VcNHrfqiNsSVR0sw+Lrh/QoxQ+/aLBKGWTOHSQYe0WHBmBINX DA2z3kJX9ilvb822VjPAedQWl3i4rYk1v65q2PKK4DIgnqIvhrjD/GrS617ntvw5eSWXzQ xwLEGdYkQNFv4s2A1Z8DR87bobuWEGs= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1736262894; 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=8MKnoaEM2eqbdSEIwek8NUSxcpZg/joWFCsMXcOwV8g=; b=xEDYdNyQFc4yS3PKefVEYJImsRrGchl4NLvK5u9X9qhOqvFW0G8VLPI78Rjead8YUOib7I Cp8hXOE3hKfi3pGrlSwNvoMarO0cVNB/hlBoNDcidAlhPn8zfBVPZMEumYRVKnJG6v7r69 /sbhJ9/tTdWWjHy1D9E9Z67acXtbk0Vkpa6xtZwN35JQF/OTHRjXiLsszzHJrESKwQFzPA q+diYTEMhS26YnqaIgw+K0ZgP+4dbsJ68AuO0J5YuIfuwT7Qw6M6ifzRdko4FroLMVxl0n vGVrRQt5L8ZAA1neAL/nD3gHTMdNEWDFagGE5zt1sgYCSdOluSJtGwYEODQd4g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1736262894; 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=8MKnoaEM2eqbdSEIwek8NUSxcpZg/joWFCsMXcOwV8g=; b=gvC+B3rWXyc/qxMwaqaSZObNNe1xvWwv3/CKHVVFYl2ybnP1xfbZCjm2f7hlL4ynU0ItoI bCMQv5vsaVEyHVBw== Date: Tue, 07 Jan 2025 16:14:45 +0100 Subject: [PATCH 1/3] selftests/mm: virtual_address_range: Fix error when CommitLimit < 1GiB MIME-Version: 1.0 Message-Id: <20250107-virtual_address_range-tests-v1-1-3834a2fb47fe@linutronix.de> References: <20250107-virtual_address_range-tests-v1-0-3834a2fb47fe@linutronix.de> In-Reply-To: <20250107-virtual_address_range-tests-v1-0-3834a2fb47fe@linutronix.de> To: Andrew Morton , Shuah Khan , Dev Jain , Thomas Gleixner Cc: linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , stable@vger.kernel.org X-Developer-Signature: v=1; a=ed25519-sha256; t=1736262892; l=1691; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=pkeSpzoPWHY8BsliSFSfbcQRoHvGqOoQKWjNi/5v8ic=; b=Q7U4tGUxDzcEKeBChx8jtgkcq7Wge8kBvCoqMUZT2oi/Qti7jPY0onQ2kqHsunfb2jqdfU1hz sAu/mvAzojZDkvqBTlCrLkZo2WWSwciE2YoG/u+CTP/BwDRiXqX58/F X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= X-Rspamd-Queue-Id: D660B180002 X-Stat-Signature: fwuj7ga6mmgf3w98ic4hx5ha54k31yni X-Rspam-User: X-Rspamd-Server: rspam09 X-HE-Tag: 1736262896-564669 X-HE-Meta: U2FsdGVkX1+l0lND5Hv72/ZQfHJZqwSquIhILHvCOkI6gBW6IX2jozlYZH6BEO+OWRDs1ab6780J5OpfCneRQej2u3EN6MrzqErvAkve2snF2cyq67Sf+/xrRFItOixx9IZtK9+2BHFcRC1Hz0kNQr8xaXWXiBXBdaRCmny9nYzu8a1aK5Rw3EGNGi4z02NtdRB/pQfs/a0WmvJGhtxEkOECwyqs3wsO1gevPeUtNswJ47cQfTOEAMifMgTrvSHRvithy9ioquJQENiSHyqv/Ce7JL7jtb0aXxo32bp0CSOxMnIVE4dNV4VdQ/0DjiZpjAPo0ZvLlnBCB/p3cHzsQ9R7wOewel07vRiptA+klLvjcj63ap4jOwvZ2eutVqAbuJCQ0mBnGMSoH8GXd3UlrcCTpvMB/TizF68iOse86scd3ZkmClEBjTOMPhw175ll8x2yPWw2e9ZaZJVu4AKtHp7FRS61wIN72dYaXi5A+aO10NZsyeN0AxyDv5JP7yzkTx3j1bEPCzfD9z/DLlZwhejGScphQGDLPkif70HV1CUF3O9p0zkdiKRQCeaCEE3/3SHzeS9fV8ZWT/WOQ7tDTOvXp1hbOttYcBGp+XOELT2MQFSyW8ZX6BABPkhH9EJRscRXYPF/b4qwK/167/2uILx+bfu05VQahIQTOC/pV470FPCJUGLOTgjIeisAvu5431n4jakYCjKF3kIiOKFP93+AyM7mQjcVDKUl50cqWTrTf55iiBpOm0u9sJjn8T2Tr0rpHnFIdw95/QKc9rKEi0tpcqiss3ugCr1QMkfcjiR91/nZcOldHkEyhzWJkB0LUvfTzu9H5Nenx1RRCOhvvNlbEUHwc7nMyUTJCvIGBGRabX3FASf6q77/84OXg4cfH1zQK/Xizvhi4xFVvc0aK5/Z+KofbCRG9pof8RE6ikgv1hkQDS9YnPLAZzSKM6RFj0ZRuqLmb/WMCH25pbR TQZ/svNy 4hhBbzUm05XGtYCC6jS9JlhrVtMB2+DEQanHzXzIE31BjX5zVeRhOnu0C5dHRpr0qE5ife7BFS+OUdeqxOTexUbkitEkBa4p8c8kQo+lGDO3xcsfoy/v2+ml2my9PQ2ZHvAs/wBEeFT1C8zhP+hUmNhe6HYbOY/N/A6ngN6ufnYe+sJnU1iG/WLbnHoM+wCX1bjL3AcRV/oBTAq7oHZ2N9rzau+95jWyqImdikd45bNK91VGEtoA5eUSc6TyUgufuHjYNAOCZqfXoIyX45dX2erwMqCSN9SaIOUWx5UIXCPQ8zXnWreDR02fI5OHfF+f6zZojoiXNhve9TnoBQa8yeUu/qbfrq4mYDWoWuNX68GKKjzovmWeIStNhHWuUgvCiNxJGcPXcCHLt42ZhQAR+88flp4M49kXJ7cy3J3p8LbZWCiZz78bMn/H9CY7IfsNTZa00W+Yc+W5h7D4WYKAsvdO186k+pm4O5U9S 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: If not enough physical memory is available the kernel may fail mmap(); see __vm_enough_memory() and vm_commit_limit(). In that case the logic in validate_complete_va_space() does not make sense and will even incorrectly fail. Instead skip the test if no mmap() succeeded. Fixes: 010409649885 ("selftests/mm: confirm VA exhaustion without reliance on correctness of mmap()") Cc: stable@vger.kernel.org Signed-off-by: Thomas Weißschuh --- The logic in __vm_enough_memory() seems weird. It describes itself as "Check that a process has enough memory to allocate a new virtual mapping", however it never checks the current memory usage of the process. So it only disallows large mappings. But many small mappings taking the same amount of memory are allowed; and then even automatically merged into one big mapping. --- tools/testing/selftests/mm/virtual_address_range.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/testing/selftests/mm/virtual_address_range.c b/tools/testing/selftests/mm/virtual_address_range.c index 2a2b69e91950a37999f606847c9c8328d79890c2..d7bf8094d8bcd4bc96e2db4dc3fcb41968def859 100644 --- a/tools/testing/selftests/mm/virtual_address_range.c +++ b/tools/testing/selftests/mm/virtual_address_range.c @@ -178,6 +178,12 @@ int main(int argc, char *argv[]) validate_addr(ptr[i], 0); } lchunks = i; + + if (!lchunks) { + ksft_test_result_skip("Not enough memory for a single chunk\n"); + ksft_finished(); + } + hptr = (char **) calloc(NR_CHUNKS_HIGH, sizeof(char *)); if (hptr == NULL) { ksft_test_result_skip("Memory constraint not fulfilled\n"); From patchwork Tue Jan 7 15:14:46 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: 13929151 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 99C80E77197 for ; Tue, 7 Jan 2025 15:15:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 037386B00AD; Tue, 7 Jan 2025 10:15:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id ED7186B00B3; Tue, 7 Jan 2025 10:15:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D83EB6B00B4; Tue, 7 Jan 2025 10:15:04 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id B8BA46B00AD for ; Tue, 7 Jan 2025 10:15:04 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 7693A80A63 for ; Tue, 7 Jan 2025 15:14:59 +0000 (UTC) X-FDA: 82981003518.12.09D2AA6 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by imf02.hostedemail.com (Postfix) with ESMTP id 828AF80019 for ; Tue, 7 Jan 2025 15:14:57 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=a9oDTS+H; dkim=pass header.d=linutronix.de header.s=2020e header.b=MlKdOtsV; spf=pass (imf02.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=1736262897; 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=xr/B0xvK7sGkfKbzNUSoXapb4RwCqM0VBcWsRspXohE=; b=UvmtMA+0Wcn7FzKd6F060UWL/UOMsmRNqrMFbsrxtXG1Cuck+tgeRGJBJYIIP0bM9tz7BF 1SlowN/wWkB9bBP25B5wACDnh1NJCwQmmjYo8aetciss+7qhc8DSzxqesvDWzqcs4pDU1x HP29iOLzs1qenqIFRrE8b31tOM3sQsI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736262897; a=rsa-sha256; cv=none; b=pIeJKumlTr+RIWaStnPBRoeb4yEYowwdMeYNTRLTrs0XnARWihqzsba4buzgfRw2a1O0br ATaRfycouDzKRQe//o3Yo2ueMJ7N+UoZCupKJ615v5ZDj6V9YPIJCjtDeP0zpLxf6NJZhf K6ArwIajT6sHeNAwRzCaBElPKEh7VJc= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=a9oDTS+H; dkim=pass header.d=linutronix.de header.s=2020e header.b=MlKdOtsV; spf=pass (imf02.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 From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1736262895; 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=xr/B0xvK7sGkfKbzNUSoXapb4RwCqM0VBcWsRspXohE=; b=a9oDTS+H17gco4eQ8kGhsCqsv9PlMnDDDlrs5LYGf2TxvF6Hc5SBP64YFNV0nppAvZUusn M/G7DF0KH/LcmAEI1xWxZL+QNzgVlBsgjstoBDXG+O5kcLjbzcxJ73XRFUfad5bU/BSlXo A7Y1TLhJxAJJJUB1Cu+ZmF8o4HPSLIsSPIGcqtN8vDA3eYzeCZSbOkqrbjlbcq4O2qsS/n 7bsoJ93HjH1DQiw0HcpeuRycJzpZhiOC/HLEyk8byYgd9q0UkBKXyK2nM17peGau2Mh0ah 0BAgqvWbeo6MZ37fDRAIoWa1XTY/LDxATu4Oigy2pzOK7TSbTD+y5AJX8XyKGw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1736262895; 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=xr/B0xvK7sGkfKbzNUSoXapb4RwCqM0VBcWsRspXohE=; b=MlKdOtsVGTXjDdT5TITCXHSRGRiOVe9EHCVyyPc/IRYFURbCmmQ3GfZsh8mk9woFCpH0+G JprG5Ns6Ac7MHGDQ== Date: Tue, 07 Jan 2025 16:14:46 +0100 Subject: [PATCH 2/3] selftests/mm: virtual_address_range: Avoid reading VVAR mappings MIME-Version: 1.0 Message-Id: <20250107-virtual_address_range-tests-v1-2-3834a2fb47fe@linutronix.de> References: <20250107-virtual_address_range-tests-v1-0-3834a2fb47fe@linutronix.de> In-Reply-To: <20250107-virtual_address_range-tests-v1-0-3834a2fb47fe@linutronix.de> To: Andrew Morton , Shuah Khan , Dev Jain , Thomas Gleixner Cc: linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , stable@vger.kernel.org, kernel test robot X-Developer-Signature: v=1; a=ed25519-sha256; t=1736262892; l=2470; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=JV1EmwhzZN8rbAZfsKr/X1cMrrhDBFJbY8LiCwcvoc8=; b=UWmnjc1iTVSO0yiJVv6/4RPN2Sb/xWnNUD78AugJktpFzXZZymMS0+1ZQxMl27beVnu+e+YDZ 8Nc8ASPkmPSCTTatBfxeZhgcl4WR/ohvWgXLmHZ4bc0wTeHWOo89/b8 X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= X-Rspamd-Queue-Id: 828AF80019 X-Rspam-User: X-Rspamd-Server: rspam07 X-Stat-Signature: hj5tjk6xc9djyr3owb9ezky8zor4nkc6 X-HE-Tag: 1736262897-496456 X-HE-Meta: U2FsdGVkX18DURYob5KV7wIq2SfDBGqBwXmjOzDq+69mk3U+bkas7k6bvBPxnmCR05ZvcDSIAfhplkKp1cedHqRI8yF/sba5KtVCXj2TebbQv1o4TeJ1x9jBYpxmFutH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oQNEt/SCbmKjWDr3vqqF1u9WPmKXpi+TqhrYbO3D2Mus2nUEHQR+8JK0WdkQ6RZxdY6Za93F2LM5i4LD3evZG5SJhSZKwQnQ4WjkNoykPk5frvKGb36JLrFjznlN2tOIPAsC6I+fHCEJ3Mrtma3iOxBpsaiSpY9QcYytyHguAl/kE6u3OZpFajUyRq3x/qikwvGCGN1KxdIOU4zWR19Q9M6+fTmFbXSdglxbEYfJrxr+PEf1Lbzi2uTzleeimP2qDKhaGiwWSpwTQx4m8lPxUvJw4fDQfJ79N9KK6MYBQ== 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: The virtual_address_range selftest reads from the start of each mapping listed in /proc/self/maps. However not all mappings are valid to be arbitrarily accessed. For example the vvar data used for virtual clocks on x86 can only be accessed if 1) the kernel configuration enables virtual clocks and 2) the hypervisor provided the data for it, which can only determined by the VDSO code itself. Since commit e93d2521b27f ("x86/vdso: Split virtual clock pages into dedicated mapping") the virtual clock data was split out into its own mapping, triggering faulting accesses by virtual_address_range. Skip the various vvar mappings in virtual_address_range to avoid errors. Fixes: e93d2521b27f ("x86/vdso: Split virtual clock pages into dedicated mapping") Fixes: 010409649885 ("selftests/mm: confirm VA exhaustion without reliance on correctness of mmap()") Cc: stable@vger.kernel.org Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-lkp/202412271148.2656e485-lkp@intel.com Signed-off-by: Thomas Weißschuh --- tools/testing/selftests/mm/virtual_address_range.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/mm/virtual_address_range.c b/tools/testing/selftests/mm/virtual_address_range.c index d7bf8094d8bcd4bc96e2db4dc3fcb41968def859..484f82c7b7c871f82a7d9ec6d6c649f2ab1eb0cd 100644 --- a/tools/testing/selftests/mm/virtual_address_range.c +++ b/tools/testing/selftests/mm/virtual_address_range.c @@ -116,10 +116,11 @@ static int validate_complete_va_space(void) prev_end_addr = 0; while (fgets(line, sizeof(line), file)) { + int path_offset = 0; unsigned long hop; - if (sscanf(line, "%lx-%lx %s[rwxp-]", - &start_addr, &end_addr, prot) != 3) + if (sscanf(line, "%lx-%lx %4s %*s %*s %*s %n", + &start_addr, &end_addr, prot, &path_offset) != 3) ksft_exit_fail_msg("cannot parse /proc/self/maps\n"); /* end of userspace mappings; ignore vsyscall mapping */ @@ -135,6 +136,10 @@ static int validate_complete_va_space(void) if (prot[0] != 'r') continue; + /* Only the VDSO can know if a VVAR mapping is really readable */ + if (path_offset && !strncmp(line + path_offset, "[vvar", 5)) + continue; + /* * Confirm whether MAP_CHUNK_SIZE chunk can be found or not. * If write succeeds, no need to check MAP_CHUNK_SIZE - 1 From patchwork Tue Jan 7 15:14:47 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: 13929150 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 ED444E7719B for ; Tue, 7 Jan 2025 15:15:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 01A106B00AE; Tue, 7 Jan 2025 10:15:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EFED86B00B0; Tue, 7 Jan 2025 10:15:00 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D77BA6B00B3; Tue, 7 Jan 2025 10:15:00 -0500 (EST) 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 B0BAC6B00AE for ; Tue, 7 Jan 2025 10:15:00 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 6C485AF665 for ; Tue, 7 Jan 2025 15:15:00 +0000 (UTC) X-FDA: 82981003560.09.87C18C0 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by imf27.hostedemail.com (Postfix) with ESMTP id 883FC40007 for ; Tue, 7 Jan 2025 15:14:58 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=UiQRK0pO; dkim=pass header.d=linutronix.de header.s=2020e header.b="Kfi/QA9H"; spf=pass (imf27.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=1736262898; 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=tydfE0F+64UOWjWNZaYZ/G6V8qY6qkkoQjYUo5kzM8U=; b=rzQvf3f7A4CYlVe66rP/as/FO5YPF9AaD/5f8WtKwMnbNLDuDuE56yskdDxjxyxg+hpO8n 3+BOzQT4Wwp9b6UslywtI7VRDhSmeF73Y7sGOrMmzggb1sCYtQkNcd0xkOn0wPrR7zdFzg IaBbtOKKlAaPOmxSihSlSyKPhe/z5CI= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=UiQRK0pO; dkim=pass header.d=linutronix.de header.s=2020e header.b="Kfi/QA9H"; spf=pass (imf27.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=1736262898; a=rsa-sha256; cv=none; b=uE+po0KQRymMMs0KXXsgPE1Lld7ek/oOURR/JaL6NMfuzIIDHWzinblybE8bHiG5dBqt4w 5va38DTWQFTPFFH7sUN3K11G5JEuf8+PbjREcPxz15+HtC4ALvZFII7ovi7IFuwkl0g2m/ WrZDLq3p5tYsziUVP31d7sC9BSCYFyQ= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1736262896; 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=tydfE0F+64UOWjWNZaYZ/G6V8qY6qkkoQjYUo5kzM8U=; b=UiQRK0pOMnBJssXVy82Zjf1x4fX0s6WRl+VbZBBCpTDHc/y/KzVxCjU8wCZTMEqfWR3CTC GkwWkidrZdh7otQx6AY4tbdd6bGm1RZhEbTUM455gxI/uYzwItJNYnFGMpl+iAyeNm4x0N Wf+kMoOtKaMN9PFgMyPViFjRTqO3unAmJZx0hlO5vAJX2AAdzO1Egbwa2I1uVQpWuHt+VE Oc23zoruxrccDh8+ZMtLsUonylVw+yjkbOejLe3JSC+J9ZdlMXcpEDIWPcSGsbovpafcU/ xE1656kYniX8lstBNsSSBpui7QJdkqSgGHt5rDDBa8w9mVSaES7WlLw/n8FHeA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1736262896; 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=tydfE0F+64UOWjWNZaYZ/G6V8qY6qkkoQjYUo5kzM8U=; b=Kfi/QA9HsvdZ4syxi4iEtnoRj7YoGxTHEfXpJeTF/g6P+zPt8wSKZ8n1LlDIE+CmZardgk JjIVXg8097Oa12Ag== Date: Tue, 07 Jan 2025 16:14:47 +0100 Subject: [PATCH 3/3] selftests/mm: virtual_address_range: Dump to /dev/null MIME-Version: 1.0 Message-Id: <20250107-virtual_address_range-tests-v1-3-3834a2fb47fe@linutronix.de> References: <20250107-virtual_address_range-tests-v1-0-3834a2fb47fe@linutronix.de> In-Reply-To: <20250107-virtual_address_range-tests-v1-0-3834a2fb47fe@linutronix.de> To: Andrew Morton , Shuah Khan , Dev Jain , Thomas Gleixner 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=1736262892; l=2277; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=MeslUuRpp6snP8kaY60rYzKdJKBjCd/nlz8O3AupkXI=; b=NgTUKSqcuckegdTFYfiFIOnS20yzvT8cJRDvGk4KpA/YgWzMR5+yLFIoBtpKsziXFS/XXkBns TiPuiJvnbd+C2YlaXpIPif/pnn6JvFsSRrw925v6Gp3yFUsERRJgQl7 X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= X-Rspamd-Queue-Id: 883FC40007 X-Rspamd-Server: rspam12 X-Stat-Signature: x6q1b4fid7n4oind9quj74sfr5w9mj9s X-Rspam-User: X-HE-Tag: 1736262898-262320 X-HE-Meta: U2FsdGVkX18sfCrfUu5gZOLvzjIgzsCnnV2unCPryGcX7tFdJfr4Ojioa2E4ru/6eQrnFvV+Y85ez6Ovw/OLAbtLQnPfOgwuG+5rMQKM915Pt2vWVT9Nay2sBBmUwAlDtKtA+sNmSFUkHtIn23ey+aYwEAS1EUW0XyOQvmazcnMXTnnpji0P3BQ9trw5tArwZ9jVx+9qlimB5icoh2+oMMKx7vrAw2NMty7cgmWE6dz/zaJbAoFCmtDOm5/4qX/Px2bur8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Cb8+9bJgo7Od5QIMZZ/Sz/T2dZvMktXJjYw2O7SoXhPq6mrwH4NqvvgTV+9rdx4ap137fmLb/zqtR30ZO0HtLXv7d/05EvtzdHI9p 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: During the execution of validate_complete_va_space() a lot of memory is on the VM subsystem. When running on a low memory subsystem an OOM may be triggered, when writing to the dump file as the filesystem may also require memory. On my test system with 1100MiB physical memory: Tasks state (memory values in pages): [ pid ] uid tgid total_vm rss rss_anon rss_file rss_shmem pgtables_bytes swapents oom_score_adj name [ 57] 0 57 34359215953 695 256 0 439 1064390656 0 0 virtual_address Out of memory: Killed process 57 (virtual_address) total-vm:137436863812kB, anon-rss:1024kB, file-rss:0kB, shmem-rss:1756kB, UID:0 pgtables:1039444kB oom_score_adj:0 fault_in_iov_iter_readable+0x4a/0xd0 generic_perform_write+0x9c/0x280 shmem_file_write_iter+0x86/0x90 vfs_write+0x29c/0x480 ksys_write+0x6c/0xe0 do_syscall_64+0x9e/0x1a0 entry_SYSCALL_64_after_hwframe+0x77/0x7f Write the dumped data into /dev/null instead which does not require additional memory during write(), making the code simpler as a side-effect. Signed-off-by: Thomas Weißschuh --- tools/testing/selftests/mm/virtual_address_range.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/mm/virtual_address_range.c b/tools/testing/selftests/mm/virtual_address_range.c index 484f82c7b7c871f82a7d9ec6d6c649f2ab1eb0cd..4042fd878acd702d23da2c3293292de33bd48143 100644 --- a/tools/testing/selftests/mm/virtual_address_range.c +++ b/tools/testing/selftests/mm/virtual_address_range.c @@ -103,10 +103,9 @@ static int validate_complete_va_space(void) FILE *file; int fd; - fd = open("va_dump", O_CREAT | O_WRONLY, 0600); - unlink("va_dump"); + fd = open("/dev/null", O_WRONLY); if (fd < 0) { - ksft_test_result_skip("cannot create or open dump file\n"); + ksft_test_result_skip("cannot create or open /dev/null\n"); ksft_finished(); } @@ -152,7 +151,6 @@ static int validate_complete_va_space(void) while (start_addr + hop < end_addr) { if (write(fd, (void *)(start_addr + hop), 1) != 1) return 1; - lseek(fd, 0, SEEK_SET); hop += MAP_CHUNK_SIZE; }