linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Lameter <cl@linux.com>
To: Tejun Heo <tj@kernel.org>
Cc: akpm@linuxfoundation.org, rostedt@goodmis.org,
	linux-kernel@vger.kernel.org, Ingo Molnar <mingo@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	linux-mm@kvack.org, Alex Shi <alex.shi@intel.com>
Subject: [PATCH 15/41] mm: Use raw_cpu ops for determining current NUMA node
Date: Fri, 17 Jan 2014 09:18:27 -0600	[thread overview]
Message-ID: <20140117151835.920139508@linux.com> (raw)
In-Reply-To: 20140117151812.770437629@linux.com

[-- Attachment #1: preempt_fix_numa_node --]
[-- Type: text/plain, Size: 4926 bytes --]

[Patch depends on another patch in this series that introduces raw_cpu_ops]

With the preempt checking logic for __this_cpu_ops we will get false
positives from locations in the code that use numa_node_id.

Before the  __this_cpu ops where introduced there were
no checks for preemption present either. smp_raw_processor_id()
was used. See http://www.spinics.net/lists/linux-numa/msg00641.html

Therefore we need to use raw_cpu_read here to avoid false postives.

Note that this issue has been discussed in prior years.
If the process changes nodes after retrieving the current numa node then
that is acceptable since most uses of numa_node etc are for optimization
and not for correctness.

There were suggestions to implement a raw_numa_node_id in order to
do preempt checks for numa_node_id as well. But I think we better
defer that to another patch since that would mean investigating
how numa_node_id() is used throughout the kernel which would increase
the scope of this patchset significantly. After all preemption was never
checked before when numa_node_id() was used.

Some sample traces:

__this_cpu_read operation in preemptible [00000000] code: login/1456
caller is __this_cpu_preempt_check+0x2b/0x2d
CPU: 0 PID: 1456 Comm: login Not tainted 3.12.0-rc4-cl-00062-g2fe80d3-dirty #185
Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
 000000000000013c ffff88001f31ba58 ffffffff8147cf5e ffff88001f31bfd8
 ffff88001f31ba88 ffffffff8127eea9 0000000000000000 ffff88001f3975c0
 00000000f7707000 ffff88001f3975c0 ffff88001f31bac0 ffffffff8127eeef
Call Trace:
 [<ffffffff8147cf5e>] dump_stack+0x4e/0x82
 [<ffffffff8127eea9>] check_preemption_disabled+0xc5/0xe0
 [<ffffffff8127eeef>] __this_cpu_preempt_check+0x2b/0x2d
 [<ffffffff81030ff5>] ? show_stack+0x3b/0x3d
 [<ffffffff810ebee3>] get_task_policy+0x1d/0x49
 [<ffffffff810ed705>] get_vma_policy+0x14/0x76
 [<ffffffff810ed8ff>] alloc_pages_vma+0x35/0xff
 [<ffffffff810dad97>] handle_mm_fault+0x290/0x73b
 [<ffffffff810503da>] __do_page_fault+0x3fe/0x44d
 [<ffffffff8109b360>] ? trace_hardirqs_on_caller+0x142/0x19e
 [<ffffffff8109b3c9>] ? trace_hardirqs_on+0xd/0xf
 [<ffffffff81278bed>] ? trace_hardirqs_off_thunk+0x3a/0x3c
 [<ffffffff810be97f>] ? find_get_pages_contig+0x18e/0x18e
 [<ffffffff810be97f>] ? find_get_pages_contig+0x18e/0x18e
 [<ffffffff81050451>] do_page_fault+0x9/0xc
 [<ffffffff81483602>] page_fault+0x22/0x30
 [<ffffffff810be97f>] ? find_get_pages_contig+0x18e/0x18e
 [<ffffffff810be97f>] ? find_get_pages_contig+0x18e/0x18e
 [<ffffffff810be4c3>] ? file_read_actor+0x3a/0x15a
 [<ffffffff810be97f>] ? find_get_pages_contig+0x18e/0x18e
 [<ffffffff810bffab>] generic_file_aio_read+0x38e/0x624
 [<ffffffff810f6d69>] do_sync_read+0x54/0x73
 [<ffffffff810f7890>] vfs_read+0x9d/0x12a
 [<ffffffff810f7a59>] SyS_read+0x47/0x7e
 [<ffffffff81484f21>] cstar_dispatch+0x7/0x23


caller is __this_cpu_preempt_check+0x2b/0x2d
CPU: 0 PID: 1456 Comm: login Not tainted 3.12.0-rc4-cl-00062-g2fe80d3-dirty #185
Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
 00000000000000e8 ffff88001f31bbf8 ffffffff8147cf5e ffff88001f31bfd8
 ffff88001f31bc28 ffffffff8127eea9 ffffffff823c5c40 00000000000213da
 0000000000000000 0000000000000000 ffff88001f31bc60 ffffffff8127eeef
Call Trace:
 [<ffffffff8147cf5e>] dump_stack+0x4e/0x82
 [<ffffffff8127eea9>] check_preemption_disabled+0xc5/0xe0
 [<ffffffff8127eeef>] __this_cpu_preempt_check+0x2b/0x2d
 [<ffffffff810e006e>] ? install_special_mapping+0x11/0xe4
 [<ffffffff810ec8a8>] alloc_pages_current+0x8f/0xbc
 [<ffffffff810bec6b>] __page_cache_alloc+0xb/0xd
 [<ffffffff810c7e90>] __do_page_cache_readahead+0xf4/0x219
 [<ffffffff810c7e0e>] ? __do_page_cache_readahead+0x72/0x219
 [<ffffffff810c827c>] ra_submit+0x1c/0x20
 [<ffffffff810c850c>] ondemand_readahead+0x28c/0x2b4
 [<ffffffff810c85e9>] page_cache_sync_readahead+0x38/0x3a
 [<ffffffff810bfe7e>] generic_file_aio_read+0x261/0x624
 [<ffffffff810f6d69>] do_sync_read+0x54/0x73
 [<ffffffff810f7890>] vfs_read+0x9d/0x12a
 [<ffffffff810f7a59>] SyS_read+0x47/0x7e
 [<ffffffff81484f21>] cstar_dispatch+0x7/0x23

Cc: linux-mm@kvack.org
Cc: Alex Shi <alex.shi@intel.com>
Acked-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Christoph Lameter <cl@linux.com>

Index: linux/include/linux/topology.h
===================================================================
--- linux.orig/include/linux/topology.h	2013-12-02 16:07:51.304591590 -0600
+++ linux/include/linux/topology.h	2013-12-02 16:07:51.304591590 -0600
@@ -188,7 +188,7 @@ DECLARE_PER_CPU(int, numa_node);
 /* Returns the number of the current Node. */
 static inline int numa_node_id(void)
 {
-	return __this_cpu_read(numa_node);
+	return raw_cpu_read(numa_node);
 }
 #endif
 
@@ -245,7 +245,7 @@ static inline void set_numa_mem(int node
 /* Returns the number of the nearest Node with memory */
 static inline int numa_mem_id(void)
 {
-	return __this_cpu_read(_numa_mem_);
+	return raw_cpu_read(_numa_mem_);
 }
 #endif
 


  parent reply	other threads:[~2014-01-17 15:26 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-17 15:18 [PATCH 00/41] percpu: Consistent per cpu operations V3 Christoph Lameter
2014-01-17 15:18 ` [PATCH 01/41] mm: Replace __get_cpu_var uses with this_cpu_ptr Christoph Lameter
2014-01-17 15:18 ` [PATCH 02/41] tracing: " Christoph Lameter
2014-01-17 15:18 ` [PATCH 03/41] percpu: Replace __get_cpu_var " Christoph Lameter
2014-01-17 15:18 ` [PATCH 04/41] kernel misc: Replace __get_cpu_var uses Christoph Lameter
2014-01-17 15:18 ` [PATCH 05/41] drivers/char/random: " Christoph Lameter
2014-01-17 15:18 ` [PATCH 06/41] drivers/cpuidle: Replace __get_cpu_var uses for address calculation Christoph Lameter
2014-01-17 15:18 ` [PATCH 07/41] drivers/oprofile: " Christoph Lameter
2014-01-17 15:18 ` [PATCH 08/41] drivers/leds: Replace __get_cpu_var use through this_cpu_ptr Christoph Lameter
2014-01-17 15:18 ` [PATCH 09/41] drivers/clocksource: Replace __get_cpu_var used for address calculation Christoph Lameter
2014-01-17 15:18 ` [PATCH 10/41] staging/zsmalloc: Replace instances of using __get_cpu_var " Christoph Lameter
2014-01-17 15:18 ` [PATCH 11/41] parisc: Replace __get_cpu_var uses " Christoph Lameter
2014-01-17 15:18 ` [PATCH 12/41] metag: " Christoph Lameter
2014-01-17 15:18 ` [PATCH 13/41] drivers/net/ethernet/tile: " Christoph Lameter
2014-01-17 15:18 ` [PATCH 14/41] percpu: Add raw_cpu_ops Christoph Lameter
2014-01-17 15:18 ` Christoph Lameter [this message]
2014-01-17 15:18 ` [PATCH 16/41] modules: Use raw_cpu_write for initialization of per cpu refcount Christoph Lameter
2014-01-17 15:18 ` [PATCH 17/41] net: Replace __this_cpu_inc in route.c with raw_cpu_inc Christoph Lameter
2014-01-18  3:05   ` David Miller
2014-01-17 15:18 ` [PATCH 18/41] percpu: Add preemption checks to __this_cpu ops Christoph Lameter
2014-01-17 15:18 ` [PATCH 19/41] time: Replace __get_cpu_var uses Christoph Lameter
2014-01-17 15:18 ` [PATCH 20/41] scheduler: Replace __get_cpu_var with this_cpu_ptr Christoph Lameter
2014-01-17 15:18 ` [PATCH 21/41] block: Replace __this_cpu_ptr with raw_cpu_ptr Christoph Lameter
2014-01-17 15:18 ` [PATCH 22/41] rcu: Replace __this_cpu_ptr uses " Christoph Lameter
2014-01-17 15:18 ` [PATCH 23/41] watchdog: Replace __raw_get_cpu_var uses Christoph Lameter
2014-01-17 15:18 ` [PATCH 24/41] net: Replace get_cpu_var through this_cpu_ptr Christoph Lameter
2014-01-18  3:05   ` David Miller
2014-01-17 15:18 ` [PATCH 25/41] md: Replace __this_cpu_ptr with raw_cpu_ptr Christoph Lameter
2014-01-17 15:18 ` [PATCH 26/41] irqchips: Replace __this_cpu_ptr uses Christoph Lameter
2014-01-17 15:18 ` [PATCH 27/41] x86: Replace __get_cpu_var uses Christoph Lameter
2014-01-17 16:29   ` H. Peter Anvin
2014-01-17 15:18 ` [PATCH 28/41] arm: Replace __this_cpu_ptr with raw_cpu_ptr Christoph Lameter
2014-01-17 15:18 ` [PATCH 29/41] MIPS: Replace __get_cpu_var uses in FPU emulator Christoph Lameter
2014-01-17 15:18 ` [PATCH 30/41] mips: Replace __get_cpu_var uses Christoph Lameter
2014-01-17 15:18 ` [PATCH 31/41] s390: rename __this_cpu_ptr to raw_cpu_ptr Christoph Lameter
2014-01-17 15:18 ` [PATCH 32/41] ia64: Replace __get_cpu_var uses Christoph Lameter
2014-01-17 15:18 ` [PATCH 33/41] powerpc: " Christoph Lameter
2014-01-17 15:18 ` [PATCH 34/41] sparc: " Christoph Lameter
2014-01-17 15:18 ` [PATCH 35/41] tile: " Christoph Lameter
2014-01-17 15:18 ` [PATCH 36/41] blackfin: " Christoph Lameter
2014-01-17 15:18 ` [PATCH 37/41] avr32: Replace __get_cpu_var with __this_cpu_write Christoph Lameter
2014-01-17 15:18 ` [PATCH 38/41] alpha: Replace __get_cpu_var Christoph Lameter
2014-01-17 15:18 ` [PATCH 39/41] sh: Replace __get_cpu_var uses Christoph Lameter
2014-01-17 15:18 ` [PATCH 40/41] Remove __get_cpu_var and __raw_get_cpu_var macros [only in 3.15] Christoph Lameter
2014-01-17 15:18 ` [PATCH 41/41] percpu: Remove __this_cpu_ptr Christoph Lameter
  -- strict thread matches above, loose matches on Subject: below --
2013-12-03 23:32 [PATCH 00/41] percpu: Consistent per cpu operations V1 Christoph Lameter
2013-12-03 23:32 ` [PATCH 15/41] mm: Use raw_cpu ops for determining current NUMA node Christoph Lameter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140117151835.920139508@linux.com \
    --to=cl@linux.com \
    --cc=akpm@linuxfoundation.org \
    --cc=alex.shi@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).