blob: 6b5c61e865c35d2e1fe3723fa16dd04b2cbd4d2c [file] [log] [blame]
robbiewd6f9ef12004-04-15 17:40:01 +00001/*
2 *
3 * Copyright (c) International Business Machines Corp., 2001
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
13 * the GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
Wanlong Gao4548c6c2012-10-19 18:03:36 +080017 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
robbiewd6f9ef12004-04-15 17:40:01 +000018 */
19
20/*
Li Wang676746e2015-12-04 14:23:05 +080021 * hugetlb.h - common definitions for the hugepage tests
robbiewd6f9ef12004-04-15 17:40:01 +000022 */
23
Li Wang676746e2015-12-04 14:23:05 +080024#ifndef __HUGETLB_H
25#define __HUGETLB_H
robbiewd6f9ef12004-04-15 17:40:01 +000026
robbiewd6f9ef12004-04-15 17:40:01 +000027#include <sys/ipc.h>
28#include <sys/shm.h>
Caspar Zhang23a3e852012-03-13 09:38:39 +080029#include <errno.h>
Steven Jackson249f4052016-12-13 16:16:00 +000030#include <sys/wait.h>
robbiewd6f9ef12004-04-15 17:40:01 +000031#include "test.h"
robbiewd6f9ef12004-04-15 17:40:01 +000032
robbiewd6f9ef12004-04-15 17:40:01 +000033#define SHM_RD 0400
34#define SHM_WR 0200
Caspar Zhang23a3e852012-03-13 09:38:39 +080035#define SHM_RW (SHM_RD|SHM_WR)
robbiewd6f9ef12004-04-15 17:40:01 +000036
robbiew90af9f32004-06-21 21:02:45 +000037#ifndef SHM_HUGETLB
Caspar Zhang23a3e852012-03-13 09:38:39 +080038#define SHM_HUGETLB 04000 /* segment is mapped via hugetlb */
robbiew90af9f32004-06-21 21:02:45 +000039#endif
40
Caspar Zhang23a3e852012-03-13 09:38:39 +080041/*
42 * to get the lower nine permission bits
43 * from shmid_ds.ipc_perm.mode
44 */
45#define MODE_MASK 0x01FF
Li Wang926c65d2015-12-04 14:29:37 +080046#define PATH_HUGEPAGES "/sys/kernel/mm/hugepages/"
robbiewd6f9ef12004-04-15 17:40:01 +000047
Caspar Zhang23a3e852012-03-13 09:38:39 +080048key_t shmkey; /* an IPC key generated by ftok() */
robbiewd6f9ef12004-04-15 17:40:01 +000049
Li Wang926c65d2015-12-04 14:29:37 +080050void check_hugepage(void);
robbiewd6f9ef12004-04-15 17:40:01 +000051
Li Wang926c65d2015-12-04 14:29:37 +080052int getipckey(void (*cleanup_fn) (void));
53int getuserid(void (*cleanup_fn) (void), char *user);
54void rm_shm(int shm_id);
robbiewd6f9ef12004-04-15 17:40:01 +000055
Caspar Zhang491f7282012-03-13 09:47:37 +080056char *nr_opt;
57int sflag;
58long orig_hugepages;
Caspar Zhang491f7282012-03-13 09:47:37 +080059
Li Wang676746e2015-12-04 14:23:05 +080060#endif /* hugetlb.h */