2017-06-06 10:57:58

by Anoob Soman

[permalink] [raw]
Subject: [PATCH V2] xen-evtchn: Bind dyn evtchn:qemu-dm interrupt to next online VCPU

A HVM domian booting generates around 200K (evtchn:qemu-dm xen-dyn)
interrupts,in a short period of time. All these evtchn:qemu-dm are bound
to VCPU 0, until irqbalance sees these IRQ and moves it to a different VCPU.
In one configuration, irqbalance runs every 10 seconds, which means
irqbalance doesn't get to see these burst of interrupts and doesn't
re-balance interrupts most of the time, making all evtchn:qemu-dm to be
processed by VCPU0. This cause VCPU0 to spend most of time processing
hardirq and very little time on softirq. Moreover, if dom0 kernel PREEMPTION
is disabled, VCPU0 never runs watchdog (process context), triggering a
softlockup detection code to panic.

Binding evtchn:qemu-dm to next online VCPU, will spread hardirq
processing evenly across different CPU. Later, irqbalance will try to balance
evtchn:qemu-dm, if required.

Signed-off-by: Anoob Soman <[email protected]>
---

Changes in v2:
- Moved bind_last_selected_cpu inside evtchn_bind_interdom_next_vcpu.
- raw_spin_unlock_irqrestore(&desc->lock) done after vpcu rebind.

drivers/xen/events/events_base.c | 9 +++++++--
drivers/xen/evtchn.c | 33 ++++++++++++++++++++++++++++++++-
include/xen/events.h | 1 +
3 files changed, 40 insertions(+), 3 deletions(-)

diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c
index b52852f..8224ec1 100644
--- a/drivers/xen/events/events_base.c
+++ b/drivers/xen/events/events_base.c
@@ -1303,10 +1303,9 @@ void rebind_evtchn_irq(int evtchn, int irq)
}

/* Rebind an evtchn so that it gets delivered to a specific cpu */
-static int rebind_irq_to_cpu(unsigned irq, unsigned tcpu)
+int xen_rebind_evtchn_to_cpu(int evtchn, unsigned tcpu)
{
struct evtchn_bind_vcpu bind_vcpu;
- int evtchn = evtchn_from_irq(irq);
int masked;

if (!VALID_EVTCHN(evtchn))
@@ -1338,6 +1337,12 @@ static int rebind_irq_to_cpu(unsigned irq, unsigned tcpu)

return 0;
}
+EXPORT_SYMBOL_GPL(xen_rebind_evtchn_to_cpu);
+
+static int rebind_irq_to_cpu(unsigned irq, unsigned tcpu)
+{
+ return xen_rebind_evtchn_to_cpu(evtchn_from_irq(irq), tcpu);
+}

static int set_affinity_irq(struct irq_data *data, const struct cpumask *dest,
bool force)
diff --git a/drivers/xen/evtchn.c b/drivers/xen/evtchn.c
index 10f1ef5..d6d6c6c 100644
--- a/drivers/xen/evtchn.c
+++ b/drivers/xen/evtchn.c
@@ -421,6 +421,35 @@ static void evtchn_unbind_from_user(struct per_user_data *u,
del_evtchn(u, evtchn);
}

