Re: [PATCH] mm-page_alloc-use-static-global-work_struct-for-draining-per-cpu-pages-fix

From: Tejun Heo
Date: Wed Feb 08 2017 - 13:19:53 EST


Hello, Andrew.

On Tue, Feb 07, 2017 at 02:14:20PM -0800, Andrew Morton wrote:
> > extern __PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \
> > ^
>
> huh, yes. The DEFINE_PER_CPU() macro is broken.

Yeah, that was the trade off I had to take with percpu vars to force
s390 and alpha to generate long references (GOT based addressing) for
percpu variables; otherwise, they generate memory deref which is too
limited to access the special percpu addresses. It's explained in
include/linux/percpu-defs.h.

> If you do
>
> foo()
> {
> static DEFINE_PER_CPU(int, bar);
> }
>
> then it won't compile, as described here. It should.
>
> And if you do
>
> static DEFINE_PER_CPU(int, bar);
>
> then you still get global symbols (__pcpu_unique_bar).
>
> The kernel does the above thing in, umm, 466 places and afaict they're
> all broken. If two code sites ever use the same identifier, they'll
> get linkage errors.

So, we have CONFIG_DEBUG_FORCE_WEAK_PER_CPU to catch those cases on
archs other than s390 or alpha.

> huh. Seems hard to fix.

This was the only way I could come up with to support alpha and s390.
All the restrictions are there to ensure that. If we can do s390 and
alpha w/o the global weak reference, neither restriction is necessary.

Thanks.

--
tejun