lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <33b628a02f190481c42a2dfd31b5ed1b2b50b37f.camel@intel.com>
Date:   Sun, 13 Aug 2023 13:30:11 +0000
From:   "Zhang, Rui" <rui.zhang@...el.com>
To:     "tglx@...utronix.de" <tglx@...utronix.de>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
CC:     "Gross, Jurgen" <jgross@...e.com>,
        "mikelley@...rosoft.com" <mikelley@...rosoft.com>,
        "arjan@...ux.intel.com" <arjan@...ux.intel.com>,
        "x86@...nel.org" <x86@...nel.org>,
        "thomas.lendacky@....com" <thomas.lendacky@....com>,
        "ray.huang@....com" <ray.huang@....com>,
        "andrew.cooper3@...rix.com" <andrew.cooper3@...rix.com>,
        "Sivanich, Dimitri" <dimitri.sivanich@....com>,
        "wei.liu@...nel.org" <wei.liu@...nel.org>
Subject: Re: [patch V3 23/40] x86/cpu: Provide cpu_init/parse_topology()

On Sat, 2023-08-12 at 06:41 +0000, Zhang, Rui wrote:
> > +
> > +static inline u32 topo_relative_domain_id(u32 apicid, enum
> > x86_topology_domains dom)
> > +{
> > +       if (dom != TOPO_SMT_DOMAIN)
> > +               apicid >>= x86_topo_system.dom_shifts[dom - 1];
> > +       return apicid & (x86_topo_system.dom_size[dom] - 1);
> > +}
> 
> relative_domain_id() is used to get a unique id value within its next
> higher level.
> 
> > +static void topo_set_ids(struct topo_scan *tscan)
> > +{
> > +       struct cpuinfo_x86 *c = tscan->c;
> > +       u32 apicid = c->topo.apicid;
> > +
> > +       c->topo.pkg_id = topo_shift_apicid(apicid,
> > TOPO_PKG_DOMAIN);
> > +       c->topo.die_id = topo_shift_apicid(apicid,
> > TOPO_DIE_DOMAIN);
> > +
> > +       /* Relative core ID */
> > +       c->topo.core_id = topo_relative_domain_id(apicid,
> > TOPO_CORE_DOMAIN);
> 
> My understanding is that, to ensure a package scope unique core_id,
> rather than Module/Tile scope unique, what is really needed here is
> something like,
>         apicid >>= x86_topo_system.dom_shifts[SMT];
>         c->topo.core_id = apicid & (x86_topo_system.dom_size[PACKAGE]
> - 1);
> 
> I don't have chance to confirm this on a platform with Module level
> yet, but will do soon.
> 
Tested on an AdlerLake-N platform, which has 2 Ecore Modules only.

[    0.212526] CPU topo: Max. logical packages:   1
[    0.212527] CPU topo: Max. logical dies:       1
[    0.212528] CPU topo: Max. dies per package:   1
[    0.212531] CPU topo: Max. threads per core:   1
[    0.212532] CPU topo: Num. cores per package:     8
[    0.212532] CPU topo: Num. threads per package:   8
[    0.212532] CPU topo: Allowing 8 present CPUs plus 0 hotplug CPUs
[    0.212535] CPU topo: Thread    :     8
[    0.212537] CPU topo: Core      :     8
[    0.212539] CPU topo: Module    :     2
[    0.212541] CPU topo: Tile      :     1
[    0.212543] CPU topo: Die       :     1
[    0.212545] CPU topo: Package   :     1

This is all good, however,

# grep . /sys/devices/system/cpu/cpu*/topology/c*_id
/sys/devices/system/cpu/cpu0/topology/cluster_id:0
/sys/devices/system/cpu/cpu0/topology/core_id:0
/sys/devices/system/cpu/cpu1/topology/cluster_id:0
/sys/devices/system/cpu/cpu1/topology/core_id:1
/sys/devices/system/cpu/cpu2/topology/cluster_id:0
/sys/devices/system/cpu/cpu2/topology/core_id:2
/sys/devices/system/cpu/cpu3/topology/cluster_id:0
/sys/devices/system/cpu/cpu3/topology/core_id:3
/sys/devices/system/cpu/cpu4/topology/cluster_id:8
/sys/devices/system/cpu/cpu4/topology/core_id:0
/sys/devices/system/cpu/cpu5/topology/cluster_id:8
/sys/devices/system/cpu/cpu5/topology/core_id:1
/sys/devices/system/cpu/cpu6/topology/cluster_id:8
/sys/devices/system/cpu/cpu6/topology/core_id:2
/sys/devices/system/cpu/cpu7/topology/cluster_id:8
/sys/devices/system/cpu/cpu7/topology/core_id:3

The core_id is broken as it is Module scope unique only. To get package
scope unique core id, it should contain all bits up to package id bits.

thanks,
rui

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