From: Andrew Jones <drjones@redhat.com>
To: Shannon Zhao <zhaoshenglong@huawei.com>
Cc: peter.maydell@linaro.org, david.daney@cavium.com,
qemu-devel@nongnu.org, peter.huangpeng@huawei.com,
qemu-arm@nongnu.org, shannon.zhao@linaro.org
Subject: Re: [Qemu-devel] [PATCH v5 1/5] ARM: Virt: Add /distance-map node for NUMA
Date: Sat, 23 Apr 2016 09:03:37 +0200 [thread overview]
Message-ID: <20160423070337.pkifpvpyheftycdz@hawk.localdomain> (raw)
In-Reply-To: <571ACD25.9070707@huawei.com>
On Sat, Apr 23, 2016 at 09:17:25AM +0800, Shannon Zhao wrote:
>
>
> On 2016/4/22 20:25, Andrew Jones wrote:
> > On Thu, Apr 21, 2016 at 02:23:50PM +0800, Shannon Zhao wrote:
> >> > From: Shannon Zhao <shannon.zhao@linaro.org>
> >> >
> >> > This /distance-map node is used to describe the accessing distance
> >> > between NUMA nodes.
> >> >
> >> > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> >> > ---
> >> > hw/arm/virt.c | 30 ++++++++++++++++++++++++++++++
> >> > 1 file changed, 30 insertions(+)
> >> >
> >> > diff --git a/hw/arm/virt.c b/hw/arm/virt.c
> >> > index 56d35c7..814a1eb 100644
> >> > --- a/hw/arm/virt.c
> >> > +++ b/hw/arm/virt.c
> >> > @@ -40,6 +40,7 @@
> >> > #include "sysemu/device_tree.h"
> >> > #include "sysemu/sysemu.h"
> >> > #include "sysemu/kvm.h"
> >> > +#include "sysemu/numa.h"
> >> > #include "hw/boards.h"
> >> > #include "hw/loader.h"
> >> > #include "exec/address-spaces.h"
> >> > @@ -203,6 +204,9 @@ static VirtBoardInfo *find_machine_info(const char *cpu)
> >> >
> >> > static void create_fdt(VirtBoardInfo *vbi)
> >> > {
> >> > + unsigned int i, j, number, count;
> > s/count/index/ ?
> >
> >> > + uint64_t *matrix;
> >> > +
> >> > void *fdt = create_device_tree(&vbi->fdt_size);
> >> >
> >> > if (!fdt) {
> >> > @@ -239,6 +243,32 @@ static void create_fdt(VirtBoardInfo *vbi)
> >> > "clk24mhz");
> >> > qemu_fdt_setprop_cell(fdt, "/apb-pclk", "phandle", vbi->clock_phandle);
> >> >
> >> > + if (nb_numa_nodes <= 0) {
> >> > + return;
> >> > + }
> >> > +
> >> > + /* Add /distance-map node for NUMA */
> >> > + qemu_fdt_add_subnode(fdt, "/distance-map");
> >> > + qemu_fdt_setprop_string(fdt, "/distance-map", "compatible",
> >> > + "numa-distance-map-v1");
> >> > +
> >> > + number = nb_numa_nodes * nb_numa_nodes * 6;
> >> > + matrix = g_malloc0(number * sizeof(uint64_t));
> >> > + for (i = 0; i < nb_numa_nodes; i++) {
> >> > + for (j = 0; j < nb_numa_nodes; j++) {
> >> > + count = (i * nb_numa_nodes + j) * 6;
> >> > + matrix[count++] = 1;
> >> > + matrix[count++] = i;
> >> > + matrix[count++] = 1;
> >> > + matrix[count++] = j;
> >> > + matrix[count++] = 1;
> >> > + matrix[count++] = (i == j) ? 10 : 20;
> >> > + }
> >> > + }
> >> > + qemu_fdt_setprop_sized_cells_from_array(fdt, "/distance-map",
> >> > + "distance-matrix", number / 2,
> >> > + matrix);
> > I had to read qemu_fdt_setprop_sized_cells_from_array to understand why
> > above we're using 6 instead of 3, and then placing all the 1's in every
> > other slot, and then dividing number by 2 here. Is using this function
> > worth the confusion?
> >
> > I think the following would greatly improve reviewability, and shave off
> > a bit of boot time (by not having to alloc more mem and copy the matrix).
> >
> > uint32_t *matrix;
> >
> > number = nb_numa_nodes * nb_numa_nodes * 3;
> > matrix = g_malloc0(number * sizeof(uint32_t));
> > for (i = 0; i < nb_numa_nodes; i++) {
> > for (j = 0; j < nb_numa_nodes; j++) {
> > count = (i * nb_numa_nodes + j) * 3;
> > matrix[count++] = cpu_to_be32(i);
> > matrix[count++] = cpu_to_be32(j);
> > matrix[count++] = cpu_to_be32(i == j ? 10 : 20);
I noticed that /distance-map is an optional node by the latest version
of the spec. In its absence default values will be used. Do we plan on
putting anything other then the 10s and 20s here? If not, then we can
leave it to Linux to determine what the defaults should be, and it'll
use them by itself if we leave this node out.
> > }
> > }
> > qemu_fdt_setprop(fdt, "/distance-map", "distance-matrix",
> > matrix, number * sizeof(uint32_t));
> >
> >
> >> > + g_free(matrix);
> > Also, I think it would nicer if all this was put in its own function, and
> > then just add the following to create_fdt.
> >
> > if (nb_numa_nodes) {
> > virt_fdt_create_distance_map(fdt);
> > }
> >
> Ok, will update this.
Thanks,
drew
>
> Thanks,
> --
> Shannon
>
>
next prev parent reply other threads:[~2016-04-23 7:03 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-21 6:23 [Qemu-devel] [PATCH v5 0/5] ARM: Add NUMA support for machine virt Shannon Zhao
2016-04-21 6:23 ` [Qemu-devel] [PATCH v5 1/5] ARM: Virt: Add /distance-map node for NUMA Shannon Zhao
2016-04-22 12:25 ` Andrew Jones
2016-04-23 1:17 ` Shannon Zhao
2016-04-23 7:03 ` Andrew Jones [this message]
2016-04-23 7:27 ` Shannon Zhao
2016-04-21 6:23 ` [Qemu-devel] [PATCH v5 2/5] ARM: Virt: Set numa-node-id for CPUs Shannon Zhao
2016-04-22 12:34 ` Andrew Jones
2016-04-21 6:23 ` [Qemu-devel] [PATCH v5 3/5] ARM: Add numa-node-id for /memory node Shannon Zhao
2016-04-22 12:48 ` Andrew Jones
2016-04-23 1:16 ` Shannon Zhao
2016-04-23 7:45 ` Andrew Jones
2016-04-23 8:02 ` Shannon Zhao
2016-04-21 6:23 ` [Qemu-devel] [PATCH v5 4/5] include/hw/acpi/acpi-defs: Add GICC Affinity Structure Shannon Zhao
2016-04-22 13:26 ` Andrew Jones
2016-04-21 6:23 ` [Qemu-devel] [PATCH v5 5/5] hw/arm/virt-acpi-build: Generate SRAT table Shannon Zhao
2016-04-22 13:26 ` Andrew Jones
2016-04-23 1:08 ` Shannon Zhao
2016-04-25 10:44 ` Igor Mammedov
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=20160423070337.pkifpvpyheftycdz@hawk.localdomain \
--to=drjones@redhat.com \
--cc=david.daney@cavium.com \
--cc=peter.huangpeng@huawei.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=shannon.zhao@linaro.org \
--cc=zhaoshenglong@huawei.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).