Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1431724 > unrolled thread
| Started by | Andy Lutomirski <luto@kernel.org> |
|---|---|
| First post | 2016-06-27 07:30 +0200 |
| Last post | 2016-06-27 19:20 +0200 |
| Articles | 4 on this page of 24 — 6 participants |
Back to article view | Back to linux.kernel
kthread_stop insanity (Re: [[DEBUG] force] 2642458962: BUG: unable to handle kernel paging request at ffffc90000997f18) Andy Lutomirski <luto@kernel.org> - 2016-06-27 07:30 +0200
Re: kthread_stop insanity (Re: [[DEBUG] force] 2642458962: BUG: unable to handle kernel paging request at ffffc90000997f18) Peter Zijlstra <peterz@infradead.org> - 2016-06-27 10:30 +0200
Re: kthread_stop insanity (Re: [[DEBUG] force] 2642458962: BUG: unable to handle kernel paging request at ffffc90000997f18) Oleg Nesterov <oleg@redhat.com> - 2016-06-27 17:00 +0200
Re: kthread_stop insanity (Re: [[DEBUG] force] 2642458962: BUG: unable to handle kernel paging request at ffffc90000997f18) Andy Lutomirski <luto@amacapital.net> - 2016-06-27 17:50 +0200
Re: kthread_stop insanity (Re: [[DEBUG] force] 2642458962: BUG: unable to handle kernel paging request at ffffc90000997f18) Oleg Nesterov <oleg@redhat.com> - 2016-06-27 19:00 +0200
Re: kthread_stop insanity (Re: [[DEBUG] force] 2642458962: BUG: unable to handle kernel paging request at ffffc90000997f18) Oleg Nesterov <oleg@redhat.com> - 2016-06-28 21:00 +0200
Re: kthread_stop insanity (Re: [[DEBUG] force] 2642458962: BUG: unable to handle kernel paging request at ffffc90000997f18) Andy Lutomirski <luto@amacapital.net> - 2016-06-28 21:20 +0200
Re: kthread_stop insanity (Re: [[DEBUG] force] 2642458962: BUG: unable to handle kernel paging request at ffffc90000997f18) Oleg Nesterov <oleg@redhat.com> - 2016-06-28 22:20 +0200
Re: kthread_stop insanity (Re: [[DEBUG] force] 2642458962: BUG: unable to handle kernel paging request at ffffc90000997f18) Andy Lutomirski <luto@amacapital.net> - 2016-06-28 23:00 +0200
Re: kthread_stop insanity (Re: [[DEBUG] force] 2642458962: BUG: unable to handle kernel paging request at ffffc90000997f18) Linus Torvalds <torvalds@linux-foundation.org> - 2016-06-28 23:20 +0200
Re: kthread_stop insanity (Re: [[DEBUG] force] 2642458962: BUG: unable to handle kernel paging request at ffffc90000997f18) Linus Torvalds <torvalds@linux-foundation.org> - 2016-06-28 23:20 +0200
Re: kthread_stop insanity (Re: [[DEBUG] force] 2642458962: BUG: unable to handle kernel paging request at ffffc90000997f18) Andy Lutomirski <luto@amacapital.net> - 2016-06-28 23:30 +0200
Re: kthread_stop insanity (Re: [[DEBUG] force] 2642458962: BUG: unable to handle kernel paging request at ffffc90000997f18) Linus Torvalds <torvalds@linux-foundation.org> - 2016-06-28 23:40 +0200
Re: kthread_stop insanity (Re: [[DEBUG] force] 2642458962: BUG: unable to handle kernel paging request at ffffc90000997f18) Linus Torvalds <torvalds@linux-foundation.org> - 2016-06-28 23:50 +0200
Re: kthread_stop insanity (Re: [[DEBUG] force] 2642458962: BUG: unable to handle kernel paging request at ffffc90000997f18) Oleg Nesterov <oleg@redhat.com> - 2016-06-29 01:00 +0200
Re: kthread_stop insanity (Re: [[DEBUG] force] 2642458962: BUG: unable to handle kernel paging request at ffffc90000997f18) Oleg Nesterov <oleg@redhat.com> - 2016-06-29 01:10 +0200
Re: kthread_stop insanity (Re: [[DEBUG] force] 2642458962: BUG: unable to handle kernel paging request at ffffc90000997f18) Andy Lutomirski <luto@amacapital.net> - 2016-06-29 17:40 +0200
[PATCH] kthread: to_live_kthread() needs try_get_task_stack() Oleg Nesterov <oleg@redhat.com> - 2016-06-29 20:10 +0200
Re: [PATCH] kthread: to_live_kthread() needs try_get_task_stack() kbuild test robot <lkp@intel.com> - 2016-06-29 20:40 +0200
Re: [PATCH] kthread: to_live_kthread() needs try_get_task_stack() Oleg Nesterov <oleg@redhat.com> - 2016-06-29 20:50 +0200
Re: [PATCH] kthread: to_live_kthread() needs try_get_task_stack() kbuild test robot <lkp@intel.com> - 2016-06-29 21:00 +0200
Re: [PATCH] kthread: to_live_kthread() needs try_get_task_stack() Andy Lutomirski <luto@amacapital.net> - 2016-06-30 01:10 +0200
Re: kthread_stop insanity (Re: [[DEBUG] force] 2642458962: BUG: unable to handle kernel paging request at ffffc90000997f18) Andy Lutomirski <luto@amacapital.net> - 2016-06-30 01:40 +0200
Re: kthread_stop insanity (Re: [[DEBUG] force] 2642458962: BUG: unable to handle kernel paging request at ffffc90000997f18) Linus Torvalds <torvalds@linux-foundation.org> - 2016-06-27 19:20 +0200
Page 2 of 2 — ← Prev page 1 [2]
| From | kbuild test robot <lkp@intel.com> |
|---|---|
| Date | 2016-06-29 21:00 +0200 |
| Subject | Re: [PATCH] kthread: to_live_kthread() needs try_get_task_stack() |
| Message-ID | <rPsSl-7My-5@gated-at.bofh.it> |
| In reply to | #1433941 |
[Multipart message — attachments visible in raw view] — view raw
Hi,
[auto build test WARNING on linus/master]
[also build test WARNING on v4.7-rc5 next-20160629]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Oleg-Nesterov/kthread-to_live_kthread-needs-try_get_task_stack/20160630-020824
config: x86_64-randconfig-s3-06300221 (attached as .config)
compiler: gcc-6 (Debian 6.1.1-1) 6.1.1 20160430
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64
All warnings (new ones prefixed by >>):
In file included from include/uapi/linux/stddef.h:1:0,
from include/linux/stddef.h:4,
from include/uapi/linux/posix_types.h:4,
from include/uapi/linux/types.h:13,
from include/linux/types.h:5,
from include/uapi/linux/capability.h:16,
from include/linux/capability.h:15,
from include/linux/sched.h:15,
from kernel/kthread.c:8:
kernel/kthread.c: In function 'to_live_kthread':
kernel/kthread.c:67:23: error: implicit declaration of function 'try_get_task_stack' [-Werror=implicit-function-declaration]
if (likely(vfork) && try_get_task_stack(k))
^
include/linux/compiler.h:151:30: note: in definition of macro '__trace_if'
if (__builtin_constant_p(!!(cond)) ? !!(cond) : \
^~~~
>> kernel/kthread.c:67:2: note: in expansion of macro 'if'
if (likely(vfork) && try_get_task_stack(k))
^~
kernel/kthread.c: In function 'kthread_unpark':
kernel/kthread.c:430:3: error: implicit declaration of function 'put_task_stack' [-Werror=implicit-function-declaration]
put_task_stack(k);
^~~~~~~~~~~~~~
cc1: some warnings being treated as errors
vim +/if +67 kernel/kthread.c
2 * Copyright (C) 2004 IBM Corporation, Rusty Russell.
3 *
4 * Creation is done via kthreadd, so that we get a clean environment
5 * even if we're invoked from userspace (think modprobe, hotplug cpu,
6 * etc.).
7 */
> 8 #include <linux/sched.h>
9 #include <linux/kthread.h>
10 #include <linux/completion.h>
11 #include <linux/err.h>
12 #include <linux/cpuset.h>
13 #include <linux/unistd.h>
14 #include <linux/file.h>
15 #include <linux/export.h>
16 #include <linux/mutex.h>
17 #include <linux/slab.h>
18 #include <linux/freezer.h>
19 #include <linux/ptrace.h>
20 #include <linux/uaccess.h>
21 #include <trace/events/sched.h>
22
23 static DEFINE_SPINLOCK(kthread_create_lock);
24 static LIST_HEAD(kthread_create_list);
25 struct task_struct *kthreadd_task;
26
27 struct kthread_create_info
28 {
29 /* Information passed to kthread() from kthreadd. */
30 int (*threadfn)(void *data);
31 void *data;
32 int node;
33
34 /* Result passed back to kthread_create() from kthreadd. */
35 struct task_struct *result;
36 struct completion *done;
37
38 struct list_head list;
39 };
40
41 struct kthread {
42 unsigned long flags;
43 unsigned int cpu;
44 void *data;
45 struct completion parked;
46 struct completion exited;
47 };
48
49 enum KTHREAD_BITS {
50 KTHREAD_IS_PER_CPU = 0,
51 KTHREAD_SHOULD_STOP,
52 KTHREAD_SHOULD_PARK,
53 KTHREAD_IS_PARKED,
54 };
55
56 #define __to_kthread(vfork) \
57 container_of(vfork, struct kthread, exited)
58
59 static inline struct kthread *to_kthread(struct task_struct *k)
60 {
61 return __to_kthread(k->vfork_done);
62 }
63
64 static struct kthread *to_live_kthread(struct task_struct *k)
65 {
66 struct completion *vfork = ACCESS_ONCE(k->vfork_done);
> 67 if (likely(vfork) && try_get_task_stack(k))
68 return __to_kthread(vfork);
69 return NULL;
70 }
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[toc] | [prev] | [next] | [standalone]
| From | Andy Lutomirski <luto@amacapital.net> |
|---|---|
| Date | 2016-06-30 01:10 +0200 |
| Subject | Re: [PATCH] kthread: to_live_kthread() needs try_get_task_stack() |
| Message-ID | <rPwMh-1Wa-1@gated-at.bofh.it> |
| In reply to | #1433941 |
On Wed, Jun 29, 2016 at 11:03 AM, Oleg Nesterov <oleg@redhat.com> wrote: > On 06/29, Andy Lutomirski wrote: >> >> I pushed that change to my tree (seems to work well enough to boot >> without warnings as long as I don't unmount XFS, but not particularly >> well tested). Want to refresh your patch on top? > > Please see the trivial fix below. Compile tested, but looks obvious. I stuck it in my tree in the right place. Thanks! > > Btw, why free_thread_stack() calls vfree() with irqs disabled? Doesn't > look good and perhaps even wrong; at least vmap_debug_free_range() does > flush_tlb_kernel_range() and smp_call_function() can deadlock? Whoops, that's a bug. Fixed now. --Andy
[toc] | [prev] | [next] | [standalone]
| From | Andy Lutomirski <luto@amacapital.net> |
|---|---|
| Date | 2016-06-30 01:40 +0200 |
| Subject | Re: kthread_stop insanity (Re: [[DEBUG] force] 2642458962: BUG: unable to handle kernel paging request at ffffc90000997f18) |
| Message-ID | <rPxfj-25K-1@gated-at.bofh.it> |
| In reply to | #1433213 |
On Tue, Jun 28, 2016 at 11:58 AM, Oleg Nesterov <oleg@redhat.com> wrote: > On 06/27, Oleg Nesterov wrote: >> >> On 06/27, Andy Lutomirski wrote: >> > >> > Want to send a patch? I could do it, but you understand this code >> > much better than I do. >> >> Well, I'll try to do this tomorrow unless you do it. > > I have cloned luto/linux.git to see if kthread_stop() can pin ->stack > somehow, but it seems this is not possible, finish_task_switch() does > free_thread_stack() unconditionally. > > Then how (say) proc_pid_stack() can work? If it hits the task which is > alreay dead we are (probably) fine, valid_stack_ptr() should fail iiuc. > I changed save_stack_trace_tsk() to use try_get_task_stack(). I think that's sufficient to fix this. --Andy
[toc] | [prev] | [next] | [standalone]
| From | Linus Torvalds <torvalds@linux-foundation.org> |
|---|---|
| Date | 2016-06-27 19:20 +0200 |
| Subject | Re: kthread_stop insanity (Re: [[DEBUG] force] 2642458962: BUG: unable to handle kernel paging request at ffffc90000997f18) |
| Message-ID | <rOImt-3d4-13@gated-at.bofh.it> |
| In reply to | #1431724 |
On Sun, Jun 26, 2016 at 10:22 PM, Andy Lutomirski <luto@kernel.org> wrote:
>
> kthread_stop is *sick*.
>
> struct kthread self;
>
>
> current->vfork_done = &self.exited;
>
>
> do_exit(ret);
>
> And then some other thread goes and waits for the completion, which is
> *on the stack*, which, in any sane world (e.g. with my series
> applied), is long gone by then.
Yeah. To be fair, that used to work. And the waiter does actually get
a reference to the task struct, and with the lifetime of the stack
historically being the same as the task struct, it was even being
fairly careful about it.
But yes, it's disgusting, and doesn't work in the new world order, and
I think it should be fairly easy to fix. Although getting the lifetime
right for a separately allocated "struct kthread_struct" might be a
bit exciting.
Linus
[toc] | [prev] | [standalone]
Page 2 of 2 — ← Prev page 1 [2]
Back to top | Article view | linux.kernel
csiph-web