blob: 57d77709fbe2a1c2cb6f8a7f47604bf560b24b9f [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#include <asm/shmparam.h>
Manfred Spraul060028b2014-06-06 14:37:42 -07007
Linus Torvalds1da177e2005-04-16 15:20:36 -07008struct shmid_kernel /* private to the kernel */
9{
10 struct kern_ipc_perm shm_perm;
Manfred Spraul239521f2014-01-27 17:07:04 -080011 struct file *shm_file;
Linus Torvalds1da177e2005-04-16 15:20:36 -070012 unsigned long shm_nattch;
13 unsigned long shm_segsz;
14 time_t shm_atim;
15 time_t shm_dtim;
16 time_t shm_ctim;
17 pid_t shm_cprid;
18 pid_t shm_lprid;
19 struct user_struct *mlock_user;
Vasiliy Kulikov5774ed02011-07-29 03:55:31 +040020
21 /* The task created the shm object. NULL if the task is dead. */
22 struct task_struct *shm_creator;
Linus Torvalds1da177e2005-04-16 15:20:36 -070023};
24
25/* shm_mode upper byte flags */
26#define SHM_DEST 01000 /* segment will be destroyed on last detach */
27#define SHM_LOCKED 02000 /* segment will not be swapped */
28#define SHM_HUGETLB 04000 /* segment will use huge TLB pages */
Badari Pulavartybf8f9722005-11-07 00:59:27 -080029#define SHM_NORESERVE 010000 /* don't check for reservations */
Linus Torvalds1da177e2005-04-16 15:20:36 -070030
Andi Kleen42d73952012-12-11 16:01:34 -080031/* Bits [26:31] are reserved */
32
33/*
34 * When SHM_HUGETLB is set bits [26:31] encode the log2 of the huge page size.
35 * This gives us 6 bits, which is enough until someone invents 128 bit address
36 * spaces.
37 *
38 * Assume these are all power of twos.
39 * When 0 use the default page size.
40 */
41#define SHM_HUGE_SHIFT 26
42#define SHM_HUGE_MASK 0x3f
43#define SHM_HUGE_2MB (21 << SHM_HUGE_SHIFT)
44#define SHM_HUGE_1GB (30 << SHM_HUGE_SHIFT)
45
Linus Torvalds1da177e2005-04-16 15:20:36 -070046#ifdef CONFIG_SYSVIPC
Will Deacon079a96a2012-07-30 14:42:38 -070047long do_shmat(int shmid, char __user *shmaddr, int shmflg, unsigned long *addr,
48 unsigned long shmlba);
Adam Litke516dffd2007-03-01 15:46:08 -080049extern int is_file_shm_hugepages(struct file *file);
Vasiliy Kulikovb34a6b12011-07-26 16:08:48 -070050extern void exit_shm(struct task_struct *task);
Linus Torvalds1da177e2005-04-16 15:20:36 -070051#else
52static inline long do_shmat(int shmid, char __user *shmaddr,
Will Deacon079a96a2012-07-30 14:42:38 -070053 int shmflg, unsigned long *addr,
54 unsigned long shmlba)
Linus Torvalds1da177e2005-04-16 15:20:36 -070055{
56 return -ENOSYS;
57}
Adam Litke516dffd2007-03-01 15:46:08 -080058static inline int is_file_shm_hugepages(struct file *file)
59{
60 return 0;
61}
Vasiliy Kulikovb34a6b12011-07-26 16:08:48 -070062static inline void exit_shm(struct task_struct *task)
63{
64}
Linus Torvalds1da177e2005-04-16 15:20:36 -070065#endif
66
Linus Torvalds1da177e2005-04-16 15:20:36 -070067#endif /* _LINUX_SHM_H_ */