Re: [PATCH-v2 1/3] percpu_ida: Make percpu_ida_alloc + callersaccept task state bitmask
From: Peter Zijlstra
Date: Fri Jan 24 2014 - 10:15:14 EST
On Thu, Jan 23, 2014 at 11:38:24AM -0800, Nicholas A. Bellinger wrote:
> > AFAICT, those changes don't address the original bug that the series was
> > trying to address, allowing the percpu_ida_alloc() tag stealing slow
> > path to be interrupted by a signal..
> >
> > Also, keep in mind this change needs to be backported to >= v3.12, which
> > is why the percpu_ida changes have been kept to a minimum.
Well, the other option is to revert whatever caused the issue in the
first place :-)
I'm not much for making ugly fixes just because its easier to backport.
> <A little too eager to SEND>
>
> So would you prefer the following addition to the original bugfix
> instead..?
I'll make a right old mess out of percpu_ida.c, but yeah.
> diff --git a/lib/percpu_ida.c b/lib/percpu_ida.c
> index a48ce2e..58b6714 100644
> --- a/lib/percpu_ida.c
> +++ b/lib/percpu_ida.c
> @@ -174,7 +174,8 @@ int percpu_ida_alloc(struct percpu_ida *pool, int state)
> *
> * global lock held and irqs disabled, don't need percpu lock
> */
> - prepare_to_wait(&pool->wait, &wait, state);
> + if (state != TASK_RUNNING)
> + prepare_to_wait(&pool->wait, &wait, state);
>
> if (!tags->nr_free)
> alloc_global_tags(pool, tags);
> @@ -199,8 +200,9 @@ int percpu_ida_alloc(struct percpu_ida *pool, int state)
> local_irq_save(flags);
> tags = this_cpu_ptr(pool->tag_cpu);
> }
> + if (state != TASK_RUNNING)
> + finish_wait(&pool->wait, &wait);
>
> - finish_wait(&pool->wait, &wait);
> return tag;
> }
> EXPORT_SYMBOL_GPL(percpu_ida_alloc);
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/