All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jan Beulich" <JBeulich@suse.com>
To: Chao Peng <chao.p.peng@linux.intel.com>
Cc: wei.liu2@citrix.com, Ian.Campbell@citrix.com,
	stefano.stabellini@eu.citrix.com, andrew.cooper3@citrix.com,
	dario.faggioli@citrix.com, Ian.Jackson@eu.citrix.com,
	xen-devel@lists.xen.org, will.auld@intel.com, keir@xen.org,
	Boris Ostrovsky <boris.ostrovsky@oracle.com>,
	dgdegra@tycho.nsa.gov
Subject: Re: [PATCH v10 01/13] x86: add socket_cpumask
Date: Wed, 08 Jul 2015 08:42:16 +0100	[thread overview]
Message-ID: <559CF078020000780008DF2E@mail.emea.novell.com> (raw)
In-Reply-To: <20150708024348.GB3333@pengc-linux.bj.intel.com>

>>> On 08.07.15 at 04:43, <chao.p.peng@linux.intel.com> wrote:
> On Tue, Jul 07, 2015 at 06:32:55PM -0400, Boris Ostrovsky wrote:
>> >@@ -245,6 +248,8 @@ static void set_cpu_sibling_map(int cpu)
>> >      cpumask_set_cpu(cpu, &cpu_sibling_setup_map);
>> >+    cpumask_set_cpu(cpu, socket_cpumask[cpu_to_socket(cpu)]);
>> 
>> This patch crashes Xen on my 32-cpu Intel box here for cpu 16, which is the
>> first CPU on the second socket (i.e. on socket 1).
>> 
>> The reason appears to be that cpu_to_socket(16) is (correctly) 1 here, but
>> ...
>> 
>> >+
>> >      if ( c[cpu].x86_num_siblings > 1 )
>> >      {
>> >          for_each_cpu ( i, &cpu_sibling_setup_map )
>> >@@ -649,7 +654,13 @@ void cpu_exit_clear(unsigned int cpu)
>> >  static void cpu_smpboot_free(unsigned int cpu)
>> >  {
>> >-    unsigned int order;
>> >+    unsigned int order, socket = cpu_to_socket(cpu);
>> >+
>> >+    if ( cpumask_empty(socket_cpumask[socket]) )
>> >+    {
>> >+        free_cpumask_var(socket_cpumask[socket]);
>> >+        socket_cpumask[socket] = NULL;
>> >+    }
>> >      free_cpumask_var(per_cpu(cpu_sibling_mask, cpu));
>> >      free_cpumask_var(per_cpu(cpu_core_mask, cpu));
>> >@@ -694,6 +705,7 @@ static int cpu_smpboot_alloc(unsigned int cpu)
>> >      nodeid_t node = cpu_to_node(cpu);
>> >      struct desc_struct *gdt;
>> >      unsigned long stub_page;
>> >+    unsigned int socket = cpu_to_socket(cpu);
>> 
>> ... is zero here, meaning that socket_cpumask[1] is NULL. I suspect that
>> phys_proc_id is probably not set at this point but is by the time we get to
>> set_cpu_sibling_map(). I haven't looked any further yet. I might do this
>> tomorrow unless Chao does it before me.
> 
> Thanks for testing.

Boris' report first of all raises the question: Did you test this at all
on a multi-socket system? Considering you not having tested the
CPU removal case either, I'm starting to wonder how much testing
this series has seen overall...

> I think I have found the reason. For AP, phys_proc_id is set in:
> start_secondary()=>smp_callin()=>smp_store_cpu_info()=>identify_cpu()
> which is behind cpu_smpboot_alloc() called from CPU_PREPARE.
> 
> One way would move 'zalloc_cpumask_var(socket_cpumask + socket)' to
> set_cpu_sibling_map() to fix it if Jan agrees that, otherwise other
> solution needs to be found.

Looks sensible at a first glance, but in order to be able to do
proper error handling the allocation needs to remain in
cpu_smpboot_alloc(). I.e. you'd add a static variable, pre-
allocate a cpumask into it if it's currently NULL, and consume the
allocation in set_cpu_sibling_map() (or maybe even better in
smp_store_cpu_info() right after the identify_cpu() call) if
socket_cpumask[socket] is NULL.

And then you test this on an affected system, and submit
asap, so we can preferably avoid reverting the whole series.

Jan

  reply	other threads:[~2015-07-08  7:42 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-26  8:43 [PATCH v10 00/13] enable Cache Allocation Technology (CAT) for VMs Chao Peng
2015-06-26  8:43 ` [PATCH v10 01/13] x86: add socket_cpumask Chao Peng
2015-07-07 22:32   ` Boris Ostrovsky
2015-07-08  2:43     ` Chao Peng
2015-07-08  7:42       ` Jan Beulich [this message]
2015-06-26  8:43 ` [PATCH v10 02/13] x86: detect and initialize Intel CAT feature Chao Peng
2015-07-07 10:25   ` Jan Beulich
2015-07-08  2:24     ` Chao Peng
2015-06-26  8:43 ` [PATCH v10 03/13] x86: maintain COS to CBM mapping for each socket Chao Peng
2015-06-26  8:43 ` [PATCH v10 04/13] x86: add COS information for each domain Chao Peng
2015-06-26  8:43 ` [PATCH v10 05/13] x86: expose CBM length and COS number information Chao Peng
2015-06-26  8:43 ` [PATCH v10 06/13] x86: dynamically get/set CBM for a domain Chao Peng
2015-06-26  8:43 ` [PATCH v10 07/13] x86: add scheduling support for Intel CAT Chao Peng
2015-06-26  8:43 ` [PATCH v10 08/13] xsm: add CAT related xsm policies Chao Peng
2015-06-26  8:43 ` [PATCH v10 09/13] tools/libxl: minor name changes for CMT commands Chao Peng
2015-06-26  8:43 ` [PATCH v10 10/13] tools/libxl: add command to show PSR hardware info Chao Peng
2015-06-26  8:43 ` [PATCH v10 11/13] tools/libxl: introduce some socket helpers Chao Peng
2015-06-26  8:43 ` [PATCH v10 12/13] tools: add tools support for Intel CAT Chao Peng
2015-06-26  8:43 ` [PATCH v10 13/13] docs: add xl-psr.markdown Chao Peng
2015-07-07 14:46 ` [PATCH v10 00/13] enable Cache Allocation Technology (CAT) for VMs Ian Campbell
2015-07-08  9:40   ` Chao Peng
2015-07-08 10:02     ` Wei Liu
2015-07-09  1:29       ` Chao Peng

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=559CF078020000780008DF2E@mail.emea.novell.com \
    --to=jbeulich@suse.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=chao.p.peng@linux.intel.com \
    --cc=dario.faggioli@citrix.com \
    --cc=dgdegra@tycho.nsa.gov \
    --cc=keir@xen.org \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=will.auld@intel.com \
    --cc=xen-devel@lists.xen.org \
    /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.