• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef _LINUX_SHM_H_
2 #define _LINUX_SHM_H_
3 
4 #include <linux/list.h>
5 #include <asm/page.h>
6 #include <uapi/linux/shm.h>
7 #include <asm/shmparam.h>
8 
9 struct shmid_kernel /* private to the kernel */
10 {
11 	struct kern_ipc_perm	shm_perm;
12 	struct file		*shm_file;
13 	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;
21 
22 	/*
23 	 * The task created the shm object, for
24 	 * task_lock(shp->shm_creator)
25 	 */
26 	struct task_struct	*shm_creator;
27 
28 	/*
29 	 * List by creator. task_lock(->shm_creator) required for read/write.
30 	 * If list_empty(), then the creator is dead already.
31 	 */
32 	struct list_head	shm_clist;
33 	struct ipc_namespace	*ns;
34 };
35 
36 /* shm_mode upper byte flags */
37 #define	SHM_DEST	01000	/* segment will be destroyed on last detach */
38 #define SHM_LOCKED      02000   /* segment will not be swapped */
39 #define SHM_HUGETLB     04000   /* segment will use huge TLB pages */
40 #define SHM_NORESERVE   010000  /* don't check for reservations */
41 
42 /* Bits [26:31] are reserved */
43 
44 /*
45  * When SHM_HUGETLB is set bits [26:31] encode the log2 of the huge page size.
46  * This gives us 6 bits, which is enough until someone invents 128 bit address
47  * spaces.
48  *
49  * Assume these are all power of twos.
50  * When 0 use the default page size.
51  */
52 #define SHM_HUGE_SHIFT  26
53 #define SHM_HUGE_MASK   0x3f
54 #define SHM_HUGE_2MB    (21 << SHM_HUGE_SHIFT)
55 #define SHM_HUGE_1GB    (30 << SHM_HUGE_SHIFT)
56 
57 #ifdef CONFIG_SYSVIPC
58 struct sysv_shm {
59 	struct list_head shm_clist;
60 };
61 
62 long do_shmat(int shmid, char __user *shmaddr, int shmflg, unsigned long *addr,
63 	      unsigned long shmlba);
64 int is_file_shm_hugepages(struct file *file);
65 void exit_shm(struct task_struct *task);
66 #define shm_init_task(task) INIT_LIST_HEAD(&(task)->sysvshm.shm_clist)
67 #else
68 struct sysv_shm {
69 	/* empty */
70 };
71 
do_shmat(int shmid,char __user * shmaddr,int shmflg,unsigned long * addr,unsigned long shmlba)72 static inline long do_shmat(int shmid, char __user *shmaddr,
73 			    int shmflg, unsigned long *addr,
74 			    unsigned long shmlba)
75 {
76 	return -ENOSYS;
77 }
is_file_shm_hugepages(struct file * file)78 static inline int is_file_shm_hugepages(struct file *file)
79 {
80 	return 0;
81 }
exit_shm(struct task_struct * task)82 static inline void exit_shm(struct task_struct *task)
83 {
84 }
shm_init_task(struct task_struct * task)85 static inline void shm_init_task(struct task_struct *task)
86 {
87 }
88 #endif
89 
90 #endif /* _LINUX_SHM_H_ */
91