public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] basic mlock() testcase from lkml
@ 2011-02-24 10:19 Han Pingtian
  2011-02-24 16:55 ` Garrett Cooper
  0 siblings, 1 reply; 8+ messages in thread
From: Han Pingtian @ 2011-02-24 10:19 UTC (permalink / raw)
  To: Garrett Cooper; +Cc: ltp-list

This is a reproducer copied from one of LKML patch submission,
which subject is

[PATCH] mlock: revert the optimization for dirtying pages and
triggering writeback.

"In 5ecfda0, we do some optimization in mlock, but it causes
a very basic test case(attached below) of mlock to fail. So
this patch revert it with some tiny modification so that it
apply successfully with the lastest 38-rc2 kernel."

Signed-off-by: Han Pingtian <phan@redhat.com>
---
 runtest/mm                           |    1 +
 testcases/kernel/mem/mlock/Makefile  |   23 ++++++++
 testcases/kernel/mem/mlock/mlock01.c |  102 ++++++++++++++++++++++++++++++++++
 3 files changed, 126 insertions(+), 0 deletions(-)
 create mode 100644 testcases/kernel/mem/mlock/Makefile
 create mode 100644 testcases/kernel/mem/mlock/mlock01.c

diff --git a/runtest/mm b/runtest/mm
index f097256..1296e59 100644
--- a/runtest/mm
+++ b/runtest/mm
@@ -76,6 +76,7 @@ hugemmap05_3 hugemmap05 -s -m
 
 cpuset01 cpuset01 -I 3600
 
+mlock01 mlock01
 mlock03 mlock03 -i 20
 
 mbind01 mbind01
diff --git a/testcases/kernel/mem/mlock/Makefile b/testcases/kernel/mem/mlock/Makefile
new file mode 100644
index 0000000..dbfbc1b
--- /dev/null
+++ b/testcases/kernel/mem/mlock/Makefile
@@ -0,0 +1,23 @@
+#
+#  Copyright (C) 2010  Red Hat, Inc.
+#
+#  This program is free software; you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or (at
+#  your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful, but
+#  WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+#  General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software
+#  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+#  02110-1301, USA.
+#
+
+top_srcdir              ?= ../../../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/mem/mlock/mlock01.c b/testcases/kernel/mem/mlock/mlock01.c
new file mode 100644
index 0000000..9fe683d
--- /dev/null
+++ b/testcases/kernel/mem/mlock/mlock01.c
@@ -0,0 +1,102 @@
+/*
+ * This is a reproducer copied from one of LKML patch submission,
+ * which subject is
+ *
+ * [PATCH] mlock: revert the optimization for dirtying pages and triggering writeback.
+ *
+ * "In 5ecfda0, we do some optimization in mlock, but it causes
+ * a very basic test case(attached below) of mlock to fail. So
+ * this patch revert it with some tiny modification so that it
+ * apply successfully with the lastest 38-rc2 kernel."
+ *
+ * Copyright (C) 2010  Red Hat, Inc.
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * Further, this software is distributed without any warranty that it
+ * is free of the rightful claim of any third person regarding
+ * infringement or the like.  Any license provided herein, whether
+ * implied or otherwise, applies only to this software file.  Patent
+ * licenses, if any, provided herein do not apply to combinations of
+ * this program with other software, or any other product whatsoever.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+#include "test.h"
+#include "usctest.h"
+#include "config.h"
+
+char *TCID = "mlock01";
+int TST_TOTAL = 1;
+
+#include <sys/mman.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+static void setup(void)
+{
+	tst_tmpdir();
+
+	TEST_PAUSE;
+}
+
+static void cleanup(void)
+{
+	TEST_CLEANUP;
+
+	tst_rmdir();
+}
+
+int main(void)
+{
+	char *buf, *testfile = "test_mmap";
+	int fd, file_len = 40960, lc;
+
+	setup();
+
+	fd = open(testfile, O_CREAT | O_RDWR);
+	if (fd == -1)
+		tst_brkm(TBROK|TERRNO, cleanup, "open");
+
+	if (ftruncate(fd, file_len) == -1)
+		tst_brkm(TBROK|TERRNO, cleanup, "ftruncate");
+
+	for (lc = 0; TEST_LOOPING(lc); lc++) {
+		buf = mmap(NULL, file_len, PROT_WRITE, MAP_SHARED, fd, 0);
+
+		if (buf == MAP_FAILED)
+			tst_brkm(TBROK|TERRNO, cleanup, "mmap");
+
+		if (mlock(buf, file_len) == -1)
+			tst_brkm(TBROK|TERRNO, cleanup, "mlock");
+
+		tst_resm(TINFO, "locked %d bytes from %p", file_len, buf);
+
+		if (munlock(buf, file_len) == -1)
+			tst_brkm(TBROK|TERRNO, cleanup, "munlock");
+
+		if (munmap(buf, file_len) == -1)
+			tst_brkm(TBROK|TERRNO, cleanup, "munmap");
+	}
+
+	tst_resm(TPASS, "mlock01 pass");
+
+	close(fd);
+
+	cleanup();
+
+	tst_exit();
+}
-- 
1.7.1

------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in 
Real-Time with Splunk. Collect, index and harness all the fast moving IT data 
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business 
insights. http://p.sf.net/sfu/splunk-dev2dev 
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH] basic mlock() testcase from lkml
  2011-02-24 10:19 [LTP] [PATCH] basic mlock() testcase from lkml Han Pingtian
@ 2011-02-24 16:55 ` Garrett Cooper
  2011-02-25  2:51   ` Han Pingtian
  0 siblings, 1 reply; 8+ messages in thread
From: Garrett Cooper @ 2011-02-24 16:55 UTC (permalink / raw)
  To: Garrett Cooper, ltp-list

On Thu, Feb 24, 2011 at 2:19 AM, Han Pingtian <phan@redhat.com> wrote:
> This is a reproducer copied from one of LKML patch submission,
> which subject is
>
> [PATCH] mlock: revert the optimization for dirtying pages and
> triggering writeback.
>
> "In 5ecfda0, we do some optimization in mlock, but it causes
> a very basic test case(attached below) of mlock to fail. So
> this patch revert it with some tiny modification so that it
> apply successfully with the lastest 38-rc2 kernel."

    The open / ftruncate should be moved to setup and the close should
be moved to cleanup. Other than that, looks fine.
Thanks,
-Garrett

------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in 
Real-Time with Splunk. Collect, index and harness all the fast moving IT data 
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business 
insights. http://p.sf.net/sfu/splunk-dev2dev 
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH] basic mlock() testcase from lkml
  2011-02-24 16:55 ` Garrett Cooper
