]> rtime.felk.cvut.cz Git - zynq/linux.git/log
zynq/linux.git
8 years agolocal-vars-migrate-disable.patch
Thomas Gleixner [Tue, 28 Jun 2011 18:42:16 +0000 (20:42 +0200)]
local-vars-migrate-disable.patch

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agogenirq: Allow disabling of softirq processing in irq thread context
Thomas Gleixner [Tue, 31 Jan 2012 12:01:27 +0000 (13:01 +0100)]
genirq: Allow disabling of softirq processing in irq thread context

The processing of softirqs in irq thread context is a performance gain
for the non-rt workloads of a system, but it's counterproductive for
interrupts which are explicitely related to the realtime
workload. Allow such interrupts to prevent softirq processing in their
thread context.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: stable-rt@vger.kernel.org
8 years agotasklet: Prevent tasklets from going into infinite spin in RT
Ingo Molnar [Wed, 30 Nov 2011 01:18:22 +0000 (20:18 -0500)]
tasklet: Prevent tasklets from going into infinite spin in RT

When CONFIG_PREEMPT_RT_FULL is enabled, tasklets run as threads,
and spinlocks turn are mutexes. But this can cause issues with
tasks disabling tasklets. A tasklet runs under ksoftirqd, and
if a tasklets are disabled with tasklet_disable(), the tasklet
count is increased. When a tasklet runs, it checks this counter
and if it is set, it adds itself back on the softirq queue and
returns.

The problem arises in RT because ksoftirq will see that a softirq
is ready to run (the tasklet softirq just re-armed itself), and will
not sleep, but instead run the softirqs again. The tasklet softirq
will still see that the count is non-zero and will not execute
the tasklet and requeue itself on the softirq again, which will
cause ksoftirqd to run it again and again and again.

It gets worse because ksoftirqd runs as a real-time thread.
If it preempted the task that disabled tasklets, and that task
has migration disabled, or can't run for other reasons, the tasklet
softirq will never run because the count will never be zero, and
ksoftirqd will go into an infinite loop. As an RT task, it this
becomes a big problem.

This is a hack solution to have tasklet_disable stop tasklets, and
when a tasklet runs, instead of requeueing the tasklet softirqd
it delays it. When tasklet_enable() is called, and tasklets are
waiting, then the tasklet_enable() will kick the tasklets to continue.
This prevents the lock up from ksoftirq going into an infinite loop.

[ rostedt@goodmis.org: ported to 3.0-rt ]

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agosoftirq-make-fifo.patch
Thomas Gleixner [Thu, 21 Jul 2011 19:06:43 +0000 (21:06 +0200)]
softirq-make-fifo.patch

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agosoftirq-disable-softirq-stacks-for-rt.patch
Thomas Gleixner [Mon, 18 Jul 2011 11:59:17 +0000 (13:59 +0200)]
softirq-disable-softirq-stacks-for-rt.patch

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agosoftirq-local-lock.patch
Thomas Gleixner [Tue, 28 Jun 2011 13:57:18 +0000 (15:57 +0200)]
softirq-local-lock.patch

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agomutex-no-spin-on-rt.patch
Thomas Gleixner [Sun, 17 Jul 2011 19:51:45 +0000 (21:51 +0200)]
mutex-no-spin-on-rt.patch

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agolockdep-rt.patch
Thomas Gleixner [Sun, 17 Jul 2011 16:51:23 +0000 (18:51 +0200)]
lockdep-rt.patch

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agosoftirq: Sanitize softirq pending for NOHZ/RT
Thomas Gleixner [Fri, 3 Jul 2009 18:16:38 +0000 (13:16 -0500)]
softirq: Sanitize softirq pending for NOHZ/RT

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agosunrpc: make svc_xprt_do_enqueue() use get_cpu_light()
Mike Galbraith [Wed, 18 Feb 2015 15:05:28 +0000 (16:05 +0100)]
sunrpc: make svc_xprt_do_enqueue() use get_cpu_light()

|BUG: sleeping function called from invalid context at kernel/locking/rtmutex.c:915
|in_atomic(): 1, irqs_disabled(): 0, pid: 3194, name: rpc.nfsd
|Preemption disabled at:[<ffffffffa06bf0bb>] svc_xprt_received+0x4b/0xc0 [sunrpc]
|CPU: 6 PID: 3194 Comm: rpc.nfsd Not tainted 3.18.7-rt1 #9
|Hardware name: MEDION MS-7848/MS-7848, BIOS M7848W08.404 11/06/2014
ffff880409630000 ffff8800d9a33c78 ffffffff815bdeb5 0000000000000002
0000000000000000 ffff8800d9a33c98 ffffffff81073c86 ffff880408dd6008
ffff880408dd6000 ffff8800d9a33cb8 ffffffff815c3d84 ffff88040b3ac000
|Call Trace:
| [<ffffffff815bdeb5>] dump_stack+0x4f/0x9e
| [<ffffffff81073c86>] __might_sleep+0xe6/0x150
| [<ffffffff815c3d84>] rt_spin_lock+0x24/0x50
| [<ffffffffa06beec0>] svc_xprt_do_enqueue+0x80/0x230 [sunrpc]
| [<ffffffffa06bf0bb>] svc_xprt_received+0x4b/0xc0 [sunrpc]
| [<ffffffffa06c03ed>] svc_add_new_perm_xprt+0x6d/0x80 [sunrpc]
| [<ffffffffa06b2693>] svc_addsock+0x143/0x200 [sunrpc]
| [<ffffffffa072e69c>] write_ports+0x28c/0x340 [nfsd]
| [<ffffffffa072d2ac>] nfsctl_transaction_write+0x4c/0x80 [nfsd]
| [<ffffffff8117ee83>] vfs_write+0xb3/0x1d0
| [<ffffffff8117f889>] SyS_write+0x49/0xb0
| [<ffffffff815c4556>] system_call_fastpath+0x16/0x1b

Cc: stable-rt@vger.kernel.org
Signed-off-by: Mike Galbraith <umgwanakikbuti@gmail.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
8 years agonet-netif_rx_ni-migrate-disable.patch
Thomas Gleixner [Sun, 17 Jul 2011 14:29:27 +0000 (16:29 +0200)]
net-netif_rx_ni-migrate-disable.patch

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agosched-clear-pf-thread-bound-on-fallback-rq.patch
Thomas Gleixner [Fri, 4 Nov 2011 19:48:36 +0000 (20:48 +0100)]
sched-clear-pf-thread-bound-on-fallback-rq.patch

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agosched: dont calculate hweight in update_migrate_disable()
Nicholas Mc Guire [Mon, 24 Mar 2014 12:18:48 +0000 (13:18 +0100)]
sched: dont calculate hweight in update_migrate_disable()

Proposal for a minor optimization in update_migrate_disable - its only a few
instructions saved but those are in the hot path of locks so it might be worth
it

When being scheduled out while migrate_disable > 0 and migrate_disabled_updated
is not yet set we end up here (kernel/sched/core.c):

