Skip to contentSkip to conversation

hugetlb: rename lib/ipcshm.* to lib/hugetlb.*

PATCH Superseded Li Wang 2 participants 6 messages Nov 27, 2015 – Dec 4, 2015

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Li Wang

author
#0 lore raw

PATCH 1/2 hugetlb: rename lib/ipcshm.* to lib/hugetlb.*

---
 testcases/kernel/mem/hugetlb/Makefile              |   2 +-
 testcases/kernel/mem/hugetlb/Makefile.inc          |   4 +-
 .../kernel/mem/hugetlb/hugeshmat/hugeshmat01.c     |   2 +-
 .../kernel/mem/hugetlb/hugeshmat/hugeshmat02.c     |   2 +-
 .../kernel/mem/hugetlb/hugeshmat/hugeshmat03.c     |   2 +-
 .../kernel/mem/hugetlb/hugeshmctl/hugeshmctl01.c   |   2 +-
 .../kernel/mem/hugetlb/hugeshmctl/hugeshmctl02.c   |   2 +-
 .../kernel/mem/hugetlb/hugeshmctl/hugeshmctl03.c   |   2 +-
 .../kernel/mem/hugetlb/hugeshmdt/hugeshmdt01.c     |   2 +-
 .../kernel/mem/hugetlb/hugeshmget/hugeshmget01.c   |   2 +-
 .../kernel/mem/hugetlb/hugeshmget/hugeshmget02.c   |   2 +-
 .../kernel/mem/hugetlb/hugeshmget/hugeshmget03.c   |   2 +-
 .../kernel/mem/hugetlb/hugeshmget/hugeshmget05.c   |   2 +-
 testcases/kernel/mem/hugetlb/lib/Makefile          |   2 +-
 testcases/kernel/mem/hugetlb/lib/hugetlb.c         | 116 +++++++++++++++++++++
 testcases/kernel/mem/hugetlb/lib/hugetlb.h         |  61 +++++++++++
 testcases/kernel/mem/hugetlb/lib/ipcshm.h          |  61 -----------
 testcases/kernel/mem/hugetlb/lib/libipc.c          | 116 ---------------------
 18 files changed, 192 insertions(+), 192 deletions(-)
 create mode 100644 testcases/kernel/mem/hugetlb/lib/hugetlb.c
 create mode 100644 testcases/kernel/mem/hugetlb/lib/hugetlb.h
 delete mode 100644 testcases/kernel/mem/hugetlb/lib/ipcshm.h
 delete mode 100644 testcases/kernel/mem/hugetlb/lib/libipc.c
testcases/kernel/mem/hugetlb/Makefile +1 -1
index 1e8f8f8..ea7867f 100644
@@ -21,7 +21,7 @@ top_srcdir		?= ../../../..
 include	$(top_srcdir)/include/mk/env_pre.mk
 
 LIBDIR			:= lib
-LIB			:= $(LIBDIR)/libipc_hugetlb.a
+LIB			:= $(LIBDIR)/libhugetlb.a
 FILTER_OUT_DIRS		:= $(LIBDIR)
 
 $(LIBDIR):
testcases/kernel/mem/hugetlb/Makefile.inc +2 -2
index cc0ada6..c07d600 100644
@@ -22,7 +22,7 @@
 
 # DO NOT USE THIS FILE FOR hugetlb / lib!!!
 LIBIPCDIR		:= ../lib
-LIBIPC			:= $(LIBIPCDIR)/libipc_hugetlb.a
+LIBIPC			:= $(LIBIPCDIR)/libhugetlb.a
 
 $(LIBIPCDIR):
 	mkdir -p "$@"
@@ -31,7 +31,7 @@ $(LIBIPC): $(LIBIPCDIR)
 
 CPPFLAGS		+= -I$(abs_srcdir)/$(LIBIPCDIR)
 LDFLAGS			+= -L$(abs_builddir)/$(LIBIPCDIR)
-LDLIBS			+= -lipc_hugetlb
+LDLIBS			+= -lhugetlb
 MAKE_DEPS		+= $(LIBIPC)
 
 include $(top_srcdir)/testcases/kernel/mem/include/libmem.mk
testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat01.c +1 -1
index 851d4cf..35e7216 100644
@@ -56,7 +56,7 @@
  *	none
  */
 
-#include "ipcshm.h"
+#include "hugetlb.h"
 #include "safe_macros.h"
 #include "mem.h"
 
testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat02.c +1 -1
index 52348f1..2bac9c2 100644
@@ -51,7 +51,7 @@
  */
 
 #include <pwd.h>
-#include "ipcshm.h"
+#include "hugetlb.h"
 #include "safe_macros.h"
 #include "mem.h"
 
testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat03.c +1 -1
index 723c8b5..fe74810 100644
@@ -57,7 +57,7 @@
  *	test must be run at root
  */
 
-#include "ipcshm.h"
+#include "hugetlb.h"
 #include "safe_macros.h"
 #include "mem.h"
 
testcases/kernel/mem/hugetlb/hugeshmctl/hugeshmctl01.c +1 -1
index 66ad1b5..d7990c7 100644
@@ -61,7 +61,7 @@
  *	none
  */
 
-#include "ipcshm.h"
+#include "hugetlb.h"
 #include "safe_macros.h"
 #include "mem.h"
 
testcases/kernel/mem/hugetlb/hugeshmctl/hugeshmctl02.c +1 -1
index 4aeb638..f79ee83 100644
@@ -53,7 +53,7 @@
  */
 
 #include <pwd.h>
-#include "ipcshm.h"
+#include "hugetlb.h"
 #include "safe_macros.h"
 #include "mem.h"
 
testcases/kernel/mem/hugetlb/hugeshmctl/hugeshmctl03.c +1 -1
index 9f5c2c9..e553a2a 100644
@@ -60,7 +60,7 @@
 
 #include <sys/types.h>
 #include <sys/wait.h>
-#include "ipcshm.h"
+#include "hugetlb.h"
 #include "safe_macros.h"
 #include "mem.h"
 
testcases/kernel/mem/hugetlb/hugeshmdt/hugeshmdt01.c +1 -1
index 9770e87..c8592b3 100644
@@ -58,7 +58,7 @@
  */
 
 #include <setjmp.h>
