From patchwork Thu May 9 09:54:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dev Jain X-Patchwork-Id: 13659610 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 7D5E2C10F1A for ; Thu, 9 May 2024 09:56:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 10BD26B007B; Thu, 9 May 2024 05:56:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 094796B0088; Thu, 9 May 2024 05:56:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E9E656B008C; Thu, 9 May 2024 05:56:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id CCBDC6B007B for ; Thu, 9 May 2024 05:56:29 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 4F43C1C0FA9 for ; Thu, 9 May 2024 09:56:29 +0000 (UTC) X-FDA: 82098402498.04.6AC7EA1 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf03.hostedemail.com (Postfix) with ESMTP id 60A6220007 for ; Thu, 9 May 2024 09:56:27 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=none; spf=pass (imf03.hostedemail.com: domain of dev.jain@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=dev.jain@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1715248587; a=rsa-sha256; cv=none; b=Y0Ac6QJQC27stGXM/VJTKXwrBUr1vezQGCRD7A6zJ51U+tsFDdixr5g9mafl1UiADlwoqA z6s7Iyi2v420Bt5KZVCDT0A2WK399SGKCifHVN5j1RFRK+I19And/LPkXCUibOnM+qR+SB Id7dnrsIkHismrw+sCpBXxCil3j3FTg= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=none; spf=pass (imf03.hostedemail.com: domain of dev.jain@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=dev.jain@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1715248587; 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:references; bh=2TO77vakJYsYteROjg3UnkKRKkYPmCCl1d+TvpXCRQc=; b=wEuhxoRSOl9U2T27tuErtW/Erhp/Z3DFt8VM5JjOsf4u4k5PbNTwB5VHd63MKk2sHXXq46 b4zhgZ2S+EYb98kMrfFwgOi/HBYXVZ+zvgV+ecAggLHjIKxWg7RSAg/UENxlDNm96NUoJY TSgoeuVnRlaeYPc5JDqGZCdFOkAp1ZE= 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 EF7C0106F; Thu, 9 May 2024 02:56:51 -0700 (PDT) Received: from e116581.blr.arm.com (e116581.arm.com [10.162.40.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id D9FD63F6A8; Thu, 9 May 2024 02:56:23 -0700 (PDT) From: Dev Jain To: akpm@linux-foundation.org, shuah@kernel.org Cc: linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Anshuman.Khandual@arm.com, Dev Jain Subject: [PATCH] selftests/mm: hugetlb_madv_vs_map: Avoid test skipping by querying hugepage size at runtime Date: Thu, 9 May 2024 15:24:47 +0530 Message-Id: <20240509095447.3791573-1-dev.jain@arm.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Stat-Signature: cxhpgyteipiwhxxq1bqggmwr1bdqo98p X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 60A6220007 X-HE-Tag: 1715248587-97021 X-HE-Meta: U2FsdGVkX1/uFTNFqPqnBeA2T+SSsbK7PF2y8B1JdFZaq0cJfz76XVAeG+dhQkqw7KBmprWyEZ+SuVqoLkaorD6O0KJ3g+ama2v+3c2SWeZHEFNP18ZyYCZ3cNCgPvvm2EZreQ7FpNK8NSJgzrX9AWPtvXUwLyUk8r3HqaSfCj/64WXaHOAJCpYkiS0g8XCb1QKeM9rTdZjPQn8mijRlc7gR+Yl1LXP9OdD+omJz/ClY0W6hZ08ZZ/3DhGWgP57g8grKcZHFfqcU8IHxok7D6y0gPdPnk1RdmK4N/l0Tcriyef20Pg418V3JrOToXcjqVfdhkyJIfquj6lFZY2bTsxvZitZB9M6yx1/gepg+E0pxKH1Biy9jEnqh8sXot5VqITlTATXDQhTQXmQCavkyV6BVLHJyN8C8+6FwpBAGvg1UvshYB9Kqr/2gtkcR/0CQQVHTBWEbk1MQPWI1ewWd/fBakhB4a3mdeG8dozZ35m64Muv14psabUzb2u3C88aUbvTAp4H8Hv9VN7MreJvVbTi4V73qMiQnmszIAZfFwN2RsX1yTPDUwezpcj1hVCeAMrPbMsh6JhV0/wR70JDDh2BnVPFTDScd/H44E9xybMyLMot0cbZDk+xaE2KsPWir1z6CVMWnf/jqQKVr7OuWIf7pMKU+coCgmTNA9zX6d40CCQXEG1MMIYQmUYR6p6pK1b7m+76HzNwQ538Ts4S7S8cX/tZjZiLXCoG7qV3nb+a0++T0gbkrc0SmoSc9upMr7Xnk2/j4wH/OkDfQXPVvVOxNaEn45bNGjYZRl83EKcJAUl/lkBLwuGgeKe6//kbUnM3ArgetaeqkeNnm9xREudqp49XR1yumKV8fCUFa+HByHwkkhEg37Zu9QMzij6bdoJMYqdGEesYx0V2fiVAVZ/RMnlKOL+moqh5FixhGBjGxRKXNAIzkk0p0XLohIZODDxvXqOKO0oU1PmNBKYs EFhlewgf 6+voLEB56Ol2OaFzUMO7yIIMVMubdFakQKLXjJm/K7D5TiPmHJxqeGFb/X5GCFg6elkDwoM/o3YV3WbSsedWRGEx4i3fi9ob1jS4patKWE04xgOCH/HOqgl2Kkq4txfz6RFOoTu9Hzj/SDDWV2OOffY8JHseEA39/AJV/i7Qh9ujCuA8p5BW0C5ZkakUh9TpneyyXfjebXH6u5Lc= X-Bogosity: Ham, tests=bogofilter, spamicity=0.019099, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Currently, the size used in mmap() is statically defined, leading to skipping of the test on a hugepage size other than 2 MB, since munmap() won't free the hugepage for a size greater than 2 MB. Hence, query the size at runtime. Also, there is no reason why a hugepage allocation should fail, since we are using a simple mmap() using MAP_HUGETLB; hence, instead of skipping the test, make it fail. Signed-off-by: Dev Jain Reviewed-by: Muhammad Usama Anjum Acked-by: David Hildenbrand --- tools/testing/selftests/mm/hugetlb_madv_vs_map.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/tools/testing/selftests/mm/hugetlb_madv_vs_map.c b/tools/testing/selftests/mm/hugetlb_madv_vs_map.c index d01e8d4901d0..8f122a0f0828 100644 --- a/tools/testing/selftests/mm/hugetlb_madv_vs_map.c +++ b/tools/testing/selftests/mm/hugetlb_madv_vs_map.c @@ -27,9 +27,9 @@ #include "vm_util.h" #include "../kselftest.h" -#define MMAP_SIZE (1 << 21) #define INLOOP_ITER 100 +size_t mmap_size; char *huge_ptr; /* Touch the memory while it is being madvised() */ @@ -44,7 +44,7 @@ void *touch(void *unused) void *madv(void *unused) { for (int i = 0; i < INLOOP_ITER; i++) - madvise(huge_ptr, MMAP_SIZE, MADV_DONTNEED); + madvise(huge_ptr, mmap_size, MADV_DONTNEED); return NULL; } @@ -59,7 +59,7 @@ void *map_extra(void *unused) void *ptr; for (int i = 0; i < INLOOP_ITER; i++) { - ptr = mmap(NULL, MMAP_SIZE, PROT_READ | PROT_WRITE, + ptr = mmap(NULL, mmap_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB, -1, 0); @@ -93,14 +93,16 @@ int main(void) free_hugepages); } + mmap_size = default_huge_page_size(); + while (max--) { - huge_ptr = mmap(NULL, MMAP_SIZE, PROT_READ | PROT_WRITE, + huge_ptr = mmap(NULL, mmap_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB, -1, 0); if ((unsigned long)huge_ptr == -1) { - ksft_exit_skip("Failed to allocated huge page\n"); - return KSFT_SKIP; + ksft_test_result_fail("Failed to allocate huge page\n"); + return KSFT_FAIL; } pthread_create(&thread1, NULL, madv, NULL); @@ -117,7 +119,7 @@ int main(void) } /* Unmap and restart */ - munmap(huge_ptr, MMAP_SIZE); + munmap(huge_ptr, mmap_size); } return KSFT_PASS;