Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp1727233rdg; Sat, 12 Aug 2023 13:45:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF38hGIo6w3TPlsKZV1xb6UwskXc3SBopdkFi8zHypw8LH9YAIy3302im0flQ2CNbz5v4id X-Received: by 2002:a05:6a20:728c:b0:13d:ee19:771f with SMTP id o12-20020a056a20728c00b0013dee19771fmr5857892pzk.8.1691873107163; Sat, 12 Aug 2023 13:45:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691873107; cv=none; d=google.com; s=arc-20160816; b=VzDbH4TkoKZoS7FHiapojcEq+Uy/6EkdtWqx6+qjGKjzM2/MY0bbLVzAl9yayudT5S oyKt/JxzE2aR2+TfzAPv9YQRny6p5n/mJD24OeQY9b5ME03/dC4qP9MIQFEhmcf+qvs2 KInHZmRsSXIzVBxqJfHrCOnsaHWlkeR6MDXB6SqGQ0SEeOWmFNiQ+5gr+ewah7UkinFt XtCFSpEdO6qx1FgDrTnPiTbpFWO0y+J9+PzmLvWqhkeDBLitjCMx4kAoETVEO+ad/ybo xpcLRnfl7eZI7youzy3Xt0Za75dMr2e7Q4RYW1pl61ym6OH2aDlL8ELIs2kRmCCToQcS ERzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:references:in-reply-to:subject:cc:to:dkim-signature :dkim-signature:from; bh=Wtvo571d87Q4UWnlp7I5H5p2cbtWMUbQPMH/PnPfg5Q=; fh=1D3M5kDz/bxvbRVlp/l4lDQ/uugkdoatc1zWGvCUXpQ=; b=fStJjOsLKt18rzllguYjge/d86hTEF59MOdXGGDGjOBfp7Nsb/I1+vCubArEXywLv9 btBnaFe7aRPXZ1CcJ04sF4EcmkiA23K0GEVawZJPFOrtPfSH6tETJVukfE0ZkNi27PHa bAbRMG3DN4JSpQweYijiAfVkWaJs5ByyjL2mwUa5FXyUKPM9Z4usCYzvYQ41mFa6PMXk 3rH01aCkLfzBvwYwbofSgbtTuyin6wuM4MLlGDT9JwwRfd9SjiPnpojlPNUpJvlXuvsc wc9zIMZUICeAbmz2PZwkytdoTIHUuMV1QWJ7uh2A4egNkMfdw6vc9+HHBCXc/JbwbXWi oqWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=RBVtPzjE; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f2-20020a656282000000b00564d938589dsi5491917pgv.326.2023.08.12.13.44.54; Sat, 12 Aug 2023 13:45:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=RBVtPzjE; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231194AbjHLUGs (ORCPT + 99 others); Sat, 12 Aug 2023 16:06:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231226AbjHLUGn (ORCPT ); Sat, 12 Aug 2023 16:06:43 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C73812706 for ; Sat, 12 Aug 2023 13:06:19 -0700 (PDT) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1691870689; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Wtvo571d87Q4UWnlp7I5H5p2cbtWMUbQPMH/PnPfg5Q=; b=RBVtPzjEiRA5J7HWVZYdE7mHLJHJAwZ93VUjc28qfOUOTwb9rUl9VY7xl4pl/zUYlydBWF rxyk57fQ7xnJ7CjHLuk7Mazy3g/9Cju+leyIWrJSaftpf7SNAYkLBX3JzLqUyYqkX3EAKX GNeGMWlneaRctlCL9SipmOxGDrDPrjgmO/oEUri4UNiFNQWKuK6rv6SDsy1Rmjdk0SdBy2 VO5GyDj/EYy8dngraf9GhIeEepuet6YfWn9xfkcCOPngM2lu7fLlI9Fe6fFswMU6aF+jM+ 25oFhM6v2p+LB7i0ZV7LPlv8ZffaaHrfI6aVio4w0BQ0mN4QHQQoXdpmo99wMQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1691870689; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Wtvo571d87Q4UWnlp7I5H5p2cbtWMUbQPMH/PnPfg5Q=; b=VuZU88itT/IYNqsGPgRsNZCxCurCX2I3Sb2zcAqul6bt1hiLKMFog5Acc/XMQ7T+npqG0m XEiDE+H8Jeo/BBCQ== To: "Zhang, Rui" , "linux-kernel@vger.kernel.org" Cc: "Gross, Jurgen" , "mikelley@microsoft.com" , "arjan@linux.intel.com" , "x86@kernel.org" , "thomas.lendacky@amd.com" , "ray.huang@amd.com" , "andrew.cooper3@citrix.com" , "Sivanich, Dimitri" , "wei.liu@kernel.org" Subject: Re: [patch V3 27/40] x86/cpu: Provide a sane leaf 0xb/0x1f parser In-Reply-To: <8e5bbbc91ff9f74244efe916a4113999abc52213.camel@intel.com> References: <20230802101635.459108805@linutronix.de> <20230802101934.258937135@linutronix.de> <8e5bbbc91ff9f74244efe916a4113999abc52213.camel@intel.com> Date: Sat, 12 Aug 2023 22:04:48 +0200 Message-ID: <87350ogh7j.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Aug 12 2023 at 08:21, Rui Zhang wrote: > On Wed, 2023-08-02 at 12:21 +0200, Thomas Gleixner wrote: >> + >> +/* >> + * Use a lookup table for the case that there are future types > 6 >> which >> + * describe an intermediate domain level which does not exist today. >> + * >> + * A table will also be handy to parse the new AMD 0x80000026 leaf >> which >> + * has defined different domain types, but otherwise uses the same >> layout >> + * with some of the reserved bits used for new information. >> + */ >> +static const unsigned int topo_domain_map[MAX_TYPE] =3D { >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0[SMT_TYPE]=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=3D TOPO_SMT_DOMAIN, >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0[CORE_TYPE]=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=3D TOPO_CORE_DOMAIN, >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0[MODULE_TYPE]=C2=A0=C2=A0=C2= =A0=3D TOPO_MODULE_DOMAIN, >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0[TILE_TYPE]=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=3D TOPO_TILE_DOMAIN, >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0[DIE_TYPE]=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=3D TOPO_DIE_DOMAIN, >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0[DIEGRP_TYPE]=C2=A0=C2=A0=C2= =A0=3D TOPO_PKG_DOMAIN, > > May I know why DIEGRP_TYPE is mapped to TOPO_PKG_DOMAIN? Where else should it go? It's the topmost, no? But diegrp is a terminoligy which is not used in the kernel >> + >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (sl.type >=3D maxtype) { > > It is still legal to have sparse type value in the future, and then > this check will break. > IMO, it is better to use a function to convert type to domain, and > check for unknown domain here, say, something like Why? If somewhere in the future Intel decides to add UBER_TILE_TYPE, then this will be a type larger than DIEGRP_TYPE. maxtype will then cover the whole thing and the table will map it to the right place. Even if in their infinite wisdom the HW folks decide to make a gap, then the table can handle it simply by putting an invalid value into the gap and checking for that. Serioulsy we don't need a switch case for that. >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0/* >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 * As the subleafs are ordered in domain level order, >> this >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 * could be recovered in theory by propagating the >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 * information at the last parsed level. >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 * >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 * But if the infinite wisdom of hardware folks >> decides to >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 * create a new domain type between CORE and MODULE >> or DIE >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 * and DIEGRP, then that would overwrite the CORE or >> DIE >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 * information. > > Sorry that I'm confused here. > > Say, we have CORE, FOO, MODULE, then the subleave of FOO must be higher > than CORE but lower than MODULE. > so we parse CORE first and propagates the info to FOO/MODULE, and then > parse FOO and propagate to MODULE, and parse MODULE in the end. > How could we overwrite the info of a lower level? We don't know about this new thing yet. So where should we propagate to? We could say, last was core so we stick the new thing into module, but do we know that's correct? Do we know there is a module actually. Let me rephrase that comment. >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 * >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 * Refuse to implement monstrosity, emit an error and = try >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 * to survive. >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 */ >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0pr_err_once("Topology: leaf 0x%x:%d Unknown domain typ= e %u\n", >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0 leaf, subleaf, sl.type); >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0return true; > > Don't want to be TLDR, I can think of a couple cases that breaks Linux > in different ways if we ignore the cpu topology info of an unknown > level. Come on. If Intel manages it to create a new level then it's not rocket science to integrate support for that a long time before actual silicon ships. So what will break? The machines of people who use ancient kernels on modern hardware? They can keep the pieces. > So I just want to understand the strategy here, does this mean that > we're not looking for a future proof solution, and instead we are > planning to take future updates (patch enum topo_types/enum > x86_topology_domains/topo_domain_map) whenever a new level is > invented? You need that anyway, no?=20 > With this, we can guarantee that all the available topology information > are always valid, even when running on future platforms. I know that it can be made work, but is it worth the extra effort? I don't think so. Thanks, tglx