From patchwork Thu Mar 14 12:22:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dev Jain X-Patchwork-Id: 13592393 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 CC08FC54E67 for ; Thu, 14 Mar 2024 12:23:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2F1428009C; Thu, 14 Mar 2024 08:23:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 29FF580073; Thu, 14 Mar 2024 08:23:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 168708009C; Thu, 14 Mar 2024 08:23:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 04D7980073 for ; Thu, 14 Mar 2024 08:23:42 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 9C3E7120A45 for ; Thu, 14 Mar 2024 12:23:41 +0000 (UTC) X-FDA: 81895560642.12.D9B2AC4 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf10.hostedemail.com (Postfix) with ESMTP id D6A59C000C for ; Thu, 14 Mar 2024 12:23:39 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf10.hostedemail.com: domain of dev.jain@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=dev.jain@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1710419020; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=t9aH/D+HbTaaqeIXv0OnSSPSI+G66wksEk+Ix23UBFw=; b=bu7ZlaAkA/ES6JjnYFb0rS+WwWpNz/37kiB6n5vFdUg04f8aNDVSTiJWhLpLZDHUmz5TZx +nGVruB7w/G111FFidKQzir6Se6iE9Qfx8ki7YlFsURe0x+yOfQ9Z6DF6XZ7L5QslbHIUG mHea/Z3iumQjtnVO5lhubxcsiSDnUZY= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf10.hostedemail.com: domain of dev.jain@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=dev.jain@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1710419020; a=rsa-sha256; cv=none; b=rTdogqUZpv77CUZsTS3PI6t1gfjIvgKG8KjsZ0CRFU0TX/3vn9pVRS2EXfZoAvL69XTS6a /E/q0FngNmYW9R/tJvfBFzwxj8iaFBzm5N5Ax+1YHtAC8f8zND83m8BGmoGHNUfh/K6XbN 1PTshiNYIX22hIDpPUbtklkWX19mmLA= Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E187F1007; Thu, 14 Mar 2024 05:24:14 -0700 (PDT) Received: from e116581.blr.arm.com (e116581.arm.com [10.162.40.27]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id E4F533F73F; Thu, 14 Mar 2024 05:23:35 -0700 (PDT) From: Dev Jain To: usama.anjum@collabora.com, akpm@linux-foundation.org, shuah@kernel.org Cc: dev.jain@arm.com, kernel@collabora.com, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Anshuman.Khandual@arm.com Subject: [PATCH] selftests/mm: virtual_address_range: Switch to ksft_exit_fail_msg Date: Thu, 14 Mar 2024 17:52:50 +0530 Message-Id: <20240314122250.68534-1-dev.jain@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <07e2e91b-7b0d-4810-a2a1-ed4654ecafb4@collabora.com> References: <07e2e91b-7b0d-4810-a2a1-ed4654ecafb4@collabora.com> MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: D6A59C000C X-Stat-Signature: 7z8a6s81kzuu5org5k7rf9dxst7p56rg X-Rspam-User: X-HE-Tag: 1710419019-529820 X-HE-Meta: U2FsdGVkX1/2rzXvZuVaSnBvunN7A5Pu78JDFkb43vDWuYJKMo50kQ6OvJb+miD8sZZT6QwoGQzoM+oncjtSGpU4PfQIgPt51A9SHYp+Bwf3Ng60EH3PGoQp2s0rybIpmQNqNbirOwMj3rhcc72Ws29L6tVpze/pYH4B8vU/O4hIjyLcExoofbPacJ5/QnN4f1LeeX9dNgVJFDIIaonAhNrgEmAXvhSk77GwuYPPMbEYc2tW9wOad3zpyKRkRquUpwX0Bg//KyHlUVoozc5S/MIb4QcQuFD+mfOE6nnudjva4G4III0Y1PQrce4iHndlE0UxdNnJLuw3qGtDOGX9kU8INRqhnlYrcAWjLS6pHMVtO1qAyu0NhzM7N7v1BGOOgCVC/yDROD80kFugfWl5mXluPPu0asy/+PE3EpnHcF3lcubB8CGG5Hy8kcJ2+5cJvsbzCjk5jTKU514Oxa6FJHIdRUxxMfB4pyysoWHraj8Qyvvlj1ecUTCzaqMkuVGCmPUinZtR/HC4ljCCqp1s7ArbQ+uOJ/Q6mw5RRMAoiyaweGROJXzCUXEziqmioKhXSob7HgoA4jToJTXhdXWksDIjbCka0x7KtYLYEUXwV6Fmc3eoWcBA5wL0aUZaUrFlaQO7i+3ZzQDbOcLik0Q5E3h8vV8ZJKLt5sCAaOI1uDxYXyT/HWulGcc77bSU3v6HiiMyP/3H8uHuBs0lptTpQ7VCTO7sKosj177yLNiqkQNksC4hnGZeWxHUoxwEFWKL6+Su6fYWoWR/Retu0g7CwrdWHmqx2PYaXGtJPwQR6rYCn6nBsdEohzo4X4zwIdAJQzxkhgOcTrZbmL1xgKs0Y1SuXAGzUU1r+GzjZR8nOtf7vHLirPa+rxBO/dh8tB91sC88/5IElwQ= 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: mmap() must not succeed in validate_lower_address_hint(), for if it does, it is a bug in mmap() itself. Reflect this behaviour with ksft_exit_fail_msg(). While at it, do some formatting changes. Signed-off-by: Dev Jain Reviewed-by: Muhammad Usama Anjum --- tools/testing/selftests/mm/virtual_address_range.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/tools/testing/selftests/mm/virtual_address_range.c b/tools/testing/selftests/mm/virtual_address_range.c index 7bcf8d48256a..426ddfc345fb 100644 --- a/tools/testing/selftests/mm/virtual_address_range.c +++ b/tools/testing/selftests/mm/virtual_address_range.c @@ -85,7 +85,7 @@ static int validate_lower_address_hint(void) char *ptr; ptr = mmap((void *) (1UL << 45), MAP_CHUNK_SIZE, PROT_READ | - PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (ptr == MAP_FAILED) return 0; @@ -105,13 +105,11 @@ int main(int argc, char *argv[]) for (i = 0; i < NR_CHUNKS_LOW; i++) { ptr[i] = mmap(NULL, MAP_CHUNK_SIZE, PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (ptr[i] == MAP_FAILED) { - if (validate_lower_address_hint()) { - ksft_test_result_skip("Memory constraint not fulfilled\n"); - ksft_finished(); - } + if (validate_lower_address_hint()) + ksft_exit_fail_msg("mmap unexpectedly succeeded with hint\n"); break; } @@ -127,7 +125,7 @@ int main(int argc, char *argv[]) for (i = 0; i < NR_CHUNKS_HIGH; i++) { hint = hind_addr(); hptr[i] = mmap(hint, MAP_CHUNK_SIZE, PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (hptr[i] == MAP_FAILED) break;