public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] madvise/madvise02.c: extend EINVAL test for MADV_MERGEABLE and MADV_UNMERGEABLE advice
@ 2014-01-16 10:26 Xiaoguang Wang
  2014-02-25  3:22 ` Xiaoguang Wang
  0 siblings, 1 reply; 2+ messages in thread
From: Xiaoguang Wang @ 2014-01-16 10:26 UTC (permalink / raw)
  To: ltp-list

Signed-off-by: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
---
 testcases/kernel/syscalls/madvise/madvise02.c | 38 ++++++++++++++++++++++++---
 1 file changed, 34 insertions(+), 4 deletions(-)

diff --git a/testcases/kernel/syscalls/madvise/madvise02.c b/testcases/kernel/syscalls/madvise/madvise02.c
index e7f4656..08ed717 100644
--- a/testcases/kernel/syscalls/madvise/madvise02.c
+++ b/testcases/kernel/syscalls/madvise/madvise02.c
@@ -27,6 +27,8 @@
  *  2. advice is not a valid value
  *  3. application is attempting to release
  *     locked or shared pages (with MADV_DONTNEED)
+ *  4. MADV_MERGEABLE or MADV_UNMERGEABLE was specified in advice,
+ *     but kernel was not configured with CONFIG_KSM
  *
  * (B) Test Case for ENOMEM
  *  4. addresses in the specified range are not currently mapped
@@ -52,9 +54,14 @@
 #include "usctest.h"
 
 #define MM_RLIMIT_RSS 5
+/*
+ * when kernel is 2.6.32 or newer and /sys/kernel/mm/ksm is exist,
+ * we think kernel was configured with CONFIG_KSM.
+ */
+#define KSM_SYS_DIR	"/sys/kernel/mm/ksm"
 
 char *TCID = "madvise02";
-int TST_TOTAL = 7;
+int TST_TOTAL = 8;
 
 static void setup(void);
 static void cleanup(void);
@@ -128,11 +135,34 @@ int main(int argc, char *argv[])
 		TEST(madvise(file, stat.st_size, MADV_DONTNEED));
 		check_and_print(EINVAL);
 
-		if (munmap(file, stat.st_size) == -1)
-			tst_brkm(TBROK | TERRNO, cleanup, "munmap failed");
 #endif /* if !defined(UCLINUX) */
 
+#if defined(MADV_MERGEABLE) && defined(MADV_UNMERGEABLE)
 		/* Test Case 4 */
+		if (tst_kvercmp(2, 6, 32) < 0) {
+			tst_resm(TCONF, "kernel samepage merging (KSM) needs "
+				 "2.6.32 or higher, skip EINVAL test for "
+				 "MADV_MERGEABLE and MADV_UNMERGEABLE.");
+		} else {
+			if (access(KSM_SYS_DIR, F_OK) < 0) {
+				tst_resm(TINFO, "kernel was not configured "
+					 "with CONFIG_KSM");
+
+				TEST(madvise(file, stat.st_size,
+				     MADV_MERGEABLE));
+				check_and_print(EINVAL);
+
+				TEST(madvise(file, stat.st_size,
+				     MADV_UNMERGEABLE));
+				check_and_print(EINVAL);
+			}
+		}
+#endif
+
+		if (munmap(file, stat.st_size) == -1)
+			tst_brkm(TBROK | TERRNO, cleanup, "munmap failed");
+
+		/* Test Case 5 */
 
 		/* We cannot be sure, which region is mapped, which is
 		 * not, at runtime.
@@ -169,7 +199,7 @@ int main(int argc, char *argv[])
 		TEST(madvise(low, len, MADV_NORMAL));
 		check_and_print(ENOMEM);
 
-		/* Test Case 5 */
+		/* Test Case 6 */
 		/* Unmap the file map from low */
 		if (munmap(low, stat.st_size / 2) < 0)
 			tst_brkm(TBROK | TERRNO, cleanup,
-- 
1.8.2.1


------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today. 
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH] madvise/madvise02.c: extend EINVAL test for MADV_MERGEABLE and MADV_UNMERGEABLE advice
  2014-01-16 10:26 [LTP] [PATCH] madvise/madvise02.c: extend EINVAL test for MADV_MERGEABLE and MADV_UNMERGEABLE advice Xiaoguang Wang
@ 2014-02-25  3:22 ` Xiaoguang Wang
  0 siblings, 0 replies; 2+ messages in thread
