Skip to contentSkip to conversation

BUG: using smp_processor_id() in preemptible

DISCUSSION Tim Blechmann 2 participants 3 messages Dec 8, 2008 – Feb 20, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

hi all,

using the 2.6.26.6-rt11 patchset on a 2.6.26.8 kernel, i get the following stack traces:

[ 4262.931832] BUG: using smp_processor_id() in preemptible [00000000] code: bash/361
[ 4262.931846] caller is mem_cgroup_charge_statistics+0x6d/0xa0
[ 4262.931852] Pid: 361, comm: bash Not tainted 2.6.26.8-rt11 #3
[ 4262.931855] 
[ 4262.931856] Call Trace:
[ 4262.931886]  [<ffffffff80396e8c>] debug_smp_processor_id+0xcc/0xd0
[ 4262.931895]  [<ffffffff802daead>] mem_cgroup_charge_statistics+0x6d/0xa0
[ 4262.931905]  [<ffffffff802daf19>] __mem_cgroup_add_list+0x39/0x60
[ 4262.931911]  [<ffffffff802db744>] mem_cgroup_charge_common+0x314/0x330
[ 4262.931925]  [<ffffffff802db78e>] mem_cgroup_charge+0xe/0x10
[ 4262.931933]  [<ffffffff802b8773>] do_wp_page+0x133/0x5a0
[ 4262.931944]  [<ffffffff804d7461>] ? __rt_spin_lock+0x81/0x90
[ 4262.931956]  [<ffffffff802ba805>] handle_mm_fault+0x605/0x900
[ 4262.931975]  [<ffffffff804dacfc>] do_page_fault+0x45c/0xd50
[ 4262.931998]  [<ffffffff8021d6ee>] ? native_smp_send_reschedule+0x2e/0x50
[ 4262.932006]  [<ffffffff8023a041>] ? __resched_task+0x91/0x120
[ 4262.932015]  [<ffffffff8023b5f4>] ? task_new_fair+0xb4/0x100
[ 4262.932027]  [<ffffffff8023e09b>] ? wake_up_new_task+0xdb/0x190
[ 4262.932038]  [<ffffffff80241190>] ? do_fork+0xf0/0x330
[ 4262.932048]  [<ffffffff804d748e>] ? rt_spin_lock+0x1e/0x50
[ 4262.932056]  [<ffffffff802dbad2>] ? fd_install+0x52/0x60
[ 4262.932072]  [<ffffffff804d81c9>] error_exit+0x0/0x60

hth, tim

Signature · 7 lines
[email protected]
http://tim.klingt.org

There's no such entity as "most people". These are generalities. All
generalities are meaningless. You've got to pin it down to a specific
person doing a specific thing at a specific time and space.
  William S. Burroughs
#1 lore raw

fyi, this is still an issue in 2.6.26.8-rt13.

tim

Quoted 28 lines · Tim Blechmann

hi all,

using the 2.6.26.6-rt11 patchset on a 2.6.26.8 kernel, i get the following stack traces:

[ 4262.931832] BUG: using smp_processor_id() in preemptible [00000000]
code: bash/361 [ 4262.931846] caller is
mem_cgroup_charge_statistics+0x6d/0xa0 [ 4262.931852] Pid: 361, comm:
bash Not tainted 2.6.26.8-rt11 #3 [ 4262.931855]
[ 4262.931856] Call Trace:
[ 4262.931886]  [<ffffffff80396e8c>] debug_smp_processor_id+0xcc/0xd0 [
4262.931895]  [<ffffffff802daead>]
mem_cgroup_charge_statistics+0x6d/0xa0 [ 4262.931905] 
[<ffffffff802daf19>] __mem_cgroup_add_list+0x39/0x60 [ 4262.931911] 
[<ffffffff802db744>] mem_cgroup_charge_common+0x314/0x330 [ 4262.931925]
 [<ffffffff802db78e>] mem_cgroup_charge+0xe/0x10 [ 4262.931933] 
[<ffffffff802b8773>] do_wp_page+0x133/0x5a0 [ 4262.931944] 
[<ffffffff804d7461>] ? __rt_spin_lock+0x81/0x90 [ 4262.931956] 
[<ffffffff802ba805>] handle_mm_fault+0x605/0x900 [ 4262.931975] 
[<ffffffff804dacfc>] do_page_fault+0x45c/0xd50 [ 4262.931998] 
[<ffffffff8021d6ee>] ? native_smp_send_reschedule+0x2e/0x50 [
4262.932006]  [<ffffffff8023a041>] ? __resched_task+0x91/0x120 [
4262.932015]  [<ffffffff8023b5f4>] ? task_new_fair+0xb4/0x100 [
4262.932027]  [<ffffffff8023e09b>] ? wake_up_new_task+0xdb/0x190 [
4262.932038]  [<ffffffff80241190>] ? do_fork+0xf0/0x330 [ 4262.932048] 
[<ffffffff804d748e>] ? rt_spin_lock+0x1e/0x50 [ 4262.932056] 
[<ffffffff802dbad2>] ? fd_install+0x52/0x60 [ 4262.932072] 
[<ffffffff804d81c9>] error_exit+0x0/0x60
Signature · 5 lines
[email protected]
http://tim.klingt.org

Lesser artists borrow, great artists steal.
  Igor Stravinsky
