[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-ppc] [RFC PATCH v3 05/24] spapr: Reorganize CPU dt generation
From: |
Bharata B Rao |
Subject: |
Re: [Qemu-ppc] [RFC PATCH v3 05/24] spapr: Reorganize CPU dt generation code |
Date: |
Mon, 27 Apr 2015 11:06:07 +0530 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
On Sun, Apr 26, 2015 at 05:17:48PM +0530, Bharata B Rao wrote:
> On Fri, Apr 24, 2015 at 12:17:27PM +0530, Bharata B Rao wrote:
> > Reorganize CPU device tree generation code so that it be reused from
> > hotplug path. CPU dt entries are now generated from spapr_finalize_fdt()
> > instead of spapr_create_fdt_skel().
>
> Creating CPU DT entries from spapr_finalize_fdt() instead of
> spapr_create_fdt_skel() has an interesting side effect.
>
> <snip>
>
> In both the cases, I am adding CPU DT nodes from QEMU in the same order,
> but not sure why the guest kernel discovers them in different orders in
> each case.
Nikunj and I tracked this down to the difference in device tree APIs that
we are using in two cases.
When CPU DT nodes are created from spapr_create_fdt_skel(), we are using
fdt_begin_node() API which does sequential write and hence CPU DT nodes
end up in the same order in which they are created.
However in my patch when I create CPU DT entries in spapr_finalize_fdt(),
I am using fdt_add_subnode() which ends up writing the CPU DT node at the
same parent offset for all the CPUs. This results in CPU DT nodes being
generated in reverse order in FDT.
>
> > +static void spapr_populate_cpus_dt_node(void *fdt, sPAPREnvironment *spapr)
> > +{
> > + CPUState *cs;
> > + int cpus_offset;
> > + char *nodename;
> > + int smt = kvmppc_smt_threads();
> > +
> > + cpus_offset = fdt_add_subnode(fdt, 0, "cpus");
> > + _FDT(cpus_offset);
> > + _FDT((fdt_setprop_cell(fdt, cpus_offset, "#address-cells", 0x1)));
> > + _FDT((fdt_setprop_cell(fdt, cpus_offset, "#size-cells", 0x0)));
> > +
> > + CPU_FOREACH(cs) {
> > + PowerPCCPU *cpu = POWERPC_CPU(cs);
> > + int index = ppc_get_vcpu_dt_id(cpu);
> > + DeviceClass *dc = DEVICE_GET_CLASS(cs);
> > + int offset;
> > +
> > + if ((index % smt) != 0) {
> > + continue;
> > + }
> > +
> > + nodename = g_strdup_printf("address@hidden", dc->fw_name, index);
> > + offset = fdt_add_subnode(fdt, cpus_offset, nodename);
> > + g_free(nodename);
> > + _FDT(offset);
> > + spapr_populate_cpu_dt(cs, fdt, offset);
> > + }
>
> I can simply fix this by walking the CPUs in reverse order in the above
> code which makes the guest kernel to discover the CPU DT nodes in the
> right order.
>
> s/CPU_FOREACH(cs)/CPU_FOREACH_REVERSE(cs) will solve this problem. Would this
> be the right approach or should we just leave it to the guest kernel to
> discover and enumerate CPUs in whatever order it finds the DT nodes in FDT ?
So using CPU_FOREACH_REVERSE(cs) appears to be right way to handle this.
Regards,
Bharata.
- [Qemu-ppc] [RFC PATCH v3 00/24] CPU and Memory hotplug for PowerPC sPAPR guests, Bharata B Rao, 2015/04/24
- [Qemu-ppc] [RFC PATCH v3 01/24] spapr: enable PHB/CPU/LMB hotplug for pseries-2.3, Bharata B Rao, 2015/04/24
- [Qemu-ppc] [RFC PATCH v3 02/24] spapr: Add DRC dt entries for CPUs, Bharata B Rao, 2015/04/24
- [Qemu-ppc] [RFC PATCH v3 03/24] spapr: Consider max_cpus during xics initialization, Bharata B Rao, 2015/04/24
- [Qemu-ppc] [RFC PATCH v3 04/24] spapr: Support ibm, lrdr-capacity device tree property, Bharata B Rao, 2015/04/24
- [Qemu-ppc] [RFC PATCH v3 05/24] spapr: Reorganize CPU dt generation code, Bharata B Rao, 2015/04/24
- [Qemu-ppc] [RFC PATCH v3 06/24] spapr: Consolidate cpu init code into a routine, Bharata B Rao, 2015/04/24
- [Qemu-ppc] [RFC PATCH v3 07/24] cpu: Prepare Socket container type, Bharata B Rao, 2015/04/24
- [Qemu-ppc] [RFC PATCH v3 08/24] ppc: Prepare CPU socket/core abstraction, Bharata B Rao, 2015/04/24
- [Qemu-ppc] [RFC PATCH v3 09/24] spapr: Add CPU hotplug handler, Bharata B Rao, 2015/04/24
- [Qemu-ppc] [RFC PATCH v3 10/24] ppc: Update cpu_model in MachineState, Bharata B Rao, 2015/04/24
- [Qemu-ppc] [RFC PATCH v3 11/24] ppc: Create sockets and cores for CPUs, Bharata B Rao, 2015/04/24
- [Qemu-ppc] [RFC PATCH v3 12/24] spapr: CPU hotplug support, Bharata B Rao, 2015/04/24
- [Qemu-ppc] [RFC PATCH v3 13/24] cpus: Add Error argument to cpu_exec_init(), Bharata B Rao, 2015/04/24
- [Qemu-ppc] [RFC PATCH v3 14/24] cpus: Convert cpu_index into a bitmap, Bharata B Rao, 2015/04/24
- [Qemu-ppc] [RFC PATCH v3 15/24] ppc: Move cpu_exec_init() call to realize function, Bharata B Rao, 2015/04/24