1 #if defined(__KERNEL__) && defined(_VX_INFO_DEF_)
3 #include <asm/atomic.h>
4 #include <asm/resource.h>
6 /* context sub struct */
8 #define RLIMIT_OPENFD 12
10 #define NUM_RLIMITS 16
12 #define VLIMIT_SOCK 16
18 unsigned long rlim[NUM_RLIMITS]; /* Per context limit */
19 atomic_t res[NUM_RLIMITS]; /* Current value */
22 static inline void vx_info_init_limit(struct _vx_limit *limit)
26 for (lim=0; lim<NUM_RLIMITS; lim++) {
27 limit->rlim[lim] = RLIM_INFINITY;
28 atomic_set(&limit->res[lim], 0);
32 extern unsigned int vx_debug_limit;
34 static inline void vx_info_exit_limit(struct _vx_limit *limit)
38 for (lim=0; lim<NUM_RLIMITS; lim++) {
39 value = atomic_read(&limit->res[lim]);
40 if (value && vx_debug_limit)
41 printk("!!! limit: %p[%d] = %d on exit.\n",
47 static inline int vx_info_proc_limit(struct _vx_limit *limit, char *buffer)
49 return sprintf(buffer,
56 ,atomic_read(&limit->res[RLIMIT_NPROC])
57 ,limit->rlim[RLIMIT_NPROC]
58 ,atomic_read(&limit->res[RLIMIT_AS])
59 ,limit->rlim[RLIMIT_AS]
60 ,atomic_read(&limit->res[RLIMIT_MEMLOCK])
61 ,limit->rlim[RLIMIT_MEMLOCK]
62 ,atomic_read(&limit->res[RLIMIT_RSS])
63 ,limit->rlim[RLIMIT_RSS]
64 ,atomic_read(&limit->res[RLIMIT_NOFILE])
65 ,limit->rlim[RLIMIT_NOFILE]
66 ,atomic_read(&limit->res[RLIMIT_OPENFD])
67 ,limit->rlim[RLIMIT_OPENFD]
71 #else /* _VX_INFO_DEF_ */
77 /* rlimit vserver commands */
79 #define VCMD_get_rlimit VC_CMD(RLIMIT, 1, 0)
80 #define VCMD_set_rlimit VC_CMD(RLIMIT, 2, 0)
81 #define VCMD_get_rlimit_mask VC_CMD(RLIMIT, 3, 0)
83 struct vcmd_ctx_rlimit_v0 {
90 struct vcmd_ctx_rlimit_mask_v0 {
96 #define CRLIM_UNSET (0ULL)
97 #define CRLIM_INFINITY (~0ULL)
98 #define CRLIM_KEEP (~1ULL)
102 #include <linux/compiler.h>
104 extern int vc_get_rlimit(uint32_t, void __user *);
105 extern int vc_set_rlimit(uint32_t, void __user *);
106 extern int vc_get_rlimit_mask(uint32_t, void __user *);
110 void vx_vsi_meminfo(struct sysinfo *);
111 void vx_vsi_swapinfo(struct sysinfo *);
114 #endif /* __KERNEL__ */
116 #endif /* _VX_LIMIT_H */