From nobody Fri May 3 19:50:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1629902472206699.181695825868; Wed, 25 Aug 2021 07:41:12 -0700 (PDT) Received: from localhost ([::1]:54164 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mIu5X-0001r8-5Q for importer@patchew.org; Wed, 25 Aug 2021 10:41:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41948) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mIu4N-0007d6-Dn; Wed, 25 Aug 2021 10:39:59 -0400 Received: from mail-qk1-x735.google.com ([2607:f8b0:4864:20::735]:41867) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mIu4L-00072Z-Ro; Wed, 25 Aug 2021 10:39:59 -0400 Received: by mail-qk1-x735.google.com with SMTP id bk29so21626264qkb.8; Wed, 25 Aug 2021 07:39:57 -0700 (PDT) Received: from rekt.ihost.com ([177.197.96.186]) by smtp.gmail.com with ESMTPSA id 69sm129819qke.55.2021.08.25.07.39.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Aug 2021 07:39:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AqJ/CANn+mLhqYcCkmI2qej991jLbuz2Di1qLnOGcV8=; b=hCuLQTTJ5O/CsBctH00kZm/gTdl8ygj6ZL3VL3fiM3KkBAFDvdBTDlF5lceZjcbwvV 6xq+eXQYuG4B/26JaEN/W9VcwhIOD9tS/7ZWn6FamzbrzcIiaPH7RzFKNyIc/hwAm+3t XB3DzDeqdnsmK+RSbyZkdHRFONd1UPMukossT5AeETJb98/VBnnQ0uAtuwmX8u3D42E7 d8y2V/KuAec1ZWD8EYVmUwZdLvBDar2RzKi6ncw1C43jiNmhqjoAQHCUsJ3R3zEsSwjx +jvO3kxaEbiZz4PpZAFHXv22jCPSbCoSc9uxlkVVzXbua7CDPTiZXzLJSh/+aAZGhBix WdgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AqJ/CANn+mLhqYcCkmI2qej991jLbuz2Di1qLnOGcV8=; b=pyXEH1v/TVKrVaNY5oPhB50avGpZbzwzg4KZbSHi58lUF9s7/HhLeZxWjVxBijOYlE CF03ts8FnCP5wCjfQ0OEQOLcmQo7w6puoezIkE0abvuPfZMEgMYzUhHEXtr3DKWEjR4/ 9BQNeCTc7oZt9YMKWLaZM4bdaGa7cx+yXzlN04uDGJ24fRkBW4ZrBVQPTUD0o4TZAkq3 GxbfrdpEKdeSF2DyEwDy2V2aG1XEYjmwm0jm+JbTxoEd441uYcSeIaK8l6jFvrzZzvbQ WH/anfZ4T1An9d25FosBkeGtWc1+uzt8DMac8p3Nsq04YTuVZg7bpj+J8nPuwh+n1xZc P17w== X-Gm-Message-State: AOAM530z4EXqD530slqZ5/WivUBm+WPodzz27IfH6oQSveOGK4AChGPk wm3OLr0GsZrvBB5vQ3X5ZflgbzhPpkc= X-Google-Smtp-Source: ABdhPJzSF46VbAI99bzEk5Ypk9YZvARiVIY95QwilG8gHWldKRdadNEYahxymh0dgpcqax/l1EJEzQ== X-Received: by 2002:a05:620a:1aa7:: with SMTP id bl39mr18897995qkb.304.1629902396560; Wed, 25 Aug 2021 07:39:56 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Subject: [RESEND PATCH v3 1/5] spapr_numa.c: split FORM1 code into helpers Date: Wed, 25 Aug 2021 11:39:39 -0300 Message-Id: <20210825143943.529733-2-danielhb413@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210825143943.529733-1-danielhb413@gmail.com> References: <20210825143943.529733-1-danielhb413@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::735; envelope-from=danielhb413@gmail.com; helo=mail-qk1-x735.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daniel Henrique Barboza , qemu-ppc@nongnu.org, groug@kaod.org, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1629902475152100001 Content-Type: text/plain; charset="utf-8" The upcoming FORM2 NUMA affinity will support asymmetric NUMA topologies and doesn't need be concerned with all the legacy support for older pseries FORM1 guests. We're also not going to calculate associativity domains based on numa distance (via spapr_numa_define_associativity_domains) since the distances will be written directly into new DT properties. Let's split FORM1 code into its own functions to allow for easier insertion of FORM2 logic later on. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Greg Kurz --- hw/ppc/spapr_numa.c | 61 +++++++++++++++++++++++++++++---------------- 1 file changed, 39 insertions(+), 22 deletions(-) diff --git a/hw/ppc/spapr_numa.c b/hw/ppc/spapr_numa.c index 779f18b994..04a86f9b5b 100644 --- a/hw/ppc/spapr_numa.c +++ b/hw/ppc/spapr_numa.c @@ -155,6 +155,32 @@ static void spapr_numa_define_associativity_domains(Sp= aprMachineState *spapr) =20 } =20 +/* + * Set NUMA machine state data based on FORM1 affinity semantics. + */ +static void spapr_numa_FORM1_affinity_init(SpaprMachineState *spapr, + MachineState *machine) +{ + bool using_legacy_numa =3D spapr_machine_using_legacy_numa(spapr); + + /* + * Legacy NUMA guests (pseries-5.1 and older, or guests with only + * 1 NUMA node) will not benefit from anything we're going to do + * after this point. + */ + if (using_legacy_numa) { + return; + } + + if (!spapr_numa_is_symmetrical(machine)) { + error_report("Asymmetrical NUMA topologies aren't supported " + "in the pSeries machine"); + exit(EXIT_FAILURE); + } + + spapr_numa_define_associativity_domains(spapr); +} + void spapr_numa_associativity_init(SpaprMachineState *spapr, MachineState *machine) { @@ -210,22 +236,7 @@ void spapr_numa_associativity_init(SpaprMachineState *= spapr, spapr->numa_assoc_array[i][MAX_DISTANCE_REF_POINTS] =3D cpu_to_be3= 2(i); } =20 - /* - * Legacy NUMA guests (pseries-5.1 and older, or guests with only - * 1 NUMA node) will not benefit from anything we're going to do - * after this point. - */ - if (using_legacy_numa) { - return; - } - - if (!spapr_numa_is_symmetrical(machine)) { - error_report("Asymmetrical NUMA topologies aren't supported " - "in the pSeries machine"); - exit(EXIT_FAILURE); - } - - spapr_numa_define_associativity_domains(spapr); + spapr_numa_FORM1_affinity_init(spapr, machine); } =20 void spapr_numa_write_associativity_dt(SpaprMachineState *spapr, void *fdt, @@ -302,12 +313,8 @@ int spapr_numa_write_assoc_lookup_arrays(SpaprMachineS= tate *spapr, void *fdt, return ret; } =20 -/* - * Helper that writes ibm,associativity-reference-points and - * max-associativity-domains in the RTAS pointed by @rtas - * in the DT @fdt. - */ -void spapr_numa_write_rtas_dt(SpaprMachineState *spapr, void *fdt, int rta= s) +static void spapr_numa_FORM1_write_rtas_dt(SpaprMachineState *spapr, + void *fdt, int rtas) { MachineState *ms =3D MACHINE(spapr); SpaprMachineClass *smc =3D SPAPR_MACHINE_GET_CLASS(spapr); @@ -365,6 +372,16 @@ void spapr_numa_write_rtas_dt(SpaprMachineState *spapr= , void *fdt, int rtas) maxdomains, sizeof(maxdomains))); } =20 +/* + * Helper that writes ibm,associativity-reference-points and + * max-associativity-domains in the RTAS pointed by @rtas + * in the DT @fdt. + */ +void spapr_numa_write_rtas_dt(SpaprMachineState *spapr, void *fdt, int rta= s) +{ + spapr_numa_FORM1_write_rtas_dt(spapr, fdt, rtas); +} + static target_ulong h_home_node_associativity(PowerPCCPU *cpu, SpaprMachineState *spapr, target_ulong opcode, --=20 2.31.1 From nobody Fri May 3 19:50:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1629902466906621.4648812642553; Wed, 25 Aug 2021 07:41:06 -0700 (PDT) Received: from localhost ([::1]:53688 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mIu5R-0001Y4-R7 for importer@patchew.org; Wed, 25 Aug 2021 10:41:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41968) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mIu4P-0007ii-NK; Wed, 25 Aug 2021 10:40:01 -0400 Received: from mail-qk1-x72b.google.com ([2607:f8b0:4864:20::72b]:41858) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mIu4N-00073g-UF; Wed, 25 Aug 2021 10:40:01 -0400 Received: by mail-qk1-x72b.google.com with SMTP id bk29so21626448qkb.8; Wed, 25 Aug 2021 07:39:59 -0700 (PDT) Received: from rekt.ihost.com ([177.197.96.186]) by smtp.gmail.com with ESMTPSA id 69sm129819qke.55.2021.08.25.07.39.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Aug 2021 07:39:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yOSCA/HZ/SuuAau7Y9wbZ/0p1CppJhBCkxM31XBlSf0=; b=UgjJEISimTZzathTN/ha772kQ9GXvAAGPMdmdH4amFHd4pQkeCZWKSa3Tnj4wsdL/o gGzwnN2ArraKIKnCsaxOnGi1WATh0DWkS41BEbp3JQeLczkfdjF5jSd+7uXFVacAPZzo qXhYPOSzph5EsItI6kOVSJsbyY2qiZNnLDeLS94ZcN14TIFj4qWXUVvIUpNTT2C0tyEW siz9euikdRt7arknSMddvxU9v8FtFH82EAZArYvG/atrF8Wupf3JkJzd9dOFips+hI77 crlQYH1vVJLkYPdYtH2pOd7x842qR6qlCn5JTIExPenixDAB2D6qt8wEgsS6knQVAFrc byMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yOSCA/HZ/SuuAau7Y9wbZ/0p1CppJhBCkxM31XBlSf0=; b=MjfLPgLHhm07tr5clJMN25DX1PQvgR1aTUpWjHDTjNNyecHaFL6SIWn7moOumq2a6H OhHw7BrE8tWRg6PYF6YfTON+dnHH5KzXC0kJMnEJXjUX28JLHom3iKL67f1We4h5zFbt IcgI4XwUMor1oOyqEb9xdzyl6XQU79tb0Cwawgbd0w2wfypDP/ZAtMibrzFDAmo645ap TymCeocTfrZpRGjaK/JwyCJ2sgwdZQMfoRRITKfRfAMZa6cS1llQ1+RCaLm7lfqepL+5 tgjzXYr1tJG1yQF70jp20Vdc+sxHBSSp2AVytXpzaozP8CrfBSvPMkwCkJnzZRHWu1c8 Q7lw== X-Gm-Message-State: AOAM533GFEcmHSQszU5DW9W/0d0mWHZb7G22JpD90tP/8bC9uUyK7L3F rmf9hewDGy1TOqMoSQMrO5x3uhISpgM= X-Google-Smtp-Source: ABdhPJz1N69JHD8X4Z6XmEdS30dYxwz9sz+c8ezJCMyRacuGWRYEQOOZUHxRPJs1X63WWOb+7VdJKw== X-Received: by 2002:a37:2754:: with SMTP id n81mr31736711qkn.297.1629902398407; Wed, 25 Aug 2021 07:39:58 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Subject: [RESEND PATCH v3 2/5] spapr: move NUMA data init to post-CAS Date: Wed, 25 Aug 2021 11:39:40 -0300 Message-Id: <20210825143943.529733-3-danielhb413@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210825143943.529733-1-danielhb413@gmail.com> References: <20210825143943.529733-1-danielhb413@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::72b; envelope-from=danielhb413@gmail.com; helo=mail-qk1-x72b.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daniel Henrique Barboza , qemu-ppc@nongnu.org, groug@kaod.org, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1629902467439100001 Content-Type: text/plain; charset="utf-8" The pSeries machine will support a new NUMA affinity form, FORM2. This new FORM will be negotiated via ibm,architecture-vec5 during CAS. All artifacts and assumptions that are currently on use for FORM1 affinity will be deprecated in a guest that chooses to use FORM2. This means that we're going to wait until CAS to determine whether we're going to use FORM1 and FORM2. This patch does that by moving all NUMA data init functions to post-CAS time. spapr_numa_associativity_init() is moved from spapr_machine_init() to do_client_architecture_support(). Straightforward change since the initialization of spapr->numa_assoc_array is transparent to the guest. spapr_numa_write_rtas_dt() is more complex. The function is called from spapr_dt_rtas(), which in turned is called by spapr_build_fdt(). spapr_build_fdt() is called in two places: spapr_machine_reset() and do_client_architecture_support(). This means that we're writing RTAS nodes with NUMA artifacts without going through CAS first, and then writing it again post CAS. This is not an issue because, at this moment, we always write the same FORM1 NUMA affinity properties in the DT. With the upcoming FORM2 support, we're now reliant on guest choice to decide what to write. The proposed solution is to change spapr_numa_write_rtas_dt() to not write the DT until we're post-CAS. This is a benign guest visible change (a well behaved guest wouldn't bother to read NUMA properties before CAs), but to be on the safe side, let's wrap it with a machine class flag to skip this logic unless we're running with the latest machine type. This also means that FORM2 support will not be available for older machine types. Signed-off-by: Daniel Henrique Barboza --- hw/ppc/spapr.c | 6 +++--- hw/ppc/spapr_hcall.c | 4 ++++ hw/ppc/spapr_numa.c | 11 +++++++++++ include/hw/ppc/spapr.h | 1 + 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 5459f9a7e9..d8363bda88 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2809,9 +2809,6 @@ static void spapr_machine_init(MachineState *machine) =20 spapr->gpu_numa_id =3D spapr_numa_initial_nvgpu_numa_id(machine); =20 - /* Init numa_assoc_array */ - spapr_numa_associativity_init(spapr, machine); - if ((!kvm_enabled() || kvmppc_has_cap_mmu_radix()) && ppc_type_check_compat(machine->cpu_type, CPU_POWERPC_LOGICAL_3_00,= 0, spapr->max_compat_pvr)) { @@ -4709,8 +4706,11 @@ DEFINE_SPAPR_MACHINE(6_1, "6.1", true); */ static void spapr_machine_6_0_class_options(MachineClass *mc) { + SpaprMachineClass *smc =3D SPAPR_MACHINE_CLASS(mc); + spapr_machine_6_1_class_options(mc); compat_props_add(mc->compat_props, hw_compat_6_0, hw_compat_6_0_len); + smc->pre_6_1_numa_affinity =3D true; } =20 DEFINE_SPAPR_MACHINE(6_0, "6.0", false); diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c index 0e9a5b2e40..1cc88716c1 100644 --- a/hw/ppc/spapr_hcall.c +++ b/hw/ppc/spapr_hcall.c @@ -11,6 +11,7 @@ #include "helper_regs.h" #include "hw/ppc/spapr.h" #include "hw/ppc/spapr_cpu_core.h" +#include "hw/ppc/spapr_numa.h" #include "mmu-hash64.h" #include "cpu-models.h" #include "trace.h" @@ -1197,6 +1198,9 @@ target_ulong do_client_architecture_support(PowerPCCP= U *cpu, spapr->cas_pre_isa3_guest =3D !spapr_ovec_test(ov1_guest, OV1_PPC_3_00= ); spapr_ovec_cleanup(ov1_guest); =20 + /* Init numa_assoc_array */ + spapr_numa_associativity_init(spapr, MACHINE(spapr)); + /* * Ensure the guest asks for an interrupt mode we support; * otherwise terminate the boot. diff --git a/hw/ppc/spapr_numa.c b/hw/ppc/spapr_numa.c index 04a86f9b5b..b0bd056546 100644 --- a/hw/ppc/spapr_numa.c +++ b/hw/ppc/spapr_numa.c @@ -379,6 +379,17 @@ static void spapr_numa_FORM1_write_rtas_dt(SpaprMachin= eState *spapr, */ void spapr_numa_write_rtas_dt(SpaprMachineState *spapr, void *fdt, int rta= s) { + SpaprMachineClass *smc =3D SPAPR_MACHINE_GET_CLASS(spapr); + + /* + * pre-6.1 machine types were writing RTAS information before + * CAS. Check if that's case before changing their existing + * behavior. + */ + if (spapr_ovec_empty(spapr->ov5_cas) && !smc->pre_6_1_numa_affinity) { + return; + } + spapr_numa_FORM1_write_rtas_dt(spapr, fdt, rtas); } =20 diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 637652ad16..068a29535a 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -145,6 +145,7 @@ struct SpaprMachineClass { hwaddr rma_limit; /* clamp the RMA to this size */ bool pre_5_1_assoc_refpoints; bool pre_5_2_numa_associativity; + bool pre_6_1_numa_affinity; =20 bool (*phb_placement)(SpaprMachineState *spapr, uint32_t index, uint64_t *buid, hwaddr *pio, --=20 2.31.1 From nobody Fri May 3 19:50:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1629902561477124.11629895386523; Wed, 25 Aug 2021 07:42:41 -0700 (PDT) Received: from localhost ([::1]:60280 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mIu6y-0005tp-AM for importer@patchew.org; Wed, 25 Aug 2021 10:42:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41990) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mIu4S-0007uA-Ib; Wed, 25 Aug 2021 10:40:04 -0400 Received: from mail-qk1-x732.google.com ([2607:f8b0:4864:20::732]:35839) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mIu4Q-00074l-2C; Wed, 25 Aug 2021 10:40:04 -0400 Received: by mail-qk1-x732.google.com with SMTP id 22so27394211qkg.2; Wed, 25 Aug 2021 07:40:01 -0700 (PDT) Received: from rekt.ihost.com ([177.197.96.186]) by smtp.gmail.com with ESMTPSA id 69sm129819qke.55.2021.08.25.07.39.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Aug 2021 07:40:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=owCZ35gtbPY8bBS59ZkdVXhAs9FpkCvk8rLNvjMOXYA=; b=mqxDnTiHyDlfDhL4ko76Nle9lfluV3aRCtzTLsl0jmM8pafSgsFc6eHrusHP4KQscu C9FWmrjxYroPGJIGDni3h33uK2PR/xSVQ87sVoRJ9yQyUIghLtykvfL7hKmvjfQSK78I CTezrKl/Zjrsxecct74GxGdEy4RaWi4H9DSUom17NtzMBHVZHNovAG4iqyp6UxzQvute t6mylYBqhShpanlJl77ZIafxTT1d94/h7NKRxWjabtjJMs5tDCIOqfuny5RdJm9U4Y/j wrd3fp9H1mKHpvDPp3/95Q7qqB0r74Ke9xwZ7AE3WiAKQmTCszSZFB9ZEF67qAp5Rxjm /pJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=owCZ35gtbPY8bBS59ZkdVXhAs9FpkCvk8rLNvjMOXYA=; b=Z4do1YlZzm4F+GwpEGzPRAiponDtRFcxzy1zNXfRVvYTH0Bv2pgLqg7F/5+0zwuKJk Q9W2OsfWALVsp1HAal/EVF6Jhcw/7+u57az+Rlw/z38NzaCZywHeUyz1nB1twf5YYR/d YJxxmoMz8K3cE6VtUDbObPloj+EnPjQwebM2Rd5cTsgGgZumWa0eY5frvvriILCmjEZr e6kJVZtySLuGwqmymhMg1AALQjd4nI0ncTAQW0f4RLabPeAiYa1sbGHQvqc2o8wf6wic Lpf9LIvrxVMFnvr4g0Vyks0mXLRsUCH5RPHYouh85Swhml0mXvEG45KX6nHlZMmVTzdb kbTQ== X-Gm-Message-State: AOAM531vH3bcJHLMcCxg3zxW8f7xKjx6uDMF2JspMzOZKo10EiG5ywhj 4fNL9Q7F+kZJKU5kl/Q7bgs9kFNAY1c= X-Google-Smtp-Source: ABdhPJx2As/xW30TtP60BhNha0MnNdYE6Up9ICe6jnsTiux/cuI41soH55UJpE1KH2wrX21hhV06/A== X-Received: by 2002:ae9:f70c:: with SMTP id s12mr32132684qkg.254.1629902400561; Wed, 25 Aug 2021 07:40:00 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Subject: [RESEND PATCH v3 3/5] spapr_numa.c: base FORM2 NUMA affinity support Date: Wed, 25 Aug 2021 11:39:41 -0300 Message-Id: <20210825143943.529733-4-danielhb413@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210825143943.529733-1-danielhb413@gmail.com> References: <20210825143943.529733-1-danielhb413@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::732; envelope-from=danielhb413@gmail.com; helo=mail-qk1-x732.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daniel Henrique Barboza , qemu-ppc@nongnu.org, groug@kaod.org, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1629902561849100001 Content-Type: text/plain; charset="utf-8" The main feature of FORM2 affinity support is the separation of NUMA distances from ibm,associativity information. This allows for a more flexible and straightforward NUMA distance assignment without relying on complex associations between several levels of NUMA via ibm,associativity matches. Another feature is its extensibility. This base support contains the facilities for NUMA distance assignment, but in the future more facilities will be added for latency, performance, bandwidth and so on. This patch implements the base FORM2 affinity support as follows: - the use of FORM2 associativity is indicated by using bit 2 of byte 5 of ibm,architecture-vec-5. A FORM2 aware guest can choose to use FORM1 or FORM2 affinity. Setting both forms will default to FORM2. We rely on CAS to decide what to write in the DT, so all writing is postponed until client architecture support is done. This also mean that we're not advertising FORM2 for pseries-6.0 and older machine versions to prevent guest visible changes; - ibm,associativity-reference-points has a new semantic. Instead of being used to calculate distances via NUMA levels, it's now used to indicate the primary domain index in the ibm,associativity domain of each resource. In our case it's set to {0x4}, matching the position where we already place logical_domain_id; - two new RTAS DT artifacts are introduced: ibm,numa-lookup-index-table and ibm,numa-distance-table. The index table is used to list all the NUMA logical domains of the platform, in ascending order, and allows for spartial NUMA configurations (although QEMU ATM doesn't support that). ibm,numa-distance-table is an array that contains all the distances from the first NUMA node to all other nodes, then the second NUMA node distances to all other nodes and so on; - spapr_post_load changes: since we're adding a new NUMA affinity that isn't compatible with the existing one, migration must be handled accordingly because we can't be certain of whether the guest went through CAS in the source. The solution chosen is to initiate the NUMA associativity data in spapr_post_load() unconditionally. The worst case would be to write the DT twice if the guest is in pre-CAS stage. Otherwise, we're making sure that a FORM1 guest will have the spapr->numa_assoc_array initialized with the proper information based on user distance, something that we're not doing with FORM2. Signed-off-by: Daniel Henrique Barboza --- hw/ppc/spapr.c | 21 ++++++ hw/ppc/spapr_numa.c | 127 +++++++++++++++++++++++++++++++++++- include/hw/ppc/spapr_ovec.h | 1 + 3 files changed, 148 insertions(+), 1 deletion(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index d8363bda88..69c7239c48 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1787,6 +1787,22 @@ static int spapr_post_load(void *opaque, int version= _id) return err; } =20 + /* + * NUMA data init is made in CAS time. There is no reliable + * way of telling whether the guest already went through CAS + * in the source due to how spapr_ov5_cas_needed works: a + * FORM1 guest can be migrated with ov5_cas empty regardless + * of going through CAS first. + * + * One solution is to always call numa_associativity_init. The + * downside is that a guest migrated before CAS will run + * numa_associativity_init again when going through it, but + * at least we're making sure spapr->numa_assoc_array will be + * initialized and hotplug operations won't fail in both before + * and after CAS migration cases. + */ + spapr_numa_associativity_init(spapr, MACHINE(spapr)); + return err; } =20 @@ -2753,6 +2769,11 @@ static void spapr_machine_init(MachineState *machine) =20 spapr_ovec_set(spapr->ov5, OV5_FORM1_AFFINITY); =20 + /* Do not advertise FORM2 support for pseries-6.0 and older */ + if (!smc->pre_6_1_numa_affinity) { + spapr_ovec_set(spapr->ov5, OV5_FORM2_AFFINITY); + } + /* advertise support for dedicated HP event source to guests */ if (spapr->use_hotplug_event_source) { spapr_ovec_set(spapr->ov5, OV5_HP_EVT); diff --git a/hw/ppc/spapr_numa.c b/hw/ppc/spapr_numa.c index b0bd056546..1c894bf877 100644 --- a/hw/ppc/spapr_numa.c +++ b/hw/ppc/spapr_numa.c @@ -202,6 +202,16 @@ void spapr_numa_associativity_init(SpaprMachineState *= spapr, spapr->numa_assoc_array[i][0] =3D cpu_to_be32(MAX_DISTANCE_REF_POI= NTS); spapr->numa_assoc_array[i][MAX_DISTANCE_REF_POINTS] =3D cpu_to_be3= 2(i); =20 + /* + * For FORM2 affinity the initialization above is enough. No + * need to fill non-zero NUMA nodes with node_id because + * there is no associativity domain match to calculate + * NUMA distances in FORM2. + */ + if (spapr_ovec_test(spapr->ov5_cas, OV5_FORM2_AFFINITY)) { + continue; + } + /* * Fill all associativity domains of non-zero NUMA nodes with * node_id. This is required because the default value (0) is @@ -236,7 +246,16 @@ void spapr_numa_associativity_init(SpaprMachineState *= spapr, spapr->numa_assoc_array[i][MAX_DISTANCE_REF_POINTS] =3D cpu_to_be3= 2(i); } =20 - spapr_numa_FORM1_affinity_init(spapr, machine); + /* + * We test for !FORM2 instead of testing for FORM1 because, + * as per spapr_ov5_cas_needed, setting FORM1 is not enough + * to get ov5_cas migrated, but setting FORM2 is. Since we're + * dealing with either FORM1 or FORM2, test for the option + * that is guaranteed to be set after a migration. + */ + if (!spapr_ovec_test(spapr->ov5_cas, OV5_FORM2_AFFINITY)) { + spapr_numa_FORM1_affinity_init(spapr, machine); + } } =20 void spapr_numa_write_associativity_dt(SpaprMachineState *spapr, void *fdt, @@ -313,6 +332,107 @@ int spapr_numa_write_assoc_lookup_arrays(SpaprMachine= State *spapr, void *fdt, return ret; } =20 +static void spapr_numa_FORM2_write_rtas_tables(SpaprMachineState *spapr, + void *fdt, int rtas) +{ + MachineState *ms =3D MACHINE(spapr); + NodeInfo *numa_info =3D ms->numa_state->nodes; + int nb_numa_nodes =3D ms->numa_state->num_nodes; + int distance_table_entries =3D nb_numa_nodes * nb_numa_nodes; + g_autofree uint32_t *lookup_index_table =3D NULL; + g_autofree uint32_t *distance_table =3D NULL; + int src, dst, i, distance_table_size; + uint8_t *node_distances; + + /* + * ibm,numa-lookup-index-table: array with length and a + * list of NUMA ids present in the guest. + */ + lookup_index_table =3D g_new0(uint32_t, nb_numa_nodes + 1); + lookup_index_table[0] =3D cpu_to_be32(nb_numa_nodes); + + for (i =3D 0; i < nb_numa_nodes; i++) { + lookup_index_table[i + 1] =3D cpu_to_be32(i); + } + + _FDT(fdt_setprop(fdt, rtas, "ibm,numa-lookup-index-table", + lookup_index_table, + (nb_numa_nodes + 1) * sizeof(uint32_t))); + + /* + * ibm,numa-distance-table: contains all node distances. First + * element is the size of the table as uint32, followed up + * by all the uint8 distances from the first NUMA node, then all + * distances from the second NUMA node and so on. + * + * ibm,numa-lookup-index-table is used by guest to navigate this + * array because NUMA ids can be sparse (node 0 is the first, + * node 8 is the second ...). + */ + distance_table =3D g_new0(uint32_t, distance_table_entries + 1); + distance_table[0] =3D cpu_to_be32(distance_table_entries); + + node_distances =3D (uint8_t *)&distance_table[1]; + i =3D 0; + + for (src =3D 0; src < nb_numa_nodes; src++) { + for (dst =3D 0; dst < nb_numa_nodes; dst++) { + node_distances[i++] =3D numa_info[src].distance[dst]; + } + } + + distance_table_size =3D distance_table_entries * sizeof(uint8_t) + + sizeof(uint32_t); + _FDT(fdt_setprop(fdt, rtas, "ibm,numa-distance-table", + distance_table, distance_table_size)); +} + +/* + * This helper could be compressed in a single function with + * FORM1 logic since we're setting the same DT values, with the + * difference being a call to spapr_numa_FORM2_write_rtas_tables() + * in the end. The separation was made to avoid clogging FORM1 code + * which already has to deal with compat modes from previous + * QEMU machine types. + */ +static void spapr_numa_FORM2_write_rtas_dt(SpaprMachineState *spapr, + void *fdt, int rtas) +{ + MachineState *ms =3D MACHINE(spapr); + uint32_t number_nvgpus_nodes =3D spapr->gpu_numa_id - + spapr_numa_initial_nvgpu_numa_id(ms); + + /* + * In FORM2, ibm,associativity-reference-points will point to + * the element in the ibm,associativity array that contains the + * primary domain index. This value (in our case, the numa-id) is + * then used as an index to retrieve all other attributes of the + * node (distance, bandwidth, latency) via ibm,numa-lookup-index-table + * and other ibm,numa-*-table properties. + */ + uint32_t refpoints[] =3D { + cpu_to_be32(0x4), + }; + + uint32_t nr_refpoints =3D ARRAY_SIZE(refpoints); + uint32_t maxdomain =3D ms->numa_state->num_nodes + number_nvgpus_nodes; + uint32_t maxdomains[] =3D { + cpu_to_be32(4), + cpu_to_be32(maxdomain), + cpu_to_be32(maxdomain), + cpu_to_be32(maxdomain), + cpu_to_be32(maxdomain) + }; + + _FDT(fdt_setprop(fdt, rtas, "ibm,associativity-reference-points", + refpoints, nr_refpoints * sizeof(refpoints[0]))); + + _FDT(fdt_setprop(fdt, rtas, "ibm,max-associativity-domains", + maxdomains, sizeof(maxdomains))); + + spapr_numa_FORM2_write_rtas_tables(spapr, fdt, rtas); +} + static void spapr_numa_FORM1_write_rtas_dt(SpaprMachineState *spapr, void *fdt, int rtas) { @@ -390,6 +510,11 @@ void spapr_numa_write_rtas_dt(SpaprMachineState *spapr= , void *fdt, int rtas) return; } =20 + if (spapr_ovec_test(spapr->ov5_cas, OV5_FORM2_AFFINITY)) { + spapr_numa_FORM2_write_rtas_dt(spapr, fdt, rtas); + return; + } + spapr_numa_FORM1_write_rtas_dt(spapr, fdt, rtas); } =20 diff --git a/include/hw/ppc/spapr_ovec.h b/include/hw/ppc/spapr_ovec.h index 48b716a060..c3e8b98e7e 100644 --- a/include/hw/ppc/spapr_ovec.h +++ b/include/hw/ppc/spapr_ovec.h @@ -49,6 +49,7 @@ typedef struct SpaprOptionVector SpaprOptionVector; /* option vector 5 */ #define OV5_DRCONF_MEMORY OV_BIT(2, 2) #define OV5_FORM1_AFFINITY OV_BIT(5, 0) +#define OV5_FORM2_AFFINITY OV_BIT(5, 2) #define OV5_HP_EVT OV_BIT(6, 5) #define OV5_HPT_RESIZE OV_BIT(6, 7) #define OV5_DRMEM_V2 OV_BIT(22, 0) --=20 2.31.1 From nobody Fri May 3 19:50:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1629902565004871.3089241958962; Wed, 25 Aug 2021 07:42:45 -0700 (PDT) Received: from localhost ([::1]:60560 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mIu71-00064y-RB for importer@patchew.org; Wed, 25 Aug 2021 10:42:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42002) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mIu4U-0007zW-1M; Wed, 25 Aug 2021 10:40:06 -0400 Received: from mail-qk1-x72e.google.com ([2607:f8b0:4864:20::72e]:45894) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mIu4S-00076Q-93; Wed, 25 Aug 2021 10:40:05 -0400 Received: by mail-qk1-x72e.google.com with SMTP id a10so18493331qka.12; Wed, 25 Aug 2021 07:40:03 -0700 (PDT) Received: from rekt.ihost.com ([177.197.96.186]) by smtp.gmail.com with ESMTPSA id 69sm129819qke.55.2021.08.25.07.40.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Aug 2021 07:40:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jajBmL3t0iOiGu48aSFaJh0GfM64YIjgMN3vMvlSCrM=; b=uAw+FcT6HFCAoANBZ3DWRuE/g6xobCwbCEUNwEmGdzI5OoFJxGCTMym2OPNPAbDgcb Xly34JxyWfegZXdNyJhNE+/5WaL5+8+TtHPklniaHoR0FZTolJLQiRTWQ4oDJ/qDna31 yARK3a3071eICkF6bzECGXrKr4SuU5/yxT7ai+woCCoUfmw55jpLAMjv1KLzRy4VGRk6 CRQl9BmLOkxcpySsoUn+OR35iiVhFcxoWZQIWId6Jw3DNoSEX55iBGUtuX/fvq5IB2rf pbc0QxJPJclPJWib1k6EhP2RyN2hORreRDjoY0FXlSDUFyG43qC30oLkttvwqAV//5oD A6Ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jajBmL3t0iOiGu48aSFaJh0GfM64YIjgMN3vMvlSCrM=; b=jiQH/Z7BkY6yM0197CWeUSjmh90SfDB025f9u85BfD/B3meudKv/O145mIluFaLyAU XdNY9yw2SZyyXvSh6+tm1x6WLDG6tQ++RyHm7nN+yE9gk/toc0rKNi/mkRSTtixFYNq/ bKlrsOzd+/aqugX2mxBeW29FGhOn34Izjs/8McE97lKgu30YOoDluq9BjZuQDVQs44X7 hxC/bvW71EpIwLi5xTShuDcXLcvXc9Ld9k9svPF8iyDlpRcNd0ZwoW1ThxgYJa/pfry+ a46Suwege/a0dfOrNk3O2xzd5kebDtUwEXwZTNS+ffDXHPBO0hx3wPmwTKLyzHo2XL8j 9Lig== X-Gm-Message-State: AOAM531IDsw0/CuH6K2b0zkKpLzYcreEbioqKXfs7Yq0GUvvHypEaqav NJhGS+lf/GYfzIPI4yX5CMxWHBRSdIU= X-Google-Smtp-Source: ABdhPJyAyvUnFlTxmnECslHlWs+Cw793unHPrtmYInE7IR56NKn4FyBfTYD6gntE/4sLqZDyieiB3A== X-Received: by 2002:a05:620a:1379:: with SMTP id d25mr32653014qkl.238.1629902402703; Wed, 25 Aug 2021 07:40:02 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Subject: [RESEND PATCH v3 4/5] spapr: simplify spapr_numa_associativity_init params Date: Wed, 25 Aug 2021 11:39:42 -0300 Message-Id: <20210825143943.529733-5-danielhb413@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210825143943.529733-1-danielhb413@gmail.com> References: <20210825143943.529733-1-danielhb413@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::72e; envelope-from=danielhb413@gmail.com; helo=mail-qk1-x72e.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daniel Henrique Barboza , qemu-ppc@nongnu.org, groug@kaod.org, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1629902566164100001 Content-Type: text/plain; charset="utf-8" When spapr_numa_associativity_init() was introduced it was being called from spapr_machine_init(), where we have pointers to a SpaprMachineState and a MachineState. Having both being passed as params spared us from calling a macro to get the MachineState. Previous patches moved the function away from spapr_machine_init(), and the new locations doesn't have a pointer to MachineState ready. This resulted in MACHINE(spapr) macro calls as the second parameter in both callers. Simplify the function by folding the 'MACHINE(spapr)' macro into the function body, which can now receive only a pointer to SpaprMachineState. Signed-off-by: Daniel Henrique Barboza --- hw/ppc/spapr.c | 2 +- hw/ppc/spapr_hcall.c | 2 +- hw/ppc/spapr_numa.c | 4 ++-- include/hw/ppc/spapr_numa.h | 3 +-- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 69c7239c48..7ea7605abf 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1801,7 +1801,7 @@ static int spapr_post_load(void *opaque, int version_= id) * initialized and hotplug operations won't fail in both before * and after CAS migration cases. */ - spapr_numa_associativity_init(spapr, MACHINE(spapr)); + spapr_numa_associativity_init(spapr); =20 return err; } diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c index 1cc88716c1..a721d3edce 100644 --- a/hw/ppc/spapr_hcall.c +++ b/hw/ppc/spapr_hcall.c @@ -1199,7 +1199,7 @@ target_ulong do_client_architecture_support(PowerPCCP= U *cpu, spapr_ovec_cleanup(ov1_guest); =20 /* Init numa_assoc_array */ - spapr_numa_associativity_init(spapr, MACHINE(spapr)); + spapr_numa_associativity_init(spapr); =20 /* * Ensure the guest asks for an interrupt mode we support; diff --git a/hw/ppc/spapr_numa.c b/hw/ppc/spapr_numa.c index 1c894bf877..bba5a984e4 100644 --- a/hw/ppc/spapr_numa.c +++ b/hw/ppc/spapr_numa.c @@ -181,9 +181,9 @@ static void spapr_numa_FORM1_affinity_init(SpaprMachine= State *spapr, spapr_numa_define_associativity_domains(spapr); } =20 -void spapr_numa_associativity_init(SpaprMachineState *spapr, - MachineState *machine) +void spapr_numa_associativity_init(SpaprMachineState *spapr) { + MachineState *machine =3D MACHINE(spapr); SpaprMachineClass *smc =3D SPAPR_MACHINE_GET_CLASS(spapr); int nb_numa_nodes =3D machine->numa_state->num_nodes; int i, j, max_nodes_with_gpus; diff --git a/include/hw/ppc/spapr_numa.h b/include/hw/ppc/spapr_numa.h index 6f9f02d3de..adaec8e163 100644 --- a/include/hw/ppc/spapr_numa.h +++ b/include/hw/ppc/spapr_numa.h @@ -22,8 +22,7 @@ * function. spapr_machine_init() is the only caller for it, and * it has both pointers resolved already. */ -void spapr_numa_associativity_init(SpaprMachineState *spapr, - MachineState *machine); +void spapr_numa_associativity_init(SpaprMachineState *spapr); void spapr_numa_write_rtas_dt(SpaprMachineState *spapr, void *fdt, int rta= s); void spapr_numa_write_associativity_dt(SpaprMachineState *spapr, void *fdt, int offset, int nodeid); --=20 2.31.1 From nobody Fri May 3 19:50:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1629902647820180.60233802585174; Wed, 25 Aug 2021 07:44:07 -0700 (PDT) Received: from localhost ([::1]:37680 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mIu8M-0001DI-Ix for importer@patchew.org; Wed, 25 Aug 2021 10:44:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42026) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mIu4W-00088X-9E; Wed, 25 Aug 2021 10:40:08 -0400 Received: from mail-qk1-x72a.google.com ([2607:f8b0:4864:20::72a]:39704) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mIu4U-00077J-Ju; Wed, 25 Aug 2021 10:40:08 -0400 Received: by mail-qk1-x72a.google.com with SMTP id y144so27388022qkb.6; Wed, 25 Aug 2021 07:40:05 -0700 (PDT) Received: from rekt.ihost.com ([177.197.96.186]) by smtp.gmail.com with ESMTPSA id 69sm129819qke.55.2021.08.25.07.40.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Aug 2021 07:40:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7k8OYciL/eUBwAke7lRKwvBq4ud894thIDkNUi64C5k=; b=n9bZG7A+DWfueGGcbftopfivsnhnNk3uHPLsutvJkyhnFTeb6UK4MsWdMJbnchhceO UW3Pp8sRwj/OcE4V0oCUt3GikM+O9NNfwtfhgre7E3YDzSXIbZC3NCfr6Rcpqz67TjDm h+nw4Qre6MTW6ufe2DZndBqM74Heu0KPq4QMr5tFpzxxjRsZyuXWo8v4Wn5dcOSZJkdx bdGSCmEROqVfYWtYNUDNJhjF8ZjDOU/uYEeihS2Xb0SxXTVTlKARePFdjnbBS1vS9uTB xj3VrT7wfbnHA+QVGTgxWPXGtphrBpj95ebvIsTarkRVzcVoqfCfemMnYhj3CLr5lnE1 VEQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7k8OYciL/eUBwAke7lRKwvBq4ud894thIDkNUi64C5k=; b=PvtFf6ZGb8QHJFr1Abcm8hrr6JyocJWimakk/uKJPUm6ke/WZaTKdw9DohSFZzwB7g wX5CwOFivPfJItKSOrsNFl5o2Ro+NxG9tn5nv5r9Er9qJFyqvcKmAaNnjOM9c9ijCBmP G4Ld6DR7iZEAczgtBMUxfrPhBp5nD60PfeGC30ecRVRlpvKQm6nrEn09C6Ps02E5CTvG ww6MMURZBTA8ISFgUB6GofYP/Jr6WMbHn9Yo7sVLdkk6ZnStWl5IXK0OjJi42QDLD4Ol EEVlmEIrBdGPhBaJPz9nJBI09XCMeUkbGQNK69AUbthNjTusgdmieFAfHW4BZUQSrSCv AFDg== X-Gm-Message-State: AOAM530sxEaSYCSLHU/mj6idrozxwydZYlNxSyyTqE7GWSLUFLlJnGaw HWx/4SsflIItTc9CYcv2BrOHA0t6xyQ= X-Google-Smtp-Source: ABdhPJytzhwSiH4OBQQvOwCrAQfcZOYSdd9q29DzLibVXmyJ5LkmHMkudt7zDIXrdYoheJIbTfU6vA== X-Received: by 2002:a37:a80c:: with SMTP id r12mr31385930qke.299.1629902404768; Wed, 25 Aug 2021 07:40:04 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Subject: [RESEND PATCH v3 5/5] spapr: move memory/cpu less check to spapr_numa_FORM1_affinity_init() Date: Wed, 25 Aug 2021 11:39:43 -0300 Message-Id: <20210825143943.529733-6-danielhb413@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210825143943.529733-1-danielhb413@gmail.com> References: <20210825143943.529733-1-danielhb413@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::72a; envelope-from=danielhb413@gmail.com; helo=mail-qk1-x72a.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daniel Henrique Barboza , qemu-ppc@nongnu.org, groug@kaod.org, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1629902648772100001 Content-Type: text/plain; charset="utf-8" FORM2 NUMA affinity is prepared to deal with memory/cpu less NUMA nodes. This is used by the DAX KMEM driver to locate a PAPR SCM device that has a different latency than the original NUMA node from the regular memory. Move this verification to FORM1 affinity code. Signed-off-by: Daniel Henrique Barboza --- hw/ppc/spapr.c | 33 --------------------------------- hw/ppc/spapr_numa.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 7ea7605abf..3605472445 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2795,39 +2795,6 @@ static void spapr_machine_init(MachineState *machine) /* init CPUs */ spapr_init_cpus(spapr); =20 - /* - * check we don't have a memory-less/cpu-less NUMA node - * Firmware relies on the existing memory/cpu topology to provide the - * NUMA topology to the kernel. - * And the linux kernel needs to know the NUMA topology at start - * to be able to hotplug CPUs later. - */ - if (machine->numa_state->num_nodes) { - for (i =3D 0; i < machine->numa_state->num_nodes; ++i) { - /* check for memory-less node */ - if (machine->numa_state->nodes[i].node_mem =3D=3D 0) { - CPUState *cs; - int found =3D 0; - /* check for cpu-less node */ - CPU_FOREACH(cs) { - PowerPCCPU *cpu =3D POWERPC_CPU(cs); - if (cpu->node_id =3D=3D i) { - found =3D 1; - break; - } - } - /* memory-less and cpu-less node */ - if (!found) { - error_report( - "Memory-less/cpu-less nodes are not supported (node= %d)", - i); - exit(1); - } - } - } - - } - spapr->gpu_numa_id =3D spapr_numa_initial_nvgpu_numa_id(machine); =20 if ((!kvm_enabled() || kvmppc_has_cap_mmu_radix()) && diff --git a/hw/ppc/spapr_numa.c b/hw/ppc/spapr_numa.c index bba5a984e4..98740c732d 100644 --- a/hw/ppc/spapr_numa.c +++ b/hw/ppc/spapr_numa.c @@ -162,6 +162,39 @@ static void spapr_numa_FORM1_affinity_init(SpaprMachin= eState *spapr, MachineState *machine) { bool using_legacy_numa =3D spapr_machine_using_legacy_numa(spapr); + int i; + + /* + * check we don't have a memory-less/cpu-less NUMA node + * Firmware relies on the existing memory/cpu topology to provide the + * NUMA topology to the kernel. + * And the linux kernel needs to know the NUMA topology at start + * to be able to hotplug CPUs later. + */ + if (machine->numa_state->num_nodes) { + for (i =3D 0; i < machine->numa_state->num_nodes; ++i) { + /* check for memory-less node */ + if (machine->numa_state->nodes[i].node_mem =3D=3D 0) { + CPUState *cs; + int found =3D 0; + /* check for cpu-less node */ + CPU_FOREACH(cs) { + PowerPCCPU *cpu =3D POWERPC_CPU(cs); + if (cpu->node_id =3D=3D i) { + found =3D 1; + break; + } + } + /* memory-less and cpu-less node */ + if (!found) { + error_report( + "Memory-less/cpu-less nodes are not supported (node= %d)", + i); + exit(1); + } + } + } + } =20 /* * Legacy NUMA guests (pseries-5.1 and older, or guests with only --=20 2.31.1