Skip to contentSkip to conversation

memcontrol02: Add VFAT/MSDOS magic and set error to 50% for it also

PATCH Superseded Richard Palethorpe via ltp 3 participants 12 messages Jan 24, 2022 – Jan 25, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 memcontrol02: Add VFAT/MSDOS magic and set error to 50% for it also

VFAT also allocates some extra non-pagecache memory for tracking buffers.

---
 include/tst_fs.h                                  | 1 +
 testcases/kernel/controllers/memcg/memcontrol02.c | 1 +
 2 files changed, 2 insertions(+)
include/tst_fs.h +1 -0
index efcdff608..3bab9da8b 100644
@@ -30,6 +30,7 @@
 #define TST_EXOFS_MAGIC    0x5DF5
 #define TST_OVERLAYFS_MAGIC 0x794c7630
 #define TST_FUSE_MAGIC     0x65735546
+#define TST_VFAT_MAGIC     0x4d44 /* AKA MSDOS */
 #define TST_EXFAT_MAGIC    0x2011BAB0UL
 
 enum {
testcases/kernel/controllers/memcg/memcontrol02.c +1 -0
index 0b8f317a8..411f5aea6 100644
@@ -153,6 +153,7 @@ static void setup(void)
 	cg_test = tst_cgroup_get_test_group();
 
 	switch (tst_fs_type(TMPDIR)) {
+	case TST_VFAT_MAGIC:
 	case TST_EXFAT_MAGIC:
 	case TST_EXT234_MAGIC:
 		file_to_all_error = 50;
Signature · 5 lines
2.34.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

PATCH 2/3 memcontrol02: Fix anon memory comparison

All memory is being compared with the size malloc'ed instead of just anon.

---
 testcases/kernel/controllers/memcg/memcontrol02.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/controllers/memcg/memcontrol02.c +1 -1
index 411f5aea6..0d144cf2d 100644
@@ -68,7 +68,7 @@ static void alloc_anon_50M_check(void)
 
 	TST_EXP_EXPR(anon > 0, "(memory.stat.anon=%zd) > 0", anon);
 	TST_EXP_EXPR(values_close(size, current, 3),
-		     "(size=%zd) ~= (memory.stat.anon=%zd)", size, current);
+		     "(size=%zd) ~= (memory.stat.anon=%zd)", size, anon);
 	TST_EXP_EXPR(values_close(anon, current, 3),
 		     "(memory.current=%zd) ~= (memory.stat.anon=%zd)",
 		     current, anon);
Signature · 5 lines
2.34.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#2 lore raw

Re: [LTP] [PATCH 2/3] memcontrol02: Fix anon memory comparison

Hi!

Quoted 13 lines

All memory is being compared with the size malloc'ed instead of just anon.

---
 testcases/kernel/controllers/memcg/memcontrol02.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/controllers/memcg/memcontrol02.c +0 -0
index 411f5aea6..0d144cf2d 100644

testcases/kernel/controllers/memcg/memcontrol02.c static void alloc_anon_50M_check(void) · line 71

Quoted 5 lines
testcases/kernel/controllers/memcg/memcontrol02.c +1 -1
@@ -68,7 +68,7 @@ static void alloc_anon_50M_check(void)
 
 	TST_EXP_EXPR(anon > 0, "(memory.stat.anon=%zd) > 0", anon);
 	TST_EXP_EXPR(values_close(size, current, 3),
-		     "(size=%zd) ~= (memory.stat.anon=%zd)", size, current);
+		     "(size=%zd) ~= (memory.stat.anon=%zd)", size, anon);

I do not get this, we compare size and current and then print anon?

Should we just change the memory.stat.annon to memory.current instead?

Quoted 9 lines
testcases/kernel/controllers/memcg/memcontrol02.c +0 -0
 	TST_EXP_EXPR(values_close(anon, current, 3),
 		     "(memory.current=%zd) ~= (memory.stat.anon=%zd)",
 		     current, anon);
Signature · 5 lines
2.34.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#3 lore raw

Re: [LTP] [PATCH 2/3] memcontrol02: Fix anon memory comparison

Hi!

Quoted 14 lines
Quoted 14 lines

All memory is being compared with the size malloc'ed instead of just anon.

---
 testcases/kernel/controllers/memcg/memcontrol02.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/controllers/memcg/memcontrol02.c +0 -0
index 411f5aea6..0d144cf2d 100644
@@ -68,7 +68,7 @@ static void alloc_anon_50M_check(void)
 
Quoted 8 lines

testcases/kernel/controllers/memcg/memcontrol02.c static void alloc_anon_50M_check(void) · line 71

Quoted 4 lines
testcases/kernel/controllers/memcg/memcontrol02.c +1 -1
 	TST_EXP_EXPR(anon > 0, "(memory.stat.anon=%zd) > 0", anon);
 	TST_EXP_EXPR(values_close(size, current, 3),
-		     "(size=%zd) ~= (memory.stat.anon=%zd)", size, current);
+		     "(size=%zd) ~= (memory.stat.anon=%zd)", size, anon);

