Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp1037889lqo; Thu, 9 May 2024 02:56:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXmSLTOcm1HKffUUbvyQaLn0AQDk9tbTOwbPxBD1pkpFO9fPrkMFd0olMrCIjlpwqkja3TAC1PL8oAs+7mVdWS6J5Ef+05FvLH6ElhDJQ== X-Google-Smtp-Source: AGHT+IGnX2UZWMBZXVVUQbKMtqSFHxTQX0CXF4NmydHEAXFOqWqoYs13ejYXijdysI4u1xZK9P2P X-Received: by 2002:a05:620a:25c9:b0:792:8d94:2bfd with SMTP id af79cd13be357-792b28a477bmr581588885a.77.1715248598998; Thu, 09 May 2024 02:56:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715248598; cv=pass; d=google.com; s=arc-20160816; b=ONjVYrLkLsEdxHjbnVvcexFx8uOA7wgpS+fIWc6IphKyQccij0ss1KjK7GLNF4j3Rm H8ZoLvehfPNlO5Ud08V/nuwdzpGX2j248/W3C47kyTexzwpkLqf4I0yS9X/k0KqnqXyL 6hxcPj9soBsvmGjB2TbQ0+ZN/VSy0OBTdT1vB4Moq8LTcslL/P600QrLi2XPA1diOzdo kmp0LmrO2nQP2/vzboRyaFuVwudiZO2a+9uiDSiLKF2ZvWRXfTv/DOi/uBNO2uubYJ+c 7cvl57jzaJiOgL8no+1HnobZEsiJ9Do942RjYi+Gj0DO1BS+Cs4zm3TJCkUumN5T67u/ GDwg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=2TO77vakJYsYteROjg3UnkKRKkYPmCCl1d+TvpXCRQc=; fh=sjxBMbigrgKUzplA8V3gIjRPqs2fwVVyor1W+PgO1Zk=; b=NXSf+m5UEqlATfbFVP8xE/EZ5s4TVYu5doaGPwyetJShiH9SQXp9LN7wC1YtURCeLP 0FiFtwDjNqyZ80DdIS3ZGdMlPyFD453cJGRP5ENZhRarHXL9KeeVU55BP8zE2PT+3Xpn DVfAXO9OrHsOmSOPui4FFwilPbg6iX9PRdhI6z4ZDn3hyRnsmaeH89manVOrwocn2g+H +9By5EDpT8Lh186V91odVgtnOTxjaNJE8EuAEjgMZ8eTYytnI5imHgNWtS1LGg4x6COS DehF18K6Xwcl23Q/ON5c0WP26GNHAOj294aNVIEqlywL3jgzQ3iyTn4u0mVKykRNt9ez GUiw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-174379-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-174379-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id af79cd13be357-792bf306697si93651585a.225.2024.05.09.02.56.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 May 2024 02:56:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-174379-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-174379-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-174379-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id B3F571C21458 for ; Thu, 9 May 2024 09:56:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1D07B14A636; Thu, 9 May 2024 09:56:36 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B4A86BE68; Thu, 9 May 2024 09:56:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715248595; cv=none; b=NWgZl+LptOdGgm0kQHazBOibozwWlb0Bi2KX6IaloACF8U+Y1CPUKUsF2Dle00O4K1QadJ7GySf4N2jJHAjfS9FtRLJ2XKDNznEq/lZeRD6v1EqM8Ho7iDcc1R/gnu+u8wZMYFoo+dpwE2oY8jqO88dgqSCmyfRTtCLoKAo9/nU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715248595; c=relaxed/simple; bh=bkdnPTqguEmErPjetrOrTQt4B1ja9Q8ssDLo3J3S05o=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=tc3nJ1Zz6cyGFfqsco5msY7IwSkaeLASOCWPPtjylHIsXXNaoYk2gceB1yidVebA1LpV9RVc8A1NKuXpiufM8C+KC9FSvy2lfp2k4whdYbUv+DWviKClnKdY8sr2SQVH7WsWq2fHfSgm/rt8wOtFDWsp2I5trrSnMelcuZv0o+4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- 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; -- 2.39.2