@ 2011-02-25  2:51   ` Han Pingtian
  2011-02-25  6:16     ` Garrett Cooper
  0 siblings, 1 reply; 8+ messages in thread
From: Han Pingtian @ 2011-02-25  2:51 UTC (permalink / raw)
  To: Garrett Cooper; +Cc: ltp-list

[-- Attachment #1: Type: text/plain, Size: 886 bytes --]

On Thu, Feb 24, 2011 at 08:55:26AM -0800, Garrett Cooper wrote:
> On Thu, Feb 24, 2011 at 2:19 AM, Han Pingtian <phan@redhat.com> wrote:
> > This is a reproducer copied from one of LKML patch submission,
> > which subject is
> >
> > [PATCH] mlock: revert the optimization for dirtying pages and
> > triggering writeback.
> >
> > "In 5ecfda0, we do some optimization in mlock, but it causes
> > a very basic test case(attached below) of mlock to fail. So
> > this patch revert it with some tiny modification so that it
> > apply successfully with the lastest 38-rc2 kernel."
> 
>     The open / ftruncate should be moved to setup and the close should
> be moved to cleanup. Other than that, looks fine.
Updated as required. Please review. Thanks.
> Thanks,
> -Garrett

-- 
Han Pingtian
Quality Engineer
hpt @ #kernel-qe
Red Hat, Inc
Freedom ... courage ... Commitment ... ACCOUNTABILITY

[-- Attachment #2: 0001-basic-mlock-testcase-from-lkml.patch --]
[-- Type: text/plain, Size: 5411 bytes --]

From a4071d84f31ed5af8203935dc95855a024ef8315 Mon Sep 17 00:00:00 2001
From: Han Pingtian <phan@redhat.com>
Date: Thu, 24 Feb 2011 17:25:03 +0800
Subject: [PATCH] basic mlock() testcase from lkml

This is a reproducer copied from one of LKML patch submission,
which subject is

[PATCH] mlock: revert the optimization for dirtying pages and
triggering writeback.

"In 5ecfda0, we do some optimization in mlock, but it causes
a very basic test case(attached below) of mlock to fail. So
this patch revert it with some tiny modification so that it
apply successfully with the lastest 38-rc2 kernel."

Signed-off-by: Han Pingtian <phan@redhat.com>
---
 runtest/mm                           |    1 +
 testcases/kernel/mem/mlock/Makefile  |   23 +++++++
 testcases/kernel/mem/mlock/mlock01.c |  105 ++++++++++++++++++++++++++++++++++
 3 files changed, 129 insertions(+), 0 deletions(-)
 create mode 100644 testcases/kernel/mem/mlock/Makefile
 create mode 100644 testcases/kernel/mem/mlock/mlock01.c

diff --git a/runtest/mm b/runtest/mm
index f097256..1296e59 100644
--- a/runtest/mm
+++ b/runtest/mm
@@ -76,6 +76,7 @@ hugemmap05_3 hugemmap05 -s -m
 
 cpuset01 cpuset01 -I 3600
 
+mlock01 mlock01
 mlock03 mlock03 -i 20
 
 mbind01 mbind01
diff --git a/testcases/kernel/mem/mlock/Makefile b/testcases/kernel/mem/mlock/Makefile
new file mode 100644
index 0000000..dbfbc1b
--- /dev/null
+++ b/testcases/kernel/mem/mlock/Makefile
@@ -0,0 +1,23 @@
+#
+#  Copyright (C) 2010  Red Hat, Inc.
+#
+#  This program is free software; you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or (at
+#  your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful, but
+#  WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+#  General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software
+#  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+#  02110-1301, USA.
+#
+
+top_srcdir              ?= ../../../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/mem/mlock/mlock01.c b/testcases/kernel/mem/mlock/mlock01.c
new file mode 100644
index 0000000..e4dc31a
--- /dev/null
+++ b/testcases/kernel/mem/mlock/mlock01.c
@@ -0,0 +1,105 @@
+/*
+ * This is a reproducer copied from one of LKML patch submission,
+ * which subject is
+ *
+ * [PATCH] mlock: revert the optimization for dirtying pages and triggering writeback.
+ *
+ * "In 5ecfda0, we do some optimization in mlock, but it causes
+ * a very basic test case(attached below) of mlock to fail. So
+ * this patch revert it with some tiny modification so that it
+ * apply successfully with the lastest 38-rc2 kernel."
+ *
+ * Copyright (C) 2010  Red Hat, Inc.
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * Further, this software is distributed without any warranty that it
+ * is free of the rightful claim of any third person regarding
+ * infringement or the like.  Any license provided herein, whether
+ * implied or otherwise, applies only to this software file.  Patent
+ * licenses, if any, provided herein do not apply to combinations of
+ * this program with other software, or any other product whatsoever.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+#include "test.h"
+#include "usctest.h"
+#include "config.h"
+
+char *TCID = "mlock01";
+int TST_TOTAL = 1;
+
+#include <sys/mman.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+int fd, file_len = 40960;
+char *testfile = "test_mmap";
+
+static void cleanup(void)
+{
+	close(fd);
+
+	TEST_CLEANUP;
+
+	tst_rmdir();
+}
+
+static void setup(void)
+{
+	tst_tmpdir();
+
+	fd = open(testfile, O_CREAT | O_RDWR);
+	if (fd == -1)
+		tst_brkm(TBROK|TERRNO, cleanup, "open");
+
+	if (ftruncate(fd, file_len) == -1)
+		tst_brkm(TBROK|TERRNO, cleanup, "ftruncate");
+
+	TEST_PAUSE;
+}
+
+int main(void)
+{
+	char *buf;
+	int lc;
+
+	setup();
+
+	for (lc = 0; TEST_LOOPING(lc); lc++) {
+		buf = mmap(NULL, file_len, PROT_WRITE, MAP_SHARED, fd, 0);
+
+		if (buf == MAP_FAILED)
+			tst_brkm(TBROK|TERRNO, cleanup, "mmap");
+
+		if (mlock(buf, file_len) == -1)
+			tst_brkm(TBROK|TERRNO, cleanup, "mlock");
+
+		tst_resm(TINFO, "locked %d bytes from %p", file_len, buf);
+
+		if (munlock(buf, file_len) == -1)
+			tst_brkm(TBROK|TERRNO, cleanup, "munlock");
+
+		if (munmap(buf, file_len) == -1)
+			tst_brkm(TBROK|TERRNO, cleanup, "munmap");
+	}
+
+	tst_resm(TPASS, "mlock01 pass");
+
+	cleanup();
+
+	tst_exit();
+}
-- 
1.7.1


[-- Attachment #3: Type: text/plain, Size: 429 bytes --]

------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in 
Real-Time with Splunk. Collect, index and harness all the fast moving IT data 
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business 
insights. http://p.sf.net/sfu/splunk-dev2dev 

[-- Attachment #4: Type: text/plain, Size: 155 bytes --]

_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH] basic mlock() testcase from lkml
  2011-02-25  2:51   ` Han Pingtian
@ 2011-02-25  6:16     ` Garrett Cooper
  2011-02-25  7:57       ` Han Pingtian
  0 siblings, 1 reply; 8+ messages in thread
From: Garrett Cooper @ 2011-02-25  6:16 UTC (permalink / raw)
  To: Garrett Cooper, ltp-list

On Thu, Feb 24, 2011 at 6:51 PM, Han Pingtian <phan@redhat.com> wrote:

...

> Updated as required. Please review. Thanks.

    close should be under TEST_CLEANUP. Other than that it's fine.
Thanks!
-Garrett

------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in 
Real-Time with Splunk. Collect, index and harness all the fast moving IT data 
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business 
insights. http://p.sf.net/sfu/splunk-dev2dev 
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH] basic mlock() testcase from lkml
  2011-02-25  6:16     ` Garrett Cooper
@ 2011-02-25  7:57       ` Han Pingtian
  2011-03-04 10:32         ` Garrett Cooper
  2011-03-09 14:02         ` Cyril Hrubis
  0 siblings, 2 replies; 8+ messages in thread
From: Han Pingtian @ 2011-02-25  7:57 UTC (permalink / raw)
  To: Garrett Cooper; +Cc: ltp-list

[-- Attachment #1: Type: text/plain, Size: 426 bytes --]

On Thu, Feb 24, 2011 at 10:16:58PM -0800, Garrett Cooper wrote:
> On Thu, Feb 24, 2011 at 6:51 PM, Han Pingtian <phan@redhat.com> wrote:
> 
> ...
> 
> > Updated as required. Please review. Thanks.
> 
>     close should be under TEST_CLEANUP. Other than that it's fine.
Updated. Thanks.
> Thanks!
> -Garrett

-- 
Han Pingtian
Quality Engineer
hpt @ #kernel-qe
Red Hat, Inc
Freedom ... courage ... Commitment ... ACCOUNTABILITY

[-- Attachment #2: 0001-basic-mlock-testcase-from-lkml.patch --]
[-- Type: text/plain, Size: 5412 bytes --]

From 4c92e20058b0349910b309e891d92c60d1f15cad Mon Sep 17 00:00:00 2001
From: Han Pingtian <phan@redhat.com>
Date: Thu, 24 Feb 2011 17:25:03 +0800
Subject: [PATCH] basic mlock() testcase from lkml

This is a reproducer copied from one of LKML patch submission,
which subject is

[PATCH] mlock: revert the optimization for dirtying pages and
triggering writeback.

"In 5ecfda0, we do some optimization in mlock, but it causes
a very basic test case(attached below) of mlock to fail. So
this patch revert it with some tiny modification so that it
apply successfully with the lastest 38-rc2 kernel."

Signed-off-by: Han Pingtian <phan@redhat.com>
---
 runtest/mm                           |    1 +
 testcases/kernel/mem/mlock/Makefile  |   23 +++++++
 testcases/kernel/mem/mlock/mlock01.c |  105 ++++++++++++++++++++++++++++++++++
 3 files changed, 129 insertions(+), 0 deletions(-)
 create mode 100644 testcases/kernel/mem/mlock/Makefile
 create mode 100644 testcases/kernel/mem/mlock/mlock01.c

diff --git a/runtest/mm b/runtest/mm
index f097256..1296e59 100644
--- a/runtest/mm
+++ b/runtest/mm
@@ -76,6 +76,7 @@ hugemmap05_3 hugemmap05 -s -m
 
 cpuset01 cpuset01 -I 3600
 
+mlock01 mlock01
 mlock03 mlock03 -i 20
 
 mbind01 mbind01
diff --git a/testcases/kernel/mem/mlock/Makefile b/testcases/kernel/mem/mlock/Makefile
new file mode 100644
index 0000000..dbfbc1b
--- /dev/null
+++ b/testcases/kernel/mem/mlock/Makefile
@@ -0,0 +1,23 @@
+#
+#  Copyright (C) 2010  Red Hat, Inc.
+#
+#  This program is free software; you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or (at
+#  your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful, but
+#  WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+#  General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software
+#  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+#  02110-1301, USA.
+#
+
+top_srcdir              ?= ../../../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/mem/mlock/mlock01.c b/testcases/kernel/mem/mlock/mlock01.c
new file mode 100644
index 0000000..9218e0c
--- /dev/null
+++ b/testcases/kernel/mem/mlock/mlock01.c
@@ -0,0 +1,105 @@
+/*
+ * This is a reproducer copied from one of LKML patch submission,
+ * which subject is
+ *
+ * [PATCH] mlock: revert the optimization for dirtying pages and triggering writeback.
+ *
+ * "In 5ecfda0, we do some optimization in mlock, but it causes
+ * a very basic test case(attached below) of mlock to fail. So
+ * this patch revert it with some tiny modification so that it
+ * apply successfully with the lastest 38-rc2 kernel."
+ *
+ * Copyright (C) 2010  Red Hat, Inc.
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * Further, this software is distributed without any warranty that it
+ * is free of the rightful claim of any third person regarding
+ * infringement or the like.  Any license provided herein, whether
+ * implied or otherwise, applies only to this software file.  Patent
+ * licenses, if any, provided herein do not apply to combinations of
+ * this program with other software, or any other product whatsoever.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+#include "test.h"
+#include "usctest.h"
+#include "config.h"
+
+char *TCID = "mlock01";
+int TST_TOTAL = 1;
+
+#include <sys/mman.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+int fd, file_len = 40960;
+char *testfile = "test_mmap";
+
+static void cleanup(void)
+{
+	TEST_CLEANUP;
+	
+	close(fd);
+
+	tst_rmdir();
+}
+
+static void setup(void)
+{
+	tst_tmpdir();
+
+	fd = open(testfile, O_CREAT | O_RDWR);
+	if (fd == -1)
+		tst_brkm(TBROK|TERRNO, cleanup, "open");
+
+	if (ftruncate(fd, file_len) == -1)
+		tst_brkm(TBROK|TERRNO, cleanup, "ftruncate");
+
+	TEST_PAUSE;
+}
+
+int main(void)
+{
+	char *buf;
+	int lc;
+
+	setup();
+
+	for (lc = 0; TEST_LOOPING(lc); lc++) {
+		buf = mmap(NULL, file_len, PROT_WRITE, MAP_SHARED, fd, 0);
+
+		if (buf == MAP_FAILED)
+			tst_brkm(TBROK|TERRNO, cleanup, "mmap");
+
+		if (mlock(buf, file_len) == -1)
+			tst_brkm(TBROK|TERRNO, cleanup, "mlock");
+
+		tst_resm(TINFO, "locked %d bytes from %p", file_len, buf);
+
+		if (munlock(buf, file_len) == -1)
+			tst_brkm(TBROK|TERRNO, cleanup, "munlock");
+
+		if (munmap(buf, file_len) == -1)
+			tst_brkm(TBROK|TERRNO, cleanup, "munmap");
+	}
+
+	tst_resm(TPASS, "mlock01 pass");
+
+	cleanup();
+
+	tst_exit();
+}
-- 
1.7.1


[-- Attachment #3: Type: text/plain, Size: 429 bytes --]

------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in 
Real-Time with Splunk. Collect, index and harness all the fast moving IT data 
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business 
insights. http://p.sf.net/sfu/splunk-dev2dev 

[-- Attachment #4: Type: text/plain, Size: 155 bytes --]

_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH] basic mlock() testcase from lkml
  2011-02-25  7:57       ` Han Pingtian
@ 2011-03-04 10:32         ` Garrett Cooper
  2011-03-09 14:02         ` Cyril Hrubis
  1 sibling, 0 replies; 8+ messages in thread
From: Garrett Cooper @ 2011-03-04 10:32 UTC (permalink / raw)
  To: Garrett Cooper, ltp-list

On Thu, Feb 24, 2011 at 11:57 PM, Han Pingtian <phan@redhat.com> wrote:
> On Thu, Feb 24, 2011 at 10:16:58PM -0800, Garrett Cooper wrote:
>> On Thu, Feb 24, 2011 at 6:51 PM, Han Pingtian <phan@redhat.com> wrote:
>>
>> ...
>>
>> > Updated as required. Please review. Thanks.
>>
>>     close should be under TEST_CLEANUP. Other than that it's fine.
> Updated. Thanks.

Committed -- thanks!
-Garrett

------------------------------------------------------------------------------
What You Don't Know About Data Connectivity CAN Hurt You
This paper provides an overview of data connectivity, details
its effect on application quality, and explores various alternative
solutions. http://p.sf.net/sfu/progress-d2d
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH] basic mlock() testcase from lkml
  2011-02-25  7:57       ` Han Pingtian
  2011-03-04 10:32         ` Garrett Cooper
@ 2011-03-09 14:02         ` Cyril Hrubis
       [not found]           ` <20110310042858.GB2918@hpt.nay.redhat.com>
  1 sibling, 1 reply; 8+ messages in thread
From: Cyril Hrubis @ 2011-03-09 14:02 UTC (permalink / raw)
  To: Han Pingtian, ltp-list

Hi!
> +static void setup(void)
> +{
> +	tst_tmpdir();
> +
> +	fd = open(testfile, O_CREAT | O_RDWR);

Sorry for not exposing this earlier. But you should specify mode for
open with O_CREAT. That's part of the open() inteface that is kind of
badly engineered...

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH] basic mlock() testcase from lkml
       [not found]           ` <20110310042858.GB2918@hpt.nay.redhat.com>
@ 2011-03-10 14:22             ` Cyril Hrubis
  0 siblings, 0 replies; 8+ messages in thread
From: Cyril Hrubis @ 2011-03-10 14:22 UTC (permalink / raw)
  To: ltp-list, Garrett Cooper

Hi!
Thanks - Commited.

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

end of thread, other threads:[~2011-03-10 14:00 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-24 10:19 [LTP] [PATCH] basic mlock() testcase from lkml Han Pingtian
2011-02-24 16:55 ` Garrett Cooper
2011-02-25  2:51   ` Han Pingtian
2011-02-25  6:16     ` Garrett Cooper
2011-02-25  7:57       ` Han Pingtian
2011-03-04 10:32         ` Garrett Cooper
2011-03-09 14:02         ` Cyril Hrubis
     [not found]           ` <20110310042858.GB2918@hpt.nay.redhat.com>
2011-03-10 14:22             ` Cyril Hrubis

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