From: David Gibson <david@gibson.dropbear.id.au>
To: "Emilio G. Cota" <cota@braap.org>
Cc: qemu-devel@nongnu.org, Paolo Bonzini <pbonzini@redhat.com>,
Peter Crosthwaite <crosthwaite.peter@gmail.com>,
Richard Henderson <rth@twiddle.net>,
Alexander Graf <agraf@suse.de>, Riku Voipio <riku.voipio@iki.fi>,
Laurent Vivier <laurent@vivier.eu>,
qemu-ppc@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 2/3] spapr: do not use CPU_FOREACH_REVERSE
Date: Tue, 14 Aug 2018 11:11:09 +1000 [thread overview]
Message-ID: <20180814011109.GC27378@umbus> (raw)
In-Reply-To: <20180813163859.17964-3-cota@braap.org>
[-- Attachment #1: Type: text/plain, Size: 2066 bytes --]
On Mon, Aug 13, 2018 at 12:38:58PM -0400, Emilio G. Cota wrote:
> This paves the way for implementing the CPU list with an RCU QLIST,
> which cannot be traversed in reverse order.
>
> Note that this is the only caller of CPU_FOREACH_REVERSE.
>
> Signed-off-by: Emilio G. Cota <cota@braap.org>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
> ---
> hw/ppc/spapr.c | 16 +++++++++++++++-
> 1 file changed, 15 insertions(+), 1 deletion(-)
>
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index 421b2dd09b..2ef5be2790 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -622,9 +622,12 @@ static void spapr_populate_cpu_dt(CPUState *cs, void *fdt, int offset,
>
> static void spapr_populate_cpus_dt_node(void *fdt, sPAPRMachineState *spapr)
> {
> + CPUState **rev;
> CPUState *cs;
> + int n_cpus;
> int cpus_offset;
> char *nodename;
> + int i;
>
> cpus_offset = fdt_add_subnode(fdt, 0, "cpus");
> _FDT(cpus_offset);
> @@ -635,8 +638,19 @@ static void spapr_populate_cpus_dt_node(void *fdt, sPAPRMachineState *spapr)
> * We walk the CPUs in reverse order to ensure that CPU DT nodes
> * created by fdt_add_subnode() end up in the right order in FDT
> * for the guest kernel the enumerate the CPUs correctly.
> + *
> + * The CPU list cannot be traversed in reverse order, so we need
> + * to do extra work.
> */
> - CPU_FOREACH_REVERSE(cs) {
> + n_cpus = 0;
> + rev = NULL;
> + CPU_FOREACH(cs) {
> + rev = g_renew(CPUState *, rev, n_cpus + 1);
> + rev[n_cpus++] = cs;
> + }
> +
> + for (i = n_cpus - 1; i >= 0; i--) {
> + CPUState *cs = rev[i];
> PowerPCCPU *cpu = POWERPC_CPU(cs);
> int index = spapr_get_vcpu_id(cpu);
> DeviceClass *dc = DEVICE_GET_CLASS(cs);
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2018-08-14 1:36 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-13 16:38 [Qemu-devel] [PATCH 0/3] convert CPU list to RCU Emilio G. Cota
2018-08-13 16:38 ` [Qemu-devel] [PATCH 1/3] qom: use cpu->in_cpu_list instead of QTAILQ_IN_USE Emilio G. Cota
2018-08-14 6:26 ` Paolo Bonzini
2018-08-13 16:38 ` [Qemu-devel] [PATCH 2/3] spapr: do not use CPU_FOREACH_REVERSE Emilio G. Cota
2018-08-14 1:11 ` David Gibson [this message]
2018-08-13 16:38 ` [Qemu-devel] [PATCH 3/3] qom: implement CPU list with an RCU QLIST Emilio G. Cota
2018-08-14 6:26 ` Paolo Bonzini
2018-08-15 0:34 ` Emilio G. Cota
2018-08-17 17:53 ` Paolo Bonzini
2018-08-19 9:06 ` Emilio G. Cota
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=20180814011109.GC27378@umbus \
--to=david@gibson.dropbear.id.au \
--cc=agraf@suse.de \
--cc=cota@braap.org \
--cc=crosthwaite.peter@gmail.com \
--cc=laurent@vivier.eu \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=riku.voipio@iki.fi \
--cc=rth@twiddle.net \
/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).