blob: 429c1995d756634f82906af0ad532d5423ec7622 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _LINUX_SHM_H_
2#define _LINUX_SHM_H_
3
Linus Torvalds1da177e2005-04-16 15:20:36 -07004#include <asm/page.h>
David Howells607ca462012-10-13 10:46:48 +01005#include <uapi/linux/shm.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07006
Linus Torvalds1da177e2005-04-16 15:20:36 -07007#define SHMALL (SHMMAX/PAGE_SIZE*(SHMMNI/16)) /* max shm system wide (pages) */
Linus Torvalds1da177e2005-04-16 15:20:36 -07008#include <asm/shmparam.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07009struct shmid_kernel /* private to the kernel */
10{
11 struct kern_ipc_perm shm_perm;
12 struct file * shm_file;
Linus Torvalds1da177e2005-04-16 15:20:36 -070013 unsigned long shm_nattch;
14 unsigned long shm_segsz;
15 time_t shm_atim;
16 time_t shm_dtim;
17 time_t shm_ctim;
18 pid_t shm_cprid;
19 pid_t shm_lprid;
20 struct user_struct *mlock_user;
Vasiliy Kulikov5774ed02011-07-29 03:55:31 +040021
22 /* The task created the shm object. NULL if the task is dead. */
23 struct task_struct *shm_creator;
Linus Torvalds1da177e2005-04-16 15:20:36 -070024};
25
26/* shm_mode upper byte flags */
27#define SHM_DEST 01000 /* segment will be destroyed on last detach */
28#define SHM_LOCKED 02000 /* segment will not be swapped */
29#define SHM_HUGETLB 04000 /* segment will use huge TLB pages */
Badari Pulavartybf8f9722005-11-07 00:59:27 -080030#define SHM_NORESERVE 010000 /* don't check for reservations */
Linus Torvalds1da177e2005-04-16 15:20:36 -070031
Andi Kleen42d73952012-12-11 16:01:34 -080032/* Bits [26:31] are reserved */
33
34/*
35 * When SHM_HUGETLB is set bits [26:31] encode the log2 of the huge page size.
36 * This gives us 6 bits, which is enough until someone invents 128 bit address
37 * spaces.
38 *
39 * Assume these are all power of twos.
40 * When 0 use the default page size.
41 */
42#define SHM_HUGE_SHIFT 26
43#define SHM_HUGE_MASK 0x3f
44#define SHM_HUGE_2MB (21 << SHM_HUGE_SHIFT)
45#define SHM_HUGE_1GB (30 << SHM_HUGE_SHIFT)
46
Linus Torvalds1da177e2005-04-16 15:20:36 -070047#ifdef CONFIG_SYSVIPC
Will Deacon079a96a2012-07-30 14:42:38 -070048long do_shmat(int shmid, char __user *shmaddr, int shmflg, unsigned long *addr,
49 unsigned long shmlba);
Adam Litke516dffd2007-03-01 15:46:08 -080050extern int is_file_shm_hugepages(struct file *file);
Vasiliy Kulikovb34a6b12011-07-26 16:08:48 -070051extern void exit_shm(struct task_struct *task);
Linus Torvalds1da177e2005-04-16 15:20:36 -070052#else
53static inline long do_shmat(int shmid, char __user *shmaddr,
Will Deacon079a96a2012-07-30 14:42:38 -070054 int shmflg, unsigned long *addr,
55 unsigned long shmlba)
Linus Torvalds1da177e2005-04-16 15:20:36 -070056{
57 return -ENOSYS;
58}
Adam Litke516dffd2007-03-01 15:46:08 -080059static inline int is_file_shm_hugepages(struct file *file)
60{
61 return 0;
62}
Vasiliy Kulikovb34a6b12011-07-26 16:08:48 -070063static inline void exit_shm(struct task_struct *task)
64{
65}
Linus Torvalds1da177e2005-04-16 15:20:36 -070066#endif
67
Linus Torvalds1da177e2005-04-16 15:20:36 -070068#endif /* _LINUX_SHM_H_ */