-#include "ipcshm.h"
+#include "hugetlb.h"
 #include "safe_macros.h"
 #include "mem.h"
 
testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget01.c +1 -1
index ee82de3..5d45aaa 100644
@@ -58,7 +58,7 @@
  *	none
  */
 
-#include "ipcshm.h"
+#include "hugetlb.h"
 #include "safe_macros.h"
 #include "mem.h"
 
testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget02.c +1 -1
index b995ef8..0ac4a29 100644
@@ -51,7 +51,7 @@
  *	none
  */
 
-#include "ipcshm.h"
+#include "hugetlb.h"
 #include "safe_macros.h"
 #include "mem.h"
 
testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget03.c +1 -1
index 9284669..9a2a0b2 100644
@@ -52,7 +52,7 @@
  *	none
  */
 
-#include "ipcshm.h"
+#include "hugetlb.h"
 #include "safe_macros.h"
 #include "mem.h"
 
testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget05.c +1 -1
index 7b8f6b4..567b02d 100644
@@ -60,7 +60,7 @@
 
 #include <sys/types.h>
 #include <sys/wait.h>
-#include "ipcshm.h"
+#include "hugetlb.h"
 #include "safe_macros.h"
 #include "mem.h"
 
testcases/kernel/mem/hugetlb/lib/Makefile +1 -1
index 4cdd142..96e8e37 100644
@@ -20,6 +20,6 @@ top_srcdir		?= ../../../../..
 
 include $(top_srcdir)/include/mk/env_pre.mk
 
-LIB			:= libipc_hugetlb.a
+LIB			:= libhugetlb.a
 
 include $(top_srcdir)/include/mk/lib.mk
testcases/kernel/mem/hugetlb/lib/hugetlb.c new file +116 -0

116 lines not on this page · raw message

testcases/kernel/mem/hugetlb/lib/hugetlb.h new file +61 -0

61 lines not on this page · raw message

testcases/kernel/mem/hugetlb/lib/ipcshm.h deleted +0 -61

61 lines not on this page · raw message

testcases/kernel/mem/hugetlb/lib/libipc.c deleted +0 -116

116 lines not on this page · raw message

Signature · 1 line
1.8.3.1
author
#1 lore raw

PATCH 1/2 hugetlb: rename lib/ipcshm.* to lib/hugetlb.*

Hi,

sorry, ping~

http://lists.linux.it/pipermail/ltp/2015-November/000563.html
http://lists.linux.it/pipermail/ltp/2015-November/000564.html
http://lists.linux.it/pipermail/ltp/2015-November/000565.html
http://lists.linux.it/pipermail/ltp/2015-November/000566.html

any comments on above patches?

Quoted 629 lines · Li Wang
---
 testcases/kernel/mem/hugetlb/Makefile              |   2 +-
 testcases/kernel/mem/hugetlb/Makefile.inc          |   4 +-
 .../kernel/mem/hugetlb/hugeshmat/hugeshmat01.c     |   2 +-
 .../kernel/mem/hugetlb/hugeshmat/hugeshmat02.c     |   2 +-
 .../kernel/mem/hugetlb/hugeshmat/hugeshmat03.c     |   2 +-
 .../kernel/mem/hugetlb/hugeshmctl/hugeshmctl01.c   |   2 +-
 .../kernel/mem/hugetlb/hugeshmctl/hugeshmctl02.c   |   2 +-
 .../kernel/mem/hugetlb/hugeshmctl/hugeshmctl03.c   |   2 +-
 .../kernel/mem/hugetlb/hugeshmdt/hugeshmdt01.c     |   2 +-
 .../kernel/mem/hugetlb/hugeshmget/hugeshmget01.c   |   2 +-
 .../kernel/mem/hugetlb/hugeshmget/hugeshmget02.c   |   2 +-
 .../kernel/mem/hugetlb/hugeshmget/hugeshmget03.c   |   2 +-
 .../kernel/mem/hugetlb/hugeshmget/hugeshmget05.c   |   2 +-
 testcases/kernel/mem/hugetlb/lib/Makefile          |   2 +-
 testcases/kernel/mem/hugetlb/lib/hugetlb.c         | 116
+++++++++++++++++++++
 testcases/kernel/mem/hugetlb/lib/hugetlb.h         |  61 +++++++++++
 testcases/kernel/mem/hugetlb/lib/ipcshm.h          |  61 -----------
 testcases/kernel/mem/hugetlb/lib/libipc.c          | 116
---------------------
 18 files changed, 192 insertions(+), 192 deletions(-)
 create mode 100644 testcases/kernel/mem/hugetlb/lib/hugetlb.c
 create mode 100644 testcases/kernel/mem/hugetlb/lib/hugetlb.h
 delete mode 100644 testcases/kernel/mem/hugetlb/lib/ipcshm.h
 delete mode 100644 testcases/kernel/mem/hugetlb/lib/libipc.c
testcases/kernel/mem/hugetlb/Makefile +1 -1
index 1e8f8f8..ea7867f 100644
@@ -21,7 +21,7 @@ top_srcdir            ?= ../../../..
 include        $(top_srcdir)/include/mk/env_pre.mk
 
 LIBDIR                 := lib
-LIB                    := $(LIBDIR)/libipc_hugetlb.a
+LIB                    := $(LIBDIR)/libhugetlb.a
 FILTER_OUT_DIRS                := $(LIBDIR)
 
 $(LIBDIR):
testcases/kernel/mem/hugetlb/Makefile.inc +2 -2
index cc0ada6..c07d600 100644
@@ -22,7 +22,7 @@
 
 # DO NOT USE THIS FILE FOR hugetlb / lib!!!
 LIBIPCDIR              := ../lib
-LIBIPC                 := $(LIBIPCDIR)/libipc_hugetlb.a
+LIBIPC                 := $(LIBIPCDIR)/libhugetlb.a
 
 $(LIBIPCDIR):
        mkdir -p "$@"
@@ -31,7 +31,7 @@ $(LIBIPC): $(LIBIPCDIR)
 
 CPPFLAGS               += -I$(abs_srcdir)/$(LIBIPCDIR)
 LDFLAGS                        += -L$(abs_builddir)/$(LIBIPCDIR)