static inline void update_migrate_disable(struct task_struct *p)
{
        ...

        mask = tsk_cpus_allowed(p);

        if (p->sched_class->set_cpus_allowed)
                p->sched_class->set_cpus_allowed(p, mask);
        p->nr_cpus_allowed = cpumask_weight(mask);

as we only can get here if migrate_disable > 0 there is no need to calculate
the cpumask_weight(mask) as tsk_cpus_allowed in that case will return
cpumask_of(task_cpu(p)) which only can have a hamming weight of 1 anyway.
So we can simply do:

        p->nr_cpus_allowed = 1;

without changing the behavior.

Reviewed-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Nicholas Mc Guire <der.herr@hofr.at>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
8 years agosched: Have migrate_disable ignore bounded threads
Peter Zijlstra [Tue, 27 Sep 2011 12:40:25 +0000 (08:40 -0400)]
sched: Have migrate_disable ignore bounded threads

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Clark Williams <williams@redhat.com>
Link: http://lkml.kernel.org/r/20110927124423.567944215@goodmis.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agosched: Do not compare cpu masks in scheduler
Peter Zijlstra [Tue, 27 Sep 2011 12:40:24 +0000 (08:40 -0400)]
sched: Do not compare cpu masks in scheduler

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Clark Williams <williams@redhat.com>
Link: http://lkml.kernel.org/r/20110927124423.128129033@goodmis.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agoallow preemption in recursive migrate_disable call
Nicholas Mc Guire [Tue, 19 Nov 2013 23:22:09 +0000 (07:22 +0800)]
allow preemption in recursive migrate_disable call

Minor cleanup in migrate_disable/migrate_enable. The recursive case
does not need to disable preemption as it is "pinned" to the current
cpu any way so it is safe to preempt it.

Signed-off-by: Nicholas Mc Guire <der.herr@hofr.at>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
8 years agosched: Postpone actual migration disalbe to schedule
Steven Rostedt [Tue, 27 Sep 2011 12:40:23 +0000 (08:40 -0400)]
sched: Postpone actual migration disalbe to schedule

The migrate_disable() can cause a bit of a overhead to the RT kernel,
as changing the affinity is expensive to do at every lock encountered.
As a running task can not migrate, the actual disabling of migration
does not need to occur until the task is about to schedule out.

In most cases, a task that disables migration will enable it before
it schedules making this change improve performance tremendously.

[ Frank Rowand: UP compile fix ]

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Clark Williams <williams@redhat.com>
Link: http://lkml.kernel.org/r/20110927124422.779693167@goodmis.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agosched: teach migrate_disable about atomic contexts
Peter Zijlstra [Fri, 2 Sep 2011 12:29:27 +0000 (14:29 +0200)]
sched: teach migrate_disable about atomic contexts

 <NMI>  [<ffffffff812dafd8>] spin_bug+0x94/0xa8
 [<ffffffff812db07f>] do_raw_spin_lock+0x43/0xea
 [<ffffffff814fa9be>] _raw_spin_lock_irqsave+0x6b/0x85
 [<ffffffff8106ff9e>] ? migrate_disable+0x75/0x12d
 [<ffffffff81078aaf>] ? pin_current_cpu+0x36/0xb0
 [<ffffffff8106ff9e>] migrate_disable+0x75/0x12d
 [<ffffffff81115b9d>] pagefault_disable+0xe/0x1f
 [<ffffffff81047027>] copy_from_user_nmi+0x74/0xe6
 [<ffffffff810489d7>] perf_callchain_user+0xf3/0x135

Now clearly we can't go around taking locks from NMI context, cure
this by short-circuiting migrate_disable() when we're in an atomic
context already.

Add some extra debugging to avoid things like:

  preempt_disable()
  migrate_disable();

  preempt_enable();
  migrate_enable();

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1314967297.1301.14.camel@twins
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/n/tip-wbot4vsmwhi8vmbf83hsclk6@git.kernel.org
8 years agosched, rt: Fix migrate_enable() thinko
Mike Galbraith [Tue, 23 Aug 2011 14:12:43 +0000 (16:12 +0200)]
sched, rt: Fix migrate_enable() thinko

Assigning mask = tsk_cpus_allowed(p) after p->migrate_disable = 0 ensures
that we won't see a mask change.. no push/pull, we stack tasks on one CPU.

Also add a couple fields to sched_debug for the next guy.

[ Build fix from Stratos Psomadakis <psomas@gentoo.org> ]

Signed-off-by: Mike Galbraith <efault@gmx.de>
Cc: Paul E. McKenney <paulmck@us.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1314108763.6689.4.camel@marge.simson.net
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agosched: Generic migrate_disable
Peter Zijlstra [Thu, 11 Aug 2011 13:14:58 +0000 (15:14 +0200)]
sched: Generic migrate_disable

Make migrate_disable() be a preempt_disable() for !rt kernels. This
allows generic code to use it but still enforces that these code
sections stay relatively small.

A preemptible migrate_disable() accessible for general use would allow
people growing arbitrary per-cpu crap instead of clean these things
up.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/n/tip-275i87sl8e1jcamtchmehonm@git.kernel.org
8 years agosched: Optimize migrate_disable
Peter Zijlstra [Thu, 11 Aug 2011 13:03:35 +0000 (15:03 +0200)]
sched: Optimize migrate_disable

Change from task_rq_lock() to raw_spin_lock(&rq->lock) to avoid a few
atomic ops. See comment on why it should be safe.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/n/tip-cbz6hkl5r5mvwtx5s3tor2y6@git.kernel.org
8 years agomigrate-disable-rt-variant.patch
Thomas Gleixner [Sun, 17 Jul 2011 17:48:20 +0000 (19:48 +0200)]
migrate-disable-rt-variant.patch

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agotracing: Show padding as unsigned short
Steven Rostedt [Wed, 16 Nov 2011 18:19:35 +0000 (13:19 -0500)]
tracing: Show padding as unsigned short

RT added two bytes to trace migrate disable counting to the trace events
and used two bytes of the padding to make the change. The structures and
all were updated correctly, but the display in the event formats was
not:

cat /debug/tracing/events/sched/sched_switch/format

name: sched_switch
ID: 51
format:
field:unsigned short common_type; offset:0; size:2; signed:0;
field:unsigned char common_flags; offset:2; size:1; signed:0;
field:unsigned char common_preempt_count; offset:3; size:1; signed:0;
field:int common_pid; offset:4; size:4; signed:1;
field:unsigned short common_migrate_disable; offset:8; size:2; signed:0;
field:int common_padding; offset:10; size:2; signed:0;

The field for common_padding has the correct size and offset, but the
use of "int" might confuse some parsers (and people that are reading
it). This needs to be changed to "unsigned short".

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1321467575.4181.36.camel@frodo
Cc: stable-rt@vger.kernel.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agoftrace-migrate-disable-tracing.patch
Thomas Gleixner [Sun, 17 Jul 2011 19:56:42 +0000 (21:56 +0200)]
ftrace-migrate-disable-tracing.patch

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agohotplug-use-migrate-disable.patch
Thomas Gleixner [Sun, 17 Jul 2011 17:35:29 +0000 (19:35 +0200)]
hotplug-use-migrate-disable.patch

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agosched-migrate-disable.patch
Thomas Gleixner [Thu, 16 Jun 2011 11:26:08 +0000 (13:26 +0200)]
sched-migrate-disable.patch

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agohotplug: Reread hotplug_pcp on pin_current_cpu() retry
Yong Zhang [Thu, 28 Jul 2011 03:16:00 +0000 (11:16 +0800)]
hotplug: Reread hotplug_pcp on pin_current_cpu() retry

When retry happens, it's likely that the task has been migrated to
another cpu (except unplug failed), but it still derefernces the
original hotplug_pcp per cpu data.

Update the pointer to hotplug_pcp in the retry path, so it points to
the current cpu.

Signed-off-by: Yong Zhang <yong.zhang0@gmail.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/20110728031600.GA338@windriver.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agohotplug: sync_unplug: No "
Yong Zhang [Sun, 16 Oct 2011 10:56:43 +0000 (18:56 +0800)]
hotplug: sync_unplug: No "
" in task name

Otherwise the output will look a little odd.

Signed-off-by: Yong Zhang <yong.zhang0@gmail.com>
Link: http://lkml.kernel.org/r/1318762607-2261-2-git-send-email-yong.zhang0@gmail.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agohotplug: Lightweight get online cpus
Thomas Gleixner [Wed, 15 Jun 2011 10:36:06 +0000 (12:36 +0200)]
hotplug: Lightweight get online cpus

get_online_cpus() is a heavy weight function which involves a global
mutex. migrate_disable() wants a simpler construct which prevents only
a CPU from going doing while a task is in a migrate disabled section.

Implement a per cpu lockless mechanism, which serializes only in the
real unplug case on a global mutex. That serialization affects only
tasks on the cpu which should be brought down.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agostomp-machine-raw-lock.patch
Thomas Gleixner [Wed, 29 Jun 2011 09:01:51 +0000 (11:01 +0200)]
stomp-machine-raw-lock.patch

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agostop_machine: convert stop_machine_run() to PREEMPT_RT
Ingo Molnar [Fri, 3 Jul 2009 13:30:27 +0000 (08:30 -0500)]
stop_machine: convert stop_machine_run() to PREEMPT_RT

Instead of playing with non-preemption, introduce explicit
startup serialization. This is more robust and cleaner as
well.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
[bigeasy: XXX: stopper_lock -> stop_cpus_lock]

8 years agosched/workqueue: Only wake up idle workers if not blocked on sleeping spin lock
Steven Rostedt [Mon, 18 Mar 2013 19:12:49 +0000 (15:12 -0400)]
sched/workqueue: Only wake up idle workers if not blocked on sleeping spin lock

In -rt, most spin_locks() turn into mutexes. One of these spin_lock
conversions is performed on the workqueue gcwq->lock. When the idle
worker is worken, the first thing it will do is grab that same lock and
it too will block, possibly jumping into the same code, but because
nr_running would already be decremented it prevents an infinite loop.

But this is still a waste of CPU cycles, and it doesn't follow the method
of mainline, as new workers should only be woken when a worker thread is
truly going to sleep, and not just blocked on a spin_lock().

Check the saved_state too before waking up new workers.

Cc: stable-rt@vger.kernel.org
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
8 years agosched: ttwu: Return success when only changing the saved_state value
Thomas Gleixner [Tue, 13 Dec 2011 20:42:19 +0000 (21:42 +0100)]
sched: ttwu: Return success when only changing the saved_state value

When a task blocks on a rt lock, it saves the current state in
p->saved_state, so a lock related wake up will not destroy the
original state.

When a real wakeup happens, while the task is running due to a lock
wakeup already, we update p->saved_state to TASK_RUNNING, but we do
not return success, which might cause another wakeup in the waitqueue
code and the task remains in the waitqueue list. Return success in
that case as well.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: stable-rt@vger.kernel.org
8 years agosched: Disable CONFIG_RT_GROUP_SCHED on RT
Thomas Gleixner [Mon, 18 Jul 2011 15:03:52 +0000 (17:03 +0200)]
sched: Disable CONFIG_RT_GROUP_SCHED on RT

Carsten reported problems when running:

taskset 01 chrt -f 1 sleep 1

from within rc.local on a F15 machine. The task stays running and
never gets on the run queue because some of the run queues have
rt_throttled=1 which does not go away. Works nice from a ssh login
shell. Disabling CONFIG_RT_GROUP_SCHED solves that as well.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agosched-disable-ttwu-queue.patch
Thomas Gleixner [Tue, 13 Sep 2011 14:42:35 +0000 (16:42 +0200)]
sched-disable-ttwu-queue.patch

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agocond-resched-lock-rt-tweak.patch
Thomas Gleixner [Sun, 17 Jul 2011 20:51:33 +0000 (22:51 +0200)]
cond-resched-lock-rt-tweak.patch

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agocond-resched-softirq-fix.patch
Thomas Gleixner [Thu, 14 Jul 2011 07:56:44 +0000 (09:56 +0200)]
cond-resched-softirq-fix.patch

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agosched-might-sleep-do-not-account-rcu-depth.patch
Thomas Gleixner [Tue, 7 Jun 2011 07:19:06 +0000 (09:19 +0200)]
sched-might-sleep-do-not-account-rcu-depth.patch

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agosched-rt-mutex-wakeup.patch
Thomas Gleixner [Sat, 25 Jun 2011 07:21:04 +0000 (09:21 +0200)]
sched-rt-mutex-wakeup.patch

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agosched-mmdrop-delayed.patch
Thomas Gleixner [Mon, 6 Jun 2011 10:20:33 +0000 (12:20 +0200)]
sched-mmdrop-delayed.patch

Needs thread context (pgd_lock) -> ifdeffed. workqueues wont work with
RT

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agosched-limit-nr-migrate.patch
Thomas Gleixner [Mon, 6 Jun 2011 10:12:51 +0000 (12:12 +0200)]
sched-limit-nr-migrate.patch

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agosched-delay-put-task.patch
Thomas Gleixner [Tue, 31 May 2011 14:59:16 +0000 (16:59 +0200)]
sched-delay-put-task.patch

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agoposix-timers: Avoid wakeups when no timers are active
Thomas Gleixner [Fri, 3 Jul 2009 13:44:44 +0000 (08:44 -0500)]
posix-timers: Avoid wakeups when no timers are active

Waking the thread even when no timers are scheduled is useless.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agoposix-timers: Shorten posix_cpu_timers/<CPU> kernel thread names
Arnaldo Carvalho de Melo [Fri, 3 Jul 2009 13:30:00 +0000 (08:30 -0500)]
posix-timers: Shorten posix_cpu_timers/<CPU> kernel thread names

Shorten the softirq kernel thread names because they always overflow the
limited comm length, appearing as "posix_cpu_timer" CPU# times.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agoposix-timers: thread posix-cpu-timers on -rt
John Stultz [Fri, 3 Jul 2009 13:29:58 +0000 (08:29 -0500)]
posix-timers: thread posix-cpu-timers on -rt

posix-cpu-timer code takes non -rt safe locks in hard irq
context. Move it to a thread.

[ 3.0 fixes from Peter Zijlstra <peterz@infradead.org> ]

Signed-off-by: John Stultz <johnstul@us.ibm.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agohrtimer: Move schedule_work call to helper thread
Yang Shi [Mon, 16 Sep 2013 21:09:19 +0000 (14:09 -0700)]
hrtimer: Move schedule_work call to helper thread

When run ltp leapsec_timer test, the following call trace is caught:

BUG: sleeping function called from invalid context at kernel/rtmutex.c:659
in_atomic(): 1, irqs_disabled(): 1, pid: 0, name: swapper/1
Preemption disabled at:[<ffffffff810857f3>] cpu_startup_entry+0x133/0x310

CPU: 1 PID: 0 Comm: swapper/1 Not tainted 3.10.10-rt3 #2
Hardware name: Intel Corporation Calpella platform/MATXM-CORE-411-B, BIOS 4.6.3 08/18/2010
ffffffff81c2f800 ffff880076843e40 ffffffff8169918d ffff880076843e58
ffffffff8106db31 ffff88007684b4a0 ffff880076843e70 ffffffff8169d9c0
ffff88007684b4a0 ffff880076843eb0 ffffffff81059da1 0000001876851200
Call Trace:
<IRQ>  [<ffffffff8169918d>] dump_stack+0x19/0x1b
[<ffffffff8106db31>] __might_sleep+0xf1/0x170
[<ffffffff8169d9c0>] rt_spin_lock+0x20/0x50
[<ffffffff81059da1>] queue_work_on+0x61/0x100
[<ffffffff81065aa1>] clock_was_set_delayed+0x21/0x30
[<ffffffff810883be>] do_timer+0x40e/0x660
[<ffffffff8108f487>] tick_do_update_jiffies64+0xf7/0x140
[<ffffffff8108fe42>] tick_check_idle+0x92/0xc0
[<ffffffff81044327>] irq_enter+0x57/0x70
[<ffffffff816a040e>] smp_apic_timer_interrupt+0x3e/0x9b
[<ffffffff8169f80a>] apic_timer_interrupt+0x6a/0x70
<EOI>  [<ffffffff8155ea1c>] ? cpuidle_enter_state+0x4c/0xc0
[<ffffffff8155eb68>] cpuidle_idle_call+0xd8/0x2d0
[<ffffffff8100b59e>] arch_cpu_idle+0xe/0x30
[<ffffffff8108585e>] cpu_startup_entry+0x19e/0x310
[<ffffffff8168efa2>] start_secondary+0x1ad/0x1b0

The clock_was_set_delayed is called in hard IRQ handler (timer interrupt), which
calls schedule_work.

Under PREEMPT_RT_FULL, schedule_work calls spinlocks which could sleep, so it's
not safe to call schedule_work in interrupt context.

Reference upstream commit b68d61c705ef02384c0538b8d9374545097899ca
(rt,ntp: Move call to schedule_delayed_work() to helper thread)
from git://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-stable-rt.git, which
makes a similar change.

add a helper thread which does the call to schedule_work and wake up that
thread instead of calling schedule_work directly.

Cc: stable-rt@vger.kernel.org
Signed-off-by: Yang Shi <yang.shi@windriver.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
8 years agohrtimer: Raise softirq if hrtimer irq stalled
Watanabe [Sun, 28 Oct 2012 10:13:44 +0000 (11:13 +0100)]
hrtimer: Raise softirq if hrtimer irq stalled

When the hrtimer stall detection hits the softirq is not raised.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: stable-rt@vger.kernel.org
8 years agotimer-fd: Prevent live lock
Thomas Gleixner [Wed, 25 Jan 2012 10:08:40 +0000 (11:08 +0100)]
timer-fd: Prevent live lock

If hrtimer_try_to_cancel() requires a retry, then depending on the
priority setting te retry loop might prevent timer callback completion
on RT. Prevent that by waiting for completion on RT, no change for a
non RT kernel.

Reported-by: Sankara Muthukrishnan <sankara.m@gmail.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: stable-rt@vger.kernel.org
8 years agosched/deadline: dl_task_timer has to be irqsafe
Juri Lelli [Tue, 13 May 2014 13:30:20 +0000 (15:30 +0200)]
sched/deadline: dl_task_timer has to be irqsafe

As for rt_period_timer, dl_task_timer has to be irqsafe.

Signed-off-by: Juri Lelli <juri.lelli@gmail.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
8 years agohrtimer: fixup hrtimer callback changes for preempt-rt
Thomas Gleixner [Fri, 3 Jul 2009 13:44:31 +0000 (08:44 -0500)]
hrtimer: fixup hrtimer callback changes for preempt-rt

In preempt-rt we can not call the callbacks which take sleeping locks
from the timer interrupt context.

Bring back the softirq split for now, until we fixed the signal
delivery problem for real.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
8 years agohrtimers: prepare full preemption
Ingo Molnar [Fri, 3 Jul 2009 13:29:34 +0000 (08:29 -0500)]
hrtimers: prepare full preemption

Make cancellation of a running callback in softirq context safe
against preemption.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agotimers: Avoid the switch timers base set to NULL trick on RT
Thomas Gleixner [Thu, 21 Jul 2011 13:23:39 +0000 (15:23 +0200)]
timers: Avoid the switch timers base set to NULL trick on RT

On RT that code is preemptible, so we cannot assign NULL to timers
base as a preempter would spin forever in lock_timer_base().

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agotimer: delay waking softirqs from the jiffy tick
Peter Zijlstra [Fri, 21 Aug 2009 09:56:45 +0000 (11:56 +0200)]
timer: delay waking softirqs from the jiffy tick

People were complaining about broken balancing with the recent -rt
series.

A look at /proc/sched_debug yielded:

cpu#0, 2393.874 MHz
  .nr_running                    : 0
  .load                          : 0
  .cpu_load[0]                   : 177522
  .cpu_load[1]                   : 177522
  .cpu_load[2]                   : 177522
  .cpu_load[3]                   : 177522
  .cpu_load[4]                   : 177522
cpu#1, 2393.874 MHz
  .nr_running                    : 4
  .load                          : 4096
  .cpu_load[0]                   : 181618
  .cpu_load[1]                   : 180850
  .cpu_load[2]                   : 180274
  .cpu_load[3]                   : 179938
  .cpu_load[4]                   : 179758

Which indicated the cpu_load computation was hosed, the 177522 value
indicates that there is one RT task runnable. Initially I thought the
old problem of calculating the cpu_load from a softirq had re-surfaced,
however looking at the code shows its being done from scheduler_tick().

[ we really should fix this RT/cfs interaction some day... ]

A few trace_printk()s later:

    sirq-timer/1-19    [001]   174.289744:     19: 50:S ==> [001]     0:140:R <idle>
          <idle>-0     [001]   174.290724: enqueue_task_rt: adding task: 19/sirq-timer/1 with load: 177522
          <idle>-0     [001]   174.290725:      0:140:R   + [001]    19: 50:S sirq-timer/1
          <idle>-0     [001]   174.290730: scheduler_tick: current load: 177522
          <idle>-0     [001]   174.290732: scheduler_tick: current: 0/swapper
          <idle>-0     [001]   174.290736:      0:140:R ==> [001]    19: 50:R sirq-timer/1
    sirq-timer/1-19    [001]   174.290741: dequeue_task_rt: removing task: 19/sirq-timer/1 with load: 177522
    sirq-timer/1-19    [001]   174.290743:     19: 50:S ==> [001]     0:140:R <idle>

We see that we always raise the timer softirq before doing the load
calculation. Avoid this by re-ordering the scheduler_tick() call in
update_process_times() to occur before we deal with timers.

This lowers the load back to sanity and restores regular load-balancing
behaviour.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agotimers: preempt-rt support
Ingo Molnar [Fri, 3 Jul 2009 13:30:20 +0000 (08:30 -0500)]
timers: preempt-rt support

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agotimers: prepare for full preemption improve
Zhao Hongjiang [Wed, 17 Apr 2013 09:44:16 +0000 (17:44 +0800)]
timers: prepare for full preemption improve

wake_up should do nothing on the nort, so we should use wakeup_timer_waiters,
also fix a spell mistake.

Cc: stable-rt@vger.kernel.org
Signed-off-by: Zhao Hongjiang <zhaohongjiang@huawei.com>
[bigeasy: s/CONFIG_PREEMPT_RT_BASE/CONFIG_PREEMPT_RT_FULL/]
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
8 years agotimers: prepare for full preemption
Ingo Molnar [Fri, 3 Jul 2009 13:29:34 +0000 (08:29 -0500)]
timers: prepare for full preemption

When softirqs can be preempted we need to make sure that cancelling
the timer from the active thread can not deadlock vs. a running timer
callback. Add a waitqueue to resolve that.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agorelay: fix timer madness
Ingo Molnar [Fri, 3 Jul 2009 13:44:07 +0000 (08:44 -0500)]
relay: fix timer madness

remove timer calls (!!!) from deep within the tracing infrastructure.
This was totally bogus code that can cause lockups and worse.  Poll
the buffer every 2 jiffies for now.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agoipc: Make the ipc code -rt aware
Ingo Molnar [Fri, 3 Jul 2009 13:30:12 +0000 (08:30 -0500)]
ipc: Make the ipc code -rt aware

RT serializes the code with the (rt)spinlock but keeps preemption
enabled. Some parts of the code need to be atomic nevertheless.

Protect it with preempt_disable/enable_rt pairts.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agopanic: skip get_random_bytes for RT_FULL in init_oops_id
Thomas Gleixner [Sun, 13 Sep 2015 07:47:12 +0000 (09:47 +0200)]
panic: skip get_random_bytes for RT_FULL in init_oops_id

8 years agoradix-tree-rt-aware.patch
Thomas Gleixner [Sun, 17 Jul 2011 19:33:18 +0000 (21:33 +0200)]
radix-tree-rt-aware.patch

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agomm/memcontrol: do no disable interrupts
Sebastian Andrzej Siewior [Wed, 28 Jan 2015 16:14:16 +0000 (17:14 +0100)]
mm/memcontrol: do no disable interrupts

There are a few local_irq_disable() which then take sleeping locks. This
patch converts them local locks.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
8 years agomm/memcontrol: Don't call schedule_work_on in preemption disabled context
Yang Shi [Wed, 30 Oct 2013 18:48:33 +0000 (11:48 -0700)]
mm/memcontrol: Don't call schedule_work_on in preemption disabled context

The following trace is triggered when running ltp oom test cases:

BUG: sleeping function called from invalid context at kernel/rtmutex.c:659
in_atomic(): 1, irqs_disabled(): 0, pid: 17188, name: oom03
Preemption disabled at:[<ffffffff8112ba70>] mem_cgroup_reclaim+0x90/0xe0

CPU: 2 PID: 17188 Comm: oom03 Not tainted 3.10.10-rt3 #2
Hardware name: Intel Corporation Calpella platform/MATXM-CORE-411-B, BIOS 4.6.3 08/18/2010
ffff88007684d730 ffff880070df9b58 ffffffff8169918d ffff880070df9b70
ffffffff8106db31 ffff88007688b4a0 ffff880070df9b88 ffffffff8169d9c0
ffff88007688b4a0 ffff880070df9bc8 ffffffff81059da1 0000000170df9bb0
Call Trace:
[<ffffffff8169918d>] dump_stack+0x19/0x1b
[<ffffffff8106db31>] __might_sleep+0xf1/0x170
[<ffffffff8169d9c0>] rt_spin_lock+0x20/0x50
[<ffffffff81059da1>] queue_work_on+0x61/0x100
[<ffffffff8112b361>] drain_all_stock+0xe1/0x1c0
[<ffffffff8112ba70>] mem_cgroup_reclaim+0x90/0xe0
[<ffffffff8112beda>] __mem_cgroup_try_charge+0x41a/0xc40
[<ffffffff810f1c91>] ? release_pages+0x1b1/0x1f0
[<ffffffff8106f200>] ? sched_exec+0x40/0xb0
[<ffffffff8112cc87>] mem_cgroup_charge_common+0x37/0x70
[<ffffffff8112e2c6>] mem_cgroup_newpage_charge+0x26/0x30
[<ffffffff8110af68>] handle_pte_fault+0x618/0x840
[<ffffffff8103ecf6>] ? unpin_current_cpu+0x16/0x70
[<ffffffff81070f94>] ? migrate_enable+0xd4/0x200
[<ffffffff8110cde5>] handle_mm_fault+0x145/0x1e0
[<ffffffff810301e1>] __do_page_fault+0x1a1/0x4c0
[<ffffffff8169c9eb>] ? preempt_schedule_irq+0x4b/0x70
[<ffffffff8169e3b7>] ? retint_kernel+0x37/0x40
[<ffffffff8103053e>] do_page_fault+0xe/0x10
[<ffffffff8169e4c2>] page_fault+0x22/0x30

So, to prevent schedule_work_on from being called in preempt disabled context,
replace the pair of get/put_cpu() to get/put_cpu_light().

Cc: stable-rt@vger.kernel.org
Signed-off-by: Yang Shi <yang.shi@windriver.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
8 years agomm: page_alloc: Use local_lock_on() instead of plain spinlock
Thomas Gleixner [Thu, 27 Sep 2012 09:11:46 +0000 (11:11 +0200)]
mm: page_alloc: Use local_lock_on() instead of plain spinlock

The plain spinlock while sufficient does not update the local_lock
internals. Use a proper local_lock function instead to ease debugging.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: stable-rt@vger.kernel.org
8 years agoslub: delay ctor until the object is requested
Sebastian Andrzej Siewior [Sun, 13 Sep 2015 07:47:12 +0000 (09:47 +0200)]
slub: delay ctor until the object is requested

It seems that allocation of plenty objects causes latency on ARM since that
code can not be preempted

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
8 years agoslub: disable SLUB_CPU_PARTIAL
Sebastian Andrzej Siewior [Wed, 15 Apr 2015 17:00:47 +0000 (19:00 +0200)]
slub: disable SLUB_CPU_PARTIAL

|BUG: sleeping function called from invalid context at kernel/locking/rtmutex.c:915
|in_atomic(): 1, irqs_disabled(): 0, pid: 87, name: rcuop/7
|1 lock held by rcuop/7/87:
| #0:  (rcu_callback){......}, at: [<ffffffff8112c76a>] rcu_nocb_kthread+0x1ca/0x5d0
|Preemption disabled at:[<ffffffff811eebd9>] put_cpu_partial+0x29/0x220
|
|CPU: 0 PID: 87 Comm: rcuop/7 Tainted: G        W       4.0.0-rt0+ #477
|Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.7.5-20140531_083030-gandalf 04/01/2014
000000000007a9fc ffff88013987baf8 ffffffff817441c7 0000000000000007
0000000000000000 ffff88013987bb18 ffffffff810eee51 0000000000000000
ffff88013fc10200 ffff88013987bb48 ffffffff8174a1c4 000000000007a9fc
|Call Trace:
| [<ffffffff817441c7>] dump_stack+0x4f/0x90
| [<ffffffff810eee51>] ___might_sleep+0x121/0x1b0
| [<ffffffff8174a1c4>] rt_spin_lock+0x24/0x60
| [<ffffffff811a689a>] __free_pages_ok+0xaa/0x540
| [<ffffffff811a729d>] __free_pages+0x1d/0x30
| [<ffffffff811eddd5>] __free_slab+0xc5/0x1e0
| [<ffffffff811edf46>] free_delayed+0x56/0x70
| [<ffffffff811eecfd>] put_cpu_partial+0x14d/0x220
| [<ffffffff811efc98>] __slab_free+0x158/0x2c0
| [<ffffffff811f0021>] kmem_cache_free+0x221/0x2d0
| [<ffffffff81204d0c>] file_free_rcu+0x2c/0x40
| [<ffffffff8112c7e3>] rcu_nocb_kthread+0x243/0x5d0
| [<ffffffff810e951c>] kthread+0xfc/0x120
| [<ffffffff8174abc8>] ret_from_fork+0x58/0x90

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
8 years agoslub: Enable irqs for __GFP_WAIT
Thomas Gleixner [Wed, 9 Jan 2013 11:08:15 +0000 (12:08 +0100)]
slub: Enable irqs for __GFP_WAIT

SYSTEM_RUNNING might be too late for enabling interrupts. Allocations
with GFP_WAIT can happen before that. So use this as an indicator.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agomm: Enable SLUB for RT
Thomas Gleixner [Thu, 25 Oct 2012 09:32:35 +0000 (10:32 +0100)]
mm: Enable SLUB for RT

Make SLUB RT aware and remove the restriction in Kconfig.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agomm: Allow only slub on RT
Ingo Molnar [Fri, 3 Jul 2009 13:44:03 +0000 (08:44 -0500)]
mm: Allow only slub on RT

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agomm: bounce: Use local_irq_save_nort
Thomas Gleixner [Wed, 9 Jan 2013 09:33:09 +0000 (10:33 +0100)]
mm: bounce: Use local_irq_save_nort

kmap_atomic() is preemptible on RT.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agoARM: Initialize ptl->lock for vector page
Frank Rowand [Sun, 2 Oct 2011 01:58:13 +0000 (18:58 -0700)]
ARM: Initialize ptl->lock for vector page

Without this patch, ARM can not use SPLIT_PTLOCK_CPUS if
PREEMPT_RT_FULL=y because vectors_user_mapping() creates a
VM_ALWAYSDUMP mapping of the vector page (address 0xffff0000), but no
ptl->lock has been allocated for the page.  An attempt to coredump
that page will result in a kernel NULL pointer dereference when
follow_page() attempts to lock the page.

The call tree to the NULL pointer dereference is:

   do_notify_resume()
      get_signal_to_deliver()
         do_coredump()
            elf_core_dump()
               get_dump_page()
                  __get_user_pages()
                     follow_page()
                        pte_offset_map_lock() <----- a #define
                           ...
                              rt_spin_lock()

The underlying problem is exposed by mm-shrink-the-page-frame-to-rt-size.patch.

Signed-off-by: Frank Rowand <frank.rowand@am.sony.com>
Cc: Frank <Frank_Rowand@sonyusa.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/4E87C535.2030907@am.sony.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agomm: make vmstat -rt aware
Ingo Molnar [Fri, 3 Jul 2009 13:30:13 +0000 (08:30 -0500)]
mm: make vmstat -rt aware

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agomm: convert swap to percpu locked
Ingo Molnar [Fri, 3 Jul 2009 13:29:51 +0000 (08:29 -0500)]
mm: convert swap to percpu locked

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agomm: page_alloc reduce lock sections further
Peter Zijlstra [Fri, 3 Jul 2009 13:44:37 +0000 (08:44 -0500)]
mm: page_alloc reduce lock sections further

Split out the pages which are to be freed into a separate list and
call free_pages_bulk() outside of the percpu page allocator locks.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agomm: page_alloc: rt-friendly per-cpu pages
Ingo Molnar [Fri, 3 Jul 2009 13:29:37 +0000 (08:29 -0500)]
mm: page_alloc: rt-friendly per-cpu pages

rt-friendly per-cpu pages: convert the irqs-off per-cpu locking
method into a preemptible, explicit-per-cpu-locks method.

Contains fixes from:
 Peter Zijlstra <a.p.zijlstra@chello.nl>
 Thomas Gleixner <tglx@linutronix.de>

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agocpu-rt-variants.patch
Thomas Gleixner [Fri, 17 Jun 2011 13:42:38 +0000 (15:42 +0200)]
cpu-rt-variants.patch

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agouse local spin_locks in local_lock
Nicholas Mc Guire [Fri, 17 Jan 2014 19:41:58 +0000 (20:41 +0100)]
use local spin_locks in local_lock

Drop recursive call to migrate_disabel/enable for local_*lock* api
reported by Steven Rostedt.

local_lock will call migrate_disable via get_local_var - call tree is

get_locked_var
 `-> local_lock(lvar)
       `-> __local_lock(&get_local_var(lvar));
                          `--> # define get_local_var(var) (*({
                                    migrate_disable();
                                    &__get_cpu_var(var); }))       \

thus there should be no need to call migrate_disable/enable recursively in
spin_try/lock/unlock. This patch addes a spin_trylock_local and replaces
the migration disabling calls by the local calls.

This patch is incomplete as it does not yet cover the _irq/_irqsave variants
by local locks. This patch requires the API cleanup in kernel/softirq.c or
it would break softirq_lock/unlock with respect to migration.

Signed-off-by: Nicholas Mc Guire <der.herr@hofr.at>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
8 years agort-local-irq-lock.patch
Thomas Gleixner [Mon, 20 Jun 2011 07:03:47 +0000 (09:03 +0200)]
rt-local-irq-lock.patch

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agolocal-var.patch
Thomas Gleixner [Fri, 24 Jun 2011 16:40:37 +0000 (18:40 +0200)]
local-var.patch

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agonet: gianfar: do not disable interrupts
Sebastian Andrzej Siewior [Tue, 25 Mar 2014 17:34:20 +0000 (18:34 +0100)]
net: gianfar: do not disable interrupts

each per-queue lock is taken with spin_lock_irqsave() except in the case
where all of them are taken for some kind of serialisation. As an
optimisation local_irq_save() is used so that lock_tx_qs() and
lock_rx_qs() can use just the spin_lock() variant instead.
On RT local_irq_save() behaves differently so we use the nort()
variant.
Lockdep screems easily by "ethtool -K eth0 rx off tx off"

What remains is missing lockdep annotation that makes lockdep think
lock_tx_qs() may cause a dead lock.

Cc: stable-rt@vger.kernel.org
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
8 years agodrivers/net: vortex fix locking issues
Steven Rostedt [Fri, 3 Jul 2009 13:30:00 +0000 (08:30 -0500)]
drivers/net: vortex fix locking issues

Argh, cut and paste wasn't enough...

Use this patch instead.  It needs an irq disable.  But, believe it or not,
on SMP this is actually better.  If the irq is shared (as it is in Mark's
case), we don't stop the irq of other devices from being handled on
another CPU (unfortunately for Mark, he pinned all interrupts to one CPU).

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
 drivers/net/ethernet/3com/3c59x.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Signed-off-by: Ingo Molnar <mingo@elte.hu>
8 years agodrivers/net: fix livelock issues
Thomas Gleixner [Sat, 20 Jun 2009 09:36:54 +0000 (11:36 +0200)]
drivers/net: fix livelock issues

Preempt-RT runs into a live lock issue with the NETDEV_TX_LOCKED micro
optimization. The reason is that the softirq thread is rescheduling
itself on that return value. Depending on priorities it starts to
monoplize the CPU and livelock on UP systems.

Remove it.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agogenirq: do not invoke the affinity callback via a workqueue
Sebastian Andrzej Siewior [Wed, 21 Aug 2013 15:48:46 +0000 (17:48 +0200)]
genirq: do not invoke the affinity callback via a workqueue

Joe Korty reported, that __irq_set_affinity_locked() schedules a
workqueue while holding a rawlock which results in a might_sleep()
warning.
This patch moves the invokation into a process context so that we only
wakeup() a process while holding the lock.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
8 years agogenirq-force-threading.patch
Thomas Gleixner [Sun, 3 Apr 2011 09:57:29 +0000 (11:57 +0200)]
genirq-force-threading.patch

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agogenirq: disable irqpoll on -rt
Ingo Molnar [Fri, 3 Jul 2009 13:29:57 +0000 (08:29 -0500)]
genirq: disable irqpoll on -rt

Creates long latencies for no value

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agogenirq: Disable DEBUG_SHIRQ for rt
Thomas Gleixner [Fri, 18 Mar 2011 09:22:04 +0000 (10:22 +0100)]
genirq: Disable DEBUG_SHIRQ for rt

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agolist_bl.h: make list head locking RT safe
Paul Gortmaker [Fri, 21 Jun 2013 19:07:25 +0000 (15:07 -0400)]
list_bl.h: make list head locking RT safe

As per changes in include/linux/jbd_common.h for avoiding the
bit_spin_locks on RT ("fs: jbd/jbd2: Make state lock and journal
head lock rt safe") we do the same thing here.

We use the non atomic __set_bit and __clear_bit inside the scope of
the lock to preserve the ability of the existing LIST_DEBUG code to
use the zero'th bit in the sanity checks.

As a bit spinlock, we had no lockdep visibility into the usage
of the list head locking.  Now, if we were to implement it as a
standard non-raw spinlock, we would see:

BUG: sleeping function called from invalid context at kernel/rtmutex.c:658
in_atomic(): 1, irqs_disabled(): 0, pid: 122, name: udevd
5 locks held by udevd/122:
 #0:  (&sb->s_type->i_mutex_key#7/1){+.+.+.}, at: [<ffffffff811967e8>] lock_rename+0xe8/0xf0
 #1:  (rename_lock){+.+...}, at: [<ffffffff811a277c>] d_move+0x2c/0x60
 #2:  (&dentry->d_lock){+.+...}, at: [<ffffffff811a0763>] dentry_lock_for_move+0xf3/0x130
 #3:  (&dentry->d_lock/2){+.+...}, at: [<ffffffff811a0734>] dentry_lock_for_move+0xc4/0x130
 #4:  (&dentry->d_lock/3){+.+...}, at: [<ffffffff811a0747>] dentry_lock_for_move+0xd7/0x130
Pid: 122, comm: udevd Not tainted 3.4.47-rt62 #7
Call Trace:
 [<ffffffff810b9624>] __might_sleep+0x134/0x1f0
 [<ffffffff817a24d4>] rt_spin_lock+0x24/0x60
 [<ffffffff811a0c4c>] __d_shrink+0x5c/0xa0
 [<ffffffff811a1b2d>] __d_drop+0x1d/0x40
 [<ffffffff811a24be>] __d_move+0x8e/0x320
 [<ffffffff811a278e>] d_move+0x3e/0x60
 [<ffffffff81199598>] vfs_rename+0x198/0x4c0
 [<ffffffff8119b093>] sys_renameat+0x213/0x240
 [<ffffffff817a2de5>] ? _raw_spin_unlock+0x35/0x60
 [<ffffffff8107781c>] ? do_page_fault+0x1ec/0x4b0
 [<ffffffff817a32ca>] ? retint_swapgs+0xe/0x13
 [<ffffffff813eb0e6>] ? trace_hardirqs_on_thunk+0x3a/0x3f
 [<ffffffff8119b0db>] sys_rename+0x1b/0x20
 [<ffffffff817a3b96>] system_call_fastpath+0x1a/0x1f

Since we are only taking the lock during short lived list operations,
lets assume for now that it being raw won't be a significant latency
concern.

Cc: stable-rt@vger.kernel.org
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
8 years agofs: jbd/jbd2: Make state lock and journal head lock rt safe
Thomas Gleixner [Fri, 18 Mar 2011 09:11:25 +0000 (10:11 +0100)]
fs: jbd/jbd2: Make state lock and journal head lock rt safe

bit_spin_locks break under RT.

Based on a previous patch from Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
--

 include/linux/buffer_head.h |   10 ++++++++++
 include/linux/jbd_common.h  |   24 ++++++++++++++++++++++++
 2 files changed, 34 insertions(+)

8 years agobuffer_head: Replace bh_uptodate_lock for -rt
Thomas Gleixner [Fri, 18 Mar 2011 08:18:52 +0000 (09:18 +0100)]
buffer_head: Replace bh_uptodate_lock for -rt

Wrap the bit_spin_lock calls into a separate inline and add the RT
replacements with a real spinlock.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agonet-wireless-warn-nort.patch
Thomas Gleixner [Thu, 21 Jul 2011 19:05:33 +0000 (21:05 +0200)]
net-wireless-warn-nort.patch

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agosignal-fix-up-rcu-wreckage.patch
Thomas Gleixner [Fri, 22 Jul 2011 06:07:08 +0000 (08:07 +0200)]
signal-fix-up-rcu-wreckage.patch

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agomm/workingset: do not protect workingset_shadow_nodes with irq off
Sebastian Andrzej Siewior [Thu, 29 Jan 2015 16:19:44 +0000 (17:19 +0100)]
mm/workingset: do not protect workingset_shadow_nodes with irq off

workingset_shadow_nodes is protected by local_irq_disable(). Some users
use spin_lock_irq().
Replace the irq/on with a local_lock(). Rename workingset_shadow_nodes
so I catch users of it which will be introduced later.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
8 years agomm: scatterlist dont disable irqs on RT
Thomas Gleixner [Fri, 3 Jul 2009 13:44:34 +0000 (08:44 -0500)]
mm: scatterlist dont disable irqs on RT

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agousb: use _nort in giveback
Sebastian Andrzej Siewior [Fri, 8 Nov 2013 16:34:54 +0000 (17:34 +0100)]
usb: use _nort in giveback

Since commit 94dfd7ed ("USB: HCD: support giveback of URB in tasklet
context") I see

|BUG: sleeping function called from invalid context at kernel/rtmutex.c:673
|in_atomic(): 0, irqs_disabled(): 1, pid: 109, name: irq/11-uhci_hcd
|no locks held by irq/11-uhci_hcd/109.
|irq event stamp: 440
|hardirqs last  enabled at (439): [<ffffffff816a7555>] _raw_spin_unlock_irqrestore+0x75/0x90
|hardirqs last disabled at (440): [<ffffffff81514906>] __usb_hcd_giveback_urb+0x46/0xc0
|softirqs last  enabled at (0): [<ffffffff81081821>] copy_process.part.52+0x511/0x1510
|softirqs last disabled at (0): [<          (null)>]           (null)
|CPU: 3 PID: 109 Comm: irq/11-uhci_hcd Not tainted 3.12.0-rt0-rc1+ #13
|Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
0000000000000000 ffff8800db9ffbe0 ffffffff8169f064 0000000000000000
ffff8800db9ffbf8 ffffffff810b2122 ffff88020f03e888 ffff8800db9ffc18
ffffffff816a6944 ffffffff810b5748 ffff88020f03c000 ffff8800db9ffc50
|Call Trace:
| [<ffffffff8169f064>] dump_stack+0x4e/0x8f
| [<ffffffff810b2122>] __might_sleep+0x112/0x190
| [<ffffffff816a6944>] rt_spin_lock+0x24/0x60
| [<ffffffff8158435b>] hid_ctrl+0x3b/0x190
| [<ffffffff8151490f>] __usb_hcd_giveback_urb+0x4f/0xc0
| [<ffffffff81514aaf>] usb_hcd_giveback_urb+0x3f/0x140
| [<ffffffff815346af>] uhci_giveback_urb+0xaf/0x280
| [<ffffffff8153666a>] uhci_scan_schedule+0x47a/0xb10
| [<ffffffff81537336>] uhci_irq+0xa6/0x1a0
| [<ffffffff81513c48>] usb_hcd_irq+0x28/0x40
| [<ffffffff810c8ba3>] irq_forced_thread_fn+0x23/0x70
| [<ffffffff810c918f>] irq_thread+0x10f/0x150
| [<ffffffff810a6fad>] kthread+0xcd/0xe0
| [<ffffffff816a842c>] ret_from_fork+0x7c/0xb0

on -RT we run threaded so no need to disable interrupts.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
8 years agocore: Do not disable interrupts on RT in kernel/users.c
Thomas Gleixner [Tue, 21 Jul 2009 21:06:05 +0000 (23:06 +0200)]
core: Do not disable interrupts on RT in kernel/users.c

Use the local_irq_*_nort variants to reduce latencies in RT. The code
is serialized by the locks. No need to disable interrupts.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agoinput: gameport: Do not disable interrupts on PREEMPT_RT
Ingo Molnar [Fri, 3 Jul 2009 13:30:16 +0000 (08:30 -0500)]
input: gameport: Do not disable interrupts on PREEMPT_RT

Use the _nort() primitives.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agoinfiniband: Mellanox IB driver patch use _nort() primitives
Sven-Thorsten Dietrich [Fri, 3 Jul 2009 13:30:35 +0000 (08:30 -0500)]
infiniband: Mellanox IB driver patch use _nort() primitives

Fixes in_atomic stack-dump, when Mellanox module is loaded into the RT
Kernel.

Michael S. Tsirkin <mst@dev.mellanox.co.il> sayeth:
"Basically, if you just make spin_lock_irqsave (and spin_lock_irq) not disable
interrupts for non-raw spinlocks, I think all of infiniband will be fine without
changes."

Signed-off-by: Sven-Thorsten Dietrich <sven@thebigcorporation.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agoide: Do not disable interrupts for PREEMPT-RT
Ingo Molnar [Fri, 3 Jul 2009 13:30:16 +0000 (08:30 -0500)]
ide: Do not disable interrupts for PREEMPT-RT

Use the local_irq_*_nort variants.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agoata: Do not disable interrupts in ide code for preempt-rt
Steven Rostedt [Fri, 3 Jul 2009 13:44:29 +0000 (08:44 -0500)]
ata: Do not disable interrupts in ide code for preempt-rt

Use the local_irq_*_nort variants.

Signed-off-by: Steven Rostedt <srostedt@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agopreempt: Provide preempt_*_(no)rt variants
Thomas Gleixner [Fri, 24 Jul 2009 10:38:56 +0000 (12:38 +0200)]
preempt: Provide preempt_*_(no)rt variants

RT needs a few preempt_disable/enable points which are not necessary
otherwise. Implement variants to avoid #ifdeffery.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
8 years agort: local_irq_* variants depending on RT/!RT
Thomas Gleixner [Tue, 21 Jul 2009 20:34:14 +0000 (22:34 +0200)]
rt: local_irq_* variants depending on RT/!RT

Add local_irq_*_(no)rt variant which are mainly used to break
interrupt disabled sections on PREEMPT_RT or to explicitely disable
interrupts on PREEMPT_RT.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>