From patchwork Fri Nov 1 14:15:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muhammad Usama Anjum X-Patchwork-Id: 13859463 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 0086DE6F061 for ; Fri, 1 Nov 2024 14:16:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5721B6B0083; Fri, 1 Nov 2024 10:16:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 521EB6B009E; Fri, 1 Nov 2024 10:16:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3C2EB6B009F; Fri, 1 Nov 2024 10:16:26 -0400 (EDT) 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 1CB706B0083 for ; Fri, 1 Nov 2024 10:16:26 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id C3A4F1A0637 for ; Fri, 1 Nov 2024 14:16:25 +0000 (UTC) X-FDA: 82737725658.05.AFA6704 Received: from sender4-pp-f112.zoho.com (sender4-pp-f112.zoho.com [136.143.188.112]) by imf01.hostedemail.com (Postfix) with ESMTP id A1C9F40010 for ; Fri, 1 Nov 2024 14:16:01 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=collabora.com header.s=zohomail header.b=kMbq5D5u; dmarc=pass (policy=none) header.from=collabora.com; arc=pass ("zohomail.com:s=zohoarc:i=1"); spf=pass (imf01.hostedemail.com: domain of usama.anjum@collabora.com designates 136.143.188.112 as permitted sender) smtp.mailfrom=usama.anjum@collabora.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1730470527; a=rsa-sha256; cv=pass; b=LCodLhH2xf6FaGWyyRJ0ltC3gGclmFJOlSyqGxziwjI63GpIns7IY0Iw9Y80F6+A9dDBYV HAGnxEnA2jU7/yx5dgCKM2/jbeay6Pi8xKu45eRZeMLk3Em6gWpwPxrmgSHLWo6GUiELU/ UzNzo48upTvPzbJEidoqGxO+2HqAE6g= ARC-Authentication-Results: i=2; imf01.hostedemail.com; dkim=pass header.d=collabora.com header.s=zohomail header.b=kMbq5D5u; dmarc=pass (policy=none) header.from=collabora.com; arc=pass ("zohomail.com:s=zohoarc:i=1"); spf=pass (imf01.hostedemail.com: domain of usama.anjum@collabora.com designates 136.143.188.112 as permitted sender) smtp.mailfrom=usama.anjum@collabora.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1730470527; 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:dkim-signature; bh=g44Wl7tnRmFijuzlRmhgh38eYyyvVTOHdNmRVeRjRyg=; b=G3ERXlToGLjsHs1UYcPgzU8O+g+QyQMCms+PCVokQaFcqDJleS6iq+/yDHjMRND4J47Ecn tdKXs9Cap2GKqxZjpMe386M7eeUs3ffYQOYPFLwaQNnRrd0CjAZudwIntl2tAYOCeRY2vG Xa1LYtWozAbg38vSxgueNPyKt5IRvvM= ARC-Seal: i=1; a=rsa-sha256; t=1730470575; cv=none; d=zohomail.com; s=zohoarc; b=kVEf9La18gUx61NeS/ypACpSeDx1iIBtgSHdQr8OlXV9fgbtxXYqCRudmVnItPieZ5Z1bHTG3azswRiKahVYNvhaHCP3tLC/sJ9KB7oY33norhcr1Cz1xRmbgZ4xvdXEBCtm8yw6NlbBHwCDABwdouGnLiccZ3kNwHBlP2jKUB0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730470575; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:MIME-Version:Message-ID:Subject:Subject:To:To:Message-Id:Reply-To; bh=g44Wl7tnRmFijuzlRmhgh38eYyyvVTOHdNmRVeRjRyg=; b=LabxpNW+KExwUo6U+UghWKhnPmVGLfAcqZ9Q+LF8WVLLcO/w/YlBvbBtv8i/q3+xkdit3VB/Dc522ElQ4JLoTCyKaoGKoBWYcOABg7d3al9c9Voe0NS3Yowpi31uqylQrNYUz3sz9lbvHOWbACOVZc2MqQI/RjJsQrH1mfh2Zl8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=usama.anjum@collabora.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1730470575; s=zohomail; d=collabora.com; i=usama.anjum@collabora.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=g44Wl7tnRmFijuzlRmhgh38eYyyvVTOHdNmRVeRjRyg=; b=kMbq5D5uY0xiYgLnuuV4gUtAEAznDJq+y9o+YsskO2il0WL/lMICQebmbpO6f4ts WBGoM7MI9wLhHV0iKKzSTjyFS2EGmLcn+ptzGzu1YVYWSazyrCpWpogUiANkkvprRM5 W6BfF8TpgnSEebJl9XZgUXTcDK1mf6WvLgue0WBM= Received: by mx.zohomail.com with SMTPS id 1730470574622616.129871650149; Fri, 1 Nov 2024 07:16:14 -0700 (PDT) From: Muhammad Usama Anjum To: Andrew Morton , Shuah Khan Cc: Muhammad Usama Anjum , kernel@collabora.com, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] selftests: hugetlb_dio: Check for initial conditions to skip in the start Date: Fri, 1 Nov 2024 19:15:57 +0500 Message-Id: <20241101141557.3159432-1-usama.anjum@collabora.com> X-Mailer: git-send-email 2.39.5 MIME-Version: 1.0 X-ZohoMailClient: External X-Rspam-User: X-Rspamd-Queue-Id: A1C9F40010 X-Rspamd-Server: rspam11 X-Stat-Signature: bhudt4ambwcb7k5zfk8cnp5qamkbxdge X-HE-Tag: 1730470561-772673 X-HE-Meta: U2FsdGVkX1/0FCNL36UkmsF7MjeVtpMEe4qmKAJx6tEyvWv8VXGrYUyZ+rv1oOnYWnjxx/2cDE6XKsrl7N6ieRtMV5IPKJUuhDaaKqI7h/jNyg8+EdyGZdpLMNawoof8JS6MzsejJW5bH0fVtMKSbDYs2qcKnKrC8aAofbnCWzJteSRx4o3Q91AGfMCyT/pZ1Rtkrzbv73DoMvbsAQESxJM4wUne92WoQP/02BDkKf/ne+BnIUAib/vNYp8s5gcby9f+sIiMwgF8znkxA5jwNyfASOxBosW7vHr3MTYCliMn7PHsQ/IxllbEKuNZSD8dsakBuGgYK0o908IrAepzXNM/cJyCIaM2RsIwDDm0Im2u8TKRJOutWm083pMHKvjCi/vb+QdWAg4XSmjTi/bzCerlqTsAAgHBW5LDoyG3NmgvG77qWsNLZKXmcfnw2nR/6o4oX5a2lHPNbWZxeAtoWuRjQNjIlnJ8xJA4VNoI2cIYiEmnNmcOYsu1ZgCi0WMdhJaUnub3CFow8Oq81Kk1FudKYqOt4acPrzUnWZ9BTTrOwx33QkjUzXmo81f4m+gJVmluCDjPf2t953srDh3tpIgJlOH7sa+ZXXpiW+uJFGN+YrooEZDDRT43ezN7AdI0a08jr5GiS2MnTlbI0GKOyUeeN2UnB1cmkJ8crULt8C2XwE8KxoPibHQ+rFNdb+7/pIhQig2Qkih712fcQ6zC4T61kU335j7yNf0goOkNhvYxm/jjNOlRaZ2a2mT5PI67CAOY6i4QQvptlu0Jq0ze0vp8r7vP5A8/CsYMv0vIT9xsGuiP7oPon7ctTfwOjaW8thDmRZajSW1TS/OUSCQLHJLSzFApTYUgzwS41PqiE9G9RFSzvd5qLwWQhvcMcOz8yR5yqhw43yW8kKfMepczvaF737d+8OcS8V9sJTQ3TZAb2GkscQWUOdCl4d2S8BfWqX9qdaHtun9hUBd+gJp KDFadqZu YQmRl+omUwkyPsEPBEh+y2tJL76Y+ybk/S8+5IwWPQ4DGrXaABFvyNePrjI074cU7nohWTG9sqcCylDSf3EhCM6jrGGVAzYMjyLytdI7R8XlLQsEwspZlIHA9wlRlE1vzjljXlPkU0lA9leoRyY2HyOgfWKMX5ITEbuvcbrdNnxSa8gU3mcXdgFeL/OZBWFEzFDpwf5T4hX15ncLETD8J+aRgFSOmhw8AIDaNuu/06E++LFBWEy4NrVN7NRtAP69G9ducTkc0IPi9gGmKhzHO9cf1XHuKNctNMHV19cW+gRJdcnHXvReQa67c41aJPl7FTmltZlhPQ1cZiGSaBnDb5h33NB9lVAs7vDC77tqm8Rq/MnJPzcV0AseyaQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000166, 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 test should be skipped if initial conditions aren't fulfilled in the start instead of failing and outputting non-compliant TAP logs. This kind of failure pollutes the results. The initial conditions are: - The test should only execute if /tmp file can be allocated. - The test should only execute if huge pages are free. Signed-off-by: Muhammad Usama Anjum --- Before: TAP version 13 1..4 Bail out! Error opening file : Read-only file system (30) # Planned tests != run tests (4 != 0) # Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0 After: TAP version 13 1..0 # SKIP Unable to allocate file: Read-only file system --- tools/testing/selftests/mm/hugetlb_dio.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/tools/testing/selftests/mm/hugetlb_dio.c b/tools/testing/selftests/mm/hugetlb_dio.c index f9ac20c657ec6..60001c142ce99 100644 --- a/tools/testing/selftests/mm/hugetlb_dio.c +++ b/tools/testing/selftests/mm/hugetlb_dio.c @@ -44,13 +44,6 @@ void run_dio_using_hugetlb(unsigned int start_off, unsigned int end_off) if (fd < 0) ksft_exit_fail_perror("Error opening file\n"); - /* Get the free huge pages before allocation */ - free_hpage_b = get_free_hugepages(); - if (free_hpage_b == 0) { - close(fd); - ksft_exit_skip("No free hugepage, exiting!\n"); - } - /* Allocate a hugetlb page */ orig_buffer = mmap(NULL, h_pagesize, mmap_prot, mmap_flags, -1, 0); if (orig_buffer == MAP_FAILED) { @@ -94,8 +87,20 @@ void run_dio_using_hugetlb(unsigned int start_off, unsigned int end_off) int main(void) { size_t pagesize = 0; + int fd; ksft_print_header(); + + /* Open the file to DIO */ + fd = open("/tmp", O_TMPFILE | O_RDWR | O_DIRECT, 0664); + if (fd < 0) + ksft_exit_skip("Unable to allocate file: %s\n", strerror(errno)); + close(fd); + + /* Check if huge pages are free */ + if (!get_free_hugepages()) + ksft_exit_skip("No free hugepage, exiting\n"); + ksft_set_plan(4); /* Get base page size */