-LDLIBS                 += -lipc_hugetlb
+LDLIBS                 += -lhugetlb
 MAKE_DEPS              += $(LIBIPC)
 
 include $(top_srcdir)/testcases/kernel/mem/include/libmem.mk
testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat01.c +1 -1
index 851d4cf..35e7216 100644
@@ -56,7 +56,7 @@
  *     none
  */
 
-#include "ipcshm.h"
+#include "hugetlb.h"
 #include "safe_macros.h"
 #include "mem.h"
 
testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat02.c +1 -1
index 52348f1..2bac9c2 100644
@@ -51,7 +51,7 @@
  */
 
 #include <pwd.h>
-#include "ipcshm.h"
+#include "hugetlb.h"
 #include "safe_macros.h"
 #include "mem.h"
 
testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat03.c +1 -1
index 723c8b5..fe74810 100644
@@ -57,7 +57,7 @@
  *     test must be run at root
  */
 
-#include "ipcshm.h"
+#include "hugetlb.h"
 #include "safe_macros.h"
 #include "mem.h"
 
testcases/kernel/mem/hugetlb/hugeshmctl/hugeshmctl01.c +1 -1
index 66ad1b5..d7990c7 100644
@@ -61,7 +61,7 @@
  *     none
  */
 
-#include "ipcshm.h"
+#include "hugetlb.h"
 #include "safe_macros.h"
 #include "mem.h"
 
testcases/kernel/mem/hugetlb/hugeshmctl/hugeshmctl02.c +1 -1
index 4aeb638..f79ee83 100644
@@ -53,7 +53,7 @@
  */
 
 #include <pwd.h>
-#include "ipcshm.h"
+#include "hugetlb.h"
 #include "safe_macros.h"
 #include "mem.h"
 
testcases/kernel/mem/hugetlb/hugeshmctl/hugeshmctl03.c +1 -1
index 9f5c2c9..e553a2a 100644
@@ -60,7 +60,7 @@
 
 #include <sys/types.h>
 #include <sys/wait.h>
-#include "ipcshm.h"
+#include "hugetlb.h"
 #include "safe_macros.h"
 #include "mem.h"
 
testcases/kernel/mem/hugetlb/hugeshmdt/hugeshmdt01.c +1 -1
index 9770e87..c8592b3 100644
@@ -58,7 +58,7 @@
  */
 
 #include <setjmp.h>
-#include "ipcshm.h"
+#include "hugetlb.h"
 #include "safe_macros.h"
 #include "mem.h"
 
testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget01.c +1 -1
index ee82de3..5d45aaa 100644
@@ -58,7 +58,7 @@
  *     none
  */
 
-#include "ipcshm.h"
+#include "hugetlb.h"
 #include "safe_macros.h"
 #include "mem.h"
 
testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget02.c +1 -1
index b995ef8..0ac4a29 100644
@@ -51,7 +51,7 @@
  *     none
  */
 
-#include "ipcshm.h"
+#include "hugetlb.h"
 #include "safe_macros.h"
 #include "mem.h"
 
testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget03.c +1 -1
index 9284669..9a2a0b2 100644
@@ -52,7 +52,7 @@
  *     none
  */
 
-#include "ipcshm.h"
+#include "hugetlb.h"
 #include "safe_macros.h"
 #include "mem.h"
 
testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget05.c +1 -1
index 7b8f6b4..567b02d 100644
@@ -60,7 +60,7 @@
 
 #include <sys/types.h>
 #include <sys/wait.h>
-#include "ipcshm.h"
+#include "hugetlb.h"
 #include "safe_macros.h"
 #include "mem.h"
 
testcases/kernel/mem/hugetlb/lib/Makefile +1 -1
index 4cdd142..96e8e37 100644
@@ -20,6 +20,6 @@ top_srcdir            ?= ../../../../..
 
 include $(top_srcdir)/include/mk/env_pre.mk
 
-LIB                    := libipc_hugetlb.a
+LIB                    := libhugetlb.a
 
 include $(top_srcdir)/include/mk/lib.mk
testcases/kernel/mem/hugetlb/lib/hugetlb.c new file +17 -0
new file mode 100644
index 0000000..4b2a3d2
@@ -0,0 +1,116 @@
+/*
+ *
+ *   Copyright (c) International Business Machines  Corp., 2001
+ *
+ *   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
+ */

