1 #ifndef _VX_VS_CONTEXT_H
2 #define _VX_VS_CONTEXT_H
4 #include <linux/kernel.h>
5 #include "vserver/debug.h"
8 #define get_vx_info(i) __get_vx_info(i,__FILE__,__LINE__,__HERE__)
10 static inline struct vx_info *__get_vx_info(struct vx_info *vxi,
11 const char *_file, int _line, void *_here)
16 vxlprintk(VXD_CBIT(xid, 2), "get_vx_info(%p[#%d.%d])",
17 vxi, vxi?vxi->vx_id:0, vxi?atomic_read(&vxi->vx_usecnt):0,
19 __vxh_get_vx_info(vxi, _here);
21 atomic_inc(&vxi->vx_usecnt);
26 extern void free_vx_info(struct vx_info *);
28 #define put_vx_info(i) __put_vx_info(i,__FILE__,__LINE__,__HERE__)
30 static inline void __put_vx_info(struct vx_info *vxi,
31 const char *_file, int _line, void *_here)
36 vxlprintk(VXD_CBIT(xid, 2), "put_vx_info(%p[#%d.%d])",
37 vxi, vxi?vxi->vx_id:0, vxi?atomic_read(&vxi->vx_usecnt):0,
39 __vxh_put_vx_info(vxi, _here);
41 if (atomic_dec_and_test(&vxi->vx_usecnt))
46 #define init_vx_info(p,i) __init_vx_info(p,i,__FILE__,__LINE__,__HERE__)
48 static inline void __init_vx_info(struct vx_info **vxp, struct vx_info *vxi,
49 const char *_file, int _line, void *_here)
52 vxlprintk(VXD_CBIT(xid, 3),
53 "init_vx_info(%p[#%d.%d])",
54 vxi, vxi?vxi->vx_id:0,
55 vxi?atomic_read(&vxi->vx_usecnt):0,
57 __vxh_init_vx_info(vxi, vxp, _here);
59 atomic_inc(&vxi->vx_usecnt);
65 #define set_vx_info(p,i) __set_vx_info(p,i,__FILE__,__LINE__,__HERE__)
67 static inline void __set_vx_info(struct vx_info **vxp, struct vx_info *vxi,
68 const char *_file, int _line, void *_here)
75 vxlprintk(VXD_CBIT(xid, 3), "set_vx_info(%p[#%d.%d])",
76 vxi, vxi?vxi->vx_id:0,
77 vxi?atomic_read(&vxi->vx_usecnt):0,
79 __vxh_set_vx_info(vxi, vxp, _here);
81 atomic_inc(&vxi->vx_usecnt);
87 #define clr_vx_info(p) __clr_vx_info(p,__FILE__,__LINE__,__HERE__)
89 static inline void __clr_vx_info(struct vx_info **vxp,
90 const char *_file, int _line, void *_here)
94 vxo = xchg(vxp, NULL);
98 vxlprintk(VXD_CBIT(xid, 3), "clr_vx_info(%p[#%d.%d])",
99 vxo, vxo?vxo->vx_id:0,
100 vxo?atomic_read(&vxo->vx_usecnt):0,
102 __vxh_clr_vx_info(vxo, vxp, _here);
104 if (atomic_dec_and_test(&vxo->vx_usecnt))
109 #define claim_vx_info(v,p) \
110 __claim_vx_info(v,p,__FILE__,__LINE__,__HERE__)
112 static inline void __claim_vx_info(struct vx_info *vxi,
113 struct task_struct *task,
114 const char *_file, int _line, void *_here)
116 vxlprintk(VXD_CBIT(xid, 3), "claim_vx_info(%p[#%d.%d.%d]) %p",
117 vxi, vxi?vxi->vx_id:0,
118 vxi?atomic_read(&vxi->vx_usecnt):0,
119 vxi?atomic_read(&vxi->vx_tasks):0,
121 __vxh_claim_vx_info(vxi, task, _here);
123 atomic_inc(&vxi->vx_tasks);
127 extern void unhash_vx_info(struct vx_info *);
129 #define release_vx_info(v,p) \
130 __release_vx_info(v,p,__FILE__,__LINE__,__HERE__)
132 static inline void __release_vx_info(struct vx_info *vxi,
133 struct task_struct *task,
134 const char *_file, int _line, void *_here)
136 vxlprintk(VXD_CBIT(xid, 3), "release_vx_info(%p[#%d.%d.%d]) %p",
137 vxi, vxi?vxi->vx_id:0,
138 vxi?atomic_read(&vxi->vx_usecnt):0,
139 vxi?atomic_read(&vxi->vx_tasks):0,
141 __vxh_release_vx_info(vxi, task, _here);
145 if (atomic_dec_and_test(&vxi->vx_tasks))
150 #define task_get_vx_info(p) \
151 __task_get_vx_info(p,__FILE__,__LINE__,__HERE__)
153 static inline struct vx_info *__task_get_vx_info(struct task_struct *p,
154 const char *_file, int _line, void *_here)
159 vxlprintk(VXD_CBIT(xid, 5), "task_get_vx_info(%p)",
161 vxi = __get_vx_info(p->vx_info, _file, _line, _here);
167 static inline void __wakeup_vx_info(struct vx_info *vxi)
169 if (waitqueue_active(&vxi->vx_wait))
170 wake_up_interruptible(&vxi->vx_wait);
173 extern void exit_vx_info(struct task_struct *, int);
176 struct task_struct *vx_child_reaper(struct task_struct *p)
178 struct vx_info *vxi = p->vx_info;
179 struct task_struct *reaper = child_reaper;
184 BUG_ON(!p->vx_info->vx_reaper);
186 /* child reaper for the guest reaper */
187 if (vxi->vx_reaper == p)
190 reaper = vxi->vx_reaper;
197 #warning duplicate inclusion