Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1335564 > unrolled thread

Re: [PATCH v4 04/22] kthread: Add create_kthread_worker*()

Started byPetr Mladek <pmladek@suse.com>
First post2016-02-16 16:50 +0100
Last post2016-02-16 17:20 +0100
Articles 3 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH v4 04/22] kthread: Add create_kthread_worker*() Petr Mladek <pmladek@suse.com> - 2016-02-16 16:50 +0100
    Re: [PATCH v4 04/22] kthread: Add create_kthread_worker*() Tejun Heo <tj@kernel.org> - 2016-02-16 17:10 +0100
    Re: [PATCH v4 04/22] kthread: Add create_kthread_worker*() Petr Mladek <pmladek@suse.com> - 2016-02-16 17:20 +0100

#1335564 — Re: [PATCH v4 04/22] kthread: Add create_kthread_worker*()

FromPetr Mladek <pmladek@suse.com>
Date2016-02-16 16:50 +0100
SubjectRe: [PATCH v4 04/22] kthread: Add create_kthread_worker*()
Message-ID<r2Q31-1iJ-33@gated-at.bofh.it>
On Mon 2016-01-25 13:53:39, Tejun Heo wrote:
> On Mon, Jan 25, 2016 at 04:44:53PM +0100, Petr Mladek wrote:
> > +struct kthread_worker *
> > +create_kthread_worker_on_cpu(int cpu, const char namefmt[])
> > +{
> > +	if (cpu < 0 || cpu > num_possible_cpus())
> > +		return ERR_PTR(-EINVAL);
> 
> Comparing cpu ID to num_possible_cpus() doesn't make any sense.  It
> should either be testing against cpu_possible_mask or testing against
> nr_cpu_ids.  Does this test need to be in this function at all?

I wanted to be sure. The cpu number is later passed to
cpu_to_node(cpu) in kthread_create_on_cpu().

I am going to replace this with a check against nr_cpu_ids in
kthread_create_on_cpu() which makes more sense.

I might be too paranoid. But this is slow path. People
do mistakes...

Thanks,
Petr

[toc] | [next] | [standalone]


#1335589

FromTejun Heo <tj@kernel.org>
Date2016-02-16 17:10 +0100
Message-ID<r2Qmo-1Is-37@gated-at.bofh.it>
In reply to#1335564
Hello,

On Tue, Feb 16, 2016 at 04:44:43PM +0100, Petr Mladek wrote:
> I wanted to be sure. The cpu number is later passed to
> cpu_to_node(cpu) in kthread_create_on_cpu().
> 
> I am going to replace this with a check against nr_cpu_ids in
> kthread_create_on_cpu() which makes more sense.
> 
> I might be too paranoid. But this is slow path. People
> do mistakes...

idk, that just ended up adding a subtly broken code which checks for
an unlikely condition which would cause a crash anyway.  I don't see
the point.  If you want to insist on it, please at least make it a
WARN_ON().  It's a clear kernel bug.

Thanks.

-- 
tejun

[toc] | [prev] | [next] | [standalone]


#1335602

FromPetr Mladek <pmladek@suse.com>
Date2016-02-16 17:20 +0100
Message-ID<r2Qw2-1LV-17@gated-at.bofh.it>
In reply to#1335564
On Tue 2016-02-16 16:44:43, Petr Mladek wrote:
> On Mon 2016-01-25 13:53:39, Tejun Heo wrote:
> > On Mon, Jan 25, 2016 at 04:44:53PM +0100, Petr Mladek wrote:
> > > +struct kthread_worker *
> > > +create_kthread_worker_on_cpu(int cpu, const char namefmt[])
> > > +{
> > > +	if (cpu < 0 || cpu > num_possible_cpus())
> > > +		return ERR_PTR(-EINVAL);
> > 
> > Comparing cpu ID to num_possible_cpus() doesn't make any sense.  It
> > should either be testing against cpu_possible_mask or testing against
> > nr_cpu_ids.  Does this test need to be in this function at all?
> 
> I wanted to be sure. The cpu number is later passed to
> cpu_to_node(cpu) in kthread_create_on_cpu().
> 
> I am going to replace this with a check against nr_cpu_ids in
> kthread_create_on_cpu() which makes more sense.
> 
> I might be too paranoid. But this is slow path. People
> do mistakes...

I take it back. I will remove the check at all.
Michal Hocko persuaded me offline that it does not make
much sense. This function is used from kernel code.
I need to believe that the usage is sane at this level.
Also too many checks makes the code harder to read.

Thanks,
Petr

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web