public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] memcg_process: cleanup the SHM segment
@ 2016-09-02 12:24 Stanislav Kholmanskikh
  2016-09-06 16:01 ` Cyril Hrubis
  0 siblings, 1 reply; 3+ messages in thread
From: Stanislav Kholmanskikh @ 2016-09-02 12:24 UTC (permalink / raw)
  To: ltp

Let's mark the segment for removal right after we attach it.
This way memcg* test cases will no longer leave unused
segments after they finish.

Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
---
 .../controllers/memcg/functional/memcg_process.c   |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/testcases/kernel/controllers/memcg/functional/memcg_process.c b/testcases/kernel/controllers/memcg/functional/memcg_process.c
index fbb76e2..e2c60de 100644
--- a/testcases/kernel/controllers/memcg/functional/memcg_process.c
+++ b/testcases/kernel/controllers/memcg/functional/memcg_process.c
@@ -234,9 +234,6 @@ static void shm(void)
 		if (key == -1)
 			err(1, "ftok() failed");
 
-		shmid = shmget(key, memsize, flag);
-		if (shmid == -1)
-			err(1, "shmget() failed");
 		shmctl(shmid, IPC_RMID, NULL);
 
 		shmid = shmget(key, memsize, flag);
@@ -248,12 +245,14 @@ static void shm(void)
 			shmctl(shmid, IPC_RMID, NULL);
 			err(1, "shmat() failed");
 		}
+
+		if (shmctl(shmid, IPC_RMID, NULL) == -1)
+			err(1, "shmctl() failed");
+
 		touch_memory(p, memsize);
 	} else {
 		if (shmdt(p) == -1)
 			err(1, "shmdt() failed");
-		if (shmctl(shmid, IPC_RMID, NULL) == -1)
-			err(1, "shmctl() failed");
 	}
 }
 
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-09-08  9:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-02 12:24 [LTP] [PATCH] memcg_process: cleanup the SHM segment Stanislav Kholmanskikh
2016-09-06 16:01 ` Cyril Hrubis
2016-09-08  9:39   ` Stanislav Kholmanskikh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox