linux-rt-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [V2 PATCH] rt: Don't call schedule_work_on in preemption disabled context
@ 2013-10-04 21:58 Yang Shi
  2013-10-30  9:22 ` Thomas Gleixner
  0 siblings, 1 reply; 3+ messages in thread
From: Yang Shi @ 2013-10-04 21:58 UTC (permalink / raw)
  To: bigeasy; +Cc: linux-rt-users, paul.gortmaker, yang.shi

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,
remove the pair of get_cpu/put_cpu and drain_local_stock shortcut.

Signed-off-by: Yang Shi <yang.shi@windriver.com>
---
 mm/memcontrol.c |   12 +++---------
 1 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 82a187a..b025731 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -2436,11 +2436,10 @@ static void refill_stock(struct mem_cgroup *memcg, unsigned int nr_pages)
  */
 static void drain_all_stock(struct mem_cgroup *root_memcg, bool sync)
 {
-	int cpu, curcpu;
+	int cpu;
 
 	/* Notify other cpus that system-wide "drain" is running */
 	get_online_cpus();
-	curcpu = get_cpu();
 	for_each_online_cpu(cpu) {
 		struct memcg_stock_pcp *stock = &per_cpu(memcg_stock, cpu);
 		struct mem_cgroup *memcg;
@@ -2450,14 +2449,9 @@ static void drain_all_stock(struct mem_cgroup *root_memcg, bool sync)
 			continue;
 		if (!mem_cgroup_same_or_subtree(root_memcg, memcg))
 			continue;
-		if (!test_and_set_bit(FLUSHING_CACHED_CHARGE, &stock->flags)) {
-			if (cpu == curcpu)
-				drain_local_stock(&stock->work);
-			else
-				schedule_work_on(cpu, &stock->work);
-		}
+		if (!test_and_set_bit(FLUSHING_CACHED_CHARGE, &stock->flags))
+			schedule_work_on(cpu, &stock->work);
 	}
-	put_cpu();
 
 	if (!sync)
 		goto out;
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [V2 PATCH] rt: Don't call schedule_work_on in preemption disabled context
  2013-10-04 21:58 [V2 PATCH] rt: Don't call schedule_work_on in preemption disabled context Yang Shi
@ 2013-10-30  9:22 ` Thomas Gleixner
  2013-10-30 15:17   ` Yang Shi
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Gleixner @ 2013-10-30  9:22 UTC (permalink / raw)
  To: Yang Shi; +Cc: bigeasy, linux-rt-users, paul.gortmaker

On Fri, 4 Oct 2013, Yang Shi wrote:

> 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,
> remove the pair of get_cpu/put_cpu and drain_local_stock shortcut.

Simply replace get/put_cpu() with get/put_cpu_light() and the problem is fixed
with 2 lines of change.
 
Thanks,

	tglx

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [V2 PATCH] rt: Don't call schedule_work_on in preemption disabled context
  2013-10-30  9:22 ` Thomas Gleixner
@ 2013-10-30 15:17   ` Yang Shi
  0 siblings, 0 replies; 3+ messages in thread
From: Yang Shi @ 2013-10-30 15:17 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: bigeasy, linux-rt-users, paul.gortmaker

On 10/30/2013 2:22 AM, Thomas Gleixner wrote:
> On Fri, 4 Oct 2013, Yang Shi wrote:
>
>> 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,
>> remove the pair of get_cpu/put_cpu and drain_local_stock shortcut.
> Simply replace get/put_cpu() with get/put_cpu_light() and the problem is fixed
> with 2 lines of change.

Thanks tglx.

I will submit follow-up patch soon.

Yang

>   
> Thanks,
>
> 	tglx


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-10-30 15:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-04 21:58 [V2 PATCH] rt: Don't call schedule_work_on in preemption disabled context Yang Shi
2013-10-30  9:22 ` Thomas Gleixner
2013-10-30 15:17   ` Yang Shi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).