From: Dmitry Antipov <dmitry.antipov@linaro.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Rusty Russell <rusty.russell@linaro.org>,
linux-kernel@vger.kernel.org, linaro-dev@lists.linaro.org,
patches@linaro.org
Subject: Re: [RFC PATCH] module: debugging check for runaway kthreads
Date: Wed, 29 Feb 2012 18:08:51 +0400 [thread overview]
Message-ID: <4F4E3173.60804@linaro.org> (raw)
In-Reply-To: <20120228124318.6ed21b02.akpm@linux-foundation.org>
On 02/29/2012 12:43 AM, Andrew Morton wrote:
> Please make the stub function a proper C function, not a macro. It
> provides type checking, can prevent compile warnings and is generally
> easier on the eyes.
OK
> I think this should be under the kernel hacking menu, dependent on
> CONFIG_DEBUG_KERNEL, in lib/Kconfig.debug.
I tried to group all module options together. Nevertheless,
I have no objections for separately grouping debugging options.
>> struct kthread {
>> int should_stop;
>> +#ifdef CONFIG_MODULE_KTHREAD_CHECK
>> + void *fn;
>> +#endif
>
> A little comment describing what this field is for would be nice.
OK
>> +unsigned long get_kthread_func(struct task_struct *tsk)
>> +{
>> + struct kthread *kt;
>> + unsigned long addr;
>> +
>> + get_task_struct(tsk);
>> + BUG_ON(!(tsk->flags& PF_KTHREAD));
>> + kt = to_kthread(tsk);
>> + barrier();
>> + addr = tsk->vfork_done ? (unsigned long)kt->fn : 0UL;
>> + put_task_struct(tsk);
>> + return addr;
>> +}
>
> gack, I hadn't noticed the kthread ab^wre^wuse of vfork_done before.
> Kooky. Undocumented, too.
Hm... vfork_done of the just created kthread is NULL. When the new
kthread calls kthread(), it assigns it's private 'struct kthread' to
it's own tsk->vfork_done (IIUC, this is just a hack to avoid ugly
stuff like excessive pointer in task_struct or pointer type conversion).
So, to_kthread(tsk) is valid only if tsk->vfork_done is non-NULL,
otherwise it's just a bogus pointer. IMHO this hack should be documented
in kthread().
>> +#ifdef CONFIG_KALLSYMS
>> +static const char *get_ksymbol(struct module *mod, unsigned long addr,
>> + unsigned long *size, unsigned long *offset);
>> +#else
>> +#define get_ksymbol(mod, addr, size, offset) NULL
>> +#endif
>
> Can this code block be moved to after the get_ksymbol() definition so
> the forward declaration is unneeded?
OK
> Did we really need to use the internal get_ksymbol(), rather than an
> official kallsyms interface function?
I don't see a kallsyms interface function which is able to look through
just one module. Since the module name (and struct module pointer) is
known, it looks redundant to lookup through the whole kallsyms tables.
> The CONFIG_KALLSYMS=n stub should be written in C. Make it return
> "<unknown>" and the ?: in check_kthreads() can be done away with.
OK
>> +#else
>> +
>> +#define check_kthreads(mod) do { } while (0)
>
> In C, please.
OK
Dmitry
prev parent reply other threads:[~2012-02-29 14:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-28 9:04 [RFC PATCH] module: debugging check for runaway kthreads Dmitry Antipov
2012-02-28 20:43 ` Andrew Morton
2012-02-29 14:08 ` Dmitry Antipov [this message]
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=4F4E3173.60804@linaro.org \
--to=dmitry.antipov@linaro.org \
--cc=akpm@linux-foundation.org \
--cc=linaro-dev@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=patches@linaro.org \
--cc=rusty.russell@linaro.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).