Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F174793057
D60391.id188769.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
D60391.id188769.diff
View Options
diff --git a/sys/compat/linux/linux_dummy.c b/sys/compat/linux/linux_dummy.c
--- a/sys/compat/linux/linux_dummy.c
+++ b/sys/compat/linux/linux_dummy.c
@@ -96,7 +96,6 @@
DUMMY(process_vm_writev);
/* Linux 3.8: */
DUMMY(finit_module);
-DUMMY(sched_setattr);
/* Linux 3.18: */
DUMMY(bpf);
/* Linux 3.19: */
diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c
--- a/sys/compat/linux/linux_misc.c
+++ b/sys/compat/linux/linux_misc.c
@@ -1511,6 +1511,77 @@
return (sys_sched_get_priority_min(td, &bsd));
}
+int
+linux_sched_setattr(struct thread *td, struct linux_sched_setattr_args *args)
+{
+ struct linux_sched_attr attr;
+ struct sched_param bsd;
+ struct thread *tdt;
+ int error, policy;
+
+ if (args->attr == NULL || args->pid < 0 || args->flags != 0)
+ return (EINVAL);
+
+ error = copyin(args->attr, &attr, sizeof(attr));
+ if (error != 0)
+ return (error);
+
+ if (attr.size < LINUX_SCHED_ATTR_SIZE_VER0)
+ return (E2BIG);
+
+ switch (attr.sched_policy) {
+ case LINUX_SCHED_FIFO:
+ policy = SCHED_FIFO;
+ break;
+ case LINUX_SCHED_RR:
+ policy = SCHED_RR;
+ break;
+ case LINUX_SCHED_NORMAL:
+ if (attr.sched_priority != 0)
+ return (EINVAL);
+ policy = SCHED_OTHER;
+ break;
+ case LINUX_SCHED_BATCH:
+ case LINUX_SCHED_DEADLINE:
+ case LINUX_SCHED_IDLE:
+ /**
+ * NB: this technically isn't correct for scheduling policies
+ * known by Linux, however, we don't support mapping all of
+ * the scheduling policies from Linux's available values to
+ * the values available on FreeBSD.
+ */
+ /* FALLTHROUGH */
+ default:
+ return (EINVAL);
+ }
+
+ switch (attr.sched_policy) {
+ case LINUX_SCHED_FIFO:
+ case LINUX_SCHED_RR:
+ /*
+ * Map [1, LINUX_MAX_RT_PRIO - 1] to
+ * [0, RTP_PRIO_MAX - RTP_PRIO_MIN] (rounding down).
+ */
+ bsd.sched_priority =
+ (bsd.sched_priority - 1) *
+ (RTP_PRIO_MAX - RTP_PRIO_MIN + 1) /
+ (LINUX_MAX_RT_PRIO - 1);
+ break;
+ case LINUX_SCHED_NORMAL:
+ bsd.sched_priority = 0;
+ break;
+ }
+
+ tdt = linux_tdfind(td, args->pid, -1);
+ if (tdt == NULL)
+ return (ESRCH);
+
+ error = kern_sched_setscheduler(td, tdt, policy, &bsd);
+
+ PROC_UNLOCK(tdt->td_proc);
+ return (error);
+}
+
#define REBOOT_CAD_ON 0x89abcdef
#define REBOOT_CAD_OFF 0
#define REBOOT_HALT 0xcdef0123
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Oct 7, 12:53 AM (19 h, 14 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
40325695
Default Alt Text
D60391.id188769.diff (2 KB)
Attached To
Mode
D60391: linux: implement basic `sched_setattr` syscall
Attached
Detach File
Event Timeline
Log In to Comment