Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2216791/?format=api
{ "id": 2216791, "url": "http://patchwork.ozlabs.org/api/patches/2216791/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linuxppc-dev/patch/41fc5be38d4205b5a4aee8499631cf60a9026163.1774591179.git.sayalip@linux.ibm.com/", "project": { "id": 2, "url": "http://patchwork.ozlabs.org/api/projects/2/?format=api", "name": "Linux PPC development", "link_name": "linuxppc-dev", "list_id": "linuxppc-dev.lists.ozlabs.org", "list_email": "linuxppc-dev@lists.ozlabs.org", "web_url": "https://github.com/linuxppc/wiki/wiki", "scm_url": "https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git", "webscm_url": "https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/", "list_archive_url": "https://lore.kernel.org/linuxppc-dev/", "list_archive_url_format": "https://lore.kernel.org/linuxppc-dev/{}/", "commit_url_format": "https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/commit/?id={}" }, "msgid": "<41fc5be38d4205b5a4aee8499631cf60a9026163.1774591179.git.sayalip@linux.ibm.com>", "list_archive_url": "https://lore.kernel.org/linuxppc-dev/41fc5be38d4205b5a4aee8499631cf60a9026163.1774591179.git.sayalip@linux.ibm.com/", "date": "2026-03-27T07:16:07", "name": "[v3,13/13] selftests/cgroup: extend test_hugetlb_memcg.c to support all huge page sizes", "commit_ref": null, "pull_url": null, "state": "handled-elsewhere", "archived": false, "hash": "61fc95a2c8494e1cf53e175d2c915e771fc5ad29", "submitter": { "id": 92656, "url": "http://patchwork.ozlabs.org/api/people/92656/?format=api", "name": "Sayali Patil", "email": "sayalip@linux.ibm.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/linuxppc-dev/patch/41fc5be38d4205b5a4aee8499631cf60a9026163.1774591179.git.sayalip@linux.ibm.com/mbox/", "series": [ { "id": 497700, "url": "http://patchwork.ozlabs.org/api/series/497700/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=497700", "date": "2026-03-27T07:15:54", "name": "selftests/mm: fix failures and robustness improvements", "version": 3, "mbox": "http://patchwork.ozlabs.org/series/497700/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2216791/comments/", "check": "success", "checks": "http://patchwork.ozlabs.org/api/patches/2216791/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "\n <linuxppc-dev+bounces-18915-incoming=patchwork.ozlabs.org@lists.ozlabs.org>", "X-Original-To": [ "incoming@patchwork.ozlabs.org", "linuxppc-dev@lists.ozlabs.org" ], "Delivered-To": "patchwork-incoming@legolas.ozlabs.org", "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256\n header.s=pp1 header.b=f+hd0QrZ;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org\n (client-ip=2404:9400:21b9:f100::1; helo=lists.ozlabs.org;\n envelope-from=linuxppc-dev+bounces-18915-incoming=patchwork.ozlabs.org@lists.ozlabs.org;\n receiver=patchwork.ozlabs.org)", "lists.ozlabs.org;\n arc=none smtp.remote-ip=148.163.156.1", "lists.ozlabs.org;\n dmarc=pass (p=none dis=none) header.from=linux.ibm.com", "lists.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256\n header.s=pp1 header.b=f+hd0QrZ;\n\tdkim-atps=neutral", "lists.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=linux.ibm.com\n (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com;\n envelope-from=sayalip@linux.ibm.com; receiver=lists.ozlabs.org)" ], "Received": [ "from lists.ozlabs.org (lists.ozlabs.org\n [IPv6:2404:9400:21b9:f100::1])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fhsT54KYMz1y1j\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 27 Mar 2026 18:19:05 +1100 (AEDT)", "from boromir.ozlabs.org (localhost [127.0.0.1])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 4fhsSL097Yz3fMm;\n\tFri, 27 Mar 2026 18:18:26 +1100 (AEDT)", "from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com\n [148.163.156.1])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n\t(No client certificate requested)\n\tby lists.ozlabs.org (Postfix) with ESMTPS id 4fhsSK21CSz2ygK\n\tfor <linuxppc-dev@lists.ozlabs.org>; Fri, 27 Mar 2026 18:18:25 +1100 (AEDT)", "from pps.filterd (m0353729.ppops.net [127.0.0.1])\n\tby mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id\n 62R2n0Hd3658690;\n\tFri, 27 Mar 2026 07:18:11 GMT", "from ppma11.dal12v.mail.ibm.com\n (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219])\n\tby mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4d1kty8xcw-1\n\t(version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT);\n\tFri, 27 Mar 2026 07:18:10 +0000 (GMT)", "from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1])\n\tby ppma11.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id\n 62R6lvRM004375;\n\tFri, 27 Mar 2026 07:18:09 GMT", "from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229])\n\tby ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 4d28c2e8rp-1\n\t(version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT);\n\tFri, 27 Mar 2026 07:18:09 +0000", "from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com\n [10.20.54.100])\n\tby smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id\n 62R7I5BJ42729776\n\t(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK);\n\tFri, 27 Mar 2026 07:18:05 GMT", "from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1])\n\tby IMSVA (Postfix) with ESMTP id C58E820043;\n\tFri, 27 Mar 2026 07:18:05 +0000 (GMT)", "from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1])\n\tby IMSVA (Postfix) with ESMTP id 4DFF22004B;\n\tFri, 27 Mar 2026 07:18:02 +0000 (GMT)", "from li-3f69264c-2ce6-11b2-a85c-c3f414d24014.ibm.com.com (unknown\n [9.124.208.5])\n\tby smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP;\n\tFri, 27 Mar 2026 07:18:02 +0000 (GMT)" ], "ARC-Seal": "i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1774595905;\n\tcv=none;\n b=asaXYZzoOgCGu20aQqVJ9LkMXIBsWKTyQyZbk0qb9VP6ZiKZFelWT/0pfnmVChekxcuGJljuqR7d3/f++RLnQp6MoIYwf7r25h5UeTA0Zh5tOI+AnA0WTzT/hK/5uH6M4YUv5s+VV0zjpkp7JmQLdSieMA/q2U/JDRgLyOou0JA5N6U6Z+U5rEtjBLV3Nab9dURELHHtx5sXkymI4qcK9pmqNQLuim3TzRlcnvFmzPQ6eD3UcTVgG2hnbfpVxsAVENKNy3RZRpwa2wq1wdbudOUivSddE2QtpXmEBS3WEpBY2UOVwySdKBzF85bOPghGSLFW0xC39y8uyXOIdr1wXA==", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707;\n\tt=1774595905; c=relaxed/relaxed;\n\tbh=tW/GuYujOO0/v8oUPeC7pky7jQo4u6+VMRwG135GnDo=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version:Content-Type;\n b=TyF/yXT0FT2D69whPR4GKj0F+6FJf0Ump2525cAwVzvQwoeOV7LjmXiYIdbMtQ5PCcDgW4lqnpyzFAySWOdyXvfLJHm8pD+Igk/s5EUgZwUpHblzW51HA59hxXO3uPv0JRNDXAirXvOAPwVBta1psBA4EQO3wenZKK116afpenKtyQ2dPTJw0CUdlimxV6Hi6M/z3yq8jlllnRhZMn6KHVorEcBxxRibH1tzjjvfuVdCnvRM/M4CtkqL3TAxPm6kg1XDXe6ZnqS2iFvLrLnaFh3iJ8XpGNyOB0/lSZuYDe+GvLBfZ4Vpsoqi5WPkd3gvA8XP8pb5nvmw6D7E7CGe/Q==", "ARC-Authentication-Results": "i=1; lists.ozlabs.org;\n dmarc=pass (p=none dis=none) header.from=linux.ibm.com;\n dkim=pass (2048-bit key;\n unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256\n header.s=pp1 header.b=f+hd0QrZ; dkim-atps=neutral;\n spf=pass (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com;\n envelope-from=sayalip@linux.ibm.com;\n receiver=lists.ozlabs.org) smtp.mailfrom=linux.ibm.com", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc\n\t:content-transfer-encoding:content-type:date:from:in-reply-to\n\t:message-id:mime-version:references:subject:to; s=pp1; bh=tW/GuY\n\tujOO0/v8oUPeC7pky7jQo4u6+VMRwG135GnDo=; b=f+hd0QrZeVIivoYu1gdOAn\n\tntWfUSB/PZAF92qbDTOw8RdjO/m9Hm5wU68ZAwgsYxSXAjIAaE84FxTd+9K0w0tN\n\tV1cmte8a/bgdDMnxMOiD3L1pBIXZev4127BmXMCKwLcauQ2Q2z52dsWHjz/KYQE8\n\t2ASzX0CLMRcyC1z7ZRhGaLZ+P4JfJevBlJ6/Xzu5WUFS9eXv8oaST2TIcDrQuVk6\n\tFffgznXmCaHXd6JVtFwxQzJtoHu/VJAlHPUJT3BIuGevse5c7JFwQvXcmaIdBOnp\n\tOJOyTtysekC445fZBSD/lbqSM/9pLmUTGXJpNnS7TAuHUhL33VqRDlzta9sjRJLA\n\t==", "From": "Sayali Patil <sayalip@linux.ibm.com>", "To": "Andrew Morton <akpm@linux-foundation.org>, Shuah Khan <shuah@kernel.org>,\n linux-mm@kvack.org, linux-kernel@vger.kernel.org,\n linux-kselftest@vger.kernel.org,\n Ritesh Harjani <ritesh.list@gmail.com>", "Cc": "David Hildenbrand <david@kernel.org>, Zi Yan <ziy@nvidia.com>,\n Michal Hocko <mhocko@kernel.org>, Oscar Salvador <osalvador@suse.de>,\n Lorenzo Stoakes <lorenzo.stoakes@oracle.com>,\n Dev Jain <dev.jain@arm.com>, Liam.Howlett@oracle.com,\n linuxppc-dev@lists.ozlabs.org, Sayali Patil <sayalip@linux.ibm.com>,\n Venkat Rao Bagalkote <venkat88@linux.ibm.com>", "Subject": "[PATCH v3 13/13] selftests/cgroup: extend test_hugetlb_memcg.c to\n support all huge page sizes", "Date": "Fri, 27 Mar 2026 12:46:07 +0530", "Message-ID": "\n <41fc5be38d4205b5a4aee8499631cf60a9026163.1774591179.git.sayalip@linux.ibm.com>", "X-Mailer": "git-send-email 2.52.0", "In-Reply-To": "<cover.1774591179.git.sayalip@linux.ibm.com>", "References": "<cover.1774591179.git.sayalip@linux.ibm.com>", "X-Mailing-List": "linuxppc-dev@lists.ozlabs.org", "List-Id": "<linuxppc-dev.lists.ozlabs.org>", "List-Help": "<mailto:linuxppc-dev+help@lists.ozlabs.org>", "List-Owner": "<mailto:linuxppc-dev+owner@lists.ozlabs.org>", "List-Post": "<mailto:linuxppc-dev@lists.ozlabs.org>", "List-Archive": "<https://lore.kernel.org/linuxppc-dev/>,\n <https://lists.ozlabs.org/pipermail/linuxppc-dev/>", "List-Subscribe": "<mailto:linuxppc-dev+subscribe@lists.ozlabs.org>,\n <mailto:linuxppc-dev+subscribe-digest@lists.ozlabs.org>,\n <mailto:linuxppc-dev+subscribe-nomail@lists.ozlabs.org>", "List-Unsubscribe": "<mailto:linuxppc-dev+unsubscribe@lists.ozlabs.org>", "Precedence": "list", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "X-TM-AS-GCONF": "00", "X-Proofpoint-Reinject": "loops=2 maxloops=12", "X-Authority-Analysis": "v=2.4 cv=IqITsb/g c=1 sm=1 tr=0 ts=69c62f33 cx=c_pps\n a=aDMHemPKRhS1OARIsFnwRA==:117 a=aDMHemPKRhS1OARIsFnwRA==:17\n a=IkcTkHD0fZMA:10 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22\n a=RnoormkPH1_aCDwRdu11:22 a=uAbxVGIbfxUO_5tXvNgY:22 a=VnNF1IyMAAAA:8\n a=sc5eBBQPW9lzBnlyZiYA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10", "X-Proofpoint-Spam-Details-Enc": "AW1haW4tMjYwMzI3MDA1MyBTYWx0ZWRfX7R3ord31TZ8m\n 3AWPD1DeP37V769ZTm5A+vKyEW7h7mKzvq8P3zZ2q6pIDdy0CbejiuqEItg8+1b8dPUj2vvhFDN\n j9bqOsAKfMNOeEoEIMJ56UnYMFyIoai+9HjMTa+2HyfV90GAK39TmBi2EpSRZ8jIa8RPqMRfkhA\n cu30lJlJmSM/jytJcW/A+jknpYX0WRymDBdQobNY42f3kW/T1NuYtKRvgQrpfvNrDiS5EdRt4V7\n Z1Nye6mHR2SjfWFR2wBaFh8tsZlYRWtkxXeiU56gTnvNEUTEAEQF6W3+RJv9iyXf/RWy3suAy3O\n JYopgvAKUcZRRDXATZyPjQJCccZdYTVeuczszcZoh2D8sPmEqouc84pZVHivJa4Ki4Usnx9Qlh7\n Tmdmsg9bt0H4DcqiucdVzSUaGAK/ZaTjCUKi4qrE1Yio3495q7k2NIjelbgIViQuhkJYuqqfQzR\n vVpGZzs5CFGTOFp0Msw==", "X-Proofpoint-GUID": "VJ_xrzwcuXC-vroi3TFYp2X8yZdEDM4A", "X-Proofpoint-ORIG-GUID": "b946YoOhPzDH-DYXEfvGjeWxDd728GXO", "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-03-26_04,2026-03-26_01,2025-10-01_01", "X-Proofpoint-Spam-Details": "rule=outbound_notspam policy=outbound score=0\n malwarescore=0 clxscore=1015 spamscore=0 impostorscore=0 suspectscore=0\n phishscore=0 bulkscore=0 adultscore=0 priorityscore=1501 lowpriorityscore=0\n classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0\n reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2603270053", "X-Spam-Status": "No, score=-0.7 required=3.0 tests=DKIM_SIGNED,DKIM_VALID,\n\tRCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,\n\tSPF_PASS autolearn=disabled version=4.0.1 OzLabs 8", "X-Spam-Checker-Version": "SpamAssassin 4.0.1 (2024-03-25) on lists.ozlabs.org" }, "content": "The hugetlb memcg selftest was previously skipped when the configured\nhuge page size was not 2MB, preventing the test from running on systems\nusing other default huge page sizes.\n\nDetect the system's configured huge page size at runtime and use it for\nthe allocation instead of assuming a fixed 2MB size. This allows the\ntest to run on configurations using non-2MB huge pages and avoids\nunnecessary skips.\n\nFixes: c0dddb7aa5f8 (\"selftests: add a selftest to verify hugetlb usage in memcg\")\nTested-by: Venkat Rao Bagalkote <venkat88@linux.ibm.com>\nSigned-off-by: Sayali Patil <sayalip@linux.ibm.com>\n---\n .../selftests/cgroup/test_hugetlb_memcg.c | 66 ++++++++++++++-----\n 1 file changed, 48 insertions(+), 18 deletions(-)", "diff": "diff --git a/tools/testing/selftests/cgroup/test_hugetlb_memcg.c b/tools/testing/selftests/cgroup/test_hugetlb_memcg.c\nindex f451aa449be6..a449dbec16a8 100644\n--- a/tools/testing/selftests/cgroup/test_hugetlb_memcg.c\n+++ b/tools/testing/selftests/cgroup/test_hugetlb_memcg.c\n@@ -12,10 +12,15 @@\n \n #define ADDR ((void *)(0x0UL))\n #define FLAGS (MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB)\n-/* mapping 8 MBs == 4 hugepages */\n-#define LENGTH (8UL*1024*1024)\n #define PROTECTION (PROT_READ | PROT_WRITE)\n \n+/*\n+ * This value matches the kernel's MEMCG_CHARGE_BATCH definition:\n+ * see include/linux/memcontrol.h. If the kernel value changes, this\n+ * test constant must be updated accordingly to stay consistent.\n+ */\n+#define MEMCG_CHARGE_BATCH 64U\n+\n /* borrowed from mm/hmm-tests.c */\n static long get_hugepage_size(void)\n {\n@@ -84,11 +89,11 @@ static unsigned int check_first(char *addr)\n \treturn *(unsigned int *)addr;\n }\n \n-static void write_data(char *addr)\n+static void write_data(char *addr, size_t length)\n {\n \tunsigned long i;\n \n-\tfor (i = 0; i < LENGTH; i++)\n+\tfor (i = 0; i < length; i++)\n \t\t*(addr + i) = (char)i;\n }\n \n@@ -96,26 +101,31 @@ static int hugetlb_test_program(const char *cgroup, void *arg)\n {\n \tchar *test_group = (char *)arg;\n \tvoid *addr;\n+\tlong hpage_size = get_hugepage_size() * 1024;\n \tlong old_current, expected_current, current;\n \tint ret = EXIT_FAILURE;\n+\tsize_t length = 4 * hpage_size;\n+\tint pagesize, nr_pages;\n+\n+\tpagesize = getpagesize();\n \n \told_current = cg_read_long(test_group, \"memory.current\");\n \tset_nr_hugepages(20);\n \tcurrent = cg_read_long(test_group, \"memory.current\");\n-\tif (current - old_current >= MB(2)) {\n+\tif (current - old_current >= hpage_size) {\n \t\tksft_print_msg(\n \t\t\t\"setting nr_hugepages should not increase hugepage usage.\\n\");\n \t\tksft_print_msg(\"before: %ld, after: %ld\\n\", old_current, current);\n \t\treturn EXIT_FAILURE;\n \t}\n \n-\taddr = mmap(ADDR, LENGTH, PROTECTION, FLAGS, 0, 0);\n+\taddr = mmap(ADDR, length, PROTECTION, FLAGS, 0, 0);\n \tif (addr == MAP_FAILED) {\n \t\tksft_print_msg(\"fail to mmap.\\n\");\n \t\treturn EXIT_FAILURE;\n \t}\n \tcurrent = cg_read_long(test_group, \"memory.current\");\n-\tif (current - old_current >= MB(2)) {\n+\tif (current - old_current >= hpage_size) {\n \t\tksft_print_msg(\"mmap should not increase hugepage usage.\\n\");\n \t\tksft_print_msg(\"before: %ld, after: %ld\\n\", old_current, current);\n \t\tgoto out_failed_munmap;\n@@ -124,10 +134,24 @@ static int hugetlb_test_program(const char *cgroup, void *arg)\n \n \t/* read the first page */\n \tcheck_first(addr);\n-\texpected_current = old_current + MB(2);\n+\tnr_pages = hpage_size / pagesize;\n+\texpected_current = old_current + hpage_size;\n \tcurrent = cg_read_long(test_group, \"memory.current\");\n-\tif (!values_close(expected_current, current, 5)) {\n-\t\tksft_print_msg(\"memory usage should increase by around 2MB.\\n\");\n+\tif (nr_pages < MEMCG_CHARGE_BATCH && current == old_current) {\n+\t\t/*\n+\t\t * Memory cgroup charging uses per-CPU stocks and batched updates to the\n+\t\t * memcg usage counters. For hugetlb allocations, the number of pages\n+\t\t * that memcg charges is expressed in base pages (nr_pages), not\n+\t\t * in hugepage units. When the charge for an allocation is smaller than\n+\t\t * the internal batching threshold (nr_pages < MEMCG_CHARGE_BATCH),\n+\t\t * it may be fully satisfied from the CPU’s local stock. In such\n+\t\t * cases memory.current does not necessarily\n+\t\t * increase.\n+\t\t * Therefore, Treat a zero delta as valid behaviour here.\n+\t\t */\n+\t\tksft_print_msg(\"no visible memcg charge, allocation consumed from local stock.\\n\");\n+\t} else if (!values_close(expected_current, current, 5)) {\n+\t\tksft_print_msg(\"memory usage should increase by ~1 huge page.\\n\");\n \t\tksft_print_msg(\n \t\t\t\"expected memory: %ld, actual memory: %ld\\n\",\n \t\t\texpected_current, current);\n@@ -135,11 +159,11 @@ static int hugetlb_test_program(const char *cgroup, void *arg)\n \t}\n \n \t/* write to the whole range */\n-\twrite_data(addr);\n+\twrite_data(addr, length);\n \tcurrent = cg_read_long(test_group, \"memory.current\");\n-\texpected_current = old_current + MB(8);\n+\texpected_current = old_current + length;\n \tif (!values_close(expected_current, current, 5)) {\n-\t\tksft_print_msg(\"memory usage should increase by around 8MB.\\n\");\n+\t\tksft_print_msg(\"memory usage should increase by around 4 huge pages.\\n\");\n \t\tksft_print_msg(\n \t\t\t\"expected memory: %ld, actual memory: %ld\\n\",\n \t\t\texpected_current, current);\n@@ -147,7 +171,7 @@ static int hugetlb_test_program(const char *cgroup, void *arg)\n \t}\n \n \t/* unmap the whole range */\n-\tmunmap(addr, LENGTH);\n+\tmunmap(addr, length);\n \tcurrent = cg_read_long(test_group, \"memory.current\");\n \texpected_current = old_current;\n \tif (!values_close(expected_current, current, 5)) {\n@@ -162,13 +186,15 @@ static int hugetlb_test_program(const char *cgroup, void *arg)\n \treturn ret;\n \n out_failed_munmap:\n-\tmunmap(addr, LENGTH);\n+\tmunmap(addr, length);\n \treturn ret;\n }\n \n static int test_hugetlb_memcg(char *root)\n {\n \tint ret = KSFT_FAIL;\n+\tint num_pages = 20;\n+\tlong hpage_size = get_hugepage_size();\n \tchar *test_group;\n \n \ttest_group = cg_name(root, \"hugetlb_memcg_test\");\n@@ -177,7 +203,7 @@ static int test_hugetlb_memcg(char *root)\n \t\tgoto out;\n \t}\n \n-\tif (cg_write(test_group, \"memory.max\", \"100M\")) {\n+\tif (cg_write_numeric(test_group, \"memory.max\", num_pages * hpage_size * 1024)) {\n \t\tksft_print_msg(\"fail to set cgroup memory limit.\\n\");\n \t\tgoto out;\n \t}\n@@ -200,6 +226,7 @@ int main(int argc, char **argv)\n {\n \tchar root[PATH_MAX];\n \tint ret = EXIT_SUCCESS, has_memory_hugetlb_acc;\n+\tlong val;\n \n \thas_memory_hugetlb_acc = proc_mount_contains(\"memory_hugetlb_accounting\");\n \tif (has_memory_hugetlb_acc < 0)\n@@ -208,12 +235,15 @@ int main(int argc, char **argv)\n \t\tksft_exit_skip(\"memory hugetlb accounting is disabled\\n\");\n \n \t/* Unit is kB! */\n-\tif (get_hugepage_size() != 2048) {\n-\t\tksft_print_msg(\"test_hugetlb_memcg requires 2MB hugepages\\n\");\n+\tval = get_hugepage_size();\n+\tif (val < 0) {\n+\t\tksft_print_msg(\"Failed to read hugepage size\\n\");\n \t\tksft_test_result_skip(\"test_hugetlb_memcg\\n\");\n \t\treturn ret;\n \t}\n \n+\tksft_print_msg(\"Hugepage size: %ld kB\\n\", val);\n+\n \tif (cg_find_unified_root(root, sizeof(root), NULL))\n \t\tksft_exit_skip(\"cgroup v2 isn't mounted\\n\");\n \n", "prefixes": [ "v3", "13/13" ] }