3.6.4-rt11
Subsystems (7)
Dear RT Folks,
I'm pleased to announce the 3.6.4-rt11 release.
Changes since 3.6.3-rt10:
* Crypto wreckage fix (Milan Broz)
Another proof why copy and paste should be forbidden, but if that would happen most of us would be serving time.
* Another attempt to tame SLUB
My previous approach turned out to be too naive though this one has at least held up against massive memory stress tests. It's a very simple and straight forward aproach now and while I'm quite sure that it will not fall over as it did before, there might be hidden latency issues with that new version.
So please give it a proper testing!
* Lazy preemption
It has become an obsession to mitigate the determinism vs. throughput loss of RT. Looking at the mainline semantics of preemption points gives a hint why RT sucks throughput wise for ordinary SCHED_OTHER tasks. One major issue is the wakeup of tasks which are right away preempting the waking task while the waking task holds a lock on which the woken task will block right after having preempted the wakee. In mainline this is prevented due to the implicit preemption disable of spin/rw_lock held regions. On RT this is not possible due to the fully preemptible nature of sleeping spinlocks.
Though for a SCHED_OTHER task preempting another SCHED_OTHER task this is really not a correctness issue. RT folks are concerned about SCHED_FIFO/RR tasks preemption and not about the purely fairness driven SCHED_OTHER preemption latencies.
So I introduced a lazy preemption mechanism which only applies to SCHED_OTHER tasks preempting another SCHED_OTHER task. Aside of the existing preempt_count each tasks sports now a preempt_lazy_count which is manipulated on lock acquiry and release. This is slightly incorrect as for lazyness reasons I coupled this on migrate_disable/enable so some other mechanisms get the same treatment (e.g. get_cpu_light).
Now on the scheduler side instead of setting NEED_RESCHED this sets NEED_RESCHED_LAZY in case of a SCHED_OTHER/SCHED_OTHER preemption and therefor allows to exit the waking task the lock held region before the woken task preempts. That also works better for cross CPU wakeups as the other side can stay in the adaptive spinning loop.
For RT class preemption there is no change. This simply sets NEED_RESCHED and forgoes the lazy preemption counter.
Initial test do not expose any observable latency increasement, but history shows that I've been proven wrong before :)
The lazy preemption mode is per default on, but with CONFIG_SCHED_DEBUG enabled it can be disabled via:
# echo NO_PREEMPT_LAZY >/sys/kernel/debug/sched_features
and reenabled via
# echo PREEMPT_LAZY >/sys/kernel/debug/sched_features
The test results so far are very machine and workload dependent, but there is a clear trend that it enhances the non RT workload performance.
Please give it a try and share your experience!
Known issues:
There is still some "softirq pending xx" fallout which I have not been able to investigate yet, but that's on my top priority list. It's not a critical issue and only annoys people with CONFIG_NO_HZ=y configurations.
The delta patch against 3.6.4-rt10 is appended below and can be found here:
http://www.kernel.org/pub/linux/kernel/projects/rt/3.6/incr/patch-3.6.4-rt10-rt11.patch.xz
The RT patch against 3.6.4 can be found here:
http://www.kernel.org/pub/linux/kernel/projects/rt/3.6/patch-3.6.4-rt11.patch.xz
The split quilt queue is available at:
http://www.kernel.org/pub/linux/kernel/projects/rt/3.6/patches-3.6.4-rt11.tar.xz
Enjoy,
tglx
------------->
arch/x86/Kconfig +1 -0
@@ -97,6 +97,7 @@ config X86 select KTIME_SCALAR if X86_32 select GENERIC_STRNCPY_FROM_USER select GENERIC_STRNLEN_USER + select HAVE_PREEMPT_LAZY config INSTRUCTION_DECODER def_bool (KPROBES || PERF_EVENTS || UPROBES)
arch/x86/kernel/entry_64.S +8 -2
@@ -1003,9 +1003,15 @@ retint_signal: ENTRY(retint_kernel) cmpl $0,TI_preempt_count(%rcx) jnz retint_restore_args - bt $TIF_NEED_RESCHED,TI_flags(%rcx) + bt $TIF_NEED_RESCHED,TI_flags(%rcx) + jc 1f + + cmpl $0,TI_preempt_lazy_count(%rcx) + jnz retint_restore_args + bt $TIF_NEED_RESCHED_LAZY,TI_flags(%rcx) jnc retint_restore_args - bt $9,EFLAGS-ARGOFFSET(%rsp) /* interrupts off? */ + +1: bt $9,EFLAGS-ARGOFFSET(%rsp) /* interrupts off? */ jnc retint_restore_args call preempt_schedule_irq jmp exit_intr
crypto/algapi.c +0 -1
@@ -956,7 +956,6 @@ EXPORT_SYMBOL_GPL(crypto_xor);static int __init crypto_algapi_init (void ) { -srcu_init_notifier_head (&crypto_chain);crypto_init_proc ();return 0 ; }
include/linux/ftrace_event.h +1 -0
@@ -51,6 +51,7 @@ struct trace_entry {int pid;unsigned short migrate_disable;unsigned short padding; +unsigned char preempt_lazy_count; };#define FTRACE_MAX_EVENT \
include/linux/preempt.h +37 -1
@@ -23,15 +23,38 @@#define preempt_count () (current_thread_info()->preempt_count) +#ifdef CONFIG_HAVE_PREEMPT_LAZY +#define add_preempt_lazy_count (val) do { preempt_lazy_count() += (val); } while (0) +#define sub_preempt_lazy_count (val) do { preempt_lazy_count() -= (val); } while (0) +#define inc_preempt_lazy_count () add_preempt_lazy_count(1) +#define dec_preempt_lazy_count () sub_preempt_lazy_count(1) +#define preempt_lazy_count () (current_thread_info()->preempt_lazy_count) +#else +#define add_preempt_lazy_count (val) do { } while (0) +#define sub_preempt_lazy_count (val) do { } while (0) +#define inc_preempt_lazy_count () do { } while (0) +#define dec_preempt_lazy_count () do { } while (0) +#define preempt_lazy_count () (0) +#endif +#ifdef CONFIG_PREEMPT asmlinkage void preempt_schedule(void); +# ifdef CONFIG_HAVE_PREEMPT_LAZY +#define preempt_check_resched () \ +do { \ + if (unlikely(test_thread_flag(TIF_NEED_RESCHED) || \ + test_thread_flag(TIF_NEED_RESCHED_LAZY))) \ + preempt_schedule(); \ +} while (0) +# else #define preempt_check_resched () \ do { \ - if (unlikely(test_thread_flag(TIF_NEED_RESCHED))) \ + if (unlikely(test_thread_flag(TIF_NEED_RESCHED))) \ preempt_schedule(); \ } while (0) +# endif #else /* !CONFIG_PREEMPT */
@@ -48,6 +71,12 @@ do { \barrier (); \ } while (0) +#define preempt_lazy_disable () \ +do { \ + inc_preempt_lazy_count(); \ + barrier(); \ +} while (0) +#define sched_preempt_enable_no_resched () \ do { \ barrier(); \
@@ -69,6 +98,13 @@ do { \preempt_check_resched (); \ } while (0) +#define preempt_lazy_enable () \ +do { \ + dec_preempt_lazy_count(); \ + barrier(); \ + preempt_check_resched(); \ +} while (0) +/* For debugging and tracer internals only! */ #define add_preempt_count_notrace (val) \ do { preempt_count() += (val); } while (0)
include/linux/sched.h +46 -5
63 lines not on this page · raw message
kernel/Kconfig.preempt +3 -0
@@ -6,6 +6,9 @@ config PREEMPT_RT_BASE bool select PREEMPT +config HAVE_PREEMPT_LAZY + bool + choice prompt "Preemption Model" default PREEMPT_NONE
kernel/sched/core.c +54 -0
96 lines not on this page · raw message
kernel/sched/features.h +2 -0
@@ -68,8 +68,10 @@ SCHED_FEAT(NONTASK_POWER, true) SCHED_FEAT(TTWU_QUEUE, true)#else SCHED_FEAT(TTWU_QUEUE, false) +SCHED_FEAT(PREEMPT_LAZY, true)#endif SCHED_FEAT(FORCE_SD_OVERLAP, false) SCHED_FEAT(RT_RUNTIME_SHARE, true)SCHED_FEAT (LB_MIN , false) +
kernel/trace/trace.c +24 -17
65 lines not on this page · raw message
kernel/trace/trace.h +2 -0
@@ -116,6 +116,7 @@ struct uprobe_trace_entry_head {* NEED_RESCHED - reschedule is requested * HARDIRQ - inside an interrupt handler * SOFTIRQ - inside a softirq handler +* NEED_RESCHED_LAZY - lazy reschedule is requested */ enum trace_flag_type {TRACE_FLAG_IRQS_OFF =0x01 ,
@@ -123,6 +124,7 @@ enum trace_flag_type {TRACE_FLAG_NEED_RESCHED =0x04 ,TRACE_FLAG_HARDIRQ =0x08 ,TRACE_FLAG_SOFTIRQ =0x10 , + TRACE_FLAG_NEED_RESCHED_LAZY = 0x20, };#define TRACE_BUF_SIZE 1024
kernel/trace/trace_output.c +11 -2
@@ -564,6 +564,7 @@ int trace_print_lat_fmt(struct trace_seq {char hardsoft_irq;char need_resched; +char need_resched_lazy;char irqs_off;int hardirq;int softirq;
@@ -578,14 +579,17 @@ int trace_print_lat_fmt(struct trace_seq'.' ; need_resched = (entry->flags &TRACE_FLAG_NEED_RESCHED ) ?'N' :'.' ; + need_resched_lazy = + (entry->flags &TRACE_FLAG_NEED_RESCHED_LAZY ) ?'L' :'.' ; hardsoft_irq = (hardirq && softirq) ?'H' : hardirq ?'h' : softirq ?'s' :'.' ; -if (!trace_seq_printf (s,"%c%c%c" , - irqs_off, need_resched, hardsoft_irq)) +if (!trace_seq_printf (s,"%c%c%c%c" , + irqs_off, need_resched, need_resched_lazy, + hardsoft_irq))return 0 ;if (entry->preempt_count)
@@ -593,6 +597,11 @@ int trace_print_lat_fmt(struct trace_seqelse ret =trace_seq_putc (s,'.' ); +if (entry->preempt_lazy_count) + ret =trace_seq_printf (s,"%x" , entry->preempt_lazy_count); +else + ret =trace_seq_putc (s,'.' ); +if (entry->migrate_disable) ret =trace_seq_printf (s,"%x" , entry->migrate_disable);else
localversion-rt +1 -1
@@ -1 +1 @@ --rt10 +-rt11
mm/slub.c +104 -58
409 lines not on this page · raw message
include/linux/slub_def.h +1 -1
@@ -54,7 +54,7 @@ struct kmem_cache_cpu { };struct kmem_cache_node { -spinlock_t list_lock;/* Protect partial list and nr_partial */ +raw_spinlock_t list_lock;/* Protect partial list and nr_partial */ unsigned long nr_partial;struct list_head partial;#ifdef CONFIG_SLUB_DEBUG
arch/x86/include/asm/thread_info.h +4 -0
@@ -31,6 +31,8 @@ struct thread_info {__u32 cpu;/* current CPU */ int preempt_count;/* 0 => preemptable, <0 => BUG */ +int preempt_lazy_count;/* 0 => lazy preemptable, +<0 => BUG */ mm_segment_t addr_limit;struct restart_block restart_block;void __user *sysenter_return;
@@ -83,6 +85,7 @@ struct thread_info {#define TIF_SYSCALL_EMU 6/* syscall emulation active */ #define TIF_SYSCALL_AUDIT 7/* syscall auditing active */ #define TIF_SECCOMP 8/* secure computing */ +#define TIF_NEED_RESCHED_LAZY 9/* lazy rescheduling necessary */ #define TIF_MCE_NOTIFY 10/* notify userspace of an MCE */ #define TIF_USER_RETURN_NOTIFY 11/* notify kernel of userspace return */ #define TIF_UPROBE 12/* breakpointed or singlestepping */
@@ -108,6 +111,7 @@ struct thread_info {#define _TIF_SYSCALL_EMU (1 << TIF_SYSCALL_EMU)#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT)#define _TIF_SECCOMP (1 << TIF_SECCOMP) +#define _TIF_NEED_RESCHED_LAZY (1 << TIF_NEED_RESCHED_LAZY)#define _TIF_MCE_NOTIFY (1 << TIF_MCE_NOTIFY)#define _TIF_USER_RETURN_NOTIFY (1 << TIF_USER_RETURN_NOTIFY)#define _TIF_UPROBE (1 << TIF_UPROBE)
arch/x86/kernel/asm-offsets.c +1 -0
@@ -33,6 +33,7 @@ void common(void) {OFFSET (TI_status, thread_info, status);OFFSET (TI_addr_limit, thread_info, addr_limit);OFFSET (TI_preempt_count, thread_info, preempt_count); +OFFSET (TI_preempt_lazy_count, thread_info, preempt_lazy_count);BLANK ();OFFSET (crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
arch/x86/kernel/entry_32.S +7 -1
@@ -352,8 +352,14 @@ ENTRY(resume_kernel) need_resched: movl TI_flags(%ebp), %ecx # need_resched set ? testb $_TIF_NEED_RESCHED, %cl + jnz 1f + + cmpl $0,TI_preempt_lazy_count(%ebp) # non-zero preempt_lazy_count ? + jnz restore_all + testb $_TIF_NEED_RESCHED_LAZY, %cl jz restore_all - testl $X86_EFLAGS_IF,PT_EFLAGS(%esp) # interrupts off (exception path) ? + +1: testl $X86_EFLAGS_IF,PT_EFLAGS(%esp) # interrupts off (exception path) ? jz restore_all call preempt_schedule_irq jmp need_resched
kernel/sched/fair.c +8 -8
@@ -1222,7 +1222,7 @@ check_preempt_tick(struct cfs_rq *cfs_rq ideal_runtime =sched_slice (cfs_rq, curr); delta_exec = curr->sum_exec_runtime - curr->prev_sum_exec_runtime;if (delta_exec > ideal_runtime) { -resched_task (rq_of (cfs_rq)->curr); +resched_task_lazy (rq_of (cfs_rq)->curr);/* * The current task ran long enough, ensure it doesn't get * re-elected due to buddy favours.
@@ -1246,7 +1246,7 @@ check_preempt_tick(struct cfs_rq *cfs_rqreturn ;if (delta > ideal_runtime) -resched_task (rq_of (cfs_rq)->curr); +resched_task_lazy (rq_of (cfs_rq)->curr); } static void
@@ -1363,7 +1363,7 @@ entity_tick(struct cfs_rq *cfs_rq, struc* validating it and just reschedule. */ if (queued) { -resched_task (rq_of (cfs_rq)->curr); +resched_task_lazy (rq_of (cfs_rq)->curr);return ; }/*
@@ -1543,7 +1543,7 @@ static void __account_cfs_rq_runtime(str* hierarchy can be throttled */ if (!assign_cfs_rq_runtime (cfs_rq) &&likely (cfs_rq->curr)) -resched_task (rq_of (cfs_rq)->curr); +resched_task_lazy (rq_of (cfs_rq)->curr); } static __always_inline
@@ -2129,7 +2129,7 @@ static void hrtick_start_fair(struct rqif (delta <0 ) {if (rq->curr == p) -resched_task (p); +resched_task_lazy (p);return ; }
@@ -2954,7 +2954,7 @@ static void check_preempt_wakeup(structreturn ; preempt: -resched_task (curr); +resched_task_lazy (curr);/* * Only set the backward buddy when the current task is still * on the rq. This can happen when a wakeup gets interleaved
@@ -5027,7 +5027,7 @@ static void task_fork_fair(struct task_s* 'current' within the tree based on its new key value. */ swap (curr->vruntime, se->vruntime); -resched_task (rq->curr); +resched_task_lazy (rq->curr); } se->vruntime -= cfs_rq->min_vruntime;
@@ -5052,7 +5052,7 @@ prio_changed_fair(struct rq *rq, struct*/ if (rq->curr == p) {if (p->prio > oldprio) -resched_task (rq->curr); +resched_task_lazy (rq->curr); }else check_preempt_curr (rq, p,0 ); }
kernel/sched/sched.h +9 -0
@@ -876,6 +876,15 @@ extern void init_sched_fair_class(void);extern void resched_task (struct task_struct *p);extern void resched_cpu (int cpu); +#ifdef CONFIG_HAVE_PREEMPT_LAZY +extern void resched_task_lazy (struct task_struct *tsk); +#else +static inline void resched_task_lazy (struct task_struct *tsk) +{ +resched_task (tsk); +} +#endif +extern struct rt_bandwidth def_rt_bandwidth;extern void init_rt_bandwidth (struct rt_bandwidth *rt_b,u64 period,u64 runtime);
Quoted 3 lines · [[ANNOUNCE] 3.6.4-rt11] On 31/10/2012 (Wed 02:19) Thomas Gleixner wrote:
Dear RT Folks,
I'm pleased to announce the 3.6.4-rt11 release.
The rt11 content is present on master in the 3.6-rt patch repo:
http://git.kernel.org/?p=linux/kernel/git/paulg/3.6-rt-patches.git
I've also created a v3.6.4-rt11-fixes branch, which contains a fix for the preempt-lazy TIF test on x86_32 (please check this; I really should not be left unattended, mucking around in .S files while on vacation). It is queued in the series right after the preempt-lazy-support.patch.
There is also a trivial fix to remove a needless whitespace change (also appeared in preempt-lazy-support.patch) that triggers a git nag during a "git am" of it.
Passes quick boot test on x86_32 UP (Note: I didn't try booting without the TIF %cl patch; not sure what would have happened there...)
[ quick link to TIF patch @kernel.org: http://goo.gl/7Gbtg ]
Paul.
--
Quoted 100 lines
Changes since 3.6.3-rt10:
* Crypto wreckage fix (Milan Broz)
Another proof why copy and paste should be forbidden, but if that would happen most of us would be serving time.
* Another attempt to tame SLUB
My previous approach turned out to be too naive though this one has at least held up against massive memory stress tests. It's a very simple and straight forward aproach now and while I'm quite sure that it will not fall over as it did before, there might be hidden latency issues with that new version.
So please give it a proper testing!
* Lazy preemption
It has become an obsession to mitigate the determinism vs. throughput loss of RT. Looking at the mainline semantics of preemption points gives a hint why RT sucks throughput wise for ordinary
SCHED_OTHERtasks. One major issue is the wakeup of tasks which are right away preempting the waking task while the waking task holds a lock on which the woken task will block right after having preempted the wakee. In mainline this is prevented due to the implicit preemption disable of spin/rw_lock held regions. On RT this is not possible due to the fully preemptible nature of sleeping spinlocks.Though for a
SCHED_OTHERtask preempting anotherSCHED_OTHERtask this is really not a correctness issue. RT folks are concerned about SCHED_FIFO/RR tasks preemption and not about the purely fairness drivenSCHED_OTHERpreemption latencies.So I introduced a lazy preemption mechanism which only applies to
SCHED_OTHERtasks preempting anotherSCHED_OTHERtask. Aside of the existingpreempt_counteach tasks sports now apreempt_lazy_countwhich is manipulated on lock acquiry and release. This is slightly incorrect as for lazyness reasons I coupled this on migrate_disable/enable so some other mechanisms get the same treatment (e.g.get_cpu_light).Now on the scheduler side instead of setting
NEED_RESCHEDthis setsNEED_RESCHED_LAZYin case of a SCHED_OTHER/SCHED_OTHER preemption and therefor allows to exit the waking task the lock held region before the woken task preempts. That also works better for cross CPU wakeups as the other side can stay in the adaptive spinning loop.For RT class preemption there is no change. This simply sets
NEED_RESCHEDand forgoes the lazy preemption counter.Initial test do not expose any observable latency increasement, but history shows that I've been proven wrong before :)
The lazy preemption mode is per default on, but with
CONFIG_SCHED_DEBUGenabled it can be disabled via:# echo
NO_PREEMPT_LAZY>/sys/kernel/debug/sched_featuresand reenabled via
# echo
PREEMPT_LAZY>/sys/kernel/debug/sched_featuresThe test results so far are very machine and workload dependent, but there is a clear trend that it enhances the non RT workload performance.
Please give it a try and share your experience!
Known issues:
There is still some "softirq pending xx" fallout which I have not been able to investigate yet, but that's on my top priority list. It's not a critical issue and only annoys people with
CONFIG_NO_HZ=yconfigurations.The delta patch against 3.6.4-rt10 is appended below and can be found here:
http://www.kernel.org/pub/linux/kernel/projects/rt/3.6/incr/patch-3.6.4-rt10-rt11.patch.xz
The RT patch against 3.6.4 can be found here:
http://www.kernel.org/pub/linux/kernel/projects/rt/3.6/patch-3.6.4-rt11.patch.xz
The split quilt queue is available at:
http://www.kernel.org/pub/linux/kernel/projects/rt/3.6/patches-3.6.4-rt11.tar.xz
Enjoy,
tglx
------------->
Quoted 6 lines · Paul Gortmaker
Quoted 3 lines · [[ANNOUNCE] 3.6.4-rt11] On 31/10/2012 (Wed 02:19) Thomas Gleixner wrote:
Dear RT Folks,
I'm pleased to announce the 3.6.4-rt11 release.
Quoted 7 lines
The rt11 content is present on master in the 3.6-rt patch repo:
http://git.kernel.org/?p=linux/kernel/git/paulg/3.6-rt-patches.gitI've also created a v3.6.4-rt11-fixes branch, which contains a fix for the preempt-lazy TIF test on
x86_32(please check this; I really should not be left unattended, mucking around in .S files while on vacation). It is queued in the series right after the preempt-lazy-support.patch.
Duh. My tired brain saw the warning fly by without actually grasping it. Will fold it back for the next release.
Quoted 1 line
[ quick link to TIF patch @kernel.org: http://goo.gl/7Gbtg ]
Good catch. Thanks,
tglx