testcases/kernel/mem/hugetlb/lib/hugetlb.c new file +90 -0
+
+/*
+ * NAME
+ *     hugetlb.c
+ *
+ * DESCRIPTION
+ *     common routines for the hugepage tests.
+ *
+ *     The library contains the following routines:
+ *
+ *     getipckey()
+ *     getuserid()
+ *     rm_shm()
+ *     help()
+ */
+
+#include <sys/types.h>
+#include <sys/ipc.h>
+#include <sys/shm.h>
+#include <sys/timeb.h>
+#include <pwd.h>
+#include "hugetlb.h"
+
+/*
+ * getipckey() - generates and returns a message key used by the "get"
+ *              calls to create an IPC resource.
+ */
+int getipckey(void)
+{
+       const char a = 'a';
+       int ascii_a = (int)a;
+       char *curdir = NULL;
+       size_t size = 0;
+       key_t ipc_key;
+       struct timeb time_info;
+
+       curdir = getcwd(curdir, size);
+       if (curdir == NULL)
+               tst_brkm(TBROK | TERRNO, cleanup, "getcwd(curdir)");
+
+       /*
+        * Get a Sys V IPC key
+        *
+        * ftok() requires a character as a second argument.  This is
+        * refered to as a "project identifier" in the man page.  In
+        * order to maximize the chance of getting a unique key, the
+        * project identifier is a "random character" produced by
+        * generating a random number between 0 and 25 and then adding
+        * that to the ascii value of 'a'.  The "seed" for the random
+        * number is the millisecond value that is set in the timeb
+        * structure after calling ftime().
+        */
+       ftime(&time_info);
+       srandom((unsigned int)time_info.millitm);
+
+       ipc_key = ftok(curdir, ascii_a + random() % 26);
+       if (ipc_key == -1)
+               tst_brkm(TBROK | TERRNO, cleanup, "ftok");
+
+       return ipc_key;
+}
+
+/*
+ * getuserid() - return the integer value for the "user" id
+ */
+int getuserid(char *user)
+{
+       struct passwd *ent;
+
+       ent = getpwnam(user);
+       if (ent == NULL)
+               tst_brkm(TBROK | TERRNO, cleanup, "getpwnam");
+
+       return ent->pw_uid;
+}
+
+/*
+ * rm_shm() - removes a shared memory segment.
+ */
+void rm_shm(int shm_id)
+{
+       if (shm_id == -1)
+               return;
+
+       /*
+        * check for # of attaches ?
+        */
+       if (shmctl(shm_id, IPC_RMID, NULL) == -1) {
+               tst_resm(TINFO, "WARNING: shared memory deletion failed.");
+               tst_resm(TINFO, "This could lead to IPC resource

problems.");

testcases/kernel/mem/hugetlb/lib/hugetlb.c new file +7 -0
+               tst_resm(TINFO, "id = %d", shm_id);
+       }
+}
+
+void help(void)
+{
+       printf("    -s NUM  Set the number of hugepages to be

allocated\n");

testcases/kernel/mem/hugetlb/lib/hugetlb.c new file +1 -0
+}
testcases/kernel/mem/hugetlb/lib/hugetlb.h new file +17 -0
new file mode 100644
index 0000000..6d73e9c
@@ -0,0 +1,61 @@
+/*
+ *
+ *   Copyright (c) International Business Machines  Corp., 2001
+ *
+ *   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
+ */

testcases/kernel/mem/hugetlb/lib/hugetlb.h new file +43 -0
+
+/*
+ * hugetlb.h - common definitions for the hugepage tests
+ */
+
+#ifndef __HUGETLB_H
+#define __HUGETLB_H
+
+#include <sys/ipc.h>
+#include <sys/shm.h>
+#include <errno.h>
+#include <wait.h>
+#include "test.h"
+
+#define SHM_RD 0400
+#define SHM_WR 0200
+#define SHM_RW (SHM_RD|SHM_WR)
+
+#ifndef SHM_HUGETLB
+#define SHM_HUGETLB    04000   /* segment is mapped via hugetlb */
+#endif
+
+/*
+ * to get the lower nine permission bits
+ * from shmid_ds.ipc_perm.mode
+ */
+#define MODE_MASK      0x01FF
+
+key_t shmkey;                  /* an IPC key generated by ftok() */
+
+int getipckey(void);
+int getuserid(char *user);
+void rm_shm(int shm_id);
+
+void cleanup(void);
+void setup(void);
+
+char *nr_opt;
+int sflag;
+long orig_hugepages;
+void help(void);
+
+#endif /* hugetlb.h */
testcases/kernel/mem/hugetlb/lib/ipcshm.h deleted +0 -17
deleted file mode 100644
index 194d14b..0000000
@@ -1,61 +0,0 @@
-/*
- *
- *   Copyright (c) International Business Machines  Corp., 2001
- *
- *   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
- */

testcases/kernel/mem/hugetlb/lib/ipcshm.h deleted +0 -43
-
-/*
- * ipcshm.h - common definitions for the IPC shared memory tests
- */
-
-#ifndef __IPCSHM_H
-#define __IPCSHM_H
-
-#include <sys/ipc.h>
-#include <sys/shm.h>
-#include <errno.h>
-#include <wait.h>
-#include "test.h"
-
-#define SHM_RD 0400
-#define SHM_WR 0200
-#define SHM_RW (SHM_RD|SHM_WR)
-
-#ifndef SHM_HUGETLB
-#define SHM_HUGETLB    04000   /* segment is mapped via hugetlb */
-#endif
-
-/*
- * to get the lower nine permission bits
- * from shmid_ds.ipc_perm.mode
- */
-#define MODE_MASK      0x01FF
-
-key_t shmkey;                  /* an IPC key generated by ftok() */
-
-int getipckey(void);
-int getuserid(char *user);
-void rm_shm(int shm_id);
-
-void cleanup(void);
-void setup(void);
-
-char *nr_opt;
-int sflag;
-long orig_hugepages;
-void help(void);
-
-#endif /* ipcshm.h */
testcases/kernel/mem/hugetlb/lib/libipc.c deleted +0 -17
deleted file mode 100644
index 1f16f22..0000000
@@ -1,116 +0,0 @@
-/*
- *
- *   Copyright (c) International Business Machines  Corp., 2001
- *
- *   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
- */

testcases/kernel/mem/hugetlb/lib/libipc.c deleted +0 -90
-
-/*
- * NAME
- *     libipc.c
- *
- * DESCRIPTION
- *     common routines for the IPC system call tests.
- *
- *     The library contains the following routines:
- *
- *     getipckey()
- *     getuserid()
- *     rm_shm()
- *     help()
- */
-
-#include <sys/types.h>
-#include <sys/ipc.h>
-#include <sys/shm.h>
-#include <sys/timeb.h>
-#include <pwd.h>
-#include "ipcshm.h"
-
-/*
- * getipckey() - generates and returns a message key used by the "get"
- *              calls to create an IPC resource.
- */
-int getipckey(void)
-{
-       const char a = 'a';
-       int ascii_a = (int)a;
-       char *curdir = NULL;
-       size_t size = 0;
-       key_t ipc_key;
-       struct timeb time_info;
-
-       curdir = getcwd(curdir, size);
-       if (curdir == NULL)
-               tst_brkm(TBROK | TERRNO, cleanup, "getcwd(curdir)");
-
-       /*
-        * Get a Sys V IPC key
-        *
-        * ftok() requires a character as a second argument.  This is
-        * refered to as a "project identifier" in the man page.  In
-        * order to maximize the chance of getting a unique key, the
-        * project identifier is a "random character" produced by
-        * generating a random number between 0 and 25 and then adding
-        * that to the ascii value of 'a'.  The "seed" for the random
-        * number is the millisecond value that is set in the timeb
-        * structure after calling ftime().
-        */
-       ftime(&time_info);
-       srandom((unsigned int)time_info.millitm);
-
-       ipc_key = ftok(curdir, ascii_a + random() % 26);
-       if (ipc_key == -1)
-               tst_brkm(TBROK | TERRNO, cleanup, "ftok");
-
-       return ipc_key;
-}
-
-/*
- * getuserid() - return the integer value for the "user" id
- */
-int getuserid(char *user)
-{
-       struct passwd *ent;
-
-       ent = getpwnam(user);
-       if (ent == NULL)
-               tst_brkm(TBROK | TERRNO, cleanup, "getpwnam");
-
-       return ent->pw_uid;
-}
-
-/*
- * rm_shm() - removes a shared memory segment.
- */
-void rm_shm(int shm_id)
-{
-       if (shm_id == -1)
-               return;
-
-       /*
-        * check for # of attaches ?
-        */
-       if (shmctl(shm_id, IPC_RMID, NULL) == -1) {
-               tst_resm(TINFO, "WARNING: shared memory deletion failed.");
-               tst_resm(TINFO, "This could lead to IPC resource

problems.");

testcases/kernel/mem/hugetlb/lib/libipc.c deleted +0 -7
-               tst_resm(TINFO, "id = %d", shm_id);
-       }
-}
-
-void help(void)
-{
-       printf("    -s NUM  Set the number of hugepages to be

allocated\n");
-}
--
1.8.3.1

--
Mailing list info: http://lists.linux.it/listinfo/ltp

Signature · 6 lines
Regards,
Li Wang
Email: [email protected]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20151203/74c0747a/attachment-0001.html>
author
#2 lore raw

PATCH 2/2 hugetlb: checking if hugepage is supported on target system

In reply to Li Wang
---
 testcases/kernel/mem/hugetlb/hugemmap/Makefile       |  2 +-
 testcases/kernel/mem/hugetlb/hugemmap/hugemmap01.c   |  4 ++--
 testcases/kernel/mem/hugetlb/hugemmap/hugemmap02.c   |  5 +++--
 testcases/kernel/mem/hugetlb/hugemmap/hugemmap04.c   |  4 ++--
 testcases/kernel/mem/hugetlb/hugemmap/hugemmap05.c   | 20 ++++++++++----------
 testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat01.c |  3 ++-
 testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat02.c |  3 ++-
 testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat03.c |  3 ++-
 testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat04.c |  3 ++-
 .../kernel/mem/hugetlb/hugeshmctl/hugeshmctl01.c     |  4 +++-
 .../kernel/mem/hugetlb/hugeshmctl/hugeshmctl02.c     |  4 +++-
 .../kernel/mem/hugetlb/hugeshmctl/hugeshmctl03.c     |  4 +++-
 testcases/kernel/mem/hugetlb/hugeshmdt/hugeshmdt01.c |  3 ++-
 .../kernel/mem/hugetlb/hugeshmget/hugeshmget01.c     |  3 ++-
 .../kernel/mem/hugetlb/hugeshmget/hugeshmget02.c     |  3 ++-
 .../kernel/mem/hugetlb/hugeshmget/hugeshmget03.c     |  3 ++-
 .../kernel/mem/hugetlb/hugeshmget/hugeshmget05.c     |  3 ++-
 testcases/kernel/mem/hugetlb/lib/hugetlb.c           | 13 +++++++------
 testcases/kernel/mem/hugetlb/lib/hugetlb.h           |  4 +++-
 testcases/kernel/syscalls/futex/futex_wake04.c       |  4 ++++
 20 files changed, 59 insertions(+), 36 deletions(-)
testcases/kernel/mem/hugetlb/hugemmap/Makefile +1 -1
index 71da630..f51f6b9 100644
@@ -23,5 +23,5 @@
 top_srcdir		?= ../../../../..
 
 include $(top_srcdir)/include/mk/testcases.mk
-include $(top_srcdir)/testcases/kernel/mem/include/libmem.mk
+include $(abs_srcdir)/../Makefile.inc
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/mem/hugetlb/hugemmap/hugemmap01.c +2 -2
index 62c3cc8..da8bdb1 100644
@@ -60,6 +60,7 @@
 #include <unistd.h>
 
 #include "test.h"
+#include "hugetlb.h"
 #include "safe_macros.h"
 #include "mem.h"
 
@@ -70,12 +71,10 @@ int TST_TOTAL = 1;
 static long *addr;
 static int fildes;
 static char *Hopt;
-static char *nr_opt;
 static long beforetest;
 static long aftertest;
 static long hugepagesmapped;
 static long hugepages = 128;
-static long orig_hugepages;
 
 static void help(void);
 
@@ -159,6 +158,7 @@ void setup(void)
 {
 	TEST_PAUSE;
 	tst_require_root();
+	check_hugepage();
 	if (mount("none", Hopt, "hugetlbfs", 0, NULL) < 0)
 		tst_brkm(TBROK | TERRNO, NULL, "mount failed on %s", Hopt);
 
testcases/kernel/mem/hugetlb/hugemmap/hugemmap02.c +3 -2
index 9fee330..1a44993 100644
@@ -55,6 +55,7 @@
 #include "test.h"
 #include "safe_macros.h"
 #include "mem.h"
+#include "hugetlb.h"
 
 #define LOW_ADDR       0x80000000
 #define LOW_ADDR2      0x90000000
@@ -72,9 +73,7 @@ static int i;
 static int fildes;
 static int nfildes;
 static char *Hopt;
-static char *nr_opt;
 static long hugepages = 128;
-static long orig_hugepages;
 
 static void help(void);
 
@@ -93,6 +92,8 @@ int main(int ac, char **av)
 
 	tst_parse_opts(ac, av, options, &help);
 
+	check_hugepage();
+
 	if (!Hflag) {
 		tst_tmpdir();
 		Hopt = tst_get_tmpdir();
testcases/kernel/mem/hugetlb/hugemmap/hugemmap04.c +2 -2
index 727b102..e1f2986 100644
@@ -63,6 +63,7 @@
 #include "test.h"
 #include "safe_macros.h"
 #include "mem.h"
+#include "hugetlb.h"
 
 static char TEMPFILE[MAXPATHLEN];
 
@@ -76,9 +77,7 @@ static long beforetest;
 static long aftertest;
 static long hugepagesmapped;
 static long hugepages = 128;
-static long orig_hugepages;
 static char *Hopt;
-static char *nr_opt;
 
 static void help(void);
 
@@ -175,6 +174,7 @@ void setup(void)
 {
 	TEST_PAUSE;
 	tst_require_root();
+	check_hugepage();
 	if (mount("none", Hopt, "hugetlbfs", 0, NULL) < 0)
 		tst_brkm(TBROK | TERRNO, NULL, "mount failed on %s", Hopt);
 	orig_hugepages = get_sys_tune("nr_hugepages");
testcases/kernel/mem/hugetlb/hugemmap/hugemmap05.c +10 -10
index b68c981..7143e82 100644
@@ -48,6 +48,7 @@
 #include <string.h>
 #include <ctype.h>
 #include "test.h"
+#include "hugetlb.h"
 
 #define PROTECTION		(PROT_READ | PROT_WRITE)
 #define PATH_MEMINFO		"/proc/meminfo"
@@ -97,8 +98,6 @@ static option_t options[] = {
 	{NULL, NULL, NULL}
 };
 
-static void setup(void);
-static void cleanup(void);
 static void overcommit(void);
 static void write_bytes(void *addr);
 static void read_bytes(void *addr);
@@ -247,7 +246,7 @@ static void overcommit(void)
 	}
 }
 
-static void cleanup(void)
+void cleanup(void)
 {
 	int fd;
 
@@ -255,7 +254,7 @@ static void cleanup(void)
 		fd = open(PATH_SHMMAX, O_WRONLY);
 		if (fd == -1)
 			tst_resm(TWARN | TERRNO, "open");
-		if (write(fd, shmmax, strlen(shmmax)) != strlen(shmmax))
+		if (write(fd, shmmax, strlen(shmmax)) != (ssize_t)strlen(shmmax))
 			tst_resm(TWARN | TERRNO, "write");
 		close(fd);
 	}
@@ -264,7 +263,7 @@ static void cleanup(void)
 		tst_resm(TWARN | TERRNO, "open");
 	tst_resm(TINFO, "restore nr_hugepages to %s.", nr_hugepages);
 	if (write(fd, nr_hugepages,
-		  strlen(nr_hugepages)) != strlen(nr_hugepages))
+		  strlen(nr_hugepages)) != (ssize_t)strlen(nr_hugepages))
 		tst_resm(TWARN | TERRNO, "write");
 	close(fd);
 
@@ -274,7 +273,7 @@ static void cleanup(void)
 	tst_resm(TINFO, "restore nr_overcommit_hugepages to %s.",
 		 nr_overcommit_hugepages);
 	if (write(fd, nr_overcommit_hugepages, strlen(nr_overcommit_hugepages))
-	    != strlen(nr_overcommit_hugepages))
+	    != (ssize_t)strlen(nr_overcommit_hugepages))
 		tst_resm(TWARN | TERRNO, "write");
 	close(fd);
 
@@ -289,7 +288,7 @@ static void cleanup(void)
 	tst_rmdir();
 }
 
-static void setup(void)
+void setup(void)
 {
 	FILE *fp;
 	int fd;
@@ -323,7 +322,7 @@ static void setup(void)
 				tst_brkm(TBROK | TERRNO, cleanup, "open");
 			snprintf(buf, BUFSIZ, "%ld",
 				 (long)(length / 2 * hugepagesize));
-			if (write(fd, buf, strlen(buf)) != strlen(buf))
+			if (write(fd, buf, strlen(buf)) != (ssize_t)strlen(buf))
 				tst_brkm(TBROK | TERRNO, cleanup,
 					 "failed to change shmmax.");
 		}
@@ -347,7 +346,7 @@ static void setup(void)
 	if (lseek(fd, 0, SEEK_SET) == -1)
 		tst_brkm(TBROK | TERRNO, cleanup, "lseek");
 	snprintf(buf, BUFSIZ, "%zd", size);
-	if (write(fd, buf, strlen(buf)) != strlen(buf))
+	if (write(fd, buf, strlen(buf)) != (ssize_t)strlen(buf))
 		tst_brkm(TBROK | TERRNO, cleanup,
 			 "failed to change nr_hugepages.");
 	close(fd);
@@ -371,7 +370,7 @@ static void setup(void)
 	if (lseek(fd, 0, SEEK_SET) == -1)
 		tst_brkm(TBROK | TERRNO, cleanup, "lseek");
 	snprintf(buf, BUFSIZ, "%zd", size);
-	if (write(fd, buf, strlen(buf)) != strlen(buf))
+	if (write(fd, buf, strlen(buf)) != (ssize_t)strlen(buf))
 		tst_brkm(TBROK | TERRNO, cleanup,
 			 "failed to change nr_hugepages.");
 	close(fd);
@@ -469,6 +468,7 @@ static void init_hugepagesize(void)
 {
 	FILE *fp;
 
+	check_hugepage();
 	memset(buf, -1, BUFSIZ);
 	fp = fopen(PATH_MEMINFO, "r");
 	if (fp == NULL)
testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat01.c +2 -1
index 35e7216..8f994f6 100644
@@ -101,7 +101,7 @@ int main(int ac, char **av)
 {
 	int lc, i;
 
-	tst_parse_opts(ac, av, options, &help);
+	tst_parse_opts(ac, av, options, NULL);
 
 	if (sflag)
 		hugepages = SAFE_STRTOL(NULL, nr_opt, 0, LONG_MAX);
@@ -209,6 +209,7 @@ void setup(void)
 	long hpage_size;
 
 	tst_require_root();
+	check_hugepage();
 	tst_sig(NOFORK, DEF_HANDLER, cleanup);
 	tst_tmpdir();
 
testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat02.c +2 -1
index 2bac9c2..b1c5812 100644
@@ -91,7 +91,7 @@ int main(int ac, char **av)
 {
 	int lc, i;
 
-	tst_parse_opts(ac, av, options, &help);
+	tst_parse_opts(ac, av, options, NULL);
 
 	if (sflag)
 		hugepages = SAFE_STRTOL(NULL, nr_opt, 0, LONG_MAX);
@@ -125,6 +125,7 @@ void setup(void)
 	long hpage_size;
 
 	tst_require_root();
+	check_hugepage();
 	tst_sig(NOFORK, DEF_HANDLER, cleanup);
 	tst_tmpdir();
 
testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat03.c +2 -1
index fe74810..12c9549 100644
@@ -83,7 +83,7 @@ int main(int ac, char **av)
 	int status;
 	pid_t pid;
 
-	tst_parse_opts(ac, av, options, &help);
+	tst_parse_opts(ac, av, options, NULL);
 
 	if (sflag)
 		hugepages = SAFE_STRTOL(NULL, nr_opt, 0, LONG_MAX);
@@ -131,6 +131,7 @@ void setup(void)
 	long hpage_size;
 
 	tst_require_root();
+	check_hugepage();
 	tst_sig(FORK, DEF_HANDLER, cleanup);
 	tst_tmpdir();
 
testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat04.c +2 -1
index f631a0a..7a71747 100644
@@ -47,6 +47,7 @@
 
 #include "test.h"
 #include "mem.h"
+#include "hugetlb.h"
 
 #define SIZE	(1024 * 1024 * 1024)
 #define BOUNDARY (1024 * 1024 * 1024)
@@ -57,7 +58,6 @@ int TST_TOTAL = 3;
 static long huge_free;
 static long huge_free2;
 static long hugepages;
-static long orig_hugepages;
 static long orig_shmmax, new_shmmax;
 
 static void shared_hugepage(void);
@@ -126,6 +126,7 @@ void setup(void)
 	long mem_total, hpage_size;
 
 	tst_require_root();
+	check_hugepage();
 
 	mem_total = read_meminfo("MemTotal:");
 	SAFE_FILE_SCANF(NULL, PATH_SHMMAX, "%ld", &orig_shmmax);
testcases/kernel/mem/hugetlb/hugeshmctl/hugeshmctl01.c +3 -1
index d7990c7..a0d0c55 100644
@@ -64,6 +64,7 @@
 #include "hugetlb.h"
 #include "safe_macros.h"
 #include "mem.h"
+#include "hugetlb.h"
 
 char *TCID = "hugeshmctl01";
 int TST_TOTAL = 4;
@@ -112,7 +113,7 @@ int main(int ac, char **av)
 {
 	int lc, i;
 
-	tst_parse_opts(ac, av, options, &help);
+	tst_parse_opts(ac, av, options, NULL);
 
 	if (sflag)
 		hugepages = SAFE_STRTOL(NULL, nr_opt, 0, LONG_MAX);
@@ -392,6 +393,7 @@ void setup(void)
 	long hpage_size;
 
 	tst_require_root();
+	check_hugepage();
 	tst_sig(FORK, sighandler, cleanup);
 	tst_tmpdir();
 
testcases/kernel/mem/hugetlb/hugeshmctl/hugeshmctl02.c +3 -1
index f79ee83..1ba6159 100644
@@ -56,6 +56,7 @@
 #include "hugetlb.h"
 #include "safe_macros.h"
 #include "mem.h"
+#include "hugetlb.h"
 
 char *TCID = "hugeshmctl02";
 int TST_TOTAL = 4;
@@ -95,7 +96,7 @@ int main(int ac, char **av)
 {
 	int lc, i;
 
-	tst_parse_opts(ac, av, options, &help);
+	tst_parse_opts(ac, av, options, NULL);
 
 	if (sflag)
 		hugepages = SAFE_STRTOL(NULL, nr_opt, 0, LONG_MAX);
@@ -130,6 +131,7 @@ void setup(void)
 	long hpage_size;
 
 	tst_require_root();
+	check_hugepage();
 	tst_sig(NOFORK, DEF_HANDLER, cleanup);
 	tst_tmpdir();
 
testcases/kernel/mem/hugetlb/hugeshmctl/hugeshmctl03.c +3 -1
index e553a2a..f3a0d22 100644
@@ -63,6 +63,7 @@
 #include "hugetlb.h"
 #include "safe_macros.h"
 #include "mem.h"
+#include "hugetlb.h"
 
 char *TCID = "hugeshmctl03";
 int TST_TOTAL = 3;
@@ -102,7 +103,7 @@ int main(int ac, char **av)
 	pid_t pid;
 	int status;
 
-	tst_parse_opts(ac, av, options, &help);
+	tst_parse_opts(ac, av, options, NULL);
 
 	if (sflag)
 		hugepages = SAFE_STRTOL(NULL, nr_opt, 0, LONG_MAX);
@@ -156,6 +157,7 @@ void setup(void)
 	long hpage_size;
 
 	tst_require_root();
+	check_hugepage();
 	tst_sig(FORK, DEF_HANDLER, cleanup);
 	tst_tmpdir();
 
testcases/kernel/mem/hugetlb/hugeshmdt/hugeshmdt01.c +2 -1
index c8592b3..02c7a3d 100644
@@ -85,7 +85,7 @@ int main(int ac, char **av)
 {
 	int lc;
 
-	tst_parse_opts(ac, av, options, &help);
+	tst_parse_opts(ac, av, options, NULL);
 
 	if (sflag)
 		hugepages = SAFE_STRTOL(NULL, nr_opt, 0, LONG_MAX);
@@ -165,6 +165,7 @@ void setup(void)
 	long hpage_size;
 
 	tst_require_root();
+	check_hugepage();
 	tst_sig(NOFORK, sighandler, cleanup);
 	tst_tmpdir();
 
testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget01.c +2 -1
index 5d45aaa..4c51599 100644
@@ -79,7 +79,7 @@ int main(int ac, char **av)
 	int lc;
 	struct shmid_ds buf;
 
-	tst_parse_opts(ac, av, options, &help);
+	tst_parse_opts(ac, av, options, NULL);
 
 	if (sflag)
 		hugepages = SAFE_STRTOL(NULL, nr_opt, 0, LONG_MAX);
@@ -143,6 +143,7 @@ void setup(void)
 	long hpage_size;
 
 	tst_require_root();
+	check_hugepage();
 	tst_sig(NOFORK, DEF_HANDLER, cleanup);
 	tst_tmpdir();
 
testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget02.c +2 -1
index 0ac4a29..73fab60 100644
@@ -95,7 +95,7 @@ int main(int ac, char **av)
 	int lc, i;
 	int shm_id_2 = -1;
 
-	tst_parse_opts(ac, av, options, &help);
+	tst_parse_opts(ac, av, options, NULL);
 
 	if (sflag)
 		hugepages = SAFE_STRTOL(NULL, nr_opt, 0, LONG_MAX);
@@ -138,6 +138,7 @@ void setup(void)
 	long hpage_size;
 
 	tst_require_root();
+	check_hugepage();
 	tst_sig(NOFORK, DEF_HANDLER, cleanup);
 	tst_tmpdir();
 
testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget03.c +2 -1
index 9a2a0b2..e38d3aa 100644
@@ -82,7 +82,7 @@ int main(int ac, char **av)
 {
 	int lc;
 
-	tst_parse_opts(ac, av, options, &help);
+	tst_parse_opts(ac, av, options, NULL);
 
 	if (sflag)
 		hugepages = SAFE_STRTOL(NULL, nr_opt, 0, LONG_MAX);
@@ -113,6 +113,7 @@ void setup(void)
 	long hpage_size;
 
 	tst_require_root();
+	check_hugepage();
 	tst_sig(NOFORK, DEF_HANDLER, cleanup);
 	tst_tmpdir();
 
testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget05.c +2 -1
index 567b02d..2a0d468 100644
@@ -85,7 +85,7 @@ int main(int ac, char **av)
 	pid_t pid;
 	int status;
 
-	tst_parse_opts(ac, av, options, &help);
+	tst_parse_opts(ac, av, options, NULL);
 
 	if (sflag)
 		hugepages = SAFE_STRTOL(NULL, nr_opt, 0, LONG_MAX);
@@ -135,6 +135,7 @@ void setup(void)
 	long hpage_size;
 
 	tst_require_root();
+	check_hugepage();
 	tst_sig(FORK, DEF_HANDLER, cleanup);
 	tst_tmpdir();
 
testcases/kernel/mem/hugetlb/lib/hugetlb.c +7 -6
index 4b2a3d2..dae7da3 100644
@@ -26,10 +26,10 @@
  *
  *	The library contains the following routines:
  *
+ *	check_hugepage()
  *	getipckey()
  *	getuserid()
  *	rm_shm()
- *	help()
  */
 
 #include <sys/types.h>
@@ -39,6 +39,12 @@
 #include <pwd.h>
 #include "hugetlb.h"
 
+void check_hugepage(void)
+{
+	if (access(PATH_HUGEPAGES, F_OK))
+		tst_brkm(TCONF, NULL, "Huge page is not supported.");
+}
+
 /*
  * getipckey() - generates and returns a message key used by the "get"
  *		 calls to create an IPC resource.
@@ -109,8 +115,3 @@ void rm_shm(int shm_id)
 		tst_resm(TINFO, "id = %d", shm_id);
 	}
 }
-
-void help(void)
-{
-	printf("    -s NUM  Set the number of hugepages to be allocated\n");
-}
testcases/kernel/mem/hugetlb/lib/hugetlb.h +3 -1
index 6d73e9c..9b76abe 100644
@@ -43,9 +43,12 @@
  * from shmid_ds.ipc_perm.mode
  */
 #define MODE_MASK	0x01FF
+#define PATH_HUGEPAGES	"/sys/kernel/mm/hugepages/"
 
 key_t shmkey;			/* an IPC key generated by ftok() */
 
+void check_hugepage(void);
+
 int getipckey(void);
 int getuserid(char *user);
 void rm_shm(int shm_id);
@@ -56,6 +59,5 @@ void setup(void);
 char *nr_opt;
 int sflag;
 long orig_hugepages;
-void help(void);
 
 #endif /* hugetlb.h */
testcases/kernel/syscalls/futex/futex_wake04.c +4 -0
index dcefde8..3c70383 100644
@@ -50,6 +50,7 @@
 
 #define PATH_MEMINFO "/proc/meminfo"
 #define PATH_NR_HUGEPAGES "/proc/sys/vm/nr_hugepages"
+#define PATH_HUGEPAGES	"/sys/kernel/mm/hugepages/"
 
 const char *TCID = "futex_wake04";
 const int TST_TOTAL = 1;
@@ -69,6 +70,9 @@ static void setup(void)
 			"that are 2.6.32 or higher");
 	}
 
+	if (access(PATH_HUGEPAGES, F_OK))
+		tst_brkm(TCONF, NULL, "Huge page is not supported.");
+
 	tst_tmpdir();
 
 	SAFE_FILE_SCANF(NULL, PATH_NR_HUGEPAGES, "%ld", &orig_hugepages);
Signature · 1 line
1.8.3.1
#3 lore raw

PATCH 2/2 hugetlb: checking if hugepage is supported on target system

Hi!

testcases/kernel/mem/hugetlb/hugemmap/hugemmap05.c static void cleanup(void) · line 291

Quoted 2 lines
testcases/kernel/mem/hugetlb/hugemmap/hugemmap05.c +1 -1
-static void setup(void)
+void setup(void)

This is wrong. What you should do instead is:

* Remove the cleanup() and setup() definitions from the header from lib/

* Change the getipckey() and getuserid() to have the callback pointer as their first parameter and pass the cleanup callback in the testcases.

Signature · 2 lines
Cyril Hrubis
[email protected]
author
#4 lore raw

PATCH 2/2 hugetlb: checking if hugepage is supported on target system

Hi,

Quoted 6 lines · Cyril Hrubis

Hi!

testcases/kernel/mem/hugetlb/hugemmap/hugemmap05.c static void cleanup(void) · line 291

Quoted 2 lines
testcases/kernel/mem/hugetlb/hugemmap/hugemmap05.c +1 -1
-static void setup(void)
+void setup(void)

This is wrong. What you should do instead is:

Quoted 6 lines

* Remove the cleanup() and setup() definitions from the header from lib/

* Change the getipckey() and getuserid() to have the callback pointer as their first parameter and pass the cleanup callback in the testcases.

ok, great. I would like to change that. patch V2 will be threw out.

Signature · 6 lines
Regards,
Li Wang
Email: [email protected]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20151204/55a132c1/attachment.html>