Re: [PATCH hw_breakpoint] percpu: add __percpu sparse annotationsto hw_breakpoint

From: Frederic Weisbecker
Date: Wed Feb 17 2010 - 11:40:12 EST


On Wed, Feb 17, 2010 at 10:50:50AM +0900, Tejun Heo wrote:
> Add __percpu sparse annotations to hw_breakpoint.
>
> These annotations are to make sparse consider percpu variables to be
> in a different address space and warn if accessed without going
> through percpu accessors. This patch doesn't affect normal builds.
>
> In kernel/hw_breakpoint.c, per_cpu(nr_task_bp_pinned, cpu)'s will
> trigger sprious noderef related warnings from sparse. Changing it to
> &per_cpu(nr_task_bp_pinned[0], cpu) will work around the problem but
> deemed to ugly by the maintainer. Leave it alone until better
> solution can be found.
>
> Signed-off-by: Tejun Heo <tj@xxxxxxxxxx>
> Cc: Frederic Weisbecker <fweisbec@xxxxxxxxx>
> ---
> Frederic, can you please put this into the tree for hw_breakpoint?
>
> Thanks.


Yeah, looks good, I'm queuing it.
Just few comments below, for nano-considerations.



> cpu_events = alloc_percpu(typeof(*cpu_events));
> if (!cpu_events)
> - return ERR_PTR(-ENOMEM);
> + return (void __percpu __force *)ERR_PTR(-ENOMEM);



Is this pattern common enough that we can think about a ERR_CPU_PTR ?




> sample_hbp = register_wide_hw_breakpoint(&attr, sample_hbp_handler);
> - if (IS_ERR(sample_hbp)) {
> - ret = PTR_ERR(sample_hbp);
> + if (IS_ERR((void __force *)sample_hbp)) {
> + ret = PTR_ERR((void __force *)sample_hbp);


Same comments here, although I wouldn't like much a CPU_PTR_ERR or
IS_ERR_CPU.... CPP is just so poor in magic for that.

I must confess I miss a bit the old per_cpu prefix that guarded the implicit
separate namespace.

Anyway, I'm queuing it, thanks.

--
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/