On Fri, Sep 24, 2010 at 6:21 AM, Jan Tluka <[email protected]> wrote:
> Resending ...
>
> I've noticed that in some cases the hugeshmget05 testcase is not
> cleaning up properly after itself. It leaves hugepages reserved and
> does not free them. This could break further test runs.
>
> I think the problem is with signal handling. The testcase will do
> rm_shm() only if it ends up properly. In case it's being killed by
> SIGTERM signal (as seen from the testlog) the cleanup() function does
> not return shared memory.
>
> Without the patch I have to use ipcrm to remove all hugepages reserved
> and not returned.
>
> # grep -i unexpected RHEL-hugepage.run.log
> hugeshmget05    1  TBROK  :  Unexpected signal 15 received.
> # ipcs -m
> ------ Shared Memory Segments --------
> key        shmid      owner      perms      bytes      nattch     status
> 0x7400ee08 3932160    root      600        4          0
> 0x7400edde 4620289    root      600        4          0
> 0x00000000 4980738    gdm       600        393216     2          dest
> 0x7400eddd 4587523    root      600        4          0
> 0x78002a3b 64552964   root      600        209715200  0
> 0x78002a38 64520197   root      600        209715200  0
> # ipcrm -m 64552964 -m 64520197
>
> With the patch the test returns hugepages back to the system even if it
> gets signal 15.
>
> Checked on RHEL5.5.
>
> Thanks, Jan
>
>
> The patch follows,
>
>
> --- ltp-full-20100831/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget05.c  
>   2010-09-14 13:04:33.000000000 +0200
> +++ 
> ltp-full-20100831.new/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget05.c  
>       2010-09-24 13:47:19.413177300 +0200
> @@ -105,7 +105,6 @@
>
>                do_child();
>
> -               cleanup();
>
>                /*NOTREACHED*/
>        } else {                /* parent */
> @@ -114,11 +113,10 @@
>                        tst_brkm(TBROK, cleanup, "waitpid failed");
>                }
>
> -               /* if it exists, remove the shared memory resource */
> -               rm_shm(shm_id_1);
> -
>                /* Remove the temporary directory */
>                tst_rmdir();
> +
> +               cleanup();
>        }
>        return 0;
>  }
> @@ -209,6 +207,9 @@
>  void
>  cleanup(void)
>  {
> +       /* if it exists, remove the shared memory resource */
> +       rm_shm(shm_id_1);
> +
>        /*
>         * print timing stats if that option was specified.
>         * print errno log if that option was specified.

Hi Jan,
    I spotted some other potential issues with the test. Please try
this patch and let me know whether or not it works for you .
Cheers,
-Garrett
diff --git a/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget05.c b/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget05.c
index bc4bd2c..3e9e26a 100644
--- a/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget05.c
+++ b/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget05.c
@@ -77,7 +77,8 @@ char *ltp_user = "nobody";
 int main(int ac, char **av)
 {
 	char *msg;			/* message returned from parse_opts */
-	int pid;
+	pid_t pid;
+	int status;
 	void do_child(void);
 
 	/* parse standard options */
@@ -105,21 +106,22 @@ int main(int ac, char **av)
 
 		do_child();
 
-		cleanup();
-
+		tst_exit();
 		/*NOTREACHED*/
 	} else {		/* parent */
 		/* wait for the child to return */
-		if (waitpid(pid, NULL, 0) == -1) {
-			tst_brkm(TBROK, cleanup, "waitpid failed");
+		if (waitpid(pid, &status, 0) == -1) {
+			tst_resm(TBROK, "waitpid failed");
+		}
+		else if (status != 0) {
+			tst_resm(TFAIL,	"child process failed to exit cleanly "
+				"(exit status = %d)", status);
 		}
+	}
 
-		/* if it exists, remove the shared memory resource */
-		rm_shm(shm_id_1);
+	cleanup();
 
-		/* Remove the temporary directory */
-		tst_rmdir();
-	}
+	/* NOTREACHED */
 	return 0;
 }
 
@@ -152,13 +154,11 @@ do_child()
 
 		switch(TEST_ERRNO) {
 		case EACCES:
-			tst_resm(TPASS, "expected failure - errno = "
-				 "%d : %s", TEST_ERRNO, strerror(TEST_ERRNO));
+			tst_resm(TPASS|TTERRNO, "expected failure");
 			break;
 		default:
-			tst_resm(TFAIL, "call failed with an "
-				 "unexpected error - %d : %s",
-				 TEST_ERRNO, strerror(TEST_ERRNO));
+			tst_resm(TFAIL|TTERRNO, "call failed with an "
+				 "unexpected error");
 			break;
 		}		
 	}
@@ -209,6 +209,9 @@ setup(void)
 void
 cleanup(void)
 {
+	/* if it exists, remove the shared memory resource */
+	rm_shm(shm_id_1);
+
 	/*
 	 * print timing stats if that option was specified.
 	 * print errno log if that option was specified.
------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to