From: "Jan Beulich" Subject: Re: POD: soft lockups in dom0 kernel Date: Thu, 16 Jan 2014 11:10:38 +0000 Message-ID: <52D7CC3E020000780011435C@nat28.tlf.novell.com> References: <1538524.5AKIkpF9LB@amur> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part6D5EE53E.0__=" Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1W3kqS-00061f-Fb for xen-devel@lists.xenproject.org; Thu, 16 Jan 2014 11:10:44 +0000 In-Reply-To: <1538524.5AKIkpF9LB@amur> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Dietmar Hahn Cc: xen-devel@lists.xenproject.org List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part6D5EE53E.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline >>> On 05.12.13 at 14:55, Dietmar Hahn = wrote: > when creating a bigger (> 50 GB) HVM guest with maxmem > memory we get > softlockups from time to time. >=20 > kernel: [ 802.084335] BUG: soft lockup - CPU#1 stuck for 22s! [xend:3135= 1] >=20 > I tracked this down to the call of xc_domain_set_pod_target() and = further > p2m_pod_set_mem_target(). >=20 > Unfortunately I can this check only with xen-4.2.2 as I don't have a = machine > with enough memory for current hypervisors. But it seems the code is = nearly > the same. While I still didn't see a formal report of this against SLE11 yet, attached a draft patch against the SP3 code base adding manual preemption to the hypercall path of privcmd. This is only lightly tested, and therefore has a little bit of debugging code still left in there. Mind giving this an try (perhaps together with the patch David had sent for the other issue - there may still be a need for further preemption points in the IOCTL_PRIVCMD_MMAP* handling, but without knowing for sure whether that matters to you I didn't want to add this right away)? Jan --=__Part6D5EE53E.0__= Content-Type: text/plain; name="xen-privcmd-hcall-preemption.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="xen-privcmd-hcall-preemption.patch" --- sle11sp3.orig/arch/x86/include/mach-xen/asm/hypervisor.h 2012-10-19 = 16:11:54.000000000 +0200=0A+++ sle11sp3/arch/x86/include/mach-xen/asm/hyper= visor.h 2014-01-15 13:02:20.000000000 +0100=0A@@ -235,6 +235,9 @@ static = inline int gnttab_post_map_adjust=0A #ifdef CONFIG_XEN=0A #define = is_running_on_xen() 1=0A extern char hypercall_page[PAGE_SIZE];=0A+#define = in_hypercall(regs) (!user_mode_vm(regs) && \=0A+ (regs)->ip >=3D = (unsigned long)hypercall_page && \=0A+ (regs)->ip < (unsigned long)hyperca= ll_page + PAGE_SIZE)=0A #else=0A extern char *hypercall_stubs;=0A #define = is_running_on_xen() (!!hypercall_stubs)=0A--- sle11sp3.orig/arch/x86/kernel= /entry_32-xen.S 2012-10-19 16:10:09.000000000 +0200=0A+++ sle11sp3/arch/x86= /kernel/entry_32-xen.S 2014-01-16 10:49:07.000000000 +0100=0A@@ -980,6 = +980,20 @@ ENTRY(hypervisor_callback)=0A call evtchn_do_upcall=0A = add $4,%esp=0A CFI_ADJUST_CFA_OFFSET -4=0A+#ifndef CONFIG_PREEMPT= =0A+ test %al,%al=0A+ jz ret_from_intr=0A+ GET_THREAD_INFO(%ed= x)=0A+ cmpl $0,TI_preempt_count(%edx)=0A+ jnz ret_from_intr=0A+ = testl $_TIF_NEED_RESCHED,TI_flags(%edx)=0A+ jz ret_from_intr=0A+ = testl $X86_EFLAGS_IF,PT_EFLAGS(%esp)=0A+ jz ret_from_intr=0A+ = movb $0,PER_CPU_VAR(privcmd_hcall)=0A+ call preempt_schedule_irq=0A+ = movb $1,PER_CPU_VAR(privcmd_hcall)=0A+#endif=0A jmp ret_from_intr= =0A CFI_ENDPROC=0A =0A--- sle11sp3.orig/arch/x86/kernel/entry_64-xen.S = 2011-10-06 13:06:38.000000000 +0200=0A+++ sle11sp3/arch/x86/kernel/entry_64= -xen.S 2014-01-16 10:52:27.000000000 +0100=0A@@ -982,6 +982,20 @@ = ENTRY(do_hypervisor_callback) # do_hyp=0A popq %rsp=0A CFI_DEF_CFA= _REGISTER rsp=0A decl PER_CPU_VAR(irq_count)=0A+#ifndef CONFIG_PREEM= PT=0A+ test %al,%al=0A+ jz error_exit=0A+ GET_THREAD_INFO(%rd= x)=0A+ cmpl $0,TI_preempt_count(%rdx)=0A+ jnz error_exit=0A+ bt = $TIF_NEED_RESCHED,TI_flags(%rdx)=0A+ jnc error_exit=0A+ bt = $9,EFLAGS-ARGOFFSET(%rsp)=0A+ jnc error_exit=0A+ movb $0,PER_CPU_VAR= (privcmd_hcall)=0A+ call preempt_schedule_irq=0A+ movb $1,PER_CPU_VAR= (privcmd_hcall)=0A+#endif=0A jmp error_exit=0A CFI_ENDPROC=0A = END(do_hypervisor_callback)=0A--- sle11sp3.orig/drivers/xen/core/evtchn.c = 2013-02-05 17:47:43.000000000 +0100=0A+++ sle11sp3/drivers/xen/core/evtchn.= c 2014-01-15 13:42:02.000000000 +0100=0A@@ -379,7 +379,14 @@ static = DEFINE_PER_CPU(unsigned int, curr=0A #endif=0A =0A /* NB. Interrupts are = disabled on entry. */=0A-asmlinkage void __irq_entry evtchn_do_upcall(struc= t pt_regs *regs)=0A+asmlinkage=0A+#ifdef CONFIG_PREEMPT=0A+void=0A+#define = return(x) return=0A+#else=0A+bool=0A+#endif=0A+__irq_entry evtchn_do_upcall= (struct pt_regs *regs)=0A {=0A unsigned long l1, l2;=0A unsigned = long masked_l1, masked_l2;=0A@@ -393,7 +400,7 @@ asmlinkage void = __irq_entry evtchn_do_up=0A __this_cpu_or(upcall_state, = UPC_NESTED_LATCH);=0A /* Avoid a callback storm when we reenable = delivery. */=0A vcpu_info_write(evtchn_upcall_pending, = 0);=0A- return;=0A+ return(false);=0A }=0A =0A = old_regs =3D set_irq_regs(regs);=0A@@ -511,6 +518,9 @@ asmlinkage void = __irq_entry evtchn_do_up=0A irq_exit();=0A xen_spin_irq_exit();=0A = set_irq_regs(old_regs);=0A+=0A+ return(__this_cpu_read(privcmd_hcall) && = in_hypercall(regs));=0A+#undef return=0A }=0A =0A static int find_unbound_i= rq(unsigned int node, struct irq_cfg **pcfg,=0A--- sle11sp3.orig/drivers/xe= n/privcmd/privcmd.c 2012-12-12 12:05:51.000000000 +0100=0A+++ = sle11sp3/drivers/xen/privcmd/privcmd.c 2014-01-16 10:01:23.000000000 = +0100=0A@@ -23,6 +23,18 @@=0A #include =0A #include = =0A #include =0A+#include =0A= +=0A+#ifndef CONFIG_PREEMPT=0A+DEFINE_PER_CPU(bool, privcmd_hcall);=0A+#end= if=0A+=0A+static inline void _privcmd_hcall(bool state)=0A+{=0A+#ifndef = CONFIG_PREEMPT=0A+ this_cpu_write(privcmd_hcall, state);=0A+#endif=0A+= }=0A =0A static struct proc_dir_entry *privcmd_intf;=0A static struct = proc_dir_entry *capabilities_intf;=0A@@ -97,6 +109,7 @@ static long = privcmd_ioctl(struct file *f=0A ret =3D -ENOSYS;=0A = if (hypercall.op >=3D (PAGE_SIZE >> 5))=0A break;=0A+ = _privcmd_hcall(true);=0A ret =3D _hypercall(long, = (unsigned int)hypercall.op,=0A (unsigned = long)hypercall.arg[0],=0A (unsigned = long)hypercall.arg[1],=0A@@ -104,8 +117,10 @@ static long privcmd_ioctl(str= uct file *f=0A (unsigned long)hypercall.arg[3],= =0A (unsigned long)hypercall.arg[4]);=0A = #else=0A+ _privcmd_hcall(true);=0A ret =3D = privcmd_hypercall(&hypercall);=0A #endif=0A+ _privcmd_hcall(fals= e);=0A }=0A break;=0A =0A--- sle11sp3.orig/include/xen/evtchn.h = 2011-12-09 15:38:45.000000000 +0100=0A+++ sle11sp3/include/xen/evtchn.h = 2014-01-15 14:32:14.000000000 +0100=0A@@ -143,7 +143,13 @@ void irq_resume(= void);=0A #endif=0A =0A /* Entry point for notifications into Linux = subsystems. */=0A-asmlinkage void evtchn_do_upcall(struct pt_regs = *regs);=0A+asmlinkage=0A+#ifdef CONFIG_PREEMPT=0A+void=0A+#else=0A+bool=0A+= #endif=0A+evtchn_do_upcall(struct pt_regs *regs);=0A =0A /* Mark a PIRQ as = unavailable for dynamic allocation. */=0A void evtchn_register_pirq(int = irq);=0A@@ -221,6 +227,8 @@ void notify_remote_via_ipi(unsigned int =0A = void clear_ipi_evtchn(void);=0A #endif=0A =0A+DECLARE_PER_CPU(bool, = privcmd_hcall);=0A+=0A #if defined(CONFIG_XEN_SPINLOCK_ACQUIRE_NESTING) = \=0A && CONFIG_XEN_SPINLOCK_ACQUIRE_NESTING=0A void xen_spin_irq_enter(= void);=0A--- sle11sp3.orig/kernel/sched.c 2014-01-10 14:11:39.0000000= 00 +0100=0A+++ sle11sp3/kernel/sched.c 2014-01-16 11:05:05.000000000 = +0100=0A@@ -4690,6 +4690,9 @@ asmlinkage void __sched notrace preempt_=0A = }=0A EXPORT_SYMBOL(preempt_schedule);=0A =0A+#endif=0A+#if defined(CONFIG_P= REEMPT) || defined(CONFIG_XEN)=0A+=0A /*=0A * this is the entry point to = schedule() from kernel preemption=0A * off of irq context.=0A@@ -4699,6 = +4702,14 @@ EXPORT_SYMBOL(preempt_schedule);=0A asmlinkage void __sched = preempt_schedule_irq(void)=0A {=0A struct thread_info *ti =3D = current_thread_info();=0A+#ifdef CONFIG_XEN//temp=0A+static DEFINE_PER_CPU(= unsigned long, cnt);=0A+static DEFINE_PER_CPU(unsigned long, thr);=0A+if(__= this_cpu_inc_return(cnt) > __this_cpu_read(thr)) {=0A+ __this_cpu_or(thr, = __this_cpu_read(cnt));=0A+ printk("psi[%02u] %08x:%d #%lx\n", raw_smp_proce= ssor_id(), ti->preempt_count, need_resched(), __this_cpu_read(cnt));=0A+}= =0A+#endif=0A =0A /* Catch callers which need to be fixed */=0A = BUG_ON(ti->preempt_count || !irqs_disabled());=0A --=__Part6D5EE53E.0__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --=__Part6D5EE53E.0__=--