Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F103031486
D34710.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D34710.diff
View Options
diff --git a/sys/compat/linprocfs/linprocfs.c b/sys/compat/linprocfs/linprocfs.c
--- a/sys/compat/linprocfs/linprocfs.c
+++ b/sys/compat/linprocfs/linprocfs.c
@@ -80,6 +80,7 @@
#include <sys/vmmeter.h>
#include <sys/vnode.h>
#include <sys/bus.h>
+#include <sys/uio.h>
#include <net/if.h>
#include <net/if_var.h>
@@ -104,6 +105,7 @@
#endif /* __i386__ || __amd64__ */
#include <compat/linux/linux.h>
+#include <compat/linux/linux_emul.h>
#include <compat/linux/linux_mib.h>
#include <compat/linux/linux_misc.h>
#include <compat/linux/linux_util.h>
@@ -1932,6 +1934,32 @@
return (error);
}
+/*
+ * Filler function for proc/self/oom_score_adj
+ */
+static int
+linprocfs_do_oom_score_adj(PFS_FILL_ARGS)
+{
+ struct linux_pemuldata *pem;
+ long oom;
+
+ pem = pem_find(p);
+ if (pem == NULL || uio == NULL)
+ return (EOPNOTSUPP);
+ if (uio->uio_rw == UIO_READ) {
+ sbuf_printf(sb, "%d\n", pem->oom_score_adj);
+ } else {
+ sbuf_trim(sb);
+ sbuf_finish(sb);
+ oom = strtol(sbuf_data(sb), NULL, 10);
+ if (oom < LINUX_OOM_SCORE_ADJ_MIN ||
+ oom > LINUX_OOM_SCORE_ADJ_MAX)
+ return (EINVAL);
+ pem->oom_score_adj = oom;
+ }
+ return (0);
+}
+
/*
* Constructor
*/
@@ -2018,6 +2046,8 @@
NULL, &procfs_candebug, NULL, PFS_RD|PFS_RAWRD);
pfs_create_file(dir, "limits", &linprocfs_doproclimits,
NULL, NULL, NULL, PFS_RD);
+ pfs_create_file(dir, "oom_score_adj", &linprocfs_do_oom_score_adj,
+ procfs_attr_rw, &procfs_candebug, NULL, PFS_RDWR);
/* /proc/<pid>/task/... */
dir = pfs_create_dir(dir, "task", linprocfs_dotaskattr, NULL, NULL, 0);
diff --git a/sys/compat/linux/linux_emul.h b/sys/compat/linux/linux_emul.h
--- a/sys/compat/linux/linux_emul.h
+++ b/sys/compat/linux/linux_emul.h
@@ -75,6 +75,7 @@
struct sx pem_sx; /* lock for this struct */
uint32_t persona; /* process execution domain */
uint32_t ptrace_flags; /* used by ptrace(2) */
+ uint32_t oom_score_adj; /* /proc/self/oom_score_adj */
};
#define LINUX_PEM_XLOCK(p) sx_xlock(&(p)->pem_sx)
diff --git a/sys/compat/linux/linux_emul.c b/sys/compat/linux/linux_emul.c
--- a/sys/compat/linux/linux_emul.c
+++ b/sys/compat/linux/linux_emul.c
@@ -187,6 +187,7 @@
pem = pem_find(p);
KASSERT(pem != NULL, ("proc_exit: proc emuldata not found.\n"));
pem->persona = 0;
+ pem->oom_score_adj = 0;
}
}
diff --git a/sys/compat/linux/linux_misc.h b/sys/compat/linux/linux_misc.h
--- a/sys/compat/linux/linux_misc.h
+++ b/sys/compat/linux/linux_misc.h
@@ -157,6 +157,10 @@
/* Linux seccomp flags */
#define LINUX_SECCOMP_GET_ACTION_AVAIL 2
+/* Linux /proc/self/oom_score_adj */
+#define LINUX_OOM_SCORE_ADJ_MIN -1000
+#define LINUX_OOM_SCORE_ADJ_MAX 1000
+
#if defined(__aarch64__) || (defined(__amd64__) && !defined(COMPAT_LINUX32))
int linux_ptrace_status(struct thread *td, int pid, int status);
#endif
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Nov 21, 1:25 AM (21 h, 39 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14751447
Default Alt Text
D34710.diff (2 KB)
Attached To
Mode
D34710: linprocfs: Add /proc/self/oom_score_adj.
Attached
Detach File
Event Timeline
Log In to Comment