From: Xiaoguang Wang @ 2014-02-25  3:22 UTC (permalink / raw)
  Cc: ltp-list

Hi,
 
Please ignore this patch. I do something wrong, thanks.

Regards,
Xiaoguang Wang


On 02/25/2014 11:09 AM, Xiaoguang Wang wrote:
> From: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
>
> Signed-off-by: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
> ---
>  testcases/kernel/syscalls/madvise/madvise02.c | 38 ++++++++++++++++++++++++---
>  1 file changed, 34 insertions(+), 4 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/madvise/madvise02.c b/testcases/kernel/syscalls/madvise/madvise02.c
> index e7f4656..08ed717 100644
> --- a/testcases/kernel/syscalls/madvise/madvise02.c
> +++ b/testcases/kernel/syscalls/madvise/madvise02.c
> @@ -27,6 +27,8 @@
>   *  2. advice is not a valid value
>   *  3. application is attempting to release
>   *     locked or shared pages (with MADV_DONTNEED)
> + *  4. MADV_MERGEABLE or MADV_UNMERGEABLE was specified in advice,
> + *     but kernel was not configured with CONFIG_KSM
>   *
>   * (B) Test Case for ENOMEM
>   *  4. addresses in the specified range are not currently mapped
> @@ -52,9 +54,14 @@
>  #include "usctest.h"
>  
>  #define MM_RLIMIT_RSS 5
> +/*
> + * when kernel is 2.6.32 or newer and /sys/kernel/mm/ksm is exist,
> + * we think kernel was configured with CONFIG_KSM.
> + */
> +#define KSM_SYS_DIR	"/sys/kernel/mm/ksm"
>  
>  char *TCID = "madvise02";
> -int TST_TOTAL = 7;
> +int TST_TOTAL = 8;
>  
>  static void setup(void);
>  static void cleanup(void);
> @@ -128,11 +135,34 @@ int main(int argc, char *argv[])
>  		TEST(madvise(file, stat.st_size, MADV_DONTNEED));
>  		check_and_print(EINVAL);
>  
> -		if (munmap(file, stat.st_size) == -1)
> -			tst_brkm(TBROK | TERRNO, cleanup, "munmap failed");
>  #endif /* if !defined(UCLINUX) */
>  
> +#if defined(MADV_MERGEABLE) && defined(MADV_UNMERGEABLE)
>  		/* Test Case 4 */
> +		if (tst_kvercmp(2, 6, 32) < 0) {
> +			tst_resm(TCONF, "kernel samepage merging (KSM) needs "
> +				 "2.6.32 or higher, skip EINVAL test for "
> +				 "MADV_MERGEABLE and MADV_UNMERGEABLE.");
> +		} else {
> +			if (access(KSM_SYS_DIR, F_OK) < 0) {
> +				tst_resm(TINFO, "kernel was not configured "
> +					 "with CONFIG_KSM");
> +
> +				TEST(madvise(file, stat.st_size,
> +				     MADV_MERGEABLE));
> +				check_and_print(EINVAL);
> +
> +				TEST(madvise(file, stat.st_size,
> +				     MADV_UNMERGEABLE));
> +				check_and_print(EINVAL);
> +			}
> +		}
> +#endif
> +
> +		if (munmap(file, stat.st_size) == -1)
> +			tst_brkm(TBROK | TERRNO, cleanup, "munmap failed");
> +
> +		/* Test Case 5 */
>  
>  		/* We cannot be sure, which region is mapped, which is
>  		 * not, at runtime.
> @@ -169,7 +199,7 @@ int main(int argc, char *argv[])
>  		TEST(madvise(low, len, MADV_NORMAL));
>  		check_and_print(ENOMEM);
>  
> -		/* Test Case 5 */
> +		/* Test Case 6 */
>  		/* Unmap the file map from low */
>  		if (munmap(low, stat.st_size / 2) < 0)
>  			tst_brkm(TBROK | TERRNO, cleanup,


------------------------------------------------------------------------------
Flow-based real-time traffic analytics software. Cisco certified tool.
Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer
Customize your own dashboards, set traffic alerts and generate reports.
Network behavioral analysis & security monitoring. All-in-one tool.
http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

end of thread, other threads:[~2014-02-25  3:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-16 10:26 [LTP] [PATCH] madvise/madvise02.c: extend EINVAL test for MADV_MERGEABLE and MADV_UNMERGEABLE advice Xiaoguang Wang
2014-02-25  3:22 ` Xiaoguang Wang

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