Date: Mon, 02 Jun 2014 18:52:10 +0400 From: "Alexander V. Chernikov" <melifaro@FreeBSD.org> To: hackers@freebsd.org Subject: Permit init(8) use its own cpuset group. Message-ID: <538C8F9A.4020301@FreeBSD.org>
next in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
Hello list!
Currently init(8) uses group 1 which is root group.
Modifications of this group affects both kernel and userland threads.
Additionally, such modifications are impossible, for example, in presence
of multi-queue NIC drivers (like igb or ixgbe) which binds their threads to
particular cpus.
Proposed change ("init_cpuset" loader tunable) permits changing cpu
masks for
userland more easily. Restricting user processes to migrate to/from CPU
cores
used for network traffic processing is one of the cases.
Phabricator: https://phabric.freebsd.org/D141 (the same version attached
inline)
If there are no objections, I'll commit this next week.
[-- Attachment #2 --]
Index: sbin/init/init.c
===================================================================
--- sbin/init/init.c (revision 266306)
+++ sbin/init/init.c (working copy)
@@ -47,6 +47,8 @@ static const char rcsid[] =
#include <sys/param.h>
#include <sys/ioctl.h>
#include <sys/mount.h>
+#include <sys/param.h>
+#include <sys/cpuset.h>
#include <sys/sysctl.h>
#include <sys/wait.h>
#include <sys/stat.h>
@@ -320,6 +322,19 @@ invalid:
warning("Can't chroot to %s: %m", kenv_value);
}
+ if (kenv(KENV_GET, "init_cpuset", kenv_value, sizeof(kenv_value)) > 0) {
+ if (getpid() == 1) {
+ cpusetid_t setid;
+
+ setid = -1;
+ if (cpuset(&setid) != 0) {
+ warning("cpu set alloc failed: %m");
+ } else {
+ if (cpuset_setid(CPU_WHICH_PID, 1, setid) != 0)
+ warning("cpuset_setsid failed: %m");
+ }
+ }
+ }
/*
* Additional check if devfs needs to be mounted:
* If "/" and "/dev" have the same device number,
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?538C8F9A.4020301>
