Khalid Aziz <khalid.aziz@xxxxxxxxxx> writes:
First it would be nice to have some standard reference lock library that
uses this. What would it take to support this in glibc?
+==================================
+Using the preemption delay feature
+==================================
+
+This feature is enabled in the kernel by setting
+CONFIG_SCHED_PREEMPT_DELAY in kernel configuration. Once this feature is
+enabled, the userspace process communicates with the kernel using a
+4-byte memory location in its address space. It first gives the kernel
+address for this memory location by writing its address to
+/proc/<tgid>/task/<tid>/sched_preempt_delay. This memory location is
+interpreted as a sequence of 4 bytes:
+
+ byte[0] = flag to request preemption delay
+ byte[1] = flag from kernel indicating preemption delay was granted
+ byte[2] = reserved for future use
+ byte[3] = reserved for future use
Should reserve more bytes (64, 128?) and rename the proc flag
to a more generic name. I could well assume other things
using such a mechanism in the future. Also please add a flag
word with feature bits (similar to the perf mmap page)
How about alignment? x86 will not care, but other architectures
may.
#endif
+#ifdef CONFIG_SCHED_PREEMPT_DELAY
+ REG("sched_preempt_delay", S_IRUGO|S_IWUSR,
proc_tid_preempt_delay_ops),
This shouldn't be readable by group/other, as it exposes the address space,
so could help exploits.
@@ -2061,6 +2069,13 @@ extern u64 scheduler_tick_max_deferment(void);
static inline bool sched_can_stop_tick(void) { return false; }
#endif
+#if defined(CONFIG_SCHED_PREEMPT_DELAY) && defined(CONFIG_PROC_FS)
+extern void sched_preempt_delay_show(struct seq_file *m,
+ struct task_struct *task);
+extern void sched_preempt_delay_set(struct task_struct *task,
+ unsigned char *val);
+#endif
Prototypes don't need to be ifdefed.
-Andi