[LTP] [PATCH v2 3/3] memcontrol02: Increase expected error with increase in pagesize

Richard Palethorpe rpalethorpe@suse.com
Tue Jan 25 15:49:23 CET 2022


A few percent seems to be wasted with the increase in page size from
4k to 64k in these tests. For some reason, this appears to cause the
test to fail on exfat on the anon test, but only exfat. We add 4% to
the error for 64k pages.

Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com>
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
---
 testcases/kernel/controllers/memcg/memcontrol02.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/testcases/kernel/controllers/memcg/memcontrol02.c b/testcases/kernel/controllers/memcg/memcontrol02.c
index 75ae5f56c..9fa4ff811 100644
--- a/testcases/kernel/controllers/memcg/memcontrol02.c
+++ b/testcases/kernel/controllers/memcg/memcontrol02.c
@@ -39,13 +39,17 @@ static int fd;
 static int file_to_all_error = 10;
 
 /*
- * Checks if two given values differ by less than err% of their sum.
+ * Checks if two given values differ by less than err% of their
+ * sum. An extra percent is added for every doubling of the page size
+ * to compensate for wastage in page sized allocations.
  */
 static inline int values_close(const ssize_t a,
 			       const ssize_t b,
 			       const ssize_t err)
 {
-	return 100 * labs(a - b) <= (a + b) * err;
+	const ssize_t page_adjusted_err = ffs(page_size >> 13) + err;
+
+	return 100 * labs(a - b) <= (a + b) * page_adjusted_err;
 }
 
 static void alloc_anon_50M_check(void)
-- 
2.34.1



More information about the ltp mailing list