I do not get this, we compare size and current and then print anon?

Should we just change the memory.stat.annon to memory.current instead?

Or did you forget to change the current in the values_close() to annon as well?

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#4 lore raw

Re: [LTP] [PATCH 2/3] memcontrol02: Fix anon memory comparison

Hello,

Quoted 22 lines · Cyril Hrubis

Hi!

Quoted 21 lines
Quoted 13 lines

All memory is being compared with the size malloc'ed instead of just anon.

---
 testcases/kernel/controllers/memcg/memcontrol02.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/controllers/memcg/memcontrol02.c +0 -0
index 411f5aea6..0d144cf2d 100644

testcases/kernel/controllers/memcg/memcontrol02.c static void alloc_anon_50M_check(void) · line 71

Quoted 5 lines
testcases/kernel/controllers/memcg/memcontrol02.c +1 -1
@@ -68,7 +68,7 @@ static void alloc_anon_50M_check(void)
 
 	TST_EXP_EXPR(anon > 0, "(memory.stat.anon=%zd) > 0", anon);
 	TST_EXP_EXPR(values_close(size, current, 3),
-		     "(size=%zd) ~= (memory.stat.anon=%zd)", size, current);
+		     "(size=%zd) ~= (memory.stat.anon=%zd)", size, anon);

I do not get this, we compare size and current and then print anon?

Quoted 4 lines
Quoted 1 line

Should we just change the memory.stat.annon to memory.current instead?

Or did you forget to change the current in the values_close() to annon as well?

Yeah, sorry!

Signature · 5 lines
Thank you,
Richard.

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#5 lore raw

PATCH 3/3 memcontrol02: Increase expected error with increase in pagesize

In reply to Richard Palethorpe via ltp

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.

---
 testcases/kernel/controllers/memcg/memcontrol02.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
testcases/kernel/controllers/memcg/memcontrol02.c +6 -2
index 0d144cf2d..fbf5f0469 100644
@@ -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)
Signature · 5 lines
2.34.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#8 lore raw

PATCH v2 1/3 memcontrol02: Add VFAT/MSDOS magic and set error to 50% for it also

In reply to Richard Palethorpe via ltp

VFAT also allocates some extra non-pagecache memory for tracking buffers.

---
 include/tst_fs.h                                  | 1 +
 testcases/kernel/controllers/memcg/memcontrol02.c | 1 +
 2 files changed, 2 insertions(+)
include/tst_fs.h +1 -0
index efcdff608..3bab9da8b 100644
@@ -30,6 +30,7 @@
 #define TST_EXOFS_MAGIC    0x5DF5
 #define TST_OVERLAYFS_MAGIC 0x794c7630
 #define TST_FUSE_MAGIC     0x65735546
+#define TST_VFAT_MAGIC     0x4d44 /* AKA MSDOS */
 #define TST_EXFAT_MAGIC    0x2011BAB0UL
 
 enum {
testcases/kernel/controllers/memcg/memcontrol02.c +1 -0
index 0b8f317a8..411f5aea6 100644
@@ -153,6 +153,7 @@ static void setup(void)
 	cg_test = tst_cgroup_get_test_group();
 
 	switch (tst_fs_type(TMPDIR)) {
+	case TST_VFAT_MAGIC:
 	case TST_EXFAT_MAGIC:
 	case TST_EXT234_MAGIC:
 		file_to_all_error = 50;
Signature · 5 lines
2.34.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#9 lore raw

PATCH v2 2/3 memcontrol02: Fix anon memory comparison

All memory is being compared with the size malloc'ed instead of just anon.

---
 testcases/kernel/controllers/memcg/memcontrol02.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
testcases/kernel/controllers/memcg/memcontrol02.c +2 -2
index 411f5aea6..75ae5f56c 100644
@@ -67,8 +67,8 @@ static void alloc_anon_50M_check(void)
 	SAFE_CGROUP_LINES_SCANF(cg_child, "memory.stat", anon_key_fmt, &anon);
 
 	TST_EXP_EXPR(anon > 0, "(memory.stat.anon=%zd) > 0", anon);
-	TST_EXP_EXPR(values_close(size, current, 3),
-		     "(size=%zd) ~= (memory.stat.anon=%zd)", size, current);
+	TST_EXP_EXPR(values_close(size, anon, 3),
+		     "(size=%zd) ~= (memory.stat.anon=%zd)", size, anon);
 	TST_EXP_EXPR(values_close(anon, current, 3),
 		     "(memory.current=%zd) ~= (memory.stat.anon=%zd)",
 		     current, anon);
Signature · 5 lines
2.34.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#11 lore raw

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

In reply to Richard Palethorpe via ltp

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.

---
 testcases/kernel/controllers/memcg/memcontrol02.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
testcases/kernel/controllers/memcg/memcontrol02.c +6 -2
index 75ae5f56c..9fa4ff811 100644
@@ -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)
Signature · 5 lines
2.34.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp