From: Andrey Ryabinin <aryabinin@virtuozzo.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: <ying.huang@linux.intel.com>,
Stephen Rothwell <sfr@canb.auug.org.au>,
Christoph Hellwig <hch@lst.de>,
Joel Fernandes <joelaf@google.com>,
Jisheng Zhang <jszhang@marvell.com>,
Chris Wilson <chris@chris-wilson.co.uk>,
John Dias <joaodias@google.com>,
Thomas Gleixner <tglx@linutronix.de>,
"H. Peter Anvin" <hpa@zytor.com>, Ingo Molnar <mingo@elte.hu>,
<linux-kernel@vger.kernel.org>, <lkp@01.org>,
Andrey Ryabinin <aryabinin@virtuozzo.com>
Subject: [PATCH] mm-add-vfree_atomic-fix
Date: Mon, 12 Dec 2016 17:46:21 +0300 [thread overview]
Message-ID: <1481553981-3856-1-git-send-email-aryabinin@virtuozzo.com> (raw)
In-Reply-To: <87lgvlzp34.fsf@yhuang-dev.intel.com>
DEBUG_PREEMPT complains about using this_cpu_ptr() in preemptible:
BUG: using smp_processor_id() in preemptible [00000000] code: iperf-300s-cs-l/277
caller is debug_smp_processor_id+0x17/0x19
CPU: 1 PID: 277 Comm: iperf-300s-cs-l Not tainted 4.9.0-rc8-00140-gcc639db #2
ffffc900003f3cf0 ffffffff8123ae6f 0000000000000001 ffffffff818181da
ffffc900003f3d20 ffffffff81252f41 0000000000012de0 00000000fffffdff
ffff880009328f40 ffff88000592c400 ffffc900003f3d30 ffffffff81252f6a
Call Trace:
[<ffffffff8123ae6f>] dump_stack+0x9a/0xd0
[<ffffffff81252f41>] check_preemption_disabled+0xdd/0xef
[<ffffffff81252f6a>] debug_smp_processor_id+0x17/0x19
[<ffffffff811796df>] __vfree_deferred+0x16/0x4c
[<ffffffff8117b584>] vfree_atomic+0x22/0x24
[<ffffffff81094f5d>] free_thread_stack+0xc2/0x106
[<ffffffff810951be>] put_task_stack+0x4c/0x62
[<ffffffff81095f81>] copy_process+0x7e0/0x16e8
[<ffffffff8109702d>] _do_fork+0xbb/0x2d3
[<ffffffff810465e8>] ? __do_page_fault+0x2e1/0x384
[<ffffffff8112633f>] ? trace_hardirqs_off_caller+0x12/0x24
[<ffffffff810972cb>] SyS_clone+0x19/0x1b
[<ffffffff81003800>] do_syscall_64+0x143/0x173
[<ffffffff81507289>] entry_SYSCALL64_slow_path+0x25/0x25
Use raw_cpu_ptr() instead of this_cpu_ptr() to hide this warning.
It's fine because llist_add() implementation is lock-less, so it works even
if we adding to the list of some other cpu. schedule_work() is also preempt-safe.
Reported-by: kernel test robot <ying.huang@linux.intel.com>
Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
---
mm/vmalloc.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 43f0608..d8813963 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -1498,7 +1498,14 @@ static void __vunmap(const void *addr, int deallocate_pages)
static inline void __vfree_deferred(const void *addr)
{
- struct vfree_deferred *p = this_cpu_ptr(&vfree_deferred);
+ /*
+ * Use raw_cpu_ptr() because this can be called from preemptible
+ * context. Preemption is absolutely fine here, because llist_add()
+ * implementation is lockless, so it works even if we adding to list
+ * of the other cpu.
+ * schedule_work() should be fine with this too.
+ */
+ struct vfree_deferred *p = raw_cpu_ptr(&vfree_deferred);
if (llist_add((struct llist_node *)addr, &p->list))
schedule_work(&p->wq);
--
2.7.3
next prev parent reply other threads:[~2016-12-12 15:02 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-12 5:35 [lkp-developer] [kernel/fork] cc639db4ac: BUG:using_smp_processor_id()in_preemptible kernel test robot
2016-12-12 14:46 ` Andrey Ryabinin [this message]
2016-12-13 10:12 ` [PATCH] mm-add-vfree_atomic-fix Michal Hocko
2016-12-13 16:57 ` Andy Lutomirski
2016-12-13 17:24 ` Michal Hocko
2016-12-13 18:15 ` Andy Lutomirski
2016-12-13 19:21 ` Andrey Ryabinin
2016-12-14 3:02 ` Andy Lutomirski
2016-12-13 19:06 ` Andrey Ryabinin
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=1481553981-3856-1-git-send-email-aryabinin@virtuozzo.com \
--to=aryabinin@virtuozzo.com \
--cc=akpm@linux-foundation.org \
--cc=chris@chris-wilson.co.uk \
--cc=hch@lst.de \
--cc=hpa@zytor.com \
--cc=joaodias@google.com \
--cc=joelaf@google.com \
--cc=jszhang@marvell.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lkp@01.org \
--cc=mingo@elte.hu \
--cc=sfr@canb.auug.org.au \
--cc=tglx@linutronix.de \
--cc=ying.huang@linux.intel.com \
/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).