From nobody Wed May 15 08:20:03 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 ARC-Seal: i=1; a=rsa-sha256; t=1600890006; cv=none; d=zohomail.com; s=zohoarc; b=YNG+VeVRLQvOnG0AyA5GM5kMr1sWjWMyhTc2PqwXW3/3F+1Zo6zsp2/W90pND1MLS5KoD7uWdABz5WmAP1NRVcQy2AI7j8e9A9x1mtMPhAYxpmw8JqxewdDZGwOgP1/YJiSB7HdvyPcI7WUrKeACd4K7F3dbTIGOpYs29/XGPKM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600890006; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3Pb2Hls/e8P7amLmEaCt/vqVuaxBFgGmr0SvcjklXJA=; b=PkjAaW1GJd7lzkuXljiKHYVxu0FpSaDOevsVgYAxglvaBPqoqtnkIdQNoyROtE4d30+xAQJc7vBVOP6sros2KSp+iByoCKqLWTHS2bm6hfuhfeSupx6cRDS7vVM+ucXqIBderEc3+kYpNtKw0sxU/il05RSvQx8K33Rc4Tn8psQ= ARC-Authentication-Results: i=1; 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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600890006056689.6875455583572; Wed, 23 Sep 2020 12:40:06 -0700 (PDT) Received: from localhost ([::1]:35292 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLAcW-0007f5-Ot for importer@patchew.org; Wed, 23 Sep 2020 15:40:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39584) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLAXs-0002bD-0W; Wed, 23 Sep 2020 15:35:16 -0400 Received: from mail-qk1-x729.google.com ([2607:f8b0:4864:20::729]:40527) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kLAXq-0008VG-2f; Wed, 23 Sep 2020 15:35:15 -0400 Received: by mail-qk1-x729.google.com with SMTP id w16so902578qkj.7; Wed, 23 Sep 2020 12:35:13 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:431:c7c7:9e50:6b84:53b8:5d9d:d408]) by smtp.gmail.com with ESMTPSA id u4sm612362qkk.68.2020.09.23.12.35.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Sep 2020 12:35:08 -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=3Pb2Hls/e8P7amLmEaCt/vqVuaxBFgGmr0SvcjklXJA=; b=hnFr3GD/OeaKVVZLyNDoUlj1EdQsYKWBbUI+IdYO8JYr+uqCwDHMMTwqb3DyBREul7 OY7Knu+II9UvXQwVI5t1JRs2CPs5IrQy1VQ5x5njTRvFJZYrLzCNxWdj2yP9msEO+y9o 8DBZSvYN0qIl+TDoDwBPCPPFxaRpkKX1TC5KLhJMXXb2stEsiUGAikDYIQvGqc4VSyXS WOqxGiL6tpy9twM6Jcu5TNE6NrawYlZi06Hkl2ZeFiSZjJ/dQom6SN5BMsDV3pldJfQd F/0lDMez6CrTiaxt+GV4YNq9QQBO1zgdbHgyK87ksG0Son2GvKqA8i6zSs8qLP8SqHzH 71PA== 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=3Pb2Hls/e8P7amLmEaCt/vqVuaxBFgGmr0SvcjklXJA=; b=sETwo8Jy5oPzuIFhsp1yRvVuTXqO7VSK1gFf3CLdQjJH74SUJguChkdlk+zkDMZTQG Ykv6an7Lp4516rQjTZIkU4UPOnkT3Uc4B/XsOJZryou7WouVSFfhmk/+9Mc0sNS2H4J3 Pt3G5soOPihFmqnUd9rP6R3BJRmHTuPzesNnHthRbUOinR1yzkeTd0oq6G1BKYMjOJ+O VsNirM1wmUUxijO/BS43/qlBkxBCvpH45NDn6PbDinOUApILkXUFf/FKRNt4JIg4OcF8 y0cM38iX82Y6Bl5elDShtqHllDynhfB2l5EHgDh7O6hcjuooVrUKHwIbAlqbdb0P49WA BAKA== X-Gm-Message-State: AOAM531oz2d5d9IChZM7jJQe0AOXxUSj6/sWZSfzJgYsOojhytFUbzmR rHDD0FO/IDquJIQsxr1U0THIxdnzXcmjGw== X-Google-Smtp-Source: ABdhPJwnuzciQgbf8B0kvcdSAsie8Po5lBusFMYMFuc4hZMa3M42i3xsg4/LpNGaIIrGnJCVjZyqhg== X-Received: by 2002:a37:d207:: with SMTP id f7mr1476639qkj.302.1600889712031; Wed, 23 Sep 2020 12:35:12 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Subject: [PATCH 1/6] spapr: add spapr_machine_using_legacy_numa() helper Date: Wed, 23 Sep 2020 16:34:53 -0300 Message-Id: <20200923193458.203186-2-danielhb413@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200923193458.203186-1-danielhb413@gmail.com> References: <20200923193458.203186-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::729; envelope-from=danielhb413@gmail.com; helo=mail-qk1-x729.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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, 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) Content-Type: text/plain; charset="utf-8" The changes to come to NUMA support are all guest visible. In theory we could just create a new 5_1 class option flag to avoid the changes to cascade to 5.1 and under. The reality is that these changes are only relevant if the machine has more than one NUMA node. There is no need to change guest behavior that has been around for years needlesly. This new helper will be used by the next patches to determine whether we should retain the (soon to be) legacy NUMA behavior in the pSeries machine. The new behavior will only be exposed if: - machine is pseries-5.2 and newer; - more than one NUMA node is declared in NUMA state. Reviewed-by: David Gibson Signed-off-by: Daniel Henrique Barboza Reviewed-by: Greg Kurz --- hw/ppc/spapr.c | 12 ++++++++++++ include/hw/ppc/spapr.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index e813c7cfb9..c5d8910a74 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -294,6 +294,15 @@ static hwaddr spapr_node0_size(MachineState *machine) return machine->ram_size; } =20 +bool spapr_machine_using_legacy_numa(SpaprMachineState *spapr) +{ + MachineState *machine =3D MACHINE(spapr); + SpaprMachineClass *smc =3D SPAPR_MACHINE_GET_CLASS(machine); + + return smc->pre_5_2_numa_associativity || + machine->numa_state->num_nodes <=3D 1; +} + static void add_str(GString *s, const gchar *s1) { g_string_append_len(s, s1, strlen(s1) + 1); @@ -4522,8 +4531,11 @@ DEFINE_SPAPR_MACHINE(5_2, "5.2", true); */ static void spapr_machine_5_1_class_options(MachineClass *mc) { + SpaprMachineClass *smc =3D SPAPR_MACHINE_CLASS(mc); + spapr_machine_5_2_class_options(mc); compat_props_add(mc->compat_props, hw_compat_5_1, hw_compat_5_1_len); + smc->pre_5_2_numa_associativity =3D true; } =20 DEFINE_SPAPR_MACHINE(5_1, "5.1", false); diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 114e819969..d1aae03b97 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -143,6 +143,7 @@ struct SpaprMachineClass { bool smp_threads_vsmt; /* set VSMT to smp_threads by default */ hwaddr rma_limit; /* clamp the RMA to this size */ bool pre_5_1_assoc_refpoints; + bool pre_5_2_numa_associativity; =20 void (*phb_placement)(SpaprMachineState *spapr, uint32_t index, uint64_t *buid, hwaddr *pio,=20 @@ -860,6 +861,7 @@ int spapr_max_server_number(SpaprMachineState *spapr); void spapr_store_hpte(PowerPCCPU *cpu, hwaddr ptex, uint64_t pte0, uint64_t pte1); void spapr_mce_req_event(PowerPCCPU *cpu, bool recovered); +bool spapr_machine_using_legacy_numa(SpaprMachineState *spapr); =20 /* DRC callbacks. */ void spapr_core_release(DeviceState *dev); --=20 2.26.2 From nobody Wed May 15 08:20:03 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 ARC-Seal: i=1; a=rsa-sha256; t=1600889851; cv=none; d=zohomail.com; s=zohoarc; b=FoKyhW0Azak7z/72h9QSh/ZDYVM+cCqXVfRqUuCp5mbZqfQUtFfuH9StlxXDUqAAsYUmAX2Q+3DSg1lHNk1KxAI/cUffO6FIcwNRxpb7e14njYfJdkcLgJyxqkFvUVyLifsYZ8sVfp3+2eBVr30TVrdRG8DuO52MyyJG08k+u7U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600889851; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=SwOEQO9kfmA7oDtZYIo2rP0M5TYu31XtL4UeyeKcFpc=; b=R/p6TIK2sljJaIbKaVfvDlvj0Fi6VIzcAUtoEh7bfS8fcPO1Vwf4dWDNJSnmQCkO9Ngnk4NMq0MOHMTCtClWM3kZmq7pBvygEoJDUnXwymXOcAIbA0puYHyvs699BoBlgiLkDelUahu+GcUBMibOAfbUlWQ2N3mWc90WM0CcTdo= ARC-Authentication-Results: i=1; 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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600889851247920.6705119464312; Wed, 23 Sep 2020 12:37:31 -0700 (PDT) Received: from localhost ([::1]:56020 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLAa1-0004Vq-S8 for importer@patchew.org; Wed, 23 Sep 2020 15:37:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39654) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLAXz-0002fA-Ua; Wed, 23 Sep 2020 15:35:24 -0400 Received: from mail-qv1-xf44.google.com ([2607:f8b0:4864:20::f44]:33335) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kLAXw-0008Vt-ET; Wed, 23 Sep 2020 15:35:23 -0400 Received: by mail-qv1-xf44.google.com with SMTP id cy2so629021qvb.0; Wed, 23 Sep 2020 12:35:17 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:431:c7c7:9e50:6b84:53b8:5d9d:d408]) by smtp.gmail.com with ESMTPSA id u4sm612362qkk.68.2020.09.23.12.35.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Sep 2020 12:35:13 -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=SwOEQO9kfmA7oDtZYIo2rP0M5TYu31XtL4UeyeKcFpc=; b=mmAPIDtkKngGrxtBlFhT2+YqOx45oxRGI1Osh0+Lp5aqJ8e3l3QlI7SE9ozZZuSBIf cCk5uca/ZFpEElObLnyeG5gU3zjRn1UoF5fjfWB01/ESia3/JLzGpDVoSS8ESwL/6fcb C2QvmAofIIoE5Us/bbleEG3iZTlmOkrnzJcjSqfNmnowXTv8IAgOrcl0DREfGREkwh3W 2Uc1YhRUVf2ctYvpGx0IRESgbB9QxJtUJVYTZKod9iXGmrl7mgWDNS3a5pBPAcDtzWrd LcH6qY3K6q6yg6E/DhXSHtxEG4AtLpdn8jfZNO/R0bG+EwJ/3mgESNOW8MkddnDyIyJB LjYA== 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=SwOEQO9kfmA7oDtZYIo2rP0M5TYu31XtL4UeyeKcFpc=; b=JumQjohF8HRDfNtV6C/kat0LWZDjHbeESzzaFfp3SuKv2KOSNPUA/E0G/+9tA6waNs il6q2LmVU3QAbyEGppoT5CJDzgOBQ9jJhO/40+Uq2VwOEcKgWD4TJmXAbxnOh9GIV0HZ V0pSb6cEJ80lCGipXj3GWpj/l/ZejZ418gS5UjcJwMb4a79fVyBmuKqym61kB3wm8pqi a8pPuRqAoEFn2KZ4/zK8o7Tq8X8L4SWI46Uutj2OXn3jxX6dcoEFVLEv6jV1xhFIuaU7 xebg//GZ9LUW4LGb3k7Kjz3Y+uNLjaD96hudOj09EGubxCUD59q0A29lYbPlez8oyWBT bw5w== X-Gm-Message-State: AOAM532vuPGTb3J5JPIqxhktFyUkhaANovYMxXyfo3YHPTX7RX/rO8J+ TPYewbhZV0Rzv63LXVYL0MKCfbVjvm+5Jw== X-Google-Smtp-Source: ABdhPJzTEhh56p2Boz2N56BdY0D+nuWeHd4fC5j/JNAAltllKilcPgYZsaqsJ4/UaHrYs59XnOEJcg== X-Received: by 2002:ad4:5387:: with SMTP id i7mr1611045qvv.43.1600889716798; Wed, 23 Sep 2020 12:35:16 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Subject: [PATCH 2/6] spapr_numa: forbid asymmetrical NUMA setups Date: Wed, 23 Sep 2020 16:34:54 -0300 Message-Id: <20200923193458.203186-3-danielhb413@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200923193458.203186-1-danielhb413@gmail.com> References: <20200923193458.203186-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::f44; envelope-from=danielhb413@gmail.com; helo=mail-qv1-xf44.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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, 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) Content-Type: text/plain; charset="utf-8" The pSeries machine does not support asymmetrical NUMA configurations. This doesn't make much of a different since we're not using user input for pSeries NUMA setup, but this will change in the next patches. To avoid breaking existing setups, gate this change by checking for legacy NUMA support. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Greg Kurz --- hw/ppc/spapr_numa.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/hw/ppc/spapr_numa.c b/hw/ppc/spapr_numa.c index 64fe567f5d..36aaa273ee 100644 --- a/hw/ppc/spapr_numa.c +++ b/hw/ppc/spapr_numa.c @@ -19,6 +19,24 @@ /* Moved from hw/ppc/spapr_pci_nvlink2.c */ #define SPAPR_GPU_NUMA_ID (cpu_to_be32(1)) =20 +static bool spapr_numa_is_symmetrical(MachineState *ms) +{ + int src, dst; + int nb_numa_nodes =3D ms->numa_state->num_nodes; + NodeInfo *numa_info =3D ms->numa_state->nodes; + + for (src =3D 0; src < nb_numa_nodes; src++) { + for (dst =3D src; dst < nb_numa_nodes; dst++) { + if (numa_info[src].distance[dst] !=3D + numa_info[dst].distance[src]) { + return false; + } + } + } + + return true; +} + void spapr_numa_associativity_init(SpaprMachineState *spapr, MachineState *machine) { @@ -61,6 +79,22 @@ void spapr_numa_associativity_init(SpaprMachineState *sp= apr, =20 spapr->numa_assoc_array[i][MAX_DISTANCE_REF_POINTS] =3D cpu_to_be3= 2(i); } + + /* + * Legacy NUMA guests (pseries-5.1 and order, or guests with only + * 1 NUMA node) will not benefit from anything we're going to do + * after this point. + */ + if (spapr_machine_using_legacy_numa(spapr)) { + return; + } + + if (!spapr_numa_is_symmetrical(machine)) { + error_report("Asymmetrical NUMA topologies aren't supported " + "in the pSeries machine"); + exit(1); + } + } =20 void spapr_numa_write_associativity_dt(SpaprMachineState *spapr, void *fdt, --=20 2.26.2 From nobody Wed May 15 08:20:03 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 ARC-Seal: i=1; a=rsa-sha256; t=1600890005; cv=none; d=zohomail.com; s=zohoarc; b=jdHijvDUcVALtMc+VYR4P19vLhB5KuiEOKD7Sq5/8l/8aPq0uwiU7hxkxA0TK9AOqTPoA5/2MtlmN7tSexHaccFH9kYIV5fGHT25M9VjfAgnYsuZ61y4ACUCj/AcjW1vOmf3fZuWQNj3SjqmohbF9j1SjXMevxDFpSLLvgYDbPA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600890005; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=2BOBuZbC65SYlx/sk/v7p8L/zpIOl98wNdQzFPXYVBQ=; b=hl3z7LzzRxtvDWxSgYA7IQyv7OWPX3DD1BHM2vSIKIjg6YO7Kdxhw9rMSldhFpus5tpEytblZbLIxMJKAmIe2NK3YzkgFBDo2spSKSXwtK7nGmenn1joCC/Tb2vLzQ4O7qqQpgb5pqQUUxF7lxl/qNZm0s/Acw7DcKta39USmuM= ARC-Authentication-Results: i=1; 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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600890005586980.7420846795454; Wed, 23 Sep 2020 12:40:05 -0700 (PDT) Received: from localhost ([::1]:35224 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLAcW-0007dU-8Z for importer@patchew.org; Wed, 23 Sep 2020 15:40:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39664) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLAY1-0002gV-3Z; Wed, 23 Sep 2020 15:35:25 -0400 Received: from mail-qv1-xf44.google.com ([2607:f8b0:4864:20::f44]:44441) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kLAXw-0008W3-Nf; Wed, 23 Sep 2020 15:35:24 -0400 Received: by mail-qv1-xf44.google.com with SMTP id j10so581571qvk.11; Wed, 23 Sep 2020 12:35:20 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:431:c7c7:9e50:6b84:53b8:5d9d:d408]) by smtp.gmail.com with ESMTPSA id u4sm612362qkk.68.2020.09.23.12.35.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Sep 2020 12:35:18 -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=2BOBuZbC65SYlx/sk/v7p8L/zpIOl98wNdQzFPXYVBQ=; b=NhBKRbjjDLM2gwpjNEqoDd1laEx7YvLhOjgyaBbmQXoY0yOMrAE+pdt9AE8LGcQE/j GOlz+05ctJRGYCqoJ4PGnb8YnRmFl5+7k25DEbKr2mxjBihc/umSr5vKz4XiSHZFVuvX zOko9m7+sS64POgcCf7zhQWIrqIfuMUspbCeTy1p6ISRReXhQzIFTAgxMu5YG5RxQZzs VM3H7b7tEmTRJVCSadalWAWYenTXOjKllznesjrTa65IE6/lYjJeY7MafHm3hnywD60P b2ZC0+bSQIRwS46LG/tMPtchPyaipgzEv+cl3B3hcMGCRqyMxcW3vI+775CZwebSXUhB vlKQ== 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=2BOBuZbC65SYlx/sk/v7p8L/zpIOl98wNdQzFPXYVBQ=; b=C4BJ63TkSxAcU8Wb9wv/UFj3zkRGQRq6Ns03dBZ3D1yHkOAlDPqB1JNDIZD/cOyXXu ntvEBqyKWTOv+VtR+JbNIukJ/0ZJtk6Bmh7PNBI54ypWnNt4bfCxgxVVrVylONnB71HS oskyXHyEOhT3IDc7A8eQT29TUTgpiyLnNUFtySk0pqksPUTl5okGaiHE1JK5ASjG7nT1 +SvZ3JweWO6O6aSZ3tEyIhL/Nknqfot3coiz53G5Upk4mM6Tvu5kDapfOruTlPQyk+jV meWDClL/dbcz2A/sHXVirxezFm9sbwnrIJt9duuk4s0/YQYnDXDbar3WB4/2f1/i5zyv CBDA== X-Gm-Message-State: AOAM532xOLLk/daSKsLljFDWHBr4Zqtks+9PuewZ038ZQfOkSdISKnO3 TfxVqEgf3RM2J+3ddZWgzqkgG25fVBuGGA== X-Google-Smtp-Source: ABdhPJxxfucnSFaoOQxOVD26OJSmmXpATxG8dnpE8PS5zcP+3WlChbXbWtlSIkaUWLukzcSuYpgY0w== X-Received: by 2002:a0c:ac02:: with SMTP id l2mr1484637qvb.25.1600889719235; Wed, 23 Sep 2020 12:35:19 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Subject: [PATCH 3/6] spapr_numa: translate regular NUMA distance to PAPR distance Date: Wed, 23 Sep 2020 16:34:55 -0300 Message-Id: <20200923193458.203186-4-danielhb413@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200923193458.203186-1-danielhb413@gmail.com> References: <20200923193458.203186-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::f44; envelope-from=danielhb413@gmail.com; helo=mail-qv1-xf44.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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, 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) Content-Type: text/plain; charset="utf-8" QEMU allows the user to set NUMA distances in the command line. For ACPI architectures like x86, this means that user input is used to populate the SLIT table, and the guest perceives the distances as the user chooses to. PPC64 does not work that way. In the PAPR concept of NUMA, associativity relations between the NUMA nodes are provided by the device tree, and the guest kernel is free to calculate the distances as it sees fit. Given how ACPI architectures works, this puts the pSeries machine in a strange spot - users expect to define NUMA distances like in the ACPI case, but QEMU does not have control over it. To give pSeries users a similar experience, we'll need to bring kernel specifics to QEMU to approximate the NUMA distances. The pSeries kernel works with the NUMA distance range 10, 20, 40, 80 and 160. The code starts at 10 (local distance) and searches for a match in the first NUMA level between the resources. If there is no match, the distance is doubled and then it proceeds to try to match in the next NUMA level. Rinse and repeat for MAX_DISTANCE_REF_POINTS levels. This patch introduces a spapr_numa_PAPRify_distances() helper that translates the user distances to kernel distance, which we're going to use to determine the associativity domains for the NUMA nodes. Signed-off-by: Daniel Henrique Barboza --- hw/ppc/spapr_numa.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/hw/ppc/spapr_numa.c b/hw/ppc/spapr_numa.c index 36aaa273ee..180800b2f3 100644 --- a/hw/ppc/spapr_numa.c +++ b/hw/ppc/spapr_numa.c @@ -37,6 +37,49 @@ static bool spapr_numa_is_symmetrical(MachineState *ms) return true; } =20 +/* + * This function will translate the user distances into + * what the kernel understand as possible values: 10 + * (local distance), 20, 40, 80 and 160. Current heuristic + * is: + * + * - distances between 11 and 30 -> rounded to 20 + * - distances between 31 and 60 -> rounded to 40 + * - distances between 61 and 120 -> rounded to 80 + * - everything above 120 -> 160 + * + * This step can also be done in the same time as the NUMA + * associativity domains calculation, at the cost of extra + * complexity. We chose to keep it simpler. + * + * Note: this will overwrite the distance values in + * ms->numa_state->nodes. + */ +static void spapr_numa_PAPRify_distances(MachineState *ms) +{ + int src, dst; + int nb_numa_nodes =3D ms->numa_state->num_nodes; + NodeInfo *numa_info =3D ms->numa_state->nodes; + + for (src =3D 0; src < nb_numa_nodes; src++) { + for (dst =3D src; dst < nb_numa_nodes; dst++) { + uint8_t distance =3D numa_info[src].distance[dst]; + uint8_t rounded_distance =3D 160; + + if (distance > 11 && distance < 30) { + rounded_distance =3D 20; + } else if (distance > 31 && distance < 60) { + rounded_distance =3D 40; + } else if (distance > 61 && distance < 120) { + rounded_distance =3D 80; + } + + numa_info[src].distance[dst] =3D rounded_distance; + numa_info[dst].distance[src] =3D rounded_distance; + } + } +} + void spapr_numa_associativity_init(SpaprMachineState *spapr, MachineState *machine) { @@ -95,6 +138,7 @@ void spapr_numa_associativity_init(SpaprMachineState *sp= apr, exit(1); } =20 + spapr_numa_PAPRify_distances(machine); } =20 void spapr_numa_write_associativity_dt(SpaprMachineState *spapr, void *fdt, --=20 2.26.2 From nobody Wed May 15 08:20:03 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 ARC-Seal: i=1; a=rsa-sha256; t=1600889833; cv=none; d=zohomail.com; s=zohoarc; b=k0Dx2vt2iNnY0Yb2gfK6+J72YkMdyTrK6TaHDCuQkSTQHjr1NO5WxPG8EuEmYZK5DjDSTiVVAT7eX88lpebsQG8PL5IsfThJseKcwfoz0zU6/mkKjOWT+sAOSmuFFc5CN+h86cvNLiKCphQ79NJMgmnNYdePg6qr82SEldd2iRc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600889833; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=XcKpR+WmJ49fFEjtlAWzJFbmoZJR2cMvUq//la+WRc4=; b=FjOOgDLi8sqCA8A/OvVqsOxXbcbtxPu8AugHktQ6cDkhNvdxufmueZQnhYWr1k6h7PLy0cnG05SNu9dIdmvn4S9DPgu+smwnbvBXkncOucy2NI4YjLgdn1DMMUVWUCZQOAHWnA/gN7FFah3dseI9Ppy/TyhJ9U3bSUslyiYRIfg= ARC-Authentication-Results: i=1; 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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600889833737215.84181626473276; Wed, 23 Sep 2020 12:37:13 -0700 (PDT) Received: from localhost ([::1]:55680 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLAZk-0004NW-8l for importer@patchew.org; Wed, 23 Sep 2020 15:37:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39658) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLAY0-0002fm-Nb; Wed, 23 Sep 2020 15:35:24 -0400 Received: from mail-qv1-xf42.google.com ([2607:f8b0:4864:20::f42]:43341) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kLAXy-0008WP-Ki; Wed, 23 Sep 2020 15:35:24 -0400 Received: by mail-qv1-xf42.google.com with SMTP id cr8so589691qvb.10; Wed, 23 Sep 2020 12:35:21 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:431:c7c7:9e50:6b84:53b8:5d9d:d408]) by smtp.gmail.com with ESMTPSA id u4sm612362qkk.68.2020.09.23.12.35.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Sep 2020 12:35:20 -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=XcKpR+WmJ49fFEjtlAWzJFbmoZJR2cMvUq//la+WRc4=; b=tEix+9XXmwcpRRdu9Cu3TRTSjDPYJHM7Vp/gnGVPW3uYx1oGeRcsjsziwy8Hk0zwZg N+fR+3GQhpRQmkN2d83EpWE2tthMgLn9YdHlJ3cjRvupjPrSTqrrz+u2CiS7CGFPEBZw P3GVTlFrKinUeeAXRMxytcj48tk27Zg0E1PK+zws0rjZxeniRUZkIoQ2S0y6poS3KHtO wbm0j2NeMh6XM+1L6tqARvLyS9jUsjXN4Ci8PXs6JO8da/T/Jc19MScFYQr4oEBVfJs4 mk95WDYZ3JnAILHWGMLLjvZuLQKcGIeuaItLqIBwRYn4S16Yu7dk2I+YDFOjzb3Z9KJy Ivyw== 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=XcKpR+WmJ49fFEjtlAWzJFbmoZJR2cMvUq//la+WRc4=; b=uXLPzLz9y4kpmxuVc4iFeNDtW1j0++/76+l91kiEWN1/lPFOuWfYCif0AOvgp4BDQC v8rW6GwplJNiyvYhhTywbT27wbWwLNmg6Axgoe4GBP1EuaRVBbVsi/aDIheaI9XdrnUR bUpyD6FAdiLMecWfTMAbwp0sAVASzGIstdfSuEutL6F7txuITZTtczikESaksIuU4vSs 93EM7JF0YVsg/VT3vnchjpAnCGs4J9e7BLz041mmh6naccQeawjW501wjwShEcknZrf/ vVC5P3gG6amHN33dT6zgcv2OgySZDyq37tk3XrlT7Z15zWM/HHDO3dyP1ONOSgwI0REC mfjQ== X-Gm-Message-State: AOAM5316Yv0hO2y13rHy3lXSrJi4EOR+m2sPRhDgh/qIDaPEzRG0uiD7 glIqyesFL8V1lwb/8DxeIYDmicFQqbwg1g== X-Google-Smtp-Source: ABdhPJxio3jZS59c8Ja6iOc8PY8nPFQgJDbWTykpw00TYkVXFJxOP5BtUbj1E1kSme+sjTRIhDQ8sw== X-Received: by 2002:a0c:e294:: with SMTP id r20mr1518845qvl.60.1600889720932; Wed, 23 Sep 2020 12:35:20 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Subject: [PATCH 4/6] spapr_numa: change reference-points and maxdomain settings Date: Wed, 23 Sep 2020 16:34:56 -0300 Message-Id: <20200923193458.203186-5-danielhb413@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200923193458.203186-1-danielhb413@gmail.com> References: <20200923193458.203186-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::f42; envelope-from=danielhb413@gmail.com; helo=mail-qv1-xf42.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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, 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) Content-Type: text/plain; charset="utf-8" This is the first guest visible change introduced in spapr_numa.c. The previous settings of both reference-points and maxdomains were too restrictive, but enough for the existing associativity we're setting in the resources. We'll change that in the following patches, populating the associativity arrays based on user input. For those changes to be effective, reference-points and maxdomains must be more flexible. After this patch, we'll have 4 distinct levels of NUMA (0x4, 0x3, 0x2, 0x1) and maxdomains will allow for any type of configuration the user intends to do - under the scope and limitations of PAPR itself, of course. Signed-off-by: Daniel Henrique Barboza --- hw/ppc/spapr_numa.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/hw/ppc/spapr_numa.c b/hw/ppc/spapr_numa.c index 180800b2f3..688391278e 100644 --- a/hw/ppc/spapr_numa.c +++ b/hw/ppc/spapr_numa.c @@ -222,21 +222,30 @@ int spapr_numa_write_assoc_lookup_arrays(SpaprMachine= State *spapr, void *fdt, */ void spapr_numa_write_rtas_dt(SpaprMachineState *spapr, void *fdt, int rta= s) { + MachineState *ms =3D MACHINE(spapr); SpaprMachineClass *smc =3D SPAPR_MACHINE_GET_CLASS(spapr); uint32_t refpoints[] =3D { cpu_to_be32(0x4), - cpu_to_be32(0x4), + cpu_to_be32(0x3), cpu_to_be32(0x2), + cpu_to_be32(0x1), }; uint32_t nr_refpoints =3D ARRAY_SIZE(refpoints); - uint32_t maxdomain =3D cpu_to_be32(spapr->gpu_numa_id > 1 ? 1 : 0); - uint32_t maxdomains[] =3D { - cpu_to_be32(4), - maxdomain, - maxdomain, - maxdomain, - cpu_to_be32(spapr->gpu_numa_id), - }; + uint32_t maxdomain =3D cpu_to_be32(ms->numa_state->num_nodes + + spapr->gpu_numa_id); + uint32_t maxdomains[] =3D {0x4, maxdomain, maxdomain, maxdomain, maxdo= main}; + + if (spapr_machine_using_legacy_numa(spapr)) { + refpoints[1] =3D cpu_to_be32(0x4); + refpoints[2] =3D cpu_to_be32(0x2); + nr_refpoints =3D 3; + + maxdomain =3D cpu_to_be32(spapr->gpu_numa_id > 1 ? 1 : 0); + maxdomains[1] =3D maxdomain; + maxdomains[2] =3D maxdomain; + maxdomains[3] =3D maxdomain; + maxdomains[4] =3D cpu_to_be32(spapr->gpu_numa_id); + } =20 if (smc->pre_5_1_assoc_refpoints) { nr_refpoints =3D 2; --=20 2.26.2 From nobody Wed May 15 08:20:03 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 ARC-Seal: i=1; a=rsa-sha256; t=1600890302; cv=none; d=zohomail.com; s=zohoarc; b=IJXGAnNR861cAZ5NTnGWF5vyi3LhBz7PDAQvQzCxQukXxJOXteSImMwtrSMbihEIPUcZNch8oghb92sOWXywDKmmL+pSqy3NDqfaWiaRh2pP/dSeM+saTlynUL0xcB8rftwCggQZLCSH3+UHN+2iAEIkl2jdgjQgZfUTTXxB95Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600890302; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=U8iLQ4CK3SSipSwps1buB7OCIE9Aj5GfsslZoNsZ8xc=; b=LkY5S5Yt4yfUHMLE6AhqdKwfgSiMdyl30RCz6TTJJncD4hfnGAx/schJseyNAEqEhTjz2hMYTyku2hgGXWy66fqDELY9lbYVhjJPhspUPJKYFYQz2SFatXQBL/Fwkm4Xky7F4Xi+WCgGUHzj60NoGl+6b+G/qyyGrofQZYlQHHA= ARC-Authentication-Results: i=1; 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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 160089030270896.22209250504659; Wed, 23 Sep 2020 12:45:02 -0700 (PDT) Received: from localhost ([::1]:43126 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLAhJ-0002oC-3I for importer@patchew.org; Wed, 23 Sep 2020 15:45:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39690) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLAY3-0002lB-SD; Wed, 23 Sep 2020 15:35:27 -0400 Received: from mail-qt1-x844.google.com ([2607:f8b0:4864:20::844]:44071) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kLAY0-000058-Of; Wed, 23 Sep 2020 15:35:27 -0400 Received: by mail-qt1-x844.google.com with SMTP id e7so894263qtj.11; Wed, 23 Sep 2020 12:35:23 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:431:c7c7:9e50:6b84:53b8:5d9d:d408]) by smtp.gmail.com with ESMTPSA id u4sm612362qkk.68.2020.09.23.12.35.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Sep 2020 12:35:22 -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=U8iLQ4CK3SSipSwps1buB7OCIE9Aj5GfsslZoNsZ8xc=; b=ED7BBIc3H5GwQLVW5PJVLWBCT6GeKF2IDV6qL2twyFHLYj/o1nKaDoC0FnVbczWTRu JARr5gucDb6f8OGSgRmDHfn3Tfy18ziyXE9AnHRnoyJ/zKU9ofjonuSE4d5pKkrdeP1x NqYGS0ww9Za3LdQsuzSa9vh6Hn6zCbROsjSPd2hyspB2Y4iJeEst2BeAcff0w8hbicDu xIqU5jRf2Bf7vWU/omSP1Rmd2WgwQ4qbO8hdwQb47O/n3xcX/hVlQ3XH7aE0XXc7xBWw v68h0FpqvnWYS1iJBxQDJ/gldsEVvn+EFmVQd3uLO+wO6KW2Wlkliib9UZUtwbDAdHsc 8O1w== 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=U8iLQ4CK3SSipSwps1buB7OCIE9Aj5GfsslZoNsZ8xc=; b=KDxTKk1JSoW8xNB2BQyU5Ze/RcMq+ZobJgWqomX52OH2AWEorbya1gNyOxAlmqooxn Pyc6w2T87bWXa5pSFJ+FcGuAxn0AChOFb+PlyoyEedFyl52NlIRdNbY4OnkyfV0wh2yb JzwQ41ipR8U63JptoVHSkQ6AQSuL4qAjSMZ7yS7NyvkkPF3drAJlGex8gNqqIiVYFcIP JlcKORYoWf9sTSDuaZaa1ENAyo+cpToed6sA7HZMhthBT37EwrAvJOFpkWIAPKXPU2V9 /obbF5Ydp12z5zQ8miY2X0vKpSaElL8sLTStWjS/GCmM2OVi3KHHDSOcw2qV70+BUU2H IgXg== X-Gm-Message-State: AOAM5306Kg2b1RCycY8ZFZTe22jisaECcpSddqV5g96jOFJ/EYZrsWoI UgrQX8CiWHEEhtZTXzwT0IVmChNl63r8WQ== X-Google-Smtp-Source: ABdhPJwbWOTMbsCG9zW4bUMj+HuV4NZyBs7REvAeDe1XuZ2O3P8o0ksNnqULIztAOErLKUVNlrrlsw== X-Received: by 2002:ac8:5650:: with SMTP id 16mr1847379qtt.120.1600889722731; Wed, 23 Sep 2020 12:35:22 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Subject: [PATCH 5/6] spapr_numa: consider user input when defining associativity Date: Wed, 23 Sep 2020 16:34:57 -0300 Message-Id: <20200923193458.203186-6-danielhb413@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200923193458.203186-1-danielhb413@gmail.com> References: <20200923193458.203186-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::844; envelope-from=danielhb413@gmail.com; helo=mail-qt1-x844.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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, 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) Content-Type: text/plain; charset="utf-8" This patch puts all the pieces together to finally allow user input when defining the NUMA topology of the spapr guest. We have one more kernel restriction to handle in this patch: the associativity array of node 0 must be filled with zeroes [1]. The strategy below ensures that this will happen. spapr_numa_define_associativity_domains() will read the distance (already PAPRified) between the nodes from numa_state and determine the appropriate NUMA level. The NUMA domains, processed in ascending order, are going to be matched via NUMA levels, and the lowest associativity domain value is assigned to that specific level for both. This will create an heuristic where the associativities of the first nodes have higher priority and are re-used in new matches, instead of overwriting them with a new associativity match. This is necessary because neither QEMU, nor the pSeries kernel, supports multiple associativity domains for each resource, meaning that we have to decide which associativity relation is relevant. Ultimately, all of this results in a best effort approximation for the actual NUMA distances the user input in the command line. Given the nature of how PAPR itself interprets NUMA distances versus the expectations risen by how ACPI SLIT works, there might be better algorithms but, in the end, it'll also result in another way to approximate what the user really wanted. To keep this commit message no longer than it already is, the next patch will update the existing documentation in ppc-spapr-numa.rst with more in depth details and design considerations/drawbacks. [1] https://lore.kernel.org/linuxppc-dev/5e8fbea3-8faf-0951-172a-b41a2138fb= cf@gmail.com/ Signed-off-by: Daniel Henrique Barboza --- hw/ppc/spapr_numa.c | 81 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 80 insertions(+), 1 deletion(-) diff --git a/hw/ppc/spapr_numa.c b/hw/ppc/spapr_numa.c index 688391278e..c84f77cda7 100644 --- a/hw/ppc/spapr_numa.c +++ b/hw/ppc/spapr_numa.c @@ -80,12 +80,79 @@ static void spapr_numa_PAPRify_distances(MachineState *= ms) } } =20 +static uint8_t spapr_numa_get_NUMA_level(uint8_t distance) +{ + uint8_t numa_level; + + switch (distance) { + case 20: + numa_level =3D 0x3; + break; + case 40: + numa_level =3D 0x2; + break; + case 80: + numa_level =3D 0x1; + break; + default: + numa_level =3D 0; + } + + return numa_level; +} + +static void spapr_numa_define_associativity_domains(SpaprMachineState *spa= pr, + MachineState *ms) +{ + int src, dst; + int nb_numa_nodes =3D ms->numa_state->num_nodes; + NodeInfo *numa_info =3D ms->numa_state->nodes; + + for (src =3D 0; src < nb_numa_nodes; src++) { + for (dst =3D src; dst < nb_numa_nodes; dst++) { + /* + * This is how the associativity domain between A and B + * is calculated: + * + * - get the distance between them + * - get the correspondent NUMA level for this distance + * - the arrays were initialized with their own numa_ids, + * and we're calculating the distance in node_id ascending ord= er, + * starting from node 0. This will have a cascade effect in the + * algorithm because the associativity domains that node 0 def= ines + * will be carried over to the other nodes, and node 1 + * associativities will be carried over unless there's already= a + * node 0 associativity assigned, and so on. This happens beca= use + * we'll assign the lowest value of assoc_src and assoc_dst to= be + * the associativity domain of both, for the given NUMA level. + * + * The PPC kernel expects the associativity domains of node 0 = to + * be always 0, and this algorithm will grant that by default. + */ + uint8_t distance =3D numa_info[src].distance[dst]; + uint8_t n_level =3D spapr_numa_get_NUMA_level(distance); + uint32_t assoc_src, assoc_dst; + + assoc_src =3D be32_to_cpu(spapr->numa_assoc_array[src][n_level= ]); + assoc_dst =3D be32_to_cpu(spapr->numa_assoc_array[dst][n_level= ]); + + if (assoc_src < assoc_dst) { + spapr->numa_assoc_array[dst][n_level] =3D cpu_to_be32(asso= c_src); + } else { + spapr->numa_assoc_array[src][n_level] =3D cpu_to_be32(asso= c_dst); + } + } + } + +} + void spapr_numa_associativity_init(SpaprMachineState *spapr, MachineState *machine) { 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; + bool using_legacy_numa =3D spapr_machine_using_legacy_numa(spapr); =20 /* * For all associativity arrays: first position is the size, @@ -99,6 +166,17 @@ void spapr_numa_associativity_init(SpaprMachineState *s= papr, for (i =3D 0; i < nb_numa_nodes; i++) { 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); + + /* + * Fill all associativity domains of the node with node_id. + * This is required because the kernel makes valid associativity + * matches with the zeroes if we leave the matrix unitialized. + */ + if (!using_legacy_numa) { + for (j =3D 1; j < MAX_DISTANCE_REF_POINTS; j++) { + spapr->numa_assoc_array[i][j] =3D cpu_to_be32(i); + } + } } =20 /* @@ -128,7 +206,7 @@ void spapr_numa_associativity_init(SpaprMachineState *s= papr, * 1 NUMA node) will not benefit from anything we're going to do * after this point. */ - if (spapr_machine_using_legacy_numa(spapr)) { + if (using_legacy_numa) { return; } =20 @@ -139,6 +217,7 @@ void spapr_numa_associativity_init(SpaprMachineState *s= papr, } =20 spapr_numa_PAPRify_distances(machine); + spapr_numa_define_associativity_domains(spapr, machine); } =20 void spapr_numa_write_associativity_dt(SpaprMachineState *spapr, void *fdt, --=20 2.26.2 From nobody Wed May 15 08:20:03 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 ARC-Seal: i=1; a=rsa-sha256; t=1600889892; cv=none; d=zohomail.com; s=zohoarc; b=er+FOQWDGJDp8unzR9ZKRJRs2VYd2V/z2Z487OJdTWX38cKeAFk+tOcE251duNwCaP3vFDacghGWr6crq+f5jnXjFNPa/1tytjLYvm4o0715pmriEvJ652ZL/1qEKRficUXUeIM9fj9IHTEnwI0VYzOTB9O+g2uVuEz8dE1CIvY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600889892; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=foegIg+R6xGelzocg1qpmzjKagMlOEuwe5qYOlr3pzs=; b=Av+ja5p/e+UMpFt9m9satlESlMWpYQAt2Lru3h+CoZANFymBWDZjtGH141p0pbAjjYIbsNAA0/xCSp3XNgFmvnknqI++vC/J14oJsCRFiKty9qzDkGTEcIJgfPpUVOn8krhiMGPSq9t3ygtWHRj88RzUWRcDXCyCYSn9zEqdxdw= ARC-Authentication-Results: i=1; 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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600889892439444.6430650416403; Wed, 23 Sep 2020 12:38:12 -0700 (PDT) Received: from localhost ([::1]:57732 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLAag-0005EZ-UY for importer@patchew.org; Wed, 23 Sep 2020 15:38:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39698) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLAY5-0002o0-5H; Wed, 23 Sep 2020 15:35:32 -0400 Received: from mail-qk1-x733.google.com ([2607:f8b0:4864:20::733]:41096) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kLAY2-00005k-P9; Wed, 23 Sep 2020 15:35:28 -0400 Received: by mail-qk1-x733.google.com with SMTP id g72so901316qke.8; Wed, 23 Sep 2020 12:35:25 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:431:c7c7:9e50:6b84:53b8:5d9d:d408]) by smtp.gmail.com with ESMTPSA id u4sm612362qkk.68.2020.09.23.12.35.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Sep 2020 12:35:24 -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=foegIg+R6xGelzocg1qpmzjKagMlOEuwe5qYOlr3pzs=; b=Ou8x6dysWim4r6RU+56H3ddgEWpce8rwfSKHIMQIQ1WQs/JGedU2zxoSPR8MVrOrah p4upj6XztlJniyHB29XkChim+6dH9Wct19ABkHPMOIqsv19TymO/cyYKOg2O/kJ/J40Z xOij4GnEW0kTyypUBMfEZdcMZOr0hPRI/8bYRtV1lhUihjs6nidhxPJHSHpNZPyKwAoJ ZJvtUXT1W6Nw90y/T32iDj5Z3AMSxMhKmYylFYc9ocm+28mbHSe9Tj1S7s/PZPvvtEyx INKz28D23TqJggnAIbIctF+oWoesVaJ3tm2AqFJhQ7Lb2CJdmJlkK8Mf80JWT45KIxK5 MR2Q== 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=foegIg+R6xGelzocg1qpmzjKagMlOEuwe5qYOlr3pzs=; b=G7O+j0sDlgPTTD5Dt3h4SfQIajBgoOdxUGY2u2JGOvJzv4lUfEIABG9qeSBmWTiwdu BCInNIYkD9QwrJmQdWicNz7Dj0aHQTFfzse2NiaGyWyG7kmizOFB+4z8CwlAilbWExXH yOz2txe6HkO0mItJhxbfzKbgc2tOUOz4jyyy6aEvLMfZ0bgOveYqasJ4BELYmotezLSU iynPFyFa/AFJaHcVYLHKUIaTzftAnS3noRFSKgB5d3QzQx7utpfEqdRCvvRKlKx+esXH xB89eyXAbHuVTlYuMDY1RV61E1PBlLEWbDX3LdoeC1WKjpKTFm7pq1xyUA/Dwdv1bTs4 EuTA== X-Gm-Message-State: AOAM531Uy7JNDyl64XNAs6MSk2M34qHBfhQfgEt3bFhCMdOz6VWsaOc7 tI99GqT8Au6684AA9NpOaWUGUvZtmKu6NA== X-Google-Smtp-Source: ABdhPJy37BANjZRnSzqNB4/hTJsxcDyAjIzWsNcN25VBd9p6OUxgqj5RyJxyyXy8n+UxmR8CAZv2qg== X-Received: by 2002:a37:9e87:: with SMTP id h129mr1409013qke.276.1600889724944; Wed, 23 Sep 2020 12:35:24 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Subject: [PATCH 6/6] specs/ppc-spapr-numa: update with new NUMA support Date: Wed, 23 Sep 2020 16:34:58 -0300 Message-Id: <20200923193458.203186-7-danielhb413@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200923193458.203186-1-danielhb413@gmail.com> References: <20200923193458.203186-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::733; envelope-from=danielhb413@gmail.com; helo=mail-qk1-x733.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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, 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) Content-Type: text/plain; charset="utf-8" This update provides more in depth information about the choices and drawbacks of the new NUMA support for the spapr machine. Signed-off-by: Daniel Henrique Barboza --- docs/specs/ppc-spapr-numa.rst | 213 ++++++++++++++++++++++++++++++++++ 1 file changed, 213 insertions(+) diff --git a/docs/specs/ppc-spapr-numa.rst b/docs/specs/ppc-spapr-numa.rst index e762038022..994bfb996f 100644 --- a/docs/specs/ppc-spapr-numa.rst +++ b/docs/specs/ppc-spapr-numa.rst @@ -189,3 +189,216 @@ QEMU up to 5.1, as follows: =20 This also means that user input in QEMU command line does not change the NUMA distancing inside the guest for the pseries machine. + +New NUMA mechanics for pseries in QEMU 5.2 +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +Starting in QEMU 5.2, the pseries machine now considers user input when +setting NUMA topology of the guest. The following changes were made: + +* ibm,associativity-reference-points was changed to {0x4, 0x3, 0x2, 0x1}, = allowing + for 4 distinct NUMA distance values based on the NUMA levels + +* ibm,max-associativity-domains was changed to support multiple associativ= ity + domains in all NUMA levels. This is needed to ensure user flexibility + +* ibm,associativity for all resources now varies with user input + +These changes are only effective for pseries-5.2 and newer machines that a= re +created with more than one NUMA node (disconsidering NUMA nodes created by +the machine itself, e.g. NVLink 2 GPUs). The now legacy support has been +around for such a long time, with users seeing NUMA distances 10 and 40 +(and 80 if using NVLink2 GPUs), and there is no need to disrupt the +existing experience of those guests. + +To bring the user experience x86 users have when tuning up NUMA, we had +to operate under the current pseries Linux kernel logic described in +`How the pseries Linux guest calculates NUMA distances`_. The result +is that we needed to translate NUMA distance user input to pseries +Linux kernel input. + +Translating user distance to kernel distance +-------------------------------------------- + +User input for NUMA distance can vary from 10 to 254. We need to translate +that to the values that the Linux kernel operates on (10, 20, 40, 80, 160). +This is how it is being done: + +* user distance 11 to 30 will be interpreted as 20 +* user distance 31 to 60 will be interpreted as 40 +* user distance 61 to 120 will be interpreted as 80 +* user distance 121 and beyond will be interpreted as 160 +* user distance 10 stays 10 + +The reasoning behind this aproximation is to avoid any round up to the loc= al +distance (10), keeping it exclusive to the 4th NUMA level (which is still +exclusive to the node_id). All other ranges were chosen under the developer +discretion of what would be (somewhat) sensible considering the user input. +Any other strategy can be used here, but in the end the reality is that we= 'll +have to accept that a large array of values will be translated to the same +NUMA topology in the guest, e.g. this user input: + +:: + + 0 1 2 + 0 10 31 120 + 1 31 10 30 + 2 120 30 10 + +And this other user input: + +:: + + 0 1 2 + 0 10 60 61 + 1 60 10 11 + 2 61 11 10 + +Will both be translated to the same values internally: + +:: + + 0 1 2 + 0 10 40 80 + 1 40 10 20 + 2 80 20 10 + +Users are encouraged to use only the kernel values in the NUMA definition = to +avoid being taken by surprise with that the guest is actually seeing in the +topology. There are enough potential surprises that are inherent to the +associativity domain assignment process, discussed below. + + +How associativity domains are assigned +-------------------------------------- + +LOPAPR allows more than one associativity array (or 'string') per allocated +resource. This would be used to represent that the resource has multiple +connections with the board, and then the operational system, when deciding +NUMA distancing, should consider the associativity information that provid= es +the shortest distance. + +The spapr implementation does not support multiple associativity arrays per +resource, neither does the pseries Linux kernel. We'll have to represent t= he +NUMA topology using one associativity per resource, which means that choic= es +and compromises are going to be made. + +Consider the following NUMA topology entered by user input: + +:: + + 0 1 2 3 + 0 10 20 20 40 + 1 20 10 80 40 + 2 20 80 10 20 + 3 40 40 20 10 + +Honoring just the relative distances of node 0 to every other node, one po= ssible +value for all associativity arrays would be: + +* node 0: 0 B A 0 +* node 1: 0 0 A 1 +* node 2: 0 0 A 2 +* node 3: 0 B 0 3 + +With the reference points {0x4, 0x3, 0x2, 0x1}, for node 0: + +* distance from 0 to 1 is 20 (no match at 0x4, will match at 0x3) +* distance from 0 to 2 is 20 (no match at 0x4, will match at 0x3) +* distance from 0 to 3 is 40 (no match at 0x4 and 0x3, will match + at 0x2) + +The distances related to node 0 are well represented. Doing for node 1, an= d keeping +in mind that we don't need to revisit node 0 again, the distance from node= 1 to +2 is 80, matching at 0x4: + +* node 1: C 0 A 1 +* node 2: C 0 A 2 + +Over here we already have the first conflict. Even if we assign a new asso= ciativity +domain at 0x4 for 1 and 2, and we do that in the code, the kernel will def= ine +the distance between 1 and 2 as 20, not 80, because both 1 and 2 have the = "A" +associativity domain from the previous step. If we decide to discard the +associativity with "A" then the node 0 distances are compromised. + +Following up with the distance from 1 to 3 being 40 (a match in 0x2) we ha= ve another +decision to make. These are the current associativity domains of each: + +* node 1: C 0 A 1 +* node 3: 0 B 0 3 + +There is already an associativity domain at 0x2 in node 3, "B", which was = assigned +by the node 0 distances. If we define a new associativity domain at this l= evel +for 1 and 3 we will overwrite the existing associativity between 0 and 3. = What +the code is doing in this case is to assign the existing domain to the +current associativity, in this case, "B" is now assigned to the 0x2 of nod= e 1, +resulting in the following associativity arrays: + +* node 0: 0 B A 0 +* node 1: C 0 A 1 +* node 2: C B A 2 +* node 3: 0 B 0 3 + +In the last step we will analyze just nodes 2 and 3. The desired distance = between +2 and 3 is 20, i.e. a match in 0x3. Node 2 already has a domain assigned i= n 0x3, +A, so we do the same as we did in the previous case and assign it to node 3 +at 0x3. This is the end result for the associativity arrays: + +* node 0: 0 B A 0 +* node 1: C 0 A 1 +* node 2: C B A 2 +* node 3: 0 B A 3 + +The kernel will read these arrays and will calculate the following NUMA to= pology for +the guest: + +:: + + 0 1 2 3 + 0 10 20 20 20 + 1 20 10 20 20 + 2 20 20 10 20 + 3 20 20 20 10 + +Which is not what the user wanted, but it is what the current logic and im= plementation +constraints of the kernel and QEMU will provide inside the LOPAPR specific= ation. + +Changing a single value, specially a low distance value, makes for drastic= changes +in the result. For example, with the same user input from above, but chang= ing the +node distance from 0 to 1 to 40: + +:: + + 0 1 2 3 + 0 10 40 20 40 + 1 40 10 80 40 + 2 20 80 10 20 + 3 40 40 20 10 + +This is the result inside the guest, applying the same heuristics: + +:: + + $ numactl -H + available: 4 nodes (0-3) + (...) + node distances: + node 0 1 2 3 + 0: 10 40 20 20 + 1: 40 10 80 40 + 2: 20 80 10 20 + 3: 20 40 20 10 + +This result is much closer to the user input and only a single distance wa= s changed +from the original. + +The kernel will always match with the shortest associativity domain possib= le, and we're +attempting to retain the previous established relations between the nodes.= This means +that a distance equal to 20 between nodes A and B and the same distance 20= between nodes +A and F will cause the distance between B and F to also be 20. The same wi= ll happen to +other distances, but shorter distances has precedent over it to the distan= ce calculation. + +Users are welcome to use this knowledge and experiment with the input to g= et the +NUMA topology they want, or as closer as they want. The important thing is= to keep +expectations up to par with what we are capable of provide at this moment:= an +approximation. --=20 2.26.2