All of lore.kernel.org
 help / color / mirror / Atom feed
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: Re: [PATCH 3/9] xen/time: Fix kasprintf splat when allocating timer%d IRQ line.
Date: Mon, 29 Apr 2013 14:36:22 -0400	[thread overview]
Message-ID: <20130429183622.GD9431@phenom.dumpdata.com> (raw)
In-Reply-To: <alpine.DEB.2.02.1304261707000.4180@kaball.uk.xensource.com>

On Fri, Apr 26, 2013 at 05:11:35PM +0100, Stefano Stabellini wrote:
> On Tue, 16 Apr 2013, Konrad Rzeszutek Wilk wrote:
> > When we online the CPU, we get this splat:
> > 
> > smpboot: Booting Node 0 Processor 1 APIC 0x2
> > installing Xen timer for CPU 1
> > BUG: sleeping function called from invalid context at /home/konrad/ssd/konrad/linux/mm/slab.c:3179
> > in_atomic(): 1, irqs_disabled(): 0, pid: 0, name: swapper/1
> > Pid: 0, comm: swapper/1 Not tainted 3.9.0-rc6upstream-00001-g3884fad #1
> > Call Trace:
> >  [<ffffffff810c1fea>] __might_sleep+0xda/0x100
> >  [<ffffffff81194617>] __kmalloc_track_caller+0x1e7/0x2c0
> >  [<ffffffff81303758>] ? kasprintf+0x38/0x40
> >  [<ffffffff813036eb>] kvasprintf+0x5b/0x90
> >  [<ffffffff81303758>] kasprintf+0x38/0x40
> >  [<ffffffff81044510>] xen_setup_timer+0x30/0xb0
> >  [<ffffffff810445af>] xen_hvm_setup_cpu_clockevents+0x1f/0x30
> >  [<ffffffff81666d0a>] start_secondary+0x19c/0x1a8
> > 
> > The solution to that is use kasprintf in the CPU hotplug path
> > that 'online's the CPU. That is, do it in in xen_hvm_cpu_notify,
> > and remove the call to in xen_hvm_setup_cpu_clockevents.
> > 
> > Unfortunatly the later is not a good idea as the bootup path
> > does not use xen_hvm_cpu_notify so we would end up never allocating
> > timer%d interrupt lines when booting. As such add the check for
> > atomic() to continue.
> 
> This last is not reflected in the code.

I found out that it was not needed.
> 
> Also, is it actually OK to move xen_setup_timer out of
> xen_hvm_setup_cpu_clockevents?

Yes. It ends up being called earlier - in the notifier.
> 
> xen_setup_cpu_clockevents registers xen_clock_events as clocksource and
> xen_clock_events is setup by xen_setup_timer so we need to make sure
> that the call order remains the same.

The order is still the same.
> 
> 
> > CC: stable@vger.kernel.org
> > Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> > ---
> >  arch/x86/xen/enlighten.c | 5 ++++-
> >  arch/x86/xen/time.c      | 6 +++++-
> >  2 files changed, 9 insertions(+), 2 deletions(-)
> > 
> > diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
> > index 47d3243..ddbd54a 100644
> > --- a/arch/x86/xen/enlighten.c
> > +++ b/arch/x86/xen/enlighten.c
> > @@ -1641,8 +1641,11 @@ static int __cpuinit xen_hvm_cpu_notify(struct notifier_block *self,
> >  	switch (action) {
> >  	case CPU_UP_PREPARE:
> >  		xen_vcpu_setup(cpu);
> > -		if (xen_have_vector_callback)
> > +		if (xen_have_vector_callback) {
> >  			xen_init_lock_cpu(cpu);
> > +			if (xen_feature(XENFEAT_hvm_safe_pvclock))
> > +				xen_setup_timer(cpu);
> > +		}
> >  		break;
> >  	default:
> >  		break;
> > diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c
> > index 0296a95..054cc01 100644
> > --- a/arch/x86/xen/time.c
> > +++ b/arch/x86/xen/time.c
> > @@ -497,7 +497,11 @@ static void xen_hvm_setup_cpu_clockevents(void)
> >  {
> >  	int cpu = smp_processor_id();
> >  	xen_setup_runstate_info(cpu);
> > -	xen_setup_timer(cpu);
> > +	/*
> > +	 * xen_setup_timer(cpu) - snprintf is bad in atomic context. Hence
> > +	 * doing it xen_hvm_cpu_notify (which gets called by smp_init during
> > +	 * early bootup and also during CPU hotplug events).
> > +	 */
> >  	xen_setup_cpu_clockevents();
> >  }
> >  
> > -- 
> > 1.8.1.4
> > 

  reply	other threads:[~2013-04-29 18:36 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-16 20:08 [PATCH] fixes for v3.10 in the CPU hotplug patch (v1) Konrad Rzeszutek Wilk
2013-04-16 20:08 ` [PATCH 1/9] xen/smp: Fix leakage of timer interrupt line for every CPU online/offline Konrad Rzeszutek Wilk
2013-04-26 16:06   ` Stefano Stabellini
2013-04-16 20:09 ` [PATCH 2/9] xen/smp/spinlock: Fix leakage of the spinlock " Konrad Rzeszutek Wilk
2013-04-26 16:06   ` Stefano Stabellini
2013-04-16 20:09 ` [PATCH 3/9] xen/time: Fix kasprintf splat when allocating timer%d IRQ line Konrad Rzeszutek Wilk
2013-04-26 16:11   ` Stefano Stabellini
2013-04-29 18:36     ` Konrad Rzeszutek Wilk [this message]
2013-04-16 20:09 ` [PATCH 4/9] xen/events: Check that IRQ value passed in is valid Konrad Rzeszutek Wilk
2013-04-26 16:12   ` Stefano Stabellini
2013-04-16 20:09 ` [PATCH 5/9] xen/time: Add default value of -1 for IRQ and check for that Konrad Rzeszutek Wilk
2013-04-26 16:15   ` Stefano Stabellini
2013-04-16 20:09 ` [PATCH 6/9] xen/spinlock: Check against default value of -1 for IRQ line Konrad Rzeszutek Wilk
2013-04-26 16:18   ` Stefano Stabellini
2013-04-29 18:35     ` Konrad Rzeszutek Wilk
2013-04-16 20:09 ` [PATCH 7/9] xen/spinlock: Disable IRQ spinlock (PV) allocation on PVHVM Konrad Rzeszutek Wilk
2013-04-26 16:20   ` Stefano Stabellini
2013-04-29 18:34     ` Konrad Rzeszutek Wilk
2013-04-16 20:09 ` [PATCH 8/9] xen/smp/pvhvm: Don't initialize IRQ_WORKER as we are using the native one Konrad Rzeszutek Wilk
2013-04-26 16:27   ` Stefano Stabellini
2013-04-29 18:34     ` Konrad Rzeszutek Wilk
2013-05-01 13:25       ` Stefano Stabellini
2013-05-01 14:57         ` Konrad Rzeszutek Wilk
2013-05-01 15:07           ` Stefano Stabellini
2013-04-16 20:09 ` [PATCH 9/9] xen/smp: Unifiy some of the PVs and PVHVM offline CPU path Konrad Rzeszutek Wilk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130429183622.GD9431@phenom.dumpdata.com \
    --to=konrad.wilk@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.