#2 lore raw
Quoted 3 lines · Tim Blechmann

fyi, this is still an issue in 2.6.26.8-rt13.

tim

The attached patch should fix it ; it is based on the discussion that took place here on rt-users.

Paul.

Quoted 8 lines
Quoted 5 lines · Tim Blechmann

hi all,

using the 2.6.26.6-rt11 patchset on a 2.6.26.8 kernel, i get the following stack traces:

Quoted 8 lines
Quoted 8 lines
[ 4262.931832] BUG: using smp_processor_id() in preemptible [00000000]
code: bash/361 [ 4262.931846] caller is
mem_cgroup_charge_statistics+0x6d/0xa0 [ 4262.931852] Pid: 361, comm:
bash Not tainted 2.6.26.8-rt11 #3 [ 4262.931855]
[ 4262.931856] Call Trace:
[ 4262.931886]  [<ffffffff80396e8c>] debug_smp_processor_id+0xcc/0xd0 [

4262.931895] [<ffffffff802daead>] mem_cgroup_charge_statistics+0x6d/0xa0 [ 4262.931905]

From faa0ea31405ec9d44e8242e224f8e607642f3c5e Mon Sep 17 00:00:00 2001
From: Paul Gortmaker <[email protected]>
Date: Mon, 26 Jan 2009 21:15:22 -0500
Subject: [PATCH] memcg: fix BUG: using smp_processor_id() in preemptible

A combination of upstream (e.g. addb9efe) and as per discussion on rt list (Dec 2008) between Tim Blechmann and Kamezawa Hiroyuki, this is needed to fix the following:

BUG: using smp_processor_id() in preemptible [00000000] code: swapper/1
caller is mem_cgroup_charge_statistics+0x85/0xa0

Pid: 1, comm: swapper Not tainted 2.6.26.8-rt12 #1

Call Trace:
 [<ffffffff8038eb94>] debug_smp_processor_id+0xc4/0xd0
 [<ffffffff8029ffe5>] mem_cgroup_charge_statistics+0x85/0xa0
 [<ffffffff802a0039>] __mem_cgroup_add_list+0x39/0x60
 [<ffffffff802a0807>] mem_cgroup_charge_common+0x317/0x340
 [<ffffffff802a0849>] mem_cgroup_cache_charge+0x19/0x20
 [<ffffffff80276918>] add_to_page_cache+0x38/0x250
 [<ffffffff8027d43d>] ? __alloc_pages_internal+0xed/0x4f0
 [<ffffffff80276b49>] add_to_page_cache_lru+0x19/0x40
 [<ffffffff80277603>] find_or_create_page+0x63/0xb0
 [<ffffffff802cd401>] __getblk+0x101/0x320
 [<ffffffff802fddd6>] __ext3_get_inode_loc+0x106/0x320
 [<ffffffff802fe060>] ext3_iget+0x70/0x420
 [<ffffffff80305068>] ext3_lookup+0xa8/0x100
---
 mm/memcontrol.c |   19 ++++++++++++-------
 1 files changed, 12 insertions(+), 7 deletions(-)
mm/memcontrol.c +12 -7
index ed1cfb1..86e7f14 100644
@@ -65,11 +65,11 @@ struct mem_cgroup_stat {
 /*
  * For accounting under irq disable, no need for increment preempt count.
  */
-static void __mem_cgroup_stat_add_safe(struct mem_cgroup_stat *stat,
+static inline void __mem_cgroup_stat_add_safe(struct mem_cgroup_stat_cpu *stat,
 		enum mem_cgroup_stat_index idx, int val)
 {
-	int cpu = smp_processor_id();
-	stat->cpustat[cpu].count[idx] += val;
+	stat->count[idx] += val;
+
 }
 
 static s64 mem_cgroup_read_stat(struct mem_cgroup_stat *stat,
@@ -195,19 +195,24 @@ static void mem_cgroup_charge_statistics(struct mem_cgroup *mem, int flags,
 {
 	int val = (charge)? 1 : -1;
 	struct mem_cgroup_stat *stat = &mem->stat;
+	struct mem_cgroup_stat_cpu *cpustat;
+	int cpu = get_cpu();
 
 	VM_BUG_ON(!irqs_disabled());
+
+	cpustat = &stat->cpustat[cpu];
 	if (flags & PAGE_CGROUP_FLAG_CACHE)
-		__mem_cgroup_stat_add_safe(stat, MEM_CGROUP_STAT_CACHE, val);
+		__mem_cgroup_stat_add_safe(cpustat, MEM_CGROUP_STAT_CACHE, val);
 	else
-		__mem_cgroup_stat_add_safe(stat, MEM_CGROUP_STAT_RSS, val);
+		__mem_cgroup_stat_add_safe(cpustat, MEM_CGROUP_STAT_RSS, val);
 
 	if (charge)
-		__mem_cgroup_stat_add_safe(stat,
+		__mem_cgroup_stat_add_safe(cpustat,
 				MEM_CGROUP_STAT_PGPGIN_COUNT, 1);
 	else
-		__mem_cgroup_stat_add_safe(stat,
+		__mem_cgroup_stat_add_safe(cpustat,
 				MEM_CGROUP_STAT_PGPGOUT_COUNT, 1);
+	put_cpu();
 }
 
 static struct mem_cgroup_per_zone *
Signature · 1 line
1.6.0.4