+static void evtchn_bind_interdom_next_vcpu(int evtchn)
+{
+ static DEFINE_PER_CPU(int, bind_last_selected_cpu);
+ unsigned int selected_cpu, irq;
+ struct irq_desc *desc;
+ unsigned long flags;
+
+ irq = irq_from_evtchn(evtchn);
+ desc = irq_to_desc(irq);
+
+ if (!desc)
+ return;
+
+ raw_spin_lock_irqsave(&desc->lock, flags);
+ selected_cpu = this_cpu_read(bind_last_selected_cpu);
+ selected_cpu = cpumask_next_and(selected_cpu,
+ desc->irq_common_data.affinity, cpu_online_mask);
+
+ if (unlikely(selected_cpu >= nr_cpu_ids))
+ selected_cpu = cpumask_first_and(desc->irq_common_data.affinity,
+ cpu_online_mask);
+
+ this_cpu_write(bind_last_selected_cpu, selected_cpu);
+
+ /* unmask expects irqs to be disabled */
+ xen_rebind_evtchn_to_cpu(evtchn, selected_cpu);
+ raw_spin_unlock_irqrestore(&desc->lock, flags);
+}
+
static long evtchn_ioctl(struct file *file,
unsigned int cmd, unsigned long arg)
{
@@ -478,8 +507,10 @@ static long evtchn_ioctl(struct file *file,
break;

rc = evtchn_bind_to_user(u, bind_interdomain.local_port);
- if (rc == 0)
+ if (rc == 0) {
rc = bind_interdomain.local_port;
+ evtchn_bind_interdom_next_vcpu(rc);
+ }
break;
}

diff --git a/include/xen/events.h b/include/xen/events.h
index 88da2ab..f442ca5 100644
--- a/include/xen/events.h
+++ b/include/xen/events.h
@@ -58,6 +58,7 @@ int bind_interdomain_evtchn_to_irqhandler(unsigned int remote_domain,

void xen_send_IPI_one(unsigned int cpu, enum ipi_vector vector);
void rebind_evtchn_irq(int evtchn, int irq);
+int xen_rebind_evtchn_to_cpu(int evtchn, unsigned tcpu);

static inline void notify_remote_via_evtchn(int port)
{
--
1.8.3.1


2017-06-06 19:43:07

by Boris Ostrovsky

[permalink] [raw]
Subject: Re: [PATCH V2] xen-evtchn: Bind dyn evtchn:qemu-dm interrupt to next online VCPU


>
> /* Rebind an evtchn so that it gets delivered to a specific cpu */
> -static int rebind_irq_to_cpu(unsigned irq, unsigned tcpu)
> +int xen_rebind_evtchn_to_cpu(int evtchn, unsigned tcpu)
> {
> struct evtchn_bind_vcpu bind_vcpu;
> - int evtchn = evtchn_from_irq(irq);
> int masked;
>
> if (!VALID_EVTCHN(evtchn))
> @@ -1338,6 +1337,12 @@ static int rebind_irq_to_cpu(unsigned irq, unsigned tcpu)
>
> return 0;
> }
> +EXPORT_SYMBOL_GPL(xen_rebind_evtchn_to_cpu);
> +
> +static int rebind_irq_to_cpu(unsigned irq, unsigned tcpu)
> +{
> + return xen_rebind_evtchn_to_cpu(evtchn_from_irq(irq), tcpu);
> +}

There is a single call site for rebind_irq_to_cpu() so why not call
xen_rebind_evtchn_to_cpu() directly?


>
> +static void evtchn_bind_interdom_next_vcpu(int evtchn)
> +{
> + static DEFINE_PER_CPU(int, bind_last_selected_cpu);
> + unsigned int selected_cpu, irq;
> + struct irq_desc *desc;
> + unsigned long flags;
> +
> + irq = irq_from_evtchn(evtchn);
> + desc = irq_to_desc(irq);
> +
> + if (!desc)
> + return;
> +
> + raw_spin_lock_irqsave(&desc->lock, flags);

Is there a reason why you are using raw_ version?

(Sorry, I should have noticed both of these earlier)

-boris

2017-06-06 20:03:08

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH V2] xen-evtchn: Bind dyn evtchn:qemu-dm interrupt to next online VCPU

Hi Anoob,

[auto build test ERROR on xen-tip/linux-next]
[also build test ERROR on v4.12-rc4 next-20170606]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Anoob-Soman/xen-evtchn-Bind-dyn-evtchn-qemu-dm-interrupt-to-next-online-VCPU/20170607-021300
base: https://git.kernel.org/pub/scm/linux/kernel/git/xen/tip.git linux-next
config: x86_64-randconfig-x010-201723 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64

All error/warnings (new ones prefixed by >>):

In file included from include/asm-generic/percpu.h:6:0,
from arch/x86/include/asm/percpu.h:542,
from arch/x86/include/asm/preempt.h:5,
from include/linux/preempt.h:80,
from include/linux/spinlock.h:50,
from include/linux/seqlock.h:35,
from include/linux/time.h:5,
from include/linux/stat.h:18,
from include/linux/module.h:10,
from drivers//xen/evtchn.c:36:
drivers//xen/evtchn.c: In function 'evtchn_bind_interdom_next_vcpu':
include/linux/percpu-defs.h:91:33: error: section attribute cannot be specified for local variables
extern __PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \
^
include/linux/percpu-defs.h:116:2: note: in expansion of macro 'DEFINE_PER_CPU_SECTION'
DEFINE_PER_CPU_SECTION(type, name, "")
^~~~~~~~~~~~~~~~~~~~~~
>> drivers//xen/evtchn.c:438:9: note: in expansion of macro 'DEFINE_PER_CPU'
static DEFINE_PER_CPU(int, bind_last_selected_cpu);
^~~~~~~~~~~~~~
include/linux/percpu-defs.h:92:26: error: section attribute cannot be specified for local variables
__PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \
^
include/linux/percpu-defs.h:116:2: note: in expansion of macro 'DEFINE_PER_CPU_SECTION'
DEFINE_PER_CPU_SECTION(type, name, "")
^~~~~~~~~~~~~~~~~~~~~~
>> drivers//xen/evtchn.c:438:9: note: in expansion of macro 'DEFINE_PER_CPU'
static DEFINE_PER_CPU(int, bind_last_selected_cpu);
^~~~~~~~~~~~~~
>> include/linux/percpu-defs.h:92:26: error: declaration of '__pcpu_unique_bind_last_selected_cpu' with no linkage follows extern declaration
__PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \
^
include/linux/percpu-defs.h:116:2: note: in expansion of macro 'DEFINE_PER_CPU_SECTION'
DEFINE_PER_CPU_SECTION(type, name, "")
^~~~~~~~~~~~~~~~~~~~~~
>> drivers//xen/evtchn.c:438:9: note: in expansion of macro 'DEFINE_PER_CPU'
static DEFINE_PER_CPU(int, bind_last_selected_cpu);
^~~~~~~~~~~~~~
include/linux/percpu-defs.h:91:33: note: previous declaration of '__pcpu_unique_bind_last_selected_cpu' was here
extern __PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \
^
include/linux/percpu-defs.h:116:2: note: in expansion of macro 'DEFINE_PER_CPU_SECTION'
DEFINE_PER_CPU_SECTION(type, name, "")
^~~~~~~~~~~~~~~~~~~~~~
>> drivers//xen/evtchn.c:438:9: note: in expansion of macro 'DEFINE_PER_CPU'
static DEFINE_PER_CPU(int, bind_last_selected_cpu);
^~~~~~~~~~~~~~
>> drivers//xen/evtchn.c:438:29: error: section attribute cannot be specified for local variables
static DEFINE_PER_CPU(int, bind_last_selected_cpu);
^
include/linux/percpu-defs.h:93:44: note: in definition of macro 'DEFINE_PER_CPU_SECTION'
extern __PCPU_ATTRS(sec) __typeof__(type) name; \
^~~~
>> drivers//xen/evtchn.c:438:9: note: in expansion of macro 'DEFINE_PER_CPU'
static DEFINE_PER_CPU(int, bind_last_selected_cpu);
^~~~~~~~~~~~~~
>> drivers//xen/evtchn.c:438:29: error: section attribute cannot be specified for local variables
static DEFINE_PER_CPU(int, bind_last_selected_cpu);
^
include/linux/percpu-defs.h:95:19: note: in definition of macro 'DEFINE_PER_CPU_SECTION'
__typeof__(type) name
^~~~
>> drivers//xen/evtchn.c:438:9: note: in expansion of macro 'DEFINE_PER_CPU'
static DEFINE_PER_CPU(int, bind_last_selected_cpu);
^~~~~~~~~~~~~~
>> drivers//xen/evtchn.c:438:29: error: weak declaration of 'bind_last_selected_cpu' must be public
static DEFINE_PER_CPU(int, bind_last_selected_cpu);
^
include/linux/percpu-defs.h:95:19: note: in definition of macro 'DEFINE_PER_CPU_SECTION'
__typeof__(type) name
^~~~
>> drivers//xen/evtchn.c:438:9: note: in expansion of macro 'DEFINE_PER_CPU'
static DEFINE_PER_CPU(int, bind_last_selected_cpu);
^~~~~~~~~~~~~~
>> drivers//xen/evtchn.c:438:29: error: declaration of 'bind_last_selected_cpu' with no linkage follows extern declaration
static DEFINE_PER_CPU(int, bind_last_selected_cpu);
^
include/linux/percpu-defs.h:95:19: note: in definition of macro 'DEFINE_PER_CPU_SECTION'
__typeof__(type) name
^~~~
>> drivers//xen/evtchn.c:438:9: note: in expansion of macro 'DEFINE_PER_CPU'
static DEFINE_PER_CPU(int, bind_last_selected_cpu);
^~~~~~~~~~~~~~
drivers//xen/evtchn.c:438:29: note: previous declaration of 'bind_last_selected_cpu' was here
static DEFINE_PER_CPU(int, bind_last_selected_cpu);
^
include/linux/percpu-defs.h:93:44: note: in definition of macro 'DEFINE_PER_CPU_SECTION'
extern __PCPU_ATTRS(sec) __typeof__(type) name; \
^~~~
>> drivers//xen/evtchn.c:438:9: note: in expansion of macro 'DEFINE_PER_CPU'
static DEFINE_PER_CPU(int, bind_last_selected_cpu);
^~~~~~~~~~~~~~
--
In file included from include/asm-generic/percpu.h:6:0,
from arch/x86/include/asm/percpu.h:542,
from arch/x86/include/asm/preempt.h:5,
from include/linux/preempt.h:80,
from include/linux/spinlock.h:50,
from include/linux/seqlock.h:35,
from include/linux/time.h:5,
from include/linux/stat.h:18,
from include/linux/module.h:10,
from drivers/xen/evtchn.c:36:
drivers/xen/evtchn.c: In function 'evtchn_bind_interdom_next_vcpu':
include/linux/percpu-defs.h:91:33: error: section attribute cannot be specified for local variables
extern __PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \
^
include/linux/percpu-defs.h:116:2: note: in expansion of macro 'DEFINE_PER_CPU_SECTION'
DEFINE_PER_CPU_SECTION(type, name, "")
^~~~~~~~~~~~~~~~~~~~~~
drivers/xen/evtchn.c:438:9: note: in expansion of macro 'DEFINE_PER_CPU'
static DEFINE_PER_CPU(int, bind_last_selected_cpu);
^~~~~~~~~~~~~~
include/linux/percpu-defs.h:92:26: error: section attribute cannot be specified for local variables
__PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \
^
include/linux/percpu-defs.h:116:2: note: in expansion of macro 'DEFINE_PER_CPU_SECTION'
DEFINE_PER_CPU_SECTION(type, name, "")
^~~~~~~~~~~~~~~~~~~~~~
drivers/xen/evtchn.c:438:9: note: in expansion of macro 'DEFINE_PER_CPU'
static DEFINE_PER_CPU(int, bind_last_selected_cpu);
^~~~~~~~~~~~~~
>> include/linux/percpu-defs.h:92:26: error: declaration of '__pcpu_unique_bind_last_selected_cpu' with no linkage follows extern declaration
__PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \
^
include/linux/percpu-defs.h:116:2: note: in expansion of macro 'DEFINE_PER_CPU_SECTION'
DEFINE_PER_CPU_SECTION(type, name, "")
^~~~~~~~~~~~~~~~~~~~~~
drivers/xen/evtchn.c:438:9: note: in expansion of macro 'DEFINE_PER_CPU'
static DEFINE_PER_CPU(int, bind_last_selected_cpu);
^~~~~~~~~~~~~~
include/linux/percpu-defs.h:91:33: note: previous declaration of '__pcpu_unique_bind_last_selected_cpu' was here
extern __PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \
^
include/linux/percpu-defs.h:116:2: note: in expansion of macro 'DEFINE_PER_CPU_SECTION'
DEFINE_PER_CPU_SECTION(type, name, "")
^~~~~~~~~~~~~~~~~~~~~~
drivers/xen/evtchn.c:438:9: note: in expansion of macro 'DEFINE_PER_CPU'
static DEFINE_PER_CPU(int, bind_last_selected_cpu);
^~~~~~~~~~~~~~
drivers/xen/evtchn.c:438:29: error: section attribute cannot be specified for local variables
static DEFINE_PER_CPU(int, bind_last_selected_cpu);
^
include/linux/percpu-defs.h:93:44: note: in definition of macro 'DEFINE_PER_CPU_SECTION'
extern __PCPU_ATTRS(sec) __typeof__(type) name; \
^~~~
drivers/xen/evtchn.c:438:9: note: in expansion of macro 'DEFINE_PER_CPU'
static DEFINE_PER_CPU(int, bind_last_selected_cpu);
^~~~~~~~~~~~~~
drivers/xen/evtchn.c:438:29: error: section attribute cannot be specified for local variables
static DEFINE_PER_CPU(int, bind_last_selected_cpu);
^
include/linux/percpu-defs.h:95:19: note: in definition of macro 'DEFINE_PER_CPU_SECTION'
__typeof__(type) name
^~~~
drivers/xen/evtchn.c:438:9: note: in expansion of macro 'DEFINE_PER_CPU'
static DEFINE_PER_CPU(int, bind_last_selected_cpu);
^~~~~~~~~~~~~~
drivers/xen/evtchn.c:438:29: error: weak declaration of 'bind_last_selected_cpu' must be public
static DEFINE_PER_CPU(int, bind_last_selected_cpu);
^
include/linux/percpu-defs.h:95:19: note: in definition of macro 'DEFINE_PER_CPU_SECTION'
__typeof__(type) name
^~~~
drivers/xen/evtchn.c:438:9: note: in expansion of macro 'DEFINE_PER_CPU'
static DEFINE_PER_CPU(int, bind_last_selected_cpu);
^~~~~~~~~~~~~~
drivers/xen/evtchn.c:438:29: error: declaration of 'bind_last_selected_cpu' with no linkage follows extern declaration
static DEFINE_PER_CPU(int, bind_last_selected_cpu);
^
include/linux/percpu-defs.h:95:19: note: in definition of macro 'DEFINE_PER_CPU_SECTION'
__typeof__(type) name
^~~~
drivers/xen/evtchn.c:438:9: note: in expansion of macro 'DEFINE_PER_CPU'
static DEFINE_PER_CPU(int, bind_last_selected_cpu);
^~~~~~~~~~~~~~
drivers/xen/evtchn.c:438:29: note: previous declaration of 'bind_last_selected_cpu' was here
static DEFINE_PER_CPU(int, bind_last_selected_cpu);
^
include/linux/percpu-defs.h:93:44: note: in definition of macro 'DEFINE_PER_CPU_SECTION'
extern __PCPU_ATTRS(sec) __typeof__(type) name; \
^~~~
drivers/xen/evtchn.c:438:9: note: in expansion of macro 'DEFINE_PER_CPU'
static DEFINE_PER_CPU(int, bind_last_selected_cpu);
^~~~~~~~~~~~~~

vim +/bind_last_selected_cpu +438 drivers//xen/evtchn.c

432
433 del_evtchn(u, evtchn);
434 }
435
436 static void evtchn_bind_interdom_next_vcpu(int evtchn)
437 {
> 438 static DEFINE_PER_CPU(int, bind_last_selected_cpu);
439 unsigned int selected_cpu, irq;
440 struct irq_desc *desc;
441 unsigned long flags;

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation


Attachments:
(No filename) (11.61 kB)
.config.gz (24.17 kB)
Download all attachments

2017-06-06 20:58:59

by Boris Ostrovsky

[permalink] [raw]
Subject: Re: [PATCH V2] xen-evtchn: Bind dyn evtchn:qemu-dm interrupt to next online VCPU

On 06/06/2017 04:02 PM, kbuild test robot wrote:
> Hi Anoob,
>
> [auto build test ERROR on xen-tip/linux-next]
> [also build test ERROR on v4.12-rc4 next-20170606]
> [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
>
> url: https://github.com/0day-ci/linux/commits/Anoob-Soman/xen-evtchn-Bind-dyn-evtchn-qemu-dm-interrupt-to-next-online-VCPU/20170607-021300
> base: https://git.kernel.org/pub/scm/linux/kernel/git/xen/tip.git linux-next
> config: x86_64-randconfig-x010-201723 (attached as .config)
> compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
> reproduce:
> # save the attached .config to linux build tree
> make ARCH=x86_64
>
> All error/warnings (new ones prefixed by >>):
>
> In file included from include/asm-generic/percpu.h:6:0,
> from arch/x86/include/asm/percpu.h:542,
> from arch/x86/include/asm/preempt.h:5,
> from include/linux/preempt.h:80,
> from include/linux/spinlock.h:50,
> from include/linux/seqlock.h:35,
> from include/linux/time.h:5,
> from include/linux/stat.h:18,
> from include/linux/module.h:10,
> from drivers//xen/evtchn.c:36:
> drivers//xen/evtchn.c: In function 'evtchn_bind_interdom_next_vcpu':
> include/linux/percpu-defs.h:91:33: error: section attribute cannot be specified for local variables
> extern __PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \
> ^
> include/linux/percpu-defs.h:116:2: note: in expansion of macro 'DEFINE_PER_CPU_SECTION'
> DEFINE_PER_CPU_SECTION(type, name, "")
> ^~~~~~~~~~~~~~~~~~~~~~
>>> drivers//xen/evtchn.c:438:9: note: in expansion of macro 'DEFINE_PER_CPU'
> static DEFINE_PER_CPU(int, bind_last_selected_cpu);
> ^~~~~~~~~~~~~~
> include/linux/percpu-defs.h:92:26: error: section attribute cannot be specified for local variables
> __PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \
> ^
> include/linux/percpu-defs.h:116:2: note: in expansion of macro 'DEFINE_PER_CPU_SECTION'
> DEFINE_PER_CPU_SECTION(type, name, "")
> ^~~~~~~~~~~~~~~~~~~~~~
>>> drivers//xen/evtchn.c:438:9: note: in expansion of macro 'DEFINE_PER_CPU'
> static DEFINE_PER_CPU(int, bind_last_selected_cpu);
> ^~~~~~~~~~~~~~
>>> include/linux/percpu-defs.h:92:26: error: declaration of '__pcpu_unique_bind_last_selected_cpu' with no linkage follows extern declaration
> __PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \
> ^
> include/linux/percpu-defs.h:116:2: note: in expansion of macro 'DEFINE_PER_CPU_SECTION'
> DEFINE_PER_CPU_SECTION(type, name, "")
> ^~~~~~~~~~~~~~~~~~~~~~
>>> drivers//xen/evtchn.c:438:9: note: in expansion of macro 'DEFINE_PER_CPU'
> static DEFINE_PER_CPU(int, bind_last_selected_cpu);
> ^~~~~~~~~~~~~~
> include/linux/percpu-defs.h:91:33: note: previous declaration of '__pcpu_unique_bind_last_selected_cpu' was here
> extern __PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \
> ^
> include/linux/percpu-defs.h:116:2: note: in expansion of macro 'DEFINE_PER_CPU_SECTION'
> DEFINE_PER_CPU_SECTION(type, name, "")
> ^~~~~~~~~~~~~~~~~~~~~~
>>> drivers//xen/evtchn.c:438:9: note: in expansion of macro 'DEFINE_PER_CPU'
> static DEFINE_PER_CPU(int, bind_last_selected_cpu);
> ^~~~~~~~~~~~~~
>>> drivers//xen/evtchn.c:438:29: error: section attribute cannot be specified for local variables
> static DEFINE_PER_CPU(int, bind_last_selected_cpu);
> ^
> include/linux/percpu-defs.h:93:44: note: in definition of macro 'DEFINE_PER_CPU_SECTION'
> extern __PCPU_ATTRS(sec) __typeof__(type) name; \
> ^~~~
>>> drivers//xen/evtchn.c:438:9: note: in expansion of macro 'DEFINE_PER_CPU'
> static DEFINE_PER_CPU(int, bind_last_selected_cpu);
> ^~~~~~~~~~~~~~
>>> drivers//xen/evtchn.c:438:29: error: section attribute cannot be specified for local variables
> static DEFINE_PER_CPU(int, bind_last_selected_cpu);
> ^
> include/linux/percpu-defs.h:95:19: note: in definition of macro 'DEFINE_PER_CPU_SECTION'
> __typeof__(type) name
> ^~~~
>>> drivers//xen/evtchn.c:438:9: note: in expansion of macro 'DEFINE_PER_CPU'
> static DEFINE_PER_CPU(int, bind_last_selected_cpu);
> ^~~~~~~~~~~~~~
>>> drivers//xen/evtchn.c:438:29: error: weak declaration of 'bind_last_selected_cpu' must be public
> static DEFINE_PER_CPU(int, bind_last_selected_cpu);
> ^
> include/linux/percpu-defs.h:95:19: note: in definition of macro 'DEFINE_PER_CPU_SECTION'
> __typeof__(type) name
> ^~~~
>>> drivers//xen/evtchn.c:438:9: note: in expansion of macro 'DEFINE_PER_CPU'
> static DEFINE_PER_CPU(int, bind_last_selected_cpu);
> ^~~~~~~~~~~~~~
>>> drivers//xen/evtchn.c:438:29: error: declaration of 'bind_last_selected_cpu' with no linkage follows extern declaration
> static DEFINE_PER_CPU(int, bind_last_selected_cpu);
> ^
> include/linux/percpu-defs.h:95:19: note: in definition of macro 'DEFINE_PER_CPU_SECTION'
> __typeof__(type) name
> ^~~~
>>> drivers//xen/evtchn.c:438:9: note: in expansion of macro 'DEFINE_PER_CPU'
> static DEFINE_PER_CPU(int, bind_last_selected_cpu);
> ^~~~~~~~~~~~~~
> drivers//xen/evtchn.c:438:29: note: previous declaration of 'bind_last_selected_cpu' was here
> static DEFINE_PER_CPU(int, bind_last_selected_cpu);
> ^
> include/linux/percpu-defs.h:93:44: note: in definition of macro 'DEFINE_PER_CPU_SECTION'
> extern __PCPU_ATTRS(sec) __typeof__(type) name; \
> ^~~~
>>> drivers//xen/evtchn.c:438:9: note: in expansion of macro 'DEFINE_PER_CPU'
> static DEFINE_PER_CPU(int, bind_last_selected_cpu);
> ^~~~~~~~~~~~~~
> --
> In file included from include/asm-generic/percpu.h:6:0,
> from arch/x86/include/asm/percpu.h:542,
> from arch/x86/include/asm/preempt.h:5,
> from include/linux/preempt.h:80,
> from include/linux/spinlock.h:50,
> from include/linux/seqlock.h:35,
> from include/linux/time.h:5,
> from include/linux/stat.h:18,
> from include/linux/module.h:10,
> from drivers/xen/evtchn.c:36:
> drivers/xen/evtchn.c: In function 'evtchn_bind_interdom_next_vcpu':
> include/linux/percpu-defs.h:91:33: error: section attribute cannot be specified for local variables
> extern __PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \
> ^
> include/linux/percpu-defs.h:116:2: note: in expansion of macro 'DEFINE_PER_CPU_SECTION'
> DEFINE_PER_CPU_SECTION(type, name, "")
> ^~~~~~~~~~~~~~~~~~~~~~
> drivers/xen/evtchn.c:438:9: note: in expansion of macro 'DEFINE_PER_CPU'
> static DEFINE_PER_CPU(int, bind_last_selected_cpu);
> ^~~~~~~~~~~~~~
> include/linux/percpu-defs.h:92:26: error: section attribute cannot be specified for local variables
> __PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \
> ^
> include/linux/percpu-defs.h:116:2: note: in expansion of macro 'DEFINE_PER_CPU_SECTION'
> DEFINE_PER_CPU_SECTION(type, name, "")
> ^~~~~~~~~~~~~~~~~~~~~~
> drivers/xen/evtchn.c:438:9: note: in expansion of macro 'DEFINE_PER_CPU'
> static DEFINE_PER_CPU(int, bind_last_selected_cpu);
> ^~~~~~~~~~~~~~
>>> include/linux/percpu-defs.h:92:26: error: declaration of '__pcpu_unique_bind_last_selected_cpu' with no linkage follows extern declaration
> __PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \
> ^
> include/linux/percpu-defs.h:116:2: note: in expansion of macro 'DEFINE_PER_CPU_SECTION'
> DEFINE_PER_CPU_SECTION(type, name, "")
> ^~~~~~~~~~~~~~~~~~~~~~
> drivers/xen/evtchn.c:438:9: note: in expansion of macro 'DEFINE_PER_CPU'
> static DEFINE_PER_CPU(int, bind_last_selected_cpu);
> ^~~~~~~~~~~~~~
> include/linux/percpu-defs.h:91:33: note: previous declaration of '__pcpu_unique_bind_last_selected_cpu' was here
> extern __PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \
> ^
> include/linux/percpu-defs.h:116:2: note: in expansion of macro 'DEFINE_PER_CPU_SECTION'
> DEFINE_PER_CPU_SECTION(type, name, "")
> ^~~~~~~~~~~~~~~~~~~~~~
> drivers/xen/evtchn.c:438:9: note: in expansion of macro 'DEFINE_PER_CPU'
> static DEFINE_PER_CPU(int, bind_last_selected_cpu);
> ^~~~~~~~~~~~~~
> drivers/xen/evtchn.c:438:29: error: section attribute cannot be specified for local variables
> static DEFINE_PER_CPU(int, bind_last_selected_cpu);
> ^
> include/linux/percpu-defs.h:93:44: note: in definition of macro 'DEFINE_PER_CPU_SECTION'
> extern __PCPU_ATTRS(sec) __typeof__(type) name; \
> ^~~~
> drivers/xen/evtchn.c:438:9: note: in expansion of macro 'DEFINE_PER_CPU'
> static DEFINE_PER_CPU(int, bind_last_selected_cpu);
> ^~~~~~~~~~~~~~
> drivers/xen/evtchn.c:438:29: error: section attribute cannot be specified for local variables
> static DEFINE_PER_CPU(int, bind_last_selected_cpu);
> ^
> include/linux/percpu-defs.h:95:19: note: in definition of macro 'DEFINE_PER_CPU_SECTION'
> __typeof__(type) name
> ^~~~
> drivers/xen/evtchn.c:438:9: note: in expansion of macro 'DEFINE_PER_CPU'
> static DEFINE_PER_CPU(int, bind_last_selected_cpu);
> ^~~~~~~~~~~~~~
> drivers/xen/evtchn.c:438:29: error: weak declaration of 'bind_last_selected_cpu' must be public
> static DEFINE_PER_CPU(int, bind_last_selected_cpu);
> ^
> include/linux/percpu-defs.h:95:19: note: in definition of macro 'DEFINE_PER_CPU_SECTION'
> __typeof__(type) name
> ^~~~
> drivers/xen/evtchn.c:438:9: note: in expansion of macro 'DEFINE_PER_CPU'
> static DEFINE_PER_CPU(int, bind_last_selected_cpu);
> ^~~~~~~~~~~~~~
> drivers/xen/evtchn.c:438:29: error: declaration of 'bind_last_selected_cpu' with no linkage follows extern declaration
> static DEFINE_PER_CPU(int, bind_last_selected_cpu);
> ^
> include/linux/percpu-defs.h:95:19: note: in definition of macro 'DEFINE_PER_CPU_SECTION'
> __typeof__(type) name
> ^~~~
> drivers/xen/evtchn.c:438:9: note: in expansion of macro 'DEFINE_PER_CPU'
> static DEFINE_PER_CPU(int, bind_last_selected_cpu);
> ^~~~~~~~~~~~~~
> drivers/xen/evtchn.c:438:29: note: previous declaration of 'bind_last_selected_cpu' was here
> static DEFINE_PER_CPU(int, bind_last_selected_cpu);
> ^
> include/linux/percpu-defs.h:93:44: note: in definition of macro 'DEFINE_PER_CPU_SECTION'
> extern __PCPU_ATTRS(sec) __typeof__(type) name; \
> ^~~~
> drivers/xen/evtchn.c:438:9: note: in expansion of macro 'DEFINE_PER_CPU'
> static DEFINE_PER_CPU(int, bind_last_selected_cpu);
> ^~~~~~~~~~~~~~
>
> vim +/bind_last_selected_cpu +438 drivers//xen/evtchn.c
>
> 432
> 433 del_evtchn(u, evtchn);
> 434 }
> 435
> 436 static void evtchn_bind_interdom_next_vcpu(int evtchn)
> 437 {
> > 438 static DEFINE_PER_CPU(int, bind_last_selected_cpu);


Oh well, so much for my request to move it. So you are going to make it
global to the file.

Here is the explanation BTW:
http://www.spinics.net/lists/linux-mm/msg121626.html

CONFIG_DEBUG_FORCE_WEAK_PER_CPU is what trips this.

-boris


2017-06-07 10:32:11

by Anoob Soman

[permalink] [raw]
Subject: Re: [PATCH V2] xen-evtchn: Bind dyn evtchn:qemu-dm interrupt to next online VCPU

On 06/06/17 20:41, Boris Ostrovsky wrote:
>
> There is a single call site for rebind_irq_to_cpu() so why not call
> xen_rebind_evtchn_to_cpu() directly?
>

Fair enough, I will change it.

>
>> + raw_spin_lock_irqsave(&desc->lock, flags);
> Is there a reason why you are using raw_ version?

desc->lock is defined as raw_spinlock_t

-Anoob

2017-06-07 10:35:56

by Anoob Soman

[permalink] [raw]
Subject: Re: [PATCH V2] xen-evtchn: Bind dyn evtchn:qemu-dm interrupt to next online VCPU

On 06/06/17 21:58, Boris Ostrovsky wrote:
>
> Oh well, so much for my request to move it. So you are going to make it
> global to the file.

Sorry about build breakage. I will move
DEFINE_PER_CPU(bind_last_selected_cpu) above
evtchn_bind_interdom_next_vcpu().

-Anoob.