{"id":2219785,"url":"http://patchwork.ozlabs.org/api/patches/2219785/?format=json","web_url":"http://patchwork.ozlabs.org/project/ltp/patch/20260404121120.1611032-1-pavrampu@linux.ibm.com/","project":{"id":59,"url":"http://patchwork.ozlabs.org/api/projects/59/?format=json","name":"Linux Test Project development","link_name":"ltp","list_id":"ltp.lists.linux.it","list_email":"ltp@lists.linux.it","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260404121120.1611032-1-pavrampu@linux.ibm.com>","list_archive_url":null,"date":"2026-04-04T12:11:20","name":"Migrating the libhugetlbfs/testcases/quota.c - v2","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"ef7cb150a81c911159b7b7f999f8a35afb22c3b3","submitter":{"id":91766,"url":"http://patchwork.ozlabs.org/api/people/91766/?format=json","name":"Pavithra","email":"pavrampu@linux.ibm.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/ltp/patch/20260404121120.1611032-1-pavrampu@linux.ibm.com/mbox/","series":[{"id":498721,"url":"http://patchwork.ozlabs.org/api/series/498721/?format=json","web_url":"http://patchwork.ozlabs.org/project/ltp/list/?series=498721","date":"2026-04-04T12:11:20","name":"Migrating the libhugetlbfs/testcases/quota.c - v2","version":1,"mbox":"http://patchwork.ozlabs.org/series/498721/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2219785/comments/","check":"warning","checks":"http://patchwork.ozlabs.org/api/patches/2219785/checks/","tags":{},"related":[],"headers":{"Return-Path":"<ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it>","X-Original-To":["incoming@patchwork.ozlabs.org","ltp@lists.linux.it"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","ltp@picard.linux.it"],"Authentication-Results":["legolas.ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256\n header.s=pp1 header.b=Ud8j2IhB;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it\n (client-ip=2001:1418:10:5::2; helo=picard.linux.it;\n envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it;\n receiver=patchwork.ozlabs.org)"],"Received":["from picard.linux.it (unknown [IPv6:2001:1418:10:5::2])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fnvbF17YJz1xtJ\n\tfor <incoming@patchwork.ozlabs.org>; Sat, 04 Apr 2026 23:11:49 +1100 (AEDT)","from picard.linux.it (localhost [IPv6:::1])\n\tby picard.linux.it (Postfix) with ESMTP id 3453E3E29F3\n\tfor <incoming@patchwork.ozlabs.org>; Sat,  4 Apr 2026 14:11:37 +0200 (CEST)","from in-5.smtp.seeweb.it (in-5.smtp.seeweb.it [217.194.8.5])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature ECDSA (secp384r1))\n (No client certificate requested)\n by picard.linux.it (Postfix) with ESMTPS id 704263D9008\n for <ltp@lists.linux.it>; Sat,  4 Apr 2026 14:11:33 +0200 (CEST)","from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com\n [148.163.158.5])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n (No client certificate requested)\n by in-5.smtp.seeweb.it (Postfix) with ESMTPS id ED157600688\n for <ltp@lists.linux.it>; Sat,  4 Apr 2026 14:11:31 +0200 (CEST)","from pps.filterd (m0360072.ppops.net [127.0.0.1])\n by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id\n 6346qmkU3484025; Sat, 4 Apr 2026 12:11:29 GMT","from ppma12.dal12v.mail.ibm.com\n (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220])\n by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4dat9r8uy9-1\n (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT);\n Sat, 04 Apr 2026 12:11:29 +0000 (GMT)","from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1])\n by ppma12.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id\n 6347cqnk021713;\n Sat, 4 Apr 2026 12:11:28 GMT","from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226])\n by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 4d6sat1gc4-1\n (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT);\n Sat, 04 Apr 2026 12:11:28 +0000","from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com\n [10.20.54.102])\n by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id\n 634CBPRV48562534\n (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK);\n Sat, 4 Apr 2026 12:11:25 GMT","from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1])\n by IMSVA (Postfix) with ESMTP id 0E2B520040;\n Sat,  4 Apr 2026 12:11:25 +0000 (GMT)","from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1])\n by IMSVA (Postfix) with ESMTP id 0EE192004B;\n Sat,  4 Apr 2026 12:11:24 +0000 (GMT)","from li-49acbccc-2994-11b2-a85c-d51b89e344f1.ibm.com.com (unknown\n [9.39.20.67]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP;\n Sat,  4 Apr 2026 12:11:23 +0000 (GMT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc\n :content-transfer-encoding:date:from:message-id:mime-version\n :subject:to; s=pp1; bh=hUmzv+oro+r4QQ2fxCpo1SkDQ/vcp8X3hTZ8z8gNU\n 5s=; b=Ud8j2IhBwJC6DPAsmaRtrAaL0uSEKMlx1ef32onJo/YaFItoSyMfnIC3r\n SDjoK5dSI8MizUpSoJHThLlDJnvwAn5aKoZ5qz4FCslYBRjhAsc/KV/noMg6/6B+\n oVapyrVp95zcaL2pRENCb854ELYZN4uIw/A/v4qe4XpSBvwqknw3x+HKiv1ivxXj\n Zxwu9JkehXFoGBSubXc34ZaGdzAt/sOGtNTMT8Vlnp3gpFNpOGU2dgtvUcvzrgfK\n /AGGgMY07zG4cdaJh8hsy34Qh1CF34ZS0NWFYPqWmZJ9Ouc9PG7Zg3VoGDn2Ftf6\n OgyIOh6A5shjeKoSzvH5bfBHIVrtQ==","From":"Pavithra <pavrampu@linux.ibm.com>","To":"ltp@lists.linux.it","Date":"Sat,  4 Apr 2026 17:41:20 +0530","Message-ID":"<20260404121120.1611032-1-pavrampu@linux.ibm.com>","X-Mailer":"git-send-email 2.53.0","MIME-Version":"1.0","X-TM-AS-GCONF":"00","X-Proofpoint-GUID":"zjeWrX_zeQ4sJSd75f_mqiTJ7s8wZfmu","X-Proofpoint-ORIG-GUID":"zjeWrX_zeQ4sJSd75f_mqiTJ7s8wZfmu","X-Authority-Analysis":"v=2.4 cv=bLYb4f+Z c=1 sm=1 tr=0 ts=69d0fff1 cx=c_pps\n a=bLidbwmWQ0KltjZqbj+ezA==:117 a=bLidbwmWQ0KltjZqbj+ezA==:17\n a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22\n a=RzCfie-kr_QcCd8fBx8p:22 a=VnNF1IyMAAAA:8 a=AqNQ2rZE2gcICQn7LrkA:9","X-Proofpoint-Spam-Details-Enc":"AW1haW4tMjYwNDA0MDEwOSBTYWx0ZWRfX+6xElrD/tOba\n wYX1olg2ofu5R5499dZ6QkjSksLa5KGQYJ5GtRyYWqqwRWsAdDxTkqcT3M8Po4gfVuQ+PfJIlLI\n l7xWXKR1XaQjamMzCShjvW3wl4L1edEZJvCJSdkb6FXS/tu2NjViawMLttZ4mLvDIthSq/xTTka\n jV+aC0gs7sDfx0pxtUWlRsH5MI1o3/TcSAXBgmMf+b90ziOXPrIzvROUNdQxVJb9j2d/XHu99e6\n Bdkg2Or3/wKDhMarXZ0cxXKtdCOjLQ4jeFR8UUb+8C3akJqIxL68P0eDJmHIyipJAjRfC8IyjWc\n L96sJnxr0DHH/COh/A5VRIT+RNNb643v1WRIXPrD2mlw7Kr/n5Frmnyu/9+5Scmh1TWStwnXQTP\n L3OHLk2FwlTtnPv3hI5p7NPKGi5fmrgPAjC5hyNpyTi2oxkGAhdUo7HSvCrjaZzLiqOjqWQu5WM\n KDvSEp9egnbM7PuwToA==","X-Proofpoint-Virus-Version":"vendor=baseguard\n engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49\n definitions=2026-04-04_01,2026-04-03_01,2025-10-01_01","X-Proofpoint-Spam-Details":"rule=outbound_notspam policy=outbound score=0\n clxscore=1011 adultscore=0 suspectscore=0 phishscore=0 bulkscore=0\n spamscore=0 priorityscore=1501 lowpriorityscore=0 malwarescore=0\n impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc=\n route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2603050001\n definitions=main-2604040109","X-Spam-Status":"No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID,\n SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=disabled version=4.0.1","X-Spam-Checker-Version":"SpamAssassin 4.0.1 (2024-03-25) on in-5.smtp.seeweb.it","X-Virus-Scanned":"clamav-milter 1.0.9 at in-5.smtp.seeweb.it","X-Virus-Status":"Clean","Subject":"[LTP] [PATCH] Migrating the libhugetlbfs/testcases/quota.c - v2","X-BeenThere":"ltp@lists.linux.it","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"Linux Test Project <ltp.lists.linux.it>","List-Unsubscribe":"<https://lists.linux.it/options/ltp>,\n <mailto:ltp-request@lists.linux.it?subject=unsubscribe>","List-Archive":"<http://lists.linux.it/pipermail/ltp/>","List-Post":"<mailto:ltp@lists.linux.it>","List-Help":"<mailto:ltp-request@lists.linux.it?subject=help>","List-Subscribe":"<https://lists.linux.it/listinfo/ltp>,\n <mailto:ltp-request@lists.linux.it?subject=subscribe>","Cc":"pavrampu@linux.ibm.com","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it","Sender":"\"ltp\" <ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it>"},"content":"Test hugetlbfs quota accounting with filesystem size limits to check\nfor regressions in quota handling for MAP_PRIVATE and MAP_SHARED pages.\n\nSigned-off-by: Pavithra <pavrampu@linux.ibm.com>\n---\n runtest/hugetlb                               |   1 +\n testcases/kernel/mem/.gitignore               |   1 +\n .../kernel/mem/hugetlb/hugemmap/hugemmap33.c  | 273 ++++++++++++++++++\n 3 files changed, 275 insertions(+)\n create mode 100644 testcases/kernel/mem/hugetlb/hugemmap/hugemmap33.c","diff":"diff --git a/runtest/hugetlb b/runtest/hugetlb\nindex 0896d3c94..24fa717ec 100644\n--- a/runtest/hugetlb\n+++ b/runtest/hugetlb\n@@ -35,6 +35,7 @@ hugemmap29 hugemmap29\n hugemmap30 hugemmap30\n hugemmap31 hugemmap31\n hugemmap32 hugemmap32\n+hugemmap33 hugemmap33\n hugemmap34 hugemmap34\n hugemmap05_1 hugemmap05 -m\n hugemmap05_2 hugemmap05 -s\ndiff --git a/testcases/kernel/mem/.gitignore b/testcases/kernel/mem/.gitignore\nindex b4455de51..7f1bcd4e7 100644\n--- a/testcases/kernel/mem/.gitignore\n+++ b/testcases/kernel/mem/.gitignore\n@@ -35,6 +35,7 @@\n /hugetlb/hugemmap/hugemmap30\n /hugetlb/hugemmap/hugemmap31\n /hugetlb/hugemmap/hugemmap32\n+/hugetlb/hugemmap/hugemmap33\n /hugetlb/hugemmap/hugemmap34\n /hugetlb/hugeshmat/hugeshmat01\n /hugetlb/hugeshmat/hugeshmat02\ndiff --git a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap33.c b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap33.c\nnew file mode 100644\nindex 000000000..75ecf5796\n--- /dev/null\n+++ b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap33.c\n@@ -0,0 +1,273 @@\n+// SPDX-License-Identifier: LGPL-2.1-or-later\n+/*\n+ * Copyright (C) 2005-2007 David Gibson & Adam Litke, IBM Corporation.\n+ * Copyright (c) Linux Test Project, 2024\n+ * Copyright (C) 2025-2026 Naveed & Pavithra, IBM Corporation.\n+ * Assisted with AI tools\n+ */\n+\n+/*\\\n+ * Test hugetlbfs quota accounting with filesystem size limits.\n+ *\n+ * The number of global huge pages available to a mounted hugetlbfs filesystem\n+ * can be limited using a quota mechanism by setting the size attribute at\n+ * mount time. Older kernels did not properly handle quota accounting in a\n+ * number of cases (e.g., for MAP_PRIVATE pages, and with MAP_SHARED reservation).\n+ *\n+ * This test replays some scenarios on a privately mounted filesystem with\n+ * quota to check for regressions in hugetlbfs quota accounting.\n+ */\n+\n+#define _GNU_SOURCE\n+#include <sys/types.h>\n+#include <sys/wait.h>\n+#include <sys/vfs.h>\n+#include <sys/statfs.h>\n+#include <sys/mount.h>\n+\n+#include \"hugetlb.h\"\n+\n+#define MNTPOINT \"hugetlbfs/\"\n+\n+static long hpage_size;\n+static int private_resv;\n+static char quota_mnt[PATH_MAX];\n+static int quota_mounted;\n+\n+/* map action flags */\n+#define ACTION_COW\t\t0x0001\n+#define ACTION_TOUCH\t\t0x0002\n+\n+/* Test result expectations */\n+#define EXPECT_SUCCESS\t0\n+#define EXPECT_SIGNAL\t1\n+#define EXPECT_FAILURE\t2\n+\n+static void verify_quota_stat(long tot, long free, long avail)\n+{\n+\tstruct statfs s;\n+\n+\tSAFE_STATFS(quota_mnt, &s);\n+\n+\tif ((long)s.f_blocks != tot || (long)s.f_bfree != free || (long)s.f_bavail != avail) {\n+\t\ttst_res(TFAIL,\n+\t\t\t\"Bad quota counters: total=%li (expected %li), \"\n+\t\t\t\"free=%li (expected %li), avail=%li (expected %li)\",\n+\t\t\t(long)s.f_blocks, tot, (long)s.f_bfree, free,\n+\t\t\t(long)s.f_bavail, avail);\n+\t}\n+}\n+\n+static void do_map(unsigned long size, int mmap_flags, int action_flags)\n+{\n+\tint fd;\n+\tchar *a = MAP_FAILED, *b, *c = MAP_FAILED;\n+\tchar path[PATH_MAX + 32];\n+\n+\tsnprintf(path, sizeof(path), \"%s/test_file_%d\", quota_mnt, getpid());\n+\tfd = SAFE_OPEN(path, O_CREAT | O_RDWR, 0600);\n+\tSAFE_UNLINK(path);\n+\n+\ta = mmap(NULL, size, PROT_READ | PROT_WRITE, mmap_flags, fd, 0);\n+\tif (a == MAP_FAILED) {\n+\t\tif (errno == ENOMEM || errno == ENOSPC) {\n+\t\t\ttst_res(TINFO | TERRNO, \"mmap failed as expected due to quota\");\n+\t\t\tgoto cleanup_fd;\n+\t\t}\n+\t\ttst_brk(TBROK | TERRNO, \"mmap failed unexpectedly\");\n+\t}\n+\n+\tif (action_flags & ACTION_TOUCH) {\n+\t\tfor (b = a; b < a + size; b += hpage_size)\n+\t\t\t*b = 1;\n+\t}\n+\n+\tif (action_flags & ACTION_COW) {\n+\t\tc = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);\n+\t\tif (c == MAP_FAILED) {\n+\t\t\tif (errno == ENOMEM || errno == ENOSPC) {\n+\t\t\t\ttst_res(TINFO | TERRNO, \"COW mapping failed as expected due to quota\");\n+\t\t\t\tgoto cleanup_a;\n+\t\t\t}\n+\t\t\ttst_brk(TBROK | TERRNO, \"COW mapping failed unexpectedly\");\n+\t\t}\n+\n+\t\tif (*c != 1) {\n+\t\t\ttst_res(TINFO, \"Data mismatch when setting up COW\");\n+\t\t\tgoto cleanup_c;\n+\t\t}\n+\t\t*c = 0;\n+\t\tSAFE_MUNMAP(c, size);\n+\t}\n+\n+\tSAFE_MUNMAP(a, size);\n+\tSAFE_CLOSE(fd);\n+\treturn;\n+\n+cleanup_c:\n+\tSAFE_MUNMAP(c, size);\n+cleanup_a:\n+\tSAFE_MUNMAP(a, size);\n+cleanup_fd:\n+\tSAFE_CLOSE(fd);\n+\texit(1);\n+}\n+\n+static void run_quota_test(int expected_result,\n+\t\t\t   unsigned long size, int mmap_flags,\n+\t\t\t   int action_flags)\n+{\n+\tpid_t pid;\n+\tint status;\n+\tint actual_result;\n+\n+\tpid = SAFE_FORK();\n+\tif (pid == 0) {\n+\t\tdo_map(size, mmap_flags, action_flags);\n+\t\texit(0);\n+\t}\n+\n+\tSAFE_WAITPID(pid, &status, 0);\n+\n+\tif (WIFEXITED(status)) {\n+\t\tif (WEXITSTATUS(status) == 0)\n+\t\t\tactual_result = EXPECT_SUCCESS;\n+\t\telse\n+\t\t\tactual_result = EXPECT_FAILURE;\n+\t} else {\n+\t\tactual_result = EXPECT_SIGNAL;\n+\t}\n+\n+\tif (actual_result != expected_result) {\n+\t\tstatic const char * const result_names[] = {\"success\", \"signal\", \"failure\"};\n+\n+\t\ttst_res(TFAIL,\n+\t\t\t\"Unexpected result: expected %s, got %s\",\n+\t\t\tresult_names[expected_result],\n+\t\t\tresult_names[actual_result]);\n+\t} else {\n+\t\ttst_res(TPASS, \"Quota test passed as expected\");\n+\t}\n+}\n+\n+static int kernel_has_private_reservations(void)\n+{\n+\tint fd;\n+\tlong t, f, r, s;\n+\tlong nt, nf, nr, ns;\n+\tvoid *p;\n+\tchar path[PATH_MAX];\n+\n+\tt = SAFE_READ_MEMINFO(MEMINFO_HPAGE_TOTAL);\n+\tf = SAFE_READ_MEMINFO(MEMINFO_HPAGE_FREE);\n+\tr = SAFE_READ_MEMINFO(MEMINFO_HPAGE_RSVD);\n+\ts = SAFE_READ_MEMINFO(MEMINFO_HPAGE_SURP);\n+\n+\tsnprintf(path, sizeof(path), \"%s/test_priv_resv\", MNTPOINT);\n+\tfd = SAFE_OPEN(path, O_CREAT | O_RDWR, 0600);\n+\tSAFE_UNLINK(path);\n+\n+\tp = SAFE_MMAP(NULL, hpage_size, PROT_READ | PROT_WRITE,\n+\t\t      MAP_PRIVATE, fd, 0);\n+\n+\tnt = SAFE_READ_MEMINFO(MEMINFO_HPAGE_TOTAL);\n+\tnf = SAFE_READ_MEMINFO(MEMINFO_HPAGE_FREE);\n+\tnr = SAFE_READ_MEMINFO(MEMINFO_HPAGE_RSVD);\n+\tns = SAFE_READ_MEMINFO(MEMINFO_HPAGE_SURP);\n+\n+\tSAFE_MUNMAP(p, hpage_size);\n+\tSAFE_CLOSE(fd);\n+\n+\t/* Check if reservation was created for private mapping */\n+\tif ((nt == t + 1) && (nf == f + 1) && (ns == s + 1) && (nr == r + 1))\n+\t\treturn 1;\n+\telse if ((nt == t) && (nf == f) && (ns == s)) {\n+\t\tif (nr == r + 1)\n+\t\t\treturn 1;\n+\t\telse if (nr == r)\n+\t\t\treturn 0;\n+\t}\n+\n+\ttst_brk(TCONF, \"Unexpected counter state - \"\n+\t\t\"T:%li F:%li R:%li S:%li -> T:%li F:%li R:%li S:%li\",\n+\t\tt, f, r, s, nt, nf, nr, ns);\n+\treturn -1;\n+}\n+\n+static void run_test(void)\n+{\n+\tint bad_priv_resv = private_resv ? EXPECT_FAILURE : EXPECT_SIGNAL;\n+\n+\ttst_res(TINFO, \"Testing unused quota cleanup for untouched mappings\");\n+\trun_quota_test(EXPECT_SUCCESS, hpage_size, MAP_PRIVATE, 0);\n+\tverify_quota_stat(1, 1, 1);\n+\trun_quota_test(EXPECT_SUCCESS, hpage_size, MAP_SHARED, 0);\n+\tverify_quota_stat(1, 1, 1);\n+\n+\ttst_res(TINFO, \"Testing page instantiation within quota limits\");\n+\trun_quota_test(EXPECT_SUCCESS, hpage_size, MAP_PRIVATE, ACTION_TOUCH);\n+\trun_quota_test(EXPECT_SUCCESS, hpage_size, MAP_SHARED, ACTION_TOUCH);\n+\n+\ttst_res(TINFO, \"Testing page instantiation over quota\");\n+\trun_quota_test(EXPECT_FAILURE, 2 * hpage_size, MAP_SHARED, ACTION_TOUCH);\n+\n+\ttst_res(TINFO, \"Testing private mapping quota check\");\n+\trun_quota_test(bad_priv_resv, 2 * hpage_size, MAP_PRIVATE, ACTION_TOUCH);\n+\n+\ttst_res(TINFO, \"Testing COW over quota\");\n+\trun_quota_test(bad_priv_resv, hpage_size, MAP_SHARED,\n+\t\t       ACTION_TOUCH | ACTION_COW);\n+\trun_quota_test(bad_priv_resv, hpage_size, MAP_PRIVATE,\n+\t\t       ACTION_TOUCH | ACTION_COW);\n+\n+\ttst_res(TINFO, \"Testing operations within quota after failures\");\n+\trun_quota_test(EXPECT_SUCCESS, hpage_size, MAP_SHARED, ACTION_TOUCH);\n+\trun_quota_test(EXPECT_SUCCESS, hpage_size, MAP_PRIVATE, ACTION_TOUCH);\n+}\n+\n+static void setup(void)\n+{\n+\tchar mount_opts[BUFSIZ];\n+\n+\thpage_size = tst_get_hugepage_size();\n+\n+\t/* Create a quota-limited hugetlbfs mount */\n+\tsnprintf(quota_mnt, sizeof(quota_mnt), \"%s/quota_test\", MNTPOINT);\n+\tSAFE_MKDIR(quota_mnt, 0755);\n+\n+\tsnprintf(mount_opts, sizeof(mount_opts), \"size=%luK\",\n+\t\t hpage_size / 1024);\n+\n+\tif (mount(\"none\", quota_mnt, \"hugetlbfs\", 0, mount_opts) == -1) {\n+\t\tif (errno == ENODEV)\n+\t\t\ttst_brk(TCONF, \"hugetlbfs not supported\");\n+\t\ttst_brk(TBROK | TERRNO, \"mount() failed\");\n+\t}\n+\tquota_mounted = 1;\n+\n+\ttst_res(TINFO, \"Mounted hugetlbfs with quota at %s (size=%luK)\",\n+\t\tquota_mnt, hpage_size / 1024);\n+\n+\tprivate_resv = kernel_has_private_reservations();\n+\ttst_res(TINFO, \"Kernel %s private reservations\",\n+\t\tprivate_resv ? \"has\" : \"does not have\");\n+}\n+\n+static void cleanup(void)\n+{\n+\tif (quota_mounted) {\n+\t\tSAFE_UMOUNT(quota_mnt);\n+\t\tSAFE_RMDIR(quota_mnt);\n+\t}\n+}\n+\n+static struct tst_test test = {\n+\t.needs_root = 1,\n+\t.mntpoint = MNTPOINT,\n+\t.needs_hugetlbfs = 1,\n+\t.forks_child = 1,\n+\t.setup = setup,\n+\t.cleanup = cleanup,\n+\t.test_all = run_test,\n+\t.hugepages = {2, TST_NEEDS},\n+};\n","prefixes":[]}