2019-07-08 06:29:26

by Stephen Rothwell

[permalink] [raw]
Subject: linux-next: build failure after merge of the rdma tree

Hi all,

After merging the rdma tree, today's linux-next build (x86_64
allmodconfig) failed like this:

In file included from include/asm-generic/percpu.h:7,
from arch/x86/include/asm/percpu.h:544,
from arch/x86/include/asm/preempt.h:6,
from include/linux/preempt.h:78,
from include/linux/spinlock.h:51,
from include/linux/seqlock.h:36,
from include/linux/time.h:6,
from include/linux/ktime.h:24,
from include/linux/timer.h:6,
from include/linux/netdevice.h:24,
from drivers/infiniband/sw/siw/siw_main.c:8:
include/linux/percpu-defs.h:92:33: warning: '__pcpu_unique_use_cnt' initialized and declared 'extern'
extern __PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \
^~~~~~~~~~~~~~
include/linux/percpu-defs.h:115:2: note: in expansion of macro 'DEFINE_PER_CPU_SECTION'
DEFINE_PER_CPU_SECTION(type, name, "")
^~~~~~~~~~~~~~~~~~~~~~
drivers/infiniband/sw/siw/siw_main.c:129:8: note: in expansion of macro 'DEFINE_PER_CPU'
static DEFINE_PER_CPU(atomic_t, use_cnt = ATOMIC_INIT(0));
^~~~~~~~~~~~~~
include/linux/percpu-defs.h:93:26: error: redefinition of '__pcpu_unique_use_cnt'
__PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \
^~~~~~~~~~~~~~
include/linux/percpu-defs.h:115:2: note: in expansion of macro 'DEFINE_PER_CPU_SECTION'
DEFINE_PER_CPU_SECTION(type, name, "")
^~~~~~~~~~~~~~~~~~~~~~
drivers/infiniband/sw/siw/siw_main.c:129:8: note: in expansion of macro 'DEFINE_PER_CPU'
static DEFINE_PER_CPU(atomic_t, use_cnt = ATOMIC_INIT(0));
^~~~~~~~~~~~~~
include/linux/percpu-defs.h:92:33: note: previous definition of '__pcpu_unique_use_cnt' was here
extern __PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \
^~~~~~~~~~~~~~
include/linux/percpu-defs.h:115:2: note: in expansion of macro 'DEFINE_PER_CPU_SECTION'
DEFINE_PER_CPU_SECTION(type, name, "")
^~~~~~~~~~~~~~~~~~~~~~
drivers/infiniband/sw/siw/siw_main.c:129:8: note: in expansion of macro 'DEFINE_PER_CPU'
static DEFINE_PER_CPU(atomic_t, use_cnt = ATOMIC_INIT(0));
^~~~~~~~~~~~~~
drivers/infiniband/sw/siw/siw_main.c:129:33: warning: 'use_cnt' initialized and declared 'extern'
static DEFINE_PER_CPU(atomic_t, use_cnt = ATOMIC_INIT(0));
^~~~~~~
include/linux/percpu-defs.h:94:44: note: in definition of macro 'DEFINE_PER_CPU_SECTION'
extern __PCPU_ATTRS(sec) __typeof__(type) name; \
^~~~
drivers/infiniband/sw/siw/siw_main.c:129:8: note: in expansion of macro 'DEFINE_PER_CPU'
static DEFINE_PER_CPU(atomic_t, use_cnt = ATOMIC_INIT(0));
^~~~~~~~~~~~~~
drivers/infiniband/sw/siw/siw_main.c:129:33: error: redefinition of 'use_cnt'
static DEFINE_PER_CPU(atomic_t, use_cnt = ATOMIC_INIT(0));
^~~~~~~
include/linux/percpu-defs.h:95:44: note: in definition of macro 'DEFINE_PER_CPU_SECTION'
__PCPU_ATTRS(sec) __weak __typeof__(type) name
^~~~
drivers/infiniband/sw/siw/siw_main.c:129:8: note: in expansion of macro 'DEFINE_PER_CPU'
static DEFINE_PER_CPU(atomic_t, use_cnt = ATOMIC_INIT(0));
^~~~~~~~~~~~~~
drivers/infiniband/sw/siw/siw_main.c:129:33: note: previous definition of 'use_cnt' was here
static DEFINE_PER_CPU(atomic_t, use_cnt = ATOMIC_INIT(0));
^~~~~~~
include/linux/percpu-defs.h:94:44: note: in definition of macro 'DEFINE_PER_CPU_SECTION'
extern __PCPU_ATTRS(sec) __typeof__(type) name; \
^~~~
drivers/infiniband/sw/siw/siw_main.c:129:8: note: in expansion of macro 'DEFINE_PER_CPU'
static DEFINE_PER_CPU(atomic_t, use_cnt = ATOMIC_INIT(0));
^~~~~~~~~~~~~~

Caused by commit

bdcf26bf9b3a ("rdma/siw: network and RDMA core interface")

I have used the rdma tree from 20190628 again today.

--
Cheers,
Stephen Rothwell


Attachments:
(No filename) (499.00 B)
OpenPGP digital signature

2019-07-08 19:14:12

by Jason Gunthorpe

[permalink] [raw]
Subject: Re: linux-next: build failure after merge of the rdma tree

On Mon, Jul 08, 2019 at 01:03:51PM +1000, Stephen Rothwell wrote:
> Hi all,
>
> After merging the rdma tree, today's linux-next build (x86_64
> allmodconfig) failed like this:
>
> In file included from include/asm-generic/percpu.h:7,
> from arch/x86/include/asm/percpu.h:544,
> from arch/x86/include/asm/preempt.h:6,
> from include/linux/preempt.h:78,
> from include/linux/spinlock.h:51,
> from include/linux/seqlock.h:36,
> from include/linux/time.h:6,
> from include/linux/ktime.h:24,
> from include/linux/timer.h:6,
> from include/linux/netdevice.h:24,
> from drivers/infiniband/sw/siw/siw_main.c:8:
> include/linux/percpu-defs.h:92:33: warning: '__pcpu_unique_use_cnt' initialized and declared 'extern'
> extern __PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \
> ^~~~~~~~~~~~~~
> include/linux/percpu-defs.h:115:2: note: in expansion of macro 'DEFINE_PER_CPU_SECTION'
> DEFINE_PER_CPU_SECTION(type, name, "")
> ^~~~~~~~~~~~~~~~~~~~~~
> drivers/infiniband/sw/siw/siw_main.c:129:8: note: in expansion of macro 'DEFINE_PER_CPU'
> static DEFINE_PER_CPU(atomic_t, use_cnt = ATOMIC_INIT(0));
> ^~~~~~~~~~~~~~
> include/linux/percpu-defs.h:93:26: error: redefinition of '__pcpu_unique_use_cnt'
> __PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \
> ^~~~~~~~~~~~~~
> include/linux/percpu-defs.h:115:2: note: in expansion of macro 'DEFINE_PER_CPU_SECTION'
> DEFINE_PER_CPU_SECTION(type, name, "")
> ^~~~~~~~~~~~~~~~~~~~~~
> drivers/infiniband/sw/siw/siw_main.c:129:8: note: in expansion of macro 'DEFINE_PER_CPU'
> static DEFINE_PER_CPU(atomic_t, use_cnt = ATOMIC_INIT(0));

Bernard,

This looks like the wrong way to use DEFINE_PER_CPU these days. I'm
not sure why my compiles don't hit it, or why 0-day didn't say
something

Looking at the other atomic_t PER_CPU users they just rely on
automatic zero initialization, so this should just be:

static DEFINE_PER_CPU(atomic_t, use_cnt);

?

Please confirm ASAP.

Jason

2019-07-08 19:26:32

by Bernard Metzler

[permalink] [raw]
Subject: Re: Re: linux-next: build failure after merge of the rdma tree

-----"Jason Gunthorpe" <[email protected]> wrote: -----

>To: "Stephen Rothwell" <[email protected]>, "Bernard Metzler"
><[email protected]>
>From: "Jason Gunthorpe" <[email protected]>
>Date: 07/08/2019 04:09PM
>Cc: "Doug Ledford" <[email protected]>, "Linux Next Mailing List"
><[email protected]>, "Linux Kernel Mailing List"
><[email protected]>
>Subject: [EXTERNAL] Re: linux-next: build failure after merge of the
>rdma tree
>
>On Mon, Jul 08, 2019 at 01:03:51PM +1000, Stephen Rothwell wrote:
>> Hi all,
>>
>> After merging the rdma tree, today's linux-next build (x86_64
>> allmodconfig) failed like this:
>>
>> In file included from include/asm-generic/percpu.h:7,
>> from arch/x86/include/asm/percpu.h:544,
>> from arch/x86/include/asm/preempt.h:6,
>> from include/linux/preempt.h:78,
>> from include/linux/spinlock.h:51,
>> from include/linux/seqlock.h:36,
>> from include/linux/time.h:6,
>> from include/linux/ktime.h:24,
>> from include/linux/timer.h:6,
>> from include/linux/netdevice.h:24,
>> from drivers/infiniband/sw/siw/siw_main.c:8:
>> include/linux/percpu-defs.h:92:33: warning: '__pcpu_unique_use_cnt'
>initialized and declared 'extern'
>> extern __PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \
>> ^~~~~~~~~~~~~~
>> include/linux/percpu-defs.h:115:2: note: in expansion of macro
>'DEFINE_PER_CPU_SECTION'
>> DEFINE_PER_CPU_SECTION(type, name, "")
>> ^~~~~~~~~~~~~~~~~~~~~~
>> drivers/infiniband/sw/siw/siw_main.c:129:8: note: in expansion of
>macro 'DEFINE_PER_CPU'
>> static DEFINE_PER_CPU(atomic_t, use_cnt = ATOMIC_INIT(0));
>> ^~~~~~~~~~~~~~
>> include/linux/percpu-defs.h:93:26: error: redefinition of
>'__pcpu_unique_use_cnt'
>> __PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \
>> ^~~~~~~~~~~~~~
>> include/linux/percpu-defs.h:115:2: note: in expansion of macro
>'DEFINE_PER_CPU_SECTION'
>> DEFINE_PER_CPU_SECTION(type, name, "")
>> ^~~~~~~~~~~~~~~~~~~~~~
>> drivers/infiniband/sw/siw/siw_main.c:129:8: note: in expansion of
>macro 'DEFINE_PER_CPU'
>> static DEFINE_PER_CPU(atomic_t, use_cnt = ATOMIC_INIT(0));
>
>Bernard,
>
>This looks like the wrong way to use DEFINE_PER_CPU these days. I'm
>not sure why my compiles don't hit it, or why 0-day didn't say
>something
>
>Looking at the other atomic_t PER_CPU users they just rely on
>automatic zero initialization, so this should just be:
>
> static DEFINE_PER_CPU(atomic_t, use_cnt);
>
>?
>
>Please confirm ASAP.
>

Hi Jason,

Thanks for bringing this up. Indeed, that explicit
initialization seem to be inappropriate. Can you please
fix that as you suggest?

Thanks very much,
Bernard.

2019-07-08 19:28:08

by Jason Gunthorpe

[permalink] [raw]
Subject: Re: Re: linux-next: build failure after merge of the rdma tree

On Mon, Jul 08, 2019 at 02:28:13PM +0000, Bernard Metzler wrote:

> Thanks for bringing this up. Indeed, that explicit
> initialization seem to be inappropriate. Can you please
> fix that as you suggest?

I'm applying this to fix the PER_CPU stuff in siw:

From 4c7d6dcd364843e408a60952ba914bb72bafc6cc Mon Sep 17 00:00:00 2001
From: Jason Gunthorpe <[email protected]>
Date: Mon, 8 Jul 2019 11:36:32 -0300
Subject: [PATCH] RDMA/siw: Fix DEFINE_PER_CPU compilation when
ARCH_NEEDS_WEAK_PER_CPU

The initializer for the variable cannot be inside the macro (and zero
initialization isn't needed anyhow).

include/linux/percpu-defs.h:92:33: warning: '__pcpu_unique_use_cnt' initialized and declared 'extern'
extern __PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \
^~~~~~~~~~~~~~
include/linux/percpu-defs.h:115:2: note: in expansion of macro 'DEFINE_PER_CPU_SECTION'
DEFINE_PER_CPU_SECTION(type, name, "")
^~~~~~~~~~~~~~~~~~~~~~
drivers/infiniband/sw/siw/siw_main.c:129:8: note: in expansion of macro 'DEFINE_PER_CPU'
static DEFINE_PER_CPU(atomic_t, use_cnt = ATOMIC_INIT(0));
^~~~~~~~~~~~~~

Also the rules for PER_CPU require the variable names to be globally
unique, so prefix them with siw_

Fixes: b9be6f18cf9e ("rdma/siw: transmit path")
Fixes: bdcf26bf9b3a ("rdma/siw: network and RDMA core interface")
Reported-by: Stephen Rothwell <[email protected]>
Signed-off-by: Jason Gunthorpe <[email protected]>
---
drivers/infiniband/sw/siw/siw_main.c | 8 ++++----
drivers/infiniband/sw/siw/siw_qp_tx.c | 10 +++++-----
2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/infiniband/sw/siw/siw_main.c b/drivers/infiniband/sw/siw/siw_main.c
index 3f5f3d27ebe5a1..fd2552a9091dee 100644
--- a/drivers/infiniband/sw/siw/siw_main.c
+++ b/drivers/infiniband/sw/siw/siw_main.c
@@ -126,7 +126,7 @@ static int siw_dev_qualified(struct net_device *netdev)
return 0;
}

-static DEFINE_PER_CPU(atomic_t, use_cnt = ATOMIC_INIT(0));
+static DEFINE_PER_CPU(atomic_t, siw_use_cnt);

static struct {
struct cpumask **tx_valid_cpus;
@@ -215,7 +215,7 @@ int siw_get_tx_cpu(struct siw_device *sdev)
if (!siw_tx_thread[cpu])
continue;

- usage = atomic_read(&per_cpu(use_cnt, cpu));
+ usage = atomic_read(&per_cpu(siw_use_cnt, cpu));
if (usage <= min_use) {
tx_cpu = cpu;
min_use = usage;
@@ -226,7 +226,7 @@ int siw_get_tx_cpu(struct siw_device *sdev)

out:
if (tx_cpu >= 0)
- atomic_inc(&per_cpu(use_cnt, tx_cpu));
+ atomic_inc(&per_cpu(siw_use_cnt, tx_cpu));
else
pr_warn("siw: no tx cpu found\n");

@@ -235,7 +235,7 @@ int siw_get_tx_cpu(struct siw_device *sdev)

void siw_put_tx_cpu(int cpu)
{
- atomic_dec(&per_cpu(use_cnt, cpu));
+ atomic_dec(&per_cpu(siw_use_cnt, cpu));
}

static struct ib_qp *siw_get_base_qp(struct ib_device *base_dev, int id)
diff --git a/drivers/infiniband/sw/siw/siw_qp_tx.c b/drivers/infiniband/sw/siw/siw_qp_tx.c
index 5e926fac51db30..1c9fa8fa96e513 100644
--- a/drivers/infiniband/sw/siw/siw_qp_tx.c
+++ b/drivers/infiniband/sw/siw/siw_qp_tx.c
@@ -1183,12 +1183,12 @@ struct tx_task_t {
wait_queue_head_t waiting;
};

-static DEFINE_PER_CPU(struct tx_task_t, tx_task_g);
+static DEFINE_PER_CPU(struct tx_task_t, siw_tx_task_g);

void siw_stop_tx_thread(int nr_cpu)
{
kthread_stop(siw_tx_thread[nr_cpu]);
- wake_up(&per_cpu(tx_task_g, nr_cpu).waiting);
+ wake_up(&per_cpu(siw_tx_task_g, nr_cpu).waiting);
}

int siw_run_sq(void *data)
@@ -1196,7 +1196,7 @@ int siw_run_sq(void *data)
const int nr_cpu = (unsigned int)(long)data;
struct llist_node *active;
struct siw_qp *qp;
- struct tx_task_t *tx_task = &per_cpu(tx_task_g, nr_cpu);
+ struct tx_task_t *tx_task = &per_cpu(siw_tx_task_g, nr_cpu);

init_llist_head(&tx_task->active);
init_waitqueue_head(&tx_task->waiting);
@@ -1261,9 +1261,9 @@ int siw_sq_start(struct siw_qp *qp)
}
siw_qp_get(qp);

- llist_add(&qp->tx_list, &per_cpu(tx_task_g, qp->tx_cpu).active);
+ llist_add(&qp->tx_list, &per_cpu(siw_tx_task_g, qp->tx_cpu).active);

- wake_up(&per_cpu(tx_task_g, qp->tx_cpu).waiting);
+ wake_up(&per_cpu(siw_tx_task_g, qp->tx_cpu).waiting);

return 0;
}
--
2.21.0