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 picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CBE4DC433FE for ; Tue, 8 Nov 2022 19:53:30 +0000 (UTC) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 0DE9D3CD905 for ; Tue, 8 Nov 2022 20:53:29 +0100 (CET) Received: from in-5.smtp.seeweb.it (in-5.smtp.seeweb.it [IPv6:2001:4b78:1:20::5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 7C1433CD920 for ; Tue, 8 Nov 2022 20:52:44 +0100 (CET) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by in-5.smtp.seeweb.it (Postfix) with ESMTPS id 798E46005DA for ; Tue, 8 Nov 2022 20:52:42 +0100 (CET) Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 2A8JQJXF029437; Tue, 8 Nov 2022 19:52:41 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=em25zatp276zcdjeIXx0EVdvJxORSfZpY7L4zsi2X0A=; b=QqwGvEHi5Bw203DUkHS2JJZkaGW3I+R1aJsFm3x6VIcz0My2P7Ml8qk5FYMNomntzbqx jULwJQRwsUfe489Uhs/vhgR42ILn6rCpy27UEBq/xn/jLaJD3iDW9gxSJF5ddX/2Lc2q 5Y3nIWq21rD5HSDq53hP+5vjo95ynWwevb1OebBOuENFz/IWAvnS5XnjZ1ZC6TeneC2F GCR7Dli6ZrDF+6ayJ9sCknuThS8pQVPcZiiEaYxsT3ir61EXXHUpnt4uMu3fPMN9Dd4B t9+PpPKAKiPcYEkLJYbz5q3/A6efxBX6J9JSN0Q9eopQWwP5LEzfIUEZ9NWrUWOVusBm TA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3kqth463e8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Nov 2022 19:52:41 +0000 Received: from m0098420.ppops.net (m0098420.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 2A8JdQnJ024477; Tue, 8 Nov 2022 19:52:41 GMT Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3kqth463dj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Nov 2022 19:52:41 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 2A8JpLkf026723; Tue, 8 Nov 2022 19:52:39 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma04ams.nl.ibm.com with ESMTP id 3kngqdckmk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Nov 2022 19:52:39 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2A8Jqa2L55509404 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 8 Nov 2022 19:52:36 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F2DC2A4040; Tue, 8 Nov 2022 19:52:35 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9E67EA404D; Tue, 8 Nov 2022 19:52:32 +0000 (GMT) Received: from tarunpc.ibmuc.com (unknown [9.43.4.5]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 8 Nov 2022 19:52:32 +0000 (GMT) From: Tarun Sahu To: ltp@lists.linux.it Date: Wed, 9 Nov 2022 01:22:07 +0530 Message-Id: <20221108195207.232115-6-tsahu@linux.ibm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221108195207.232115-1-tsahu@linux.ibm.com> References: <20221108195207.232115-1-tsahu@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: WbRzpAAris-jf6rMrjwR00r5Ls1RNbxR X-Proofpoint-ORIG-GUID: Puce1K8ESKxwCn8LMYEkqG55dv-7KTib X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-07_11,2022-11-08_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 impostorscore=0 lowpriorityscore=0 clxscore=1015 spamscore=0 priorityscore=1501 bulkscore=0 phishscore=0 suspectscore=0 mlxlogscore=999 malwarescore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211080125 X-Virus-Scanned: clamav-milter 0.102.4 at in-5.smtp.seeweb.it X-Virus-Status: Clean Subject: [LTP] [PATCH v2 5/5] Hugetlb: Migrating libhugetlbfs fallocate_basic X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: geetika@linux.ibm.com, sbhat@linux.ibm.com, aneesh.kumar@linux.ibm.com, vaibhav@linux.ibm.com, mike.kravetz@oracle.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ltp-bounces+ltp=archiver.kernel.org@lists.linux.it Sender: "ltp" Migrating the libhugetlbfs/testcases/fallocate_basic.c test Test Description: It tests basic fallocate functionality in hugetlbfs. Preallocate huge pages to a file in hugetlbfs, and then remove the pages via hole punch. Signed-off-by: Tarun Sahu --- runtest/hugetlb | 1 + testcases/kernel/mem/.gitignore | 1 + .../hugetlb/hugefallocate/hugefallocate02.c | 90 +++++++++++++++++++ 3 files changed, 92 insertions(+) create mode 100644 testcases/kernel/mem/hugetlb/hugefallocate/hugefallocate02.c diff --git a/runtest/hugetlb b/runtest/hugetlb index ca92dfcff..ec1fc2515 100644 --- a/runtest/hugetlb +++ b/runtest/hugetlb @@ -1,4 +1,5 @@ hugefallocate01 hugefallocate01 +hugefallocate02 hugefallocate02 hugemmap01 hugemmap01 hugemmap02 hugemmap02 diff --git a/testcases/kernel/mem/.gitignore b/testcases/kernel/mem/.gitignore index cafdb5259..c0906f3d3 100644 --- a/testcases/kernel/mem/.gitignore +++ b/testcases/kernel/mem/.gitignore @@ -1,5 +1,6 @@ /cpuset/cpuset01 /hugetlb/hugefallocate/hugefallocate01 +/hugetlb/hugefallocate/hugefallocate02 /hugetlb/hugemmap/hugemmap01 /hugetlb/hugemmap/hugemmap02 /hugetlb/hugemmap/hugemmap04 diff --git a/testcases/kernel/mem/hugetlb/hugefallocate/hugefallocate02.c b/testcases/kernel/mem/hugetlb/hugefallocate/hugefallocate02.c new file mode 100644 index 000000000..c8f8f87c9 --- /dev/null +++ b/testcases/kernel/mem/hugetlb/hugefallocate/hugefallocate02.c @@ -0,0 +1,90 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later +/* + * Copyright (C) 2015 Oracle Corporation + * Author: Mike Kravetz + */ + +/*\ + * [Description] + * + * It tests basic fallocate functionality in hugetlbfs. Preallocate huge + * pages to a file in hugetlbfs, and then remove the pages via hole punch. + * + */ + +#define _GNU_SOURCE +#include +#include +#include +#include +#include + +#include "hugetlb.h" + +#define MAX_PAGES_TO_USE 5 +#define MNTPOINT "hugetlbfs/" + +static int fd = -1; +static long hpage_size; + +static void run_test(void) +{ + int err; + unsigned long max_iterations; + unsigned long free_initial, free_after, free_end; + + free_initial = SAFE_READ_MEMINFO(MEMINFO_HPAGE_FREE); + max_iterations = MIN(free_initial, MAX_PAGES_TO_USE); + + fd = tst_creat_unlinked(MNTPOINT); + + /* First preallocate file with max_iterations pages */ + err = fallocate(fd, 0, 0, hpage_size * max_iterations); + if (err) { + if (errno == EOPNOTSUPP) + tst_brk(TCONF, "fallocate() Operation is not supported"); + tst_res(TFAIL|TERRNO, "fallocate()"); + goto cleanup; + } + + free_after = SAFE_READ_MEMINFO(MEMINFO_HPAGE_FREE); + if (free_initial - free_after != max_iterations) { + tst_res(TFAIL, "fallocate did not preallocate %lu huge pages", + max_iterations); + goto cleanup; + } + + /* Now punch a hole of the same size */ + err = fallocate(fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, + 0, hpage_size * max_iterations); + if (err) { + tst_res(TFAIL|TERRNO, "fallocate(FALLOC_FL_PUNCH_HOLE)"); + goto cleanup; + } + + free_end = SAFE_READ_MEMINFO(MEMINFO_HPAGE_FREE); + TST_EXP_EQ_LU(free_end, free_initial); +cleanup: + SAFE_CLOSE(fd); +} + +static void setup(void) +{ + hpage_size = SAFE_READ_MEMINFO(MEMINFO_HPAGE_SIZE)*1024; +} + +static void cleanup(void) +{ + if (fd > 0) + SAFE_CLOSE(fd); +} + +static struct tst_test test = { + .needs_root = 1, + .mntpoint = MNTPOINT, + .needs_hugetlbfs = 1, + .setup = setup, + .cleanup = cleanup, + .test_all = run_test, + .hugepages = {3, TST_NEEDS}, +}; -- 2.31.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp