[folded-merged] mm-memcg-cg2-memoryswappeak-write-tests-v7.patch removed from -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The quilt patch titled
     Subject: mm, memcg: cg2 memory{.swap,}.peak write tests
has been removed from the -mm tree.  Its filename was
     mm-memcg-cg2-memoryswappeak-write-tests-v7.patch

This patch was dropped because it was folded into mm-memcg-cg2-memoryswappeak-write-tests.patch

------------------------------------------------------
From: David Finkel <davidf@xxxxxxxxx>
Subject: mm, memcg: cg2 memory{.swap,}.peak write tests
Date: Tue, 30 Jul 2024 19:13:04 -0400

update tests

Link: https://lkml.kernel.org/r/20240730231304.761942-3-davidf@xxxxxxxxx
Signed-off-by: David Finkel <davidf@xxxxxxxxx>
Acked-by: Tejun Heo <tj@xxxxxxxxxx>
Cc: Johannes Weiner <hannes@xxxxxxxxxxx>
Cc: Jonathan Corbet <corbet@xxxxxxx>
Cc: Michal Hocko <mhocko@xxxxxxxxxx>
Cc: Michal Koutný <mkoutny@xxxxxxxx>
Cc: Muchun Song <muchun.song@xxxxxxxxx>
Cc: Roman Gushchin <roman.gushchin@xxxxxxxxx>
Cc: Shakeel Butt <shakeel.butt@xxxxxxxxx>
Cc: Shuah Khan <shuah@xxxxxxxxxx>
Cc: Waiman Long <longman@xxxxxxxxxx>
Cc: Zefan Li <lizefan.x@xxxxxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

 tools/testing/selftests/cgroup/test_memcontrol.c |   49 +++++++++++--
 1 file changed, 42 insertions(+), 7 deletions(-)

--- a/tools/testing/selftests/cgroup/test_memcontrol.c~mm-memcg-cg2-memoryswappeak-write-tests-v7
+++ a/tools/testing/selftests/cgroup/test_memcontrol.c
@@ -170,6 +170,7 @@ static int test_memcg_current_peak(const
 	char *memcg;
 	bool fd2_closed = false, fd3_closed = false, fd4_closed = false;
 	int peak_fd = -1, peak_fd2 = -1, peak_fd3 = -1, peak_fd4 = -1;
+	struct stat ss;
 
 	memcg = cg_name(root, "memcg_test");
 	if (!memcg)
@@ -200,9 +201,25 @@ static int test_memcg_current_peak(const
 	 */
 	peak_fd = cg_open(memcg, "memory.peak", O_RDWR | O_APPEND | O_CLOEXEC);
 
-	if (peak_fd == -1)
+	if (peak_fd == -1) {
+		if (errno == ENOENT)
+			ret = KSFT_SKIP;
+		goto cleanup;
+	}
+
+	/*
+	 * Before we try to use memory.peak's fd, try to figure out whether
+	 * this kernel supports writing to that file in the first place. (by
+	 * checking the writable bit on the file's st_mode)
+	 */
+	if (fstat(peak_fd, &ss))
 		goto cleanup;
 
+	if ((ss.st_mode & S_IWUSR) == 0) {
+		ret = KSFT_SKIP;
+		goto cleanup;
+	}
+
 	peak_fd2 = cg_open(memcg, "memory.peak", O_RDWR | O_APPEND | O_CLOEXEC);
 
 	if (peak_fd2 == -1)
@@ -920,6 +937,8 @@ static int test_memcg_swap_max_peak(cons
 	int ret = KSFT_FAIL;
 	char *memcg;
 	long max, peak;
+	struct stat ss;
+	int swap_peak_fd = -1, mem_peak_fd = -1;
 
 	/* any non-empty string resets */
 	static const char reset_string[] = "foobarbaz";
@@ -939,13 +958,29 @@ static int test_memcg_swap_max_peak(cons
 		goto cleanup;
 	}
 
-	int swap_peak_fd = cg_open(memcg, "memory.swap.peak",
-				   O_RDWR | O_APPEND | O_CLOEXEC);
+	swap_peak_fd = cg_open(memcg, "memory.swap.peak",
+			       O_RDWR | O_APPEND | O_CLOEXEC);
 
-	if (swap_peak_fd == -1)
+	if (swap_peak_fd == -1) {
+		if (errno == ENOENT)
+			ret = KSFT_SKIP;
+		goto cleanup;
+	}
+
+	/*
+	 * Before we try to use memory.swap.peak's fd, try to figure out
+	 * whether this kernel supports writing to that file in the first
+	 * place. (by checking the writable bit on the file's st_mode)
+	 */
+	if (fstat(swap_peak_fd, &ss))
 		goto cleanup;
 
-	int mem_peak_fd = cg_open(memcg, "memory.peak", O_RDWR | O_APPEND | O_CLOEXEC);
+	if ((ss.st_mode & S_IWUSR) == 0) {
+		ret = KSFT_SKIP;
+		goto cleanup;
+	}
+
+	mem_peak_fd = cg_open(memcg, "memory.peak", O_RDWR | O_APPEND | O_CLOEXEC);
 
 	if (mem_peak_fd == -1)
 		goto cleanup;
@@ -1081,9 +1116,9 @@ static int test_memcg_swap_max_peak(cons
 	ret = KSFT_PASS;
 
 cleanup:
-	if (close(mem_peak_fd))
+	if (mem_peak_fd != -1 && close(mem_peak_fd))
 		ret = KSFT_FAIL;
-	if (close(swap_peak_fd))
+	if (swap_peak_fd != -1 && close(swap_peak_fd))
 		ret = KSFT_FAIL;
 	cg_destroy(memcg);
 	free(memcg);
_

Patches currently in -mm which might be from davidf@xxxxxxxxx are

mm-memcg-cg2-memoryswappeak-write-handlers.patch
mm-memcg-cg2-memoryswappeak-write-tests.patch





[Index of Archives]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux