From mboxrd@z Thu Jan 1 00:00:00 1970 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 608F3D5E159 for ; Fri, 8 Nov 2024 10:49:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E11E56B009F; Fri, 8 Nov 2024 05:49:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D9A186B00A1; Fri, 8 Nov 2024 05:49:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C13D26B00A2; Fri, 8 Nov 2024 05:49:48 -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 99F6B6B009F for ; Fri, 8 Nov 2024 05:49:48 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 44A111A0B71 for ; Fri, 8 Nov 2024 10:49:48 +0000 (UTC) X-FDA: 82762606164.22.632CD92 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by imf29.hostedemail.com (Postfix) with ESMTP id 5544D12001E for ; Fri, 8 Nov 2024 10:48:56 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=MYS4ExCf; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf29.hostedemail.com: domain of donettom@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=donettom@linux.ibm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731062815; a=rsa-sha256; cv=none; b=YAW60gNjT/C82ZoKym64sj7QGOuJh6T++AAUtbM+w6KxNftzlBvLC+VyNwXr0nC1GYroS+ we/BSUNIHZJglRzQNTBXaKOT1lJgVVyzlPgpJ6GWGCk76FH714lyLXE2nD04VWLx4oX6do W93BYrApx25SC0/Us1n3tcSRzzwzyec= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=MYS4ExCf; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf29.hostedemail.com: domain of donettom@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=donettom@linux.ibm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731062815; 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=xHgmF6UU6hfAi+WJL2nBRYQKhfD8a/G2aximWS/8Ces=; b=kbeNGM0C977v7TuYewuJhrnjrzKlOjvCg8AKkXK41ZhvovpFs3F06Dgn9ln96RK6dUXCpc 0WM6lGz3hxeLFZm57XlyekQ9aOH7NoyrLNu4dAgnSgIP0dh7KrhhD7xMQu7LkrpJbkwKAY TaewddYKUpd5SzSlhy4+dULfh9MYgc8= Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4A8AeXJR031436; Fri, 8 Nov 2024 10:49:39 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pp1; bh=xHgmF6 UU6hfAi+WJL2nBRYQKhfD8a/G2aximWS/8Ces=; b=MYS4ExCf9qDYVg254pakAw sUVZ6X+4/X3D0n7Zs26EFcWI3w9jTf7UOuNCZkckKKgMFQfBWxybxObArv41Ov8w HxPygx2ITzMo0Ze18p4PSTNf2saMRz8iUeDj2CFtiLM3e/RBqRFQVJBl5U6OgQi3 M+QK5T/JNtRCRFOSDZu1HclERf1aO+lY0rTiYY1z2uCd31Jwozi9xNQKuxEazRcE tUHsv7DLhfEihPh0HeX3e3cKqq9ZO3UBKCoIIIT2K1A7VtipSpew5tSCTe5cEXNX JD1laYV1sRSK31d6i7XYdCwJ6f5Jumv6Y5gH2/r8sIo8/IJ7yglXwNiGpmy2yuJA == Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 42sh3br157-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 08 Nov 2024 10:49:38 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 4A7NjCXn013158; Fri, 8 Nov 2024 10:49:37 GMT Received: from smtprelay01.wdc07v.mail.ibm.com ([172.16.1.68]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 42p14120hw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 08 Nov 2024 10:49:37 +0000 Received: from smtpav04.dal12v.mail.ibm.com (smtpav04.dal12v.mail.ibm.com [10.241.53.103]) by smtprelay01.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 4A8Anaxs49742418 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 8 Nov 2024 10:49:36 GMT Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 83C0258063; Fri, 8 Nov 2024 10:49:36 +0000 (GMT) Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 041E258052; Fri, 8 Nov 2024 10:49:34 +0000 (GMT) Received: from [9.179.28.136] (unknown [9.179.28.136]) by smtpav04.dal12v.mail.ibm.com (Postfix) with ESMTP; Fri, 8 Nov 2024 10:49:33 +0000 (GMT) Message-ID: <13a96176-1bfa-4567-8ce5-a2b75b110afc@linux.ibm.com> Date: Fri, 8 Nov 2024 16:19:31 +0530 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] selftests: hugetlb_dio: Check for initial conditions to skip in the start From: Donet Tom To: Muhammad Usama Anjum , Andrew Morton , Shuah Khan Cc: kernel@collabora.com, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org References: <20241101141557.3159432-1-usama.anjum@collabora.com> <5883b1c0-13c6-4593-9dd5-17f34c1319fe@linux.ibm.com> Content-Language: en-US In-Reply-To: <5883b1c0-13c6-4593-9dd5-17f34c1319fe@linux.ibm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: Xo7lmAb9_QkAWEe77q2eSQoteq00qaQ_ X-Proofpoint-ORIG-GUID: Xo7lmAb9_QkAWEe77q2eSQoteq00qaQ_ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_01,2024-10-11_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 impostorscore=0 suspectscore=0 priorityscore=1501 bulkscore=0 malwarescore=0 phishscore=0 mlxscore=0 lowpriorityscore=0 spamscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2411080086 X-Stat-Signature: 7enkysug6wnye3bb6x3k5kkwg5phrtsk X-Rspamd-Queue-Id: 5544D12001E X-Rspamd-Server: rspam08 X-Rspam-User: X-HE-Tag: 1731062936-152939 X-HE-Meta: U2FsdGVkX1+1RSdPJFye6N63CC5yf6+B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V9AioHoAMxpKiCc0+2WwsWsPzDkuEzex9GCPkLNIwaDv1E4x4DNf9SQsjC5jvj74kB2JY3v7i+rSwlDLkL4lFY7kkIA292DXenjLkUI7Oxs/Zi9a+b5gr2HEnePkegbLGfrF8/EJajOWmQz2OiVytwKJJe2XsGtxP4ElECODiKKAbnlzmG8pIm572pk+Z4MNsnxFlZZomeFovPypswd0P3QWjQ5p2f3FOGvWTfTK9ubChwnSPTQcN5vOy7vQo2vX9H6KDnMDZllHLpq99/Ks1YHTbX5gzDMYmVKRPh0IV82cP3CPq5Q6p8Se2XqGN4FhRgKAjiqScpZxdeSV7CvHPK67UwDF+8B/7Ui X-Bogosity: Ham, tests=bogofilter, spamicity=0.000078, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On 11/8/24 16:05, Donet Tom wrote: > > On 11/1/24 19:45, Muhammad Usama Anjum wrote: >> 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(); > > Hi Muhammed Usman Anjum > > Reading the free pages is required before starting the test. This > value will be compared to the free pages after the test. If they are > not the same, the test will be considered a failure. > > Since reading the free pages before the test was > removed,|free_hpage_b|  is always 0, causing the test to fail. > > ./tools/testing/selftests/mm/hugetlb_dio TAP version 13 1..4 # No. > Free pages before allocation : 0 # No. Free pages after munmap : 100 > not ok 1 : Huge pages not freed! # No. Free pages before allocation : > 0 # No. Free pages after munmap : 100 not ok 2 : Huge pages not freed! > # No. Free pages before allocation : 0 # No. Free pages after munmap : > 100 not ok 3 : Huge pages not freed! # No. Free pages before > allocation : 0 # No. Free pages after munmap : 100 not ok 4 : Huge > pages not freed! # Totals: pass:0 fail:4 xfail:0 xpass:0 skip:0 > error:0 I think below changes are required. --- > a/tools/testing/selftests/mm/hugetlb_dio.c +++ > b/tools/testing/selftests/mm/hugetlb_dio.c @@ -44,6 +44,9 @@ 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(); + /* Allocate a hugetlb page */ orig_buffer = > mmap(NULL, h_pagesize, mmap_prot, mmap_flags, -1, 0); if (orig_buffer > == MAP_FAILED) { With this change the tests are passing. > ./tools/testing/selftests/mm/hugetlb_dio TAP version 13 1..4 # No. > Free pages before allocation : 100 # No. Free pages after munmap : 100 > ok 1 : Huge pages freed successfully ! # No. Free pages before > allocation : 100 # No. Free pages after munmap : 100 ok 2 : Huge pages > freed successfully ! # No. Free pages before allocation : 100 # No. > Free pages after munmap : 100 ok 3 : Huge pages freed successfully ! # > No. Free pages before allocation : 100 # No. Free pages after munmap : > 100 ok 4 : Huge pages freed successfully ! # Totals: pass:4 fail:0 > xfail:0 xpass:0 skip:0 error:0 Thank > > Donet > > Sorry. Please ignore above mail. Reading the free pages is required before starting the test. This value will be compared to the free pages after the test. If they are not the same, the test will be considered a failure. Since reading the free pages before the test was removed,free_hpage_b is always 0, causing the test to fail. ./tools/testing/selftests/mm/hugetlb_dio TAP version 13 1..4 # No. Free pages before allocation : 0 # No. Free pages after munmap : 100 not ok 1 : Huge pages not freed! # No. Free pages before allocation : 0 # No. Free pages after munmap : 100 not ok 2 : Huge pages not freed! # No. Free pages before allocation : 0 # No. Free pages after munmap : 100 not ok 3 : Huge pages not freed! # No. Free pages before allocation : 0 # No. Free pages after munmap : 100 not ok 4 : Huge pages not freed! # Totals: pass:0 fail:4 xfail:0 xpass:0 skip:0 error:0 I think below changes are required. iff --git a/tools/testing/selftests/mm/hugetlb_dio.c b/tools/testing/selftests/mm/hugetlb_dio.c index 60001c142ce9..4b52106b8124 100644 --- a/tools/testing/selftests/mm/hugetlb_dio.c +++ b/tools/testing/selftests/mm/hugetlb_dio.c @@ -44,6 +44,9 @@ 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(); +         /* Allocate a hugetlb page */         orig_buffer = mmap(NULL, h_pagesize, mmap_prot, mmap_flags, -1, 0);         if (orig_buffer == MAP_FAILED) { With this change the tests are passing. ./tools/testing/selftests/mm/hugetlb_dio TAP version 131..4 # No. Free pages before allocation : 100 # No. Free pages after munmap : 100 ok 1 : Huge pages freed successfully ! # No. Free pages before allocation : 100 # No. Free pages after munmap : 100 ok 2 : Huge pages freed successfully ! # No. Free pages before allocation : 100 # No. Free pages after munmap : 100 ok 3 : Huge pages freed successfully ! # No. Free pages before allocation : 100 # No. Free pages after munmap : 100 ok 4 : Huge pages freed successfully ! # Totals: pass:4 fail:0 xfail:0 xpass:0 skip:0 error:0 Thanks Donet >> -    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 */