FreeBSD Bugzilla – Attachment 167260 Details for
Bug 207386
[PATCH] implementation of the /proc/<pid>/limits file for linprocfs
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
more complete implementation
linprocfs1.patch (text/plain), 4.95 KB, created by
Dmitry Chagin
on 2016-02-21 15:24:47 UTC
(
hide
)
Description:
more complete implementation
Filename:
MIME Type:
Creator:
Dmitry Chagin
Created:
2016-02-21 15:24:47 UTC
Size:
4.95 KB
patch
obsolete
>diff --git a/sys/compat/linprocfs/linprocfs.c b/sys/compat/linprocfs/linprocfs.c >index 86c4b05..43537b2 100644 >--- a/sys/compat/linprocfs/linprocfs.c >+++ b/sys/compat/linprocfs/linprocfs.c >@@ -1370,65 +1370,91 @@ linprocfs_dofdescfs(PFS_FILL_ARGS) > /* > * Filler function for proc/pid/limits > */ >- >-#define RLIM_NONE -1 >- >-static const struct limit_info { >+static const struct linux_rlimit_ident { > const char *desc; > const char *unit; >- unsigned long long rlim_id; >-} limits_info[] = { >- { "Max cpu time", "seconds", RLIMIT_CPU }, >- { "Max file size", "bytes", RLIMIT_FSIZE }, >- { "Max data size", "bytes", RLIMIT_DATA }, >- { "Max stack size", "bytes", RLIMIT_STACK }, >- { "Max core file size", "bytes", RLIMIT_CORE }, >- { "Max resident set", "bytes", RLIMIT_RSS }, >- { "Max processes", "processes", RLIMIT_NPROC }, >- { "Max open files", "files", RLIMIT_NOFILE }, >- { "Max locked memory", "bytes", RLIMIT_MEMLOCK }, >- { "Max address space", "bytes", RLIMIT_AS }, >- { "Max file locks", "locks", RLIM_INFINITY }, >- { "Max pending signals", "signals", RLIM_INFINITY }, >- { "Max msgqueue size", "bytes", RLIM_NONE }, >- { "Max nice priority", "", RLIM_NONE }, >- { "Max realtime priority", "", RLIM_NONE }, >- { "Max realtime timeout", "us", RLIM_INFINITY }, >+ unsigned int rlim_id; >+} linux_rlimits_ident[] = { >+ { "Max cpu time", "seconds", RLIMIT_CPU }, >+ { "Max file size", "bytes", RLIMIT_FSIZE }, >+ { "Max data size", "bytes", RLIMIT_DATA }, >+ { "Max stack size", "bytes", RLIMIT_STACK }, >+ { "Max core file size", "bytes", RLIMIT_CORE }, >+ { "Max resident set", "bytes", RLIMIT_RSS }, >+ { "Max processes", "processes", RLIMIT_NPROC }, >+ { "Max open files", "files", RLIMIT_NOFILE }, >+ { "Max locked memory", "bytes", RLIMIT_MEMLOCK }, >+ { "Max address space", "bytes", RLIMIT_AS }, >+ { "Max file locks", "locks", LINUX_RLIMIT_LOCKS }, >+ { "Max pending signals", "signals", LINUX_RLIMIT_SIGPENDING }, >+ { "Max msgqueue size", "bytes", LINUX_RLIMIT_MSGQUEUE }, >+ { "Max nice priority", "", LINUX_RLIMIT_NICE }, >+ { "Max realtime priority", "", LINUX_RLIMIT_RTPRIO }, >+ { "Max realtime timeout", "us", LINUX_RLIMIT_RTTIME }, > { 0, 0, 0 } > }; > > static int > linprocfs_doproclimits(PFS_FILL_ARGS) > { >- const struct limit_info *li; >- struct rlimit li_rlimits; >- struct plimit *cur_proc_lim; >- >- cur_proc_lim = lim_alloc(); >- lim_copy(cur_proc_lim, p->p_limit); >- sbuf_printf(sb, "%-26s%-21s%-21s%-10s\n", "Limit", "Soft Limit", >+ const struct linux_rlimit_ident *li; >+ struct plimit *cpl; >+ struct rlimit rl; >+ ssize_t size; >+ int res, error; >+ >+ size = sizeof(res); >+ cpl = lim_alloc(); >+ lim_copy(cpl, p->p_limit); >+ sbuf_printf(sb, "%-26s%-21s%-21s%-21s\n", "Limit", "Soft Limit", > "Hard Limit", "Units"); >- for (li = limits_info; li->desc != NULL; ++li) { >- if (li->rlim_id != RLIM_INFINITY && li->rlim_id != RLIM_NONE) >- li_rlimits = cur_proc_lim->pl_rlimit[li->rlim_id]; >- else { >- li_rlimits.rlim_cur = 0; >- li_rlimits.rlim_max = 0; >+ for (li = linux_rlimits_ident; li->desc != NULL; ++li) { >+ switch (li->rlim_id) >+ { >+ case LINUX_RLIMIT_LOCKS: >+ /* FALLTHROUGH */ >+ case LINUX_RLIMIT_RTTIME: >+ rl.rlim_cur = RLIM_INFINITY; >+ break; >+ case LINUX_RLIMIT_SIGPENDING: >+ error = kernel_sysctlbyname(td, >+ "kern.sigqueue.max_pending_per_proc", >+ &res, &size, 0, 0, 0, 0); >+ if (error != 0) >+ break; >+ rl.rlim_cur = res; >+ rl.rlim_max = res; >+ break; >+ case LINUX_RLIMIT_MSGQUEUE: >+ error = kernel_sysctlbyname(td, >+ "kern.ipc.msgmnb", &res, &size, 0, 0, 0, 0); >+ if (error != 0) >+ break; >+ rl.rlim_cur = res; >+ rl.rlim_max = res; >+ break; >+ case LINUX_RLIMIT_NICE: >+ /* FALLTHROUGH */ >+ case LINUX_RLIMIT_RTPRIO: >+ rl.rlim_cur = 0; >+ rl.rlim_max = 0; >+ break; >+ default: >+ rl = cpl->pl_rlimit[li->rlim_id]; >+ break; > } >- if (li->rlim_id == RLIM_INFINITY || >- li_rlimits.rlim_cur == RLIM_INFINITY) >+ if (rl.rlim_cur == RLIM_INFINITY) > sbuf_printf(sb, "%-26s%-21s%-21s%-10s\n", > li->desc, "unlimited", "unlimited", li->unit); > else > sbuf_printf(sb, "%-26s%-21ld%-21ld%-10s\n", >- li->desc, (long)li_rlimits.rlim_cur, >- (long)li_rlimits.rlim_max, li->unit); >+ li->desc, (long)rl.rlim_cur, >+ (long)rl.rlim_max, li->unit); > } >- lim_free(cur_proc_lim); >- return (0); >+ lim_free(cpl); >+ return (error); > } > >- > /* > * Filler function for proc/sys/kernel/random/uuid > */ >diff --git a/sys/compat/linux/linux_misc.h b/sys/compat/linux/linux_misc.h >index c2d6065..64037f5 100644 >--- a/sys/compat/linux/linux_misc.h >+++ b/sys/compat/linux/linux_misc.h >@@ -150,6 +150,13 @@ extern int stclohz; > #define LINUX_P_PID 1 > #define LINUX_P_PGID 2 > >+#define LINUX_RLIMIT_LOCKS RLIM_NLIMITS + 1 >+#define LINUX_RLIMIT_SIGPENDING RLIM_NLIMITS + 2 >+#define LINUX_RLIMIT_MSGQUEUE RLIM_NLIMITS + 3 >+#define LINUX_RLIMIT_NICE RLIM_NLIMITS + 4 >+#define LINUX_RLIMIT_RTPRIO RLIM_NLIMITS + 5 >+#define LINUX_RLIMIT_RTTIME RLIM_NLIMITS + 6 >+ > #define LINUX_RLIM_INFINITY (~0UL) > > int linux_common_wait(struct thread *td, int pid, int *status,
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 207386
:
167233
|
167260
|
167315
|
167814