* bug#74731: guix/cpu should parse /sys/devices/system/cpu/modalias
@ 2024-12-08 7:25 Efraim Flashner
2024-12-09 17:37 ` Ludovic Courtès
0 siblings, 1 reply; 3+ messages in thread
From: Efraim Flashner @ 2024-12-08 7:25 UTC (permalink / raw)
To: 74731
[-- Attachment #1: Type: text/plain, Size: 4407 bytes --]
I saw a post by Marcan¹ of Asahi Linux the other day about not parsing
/proc/cpuinfo and remembered that's what we're doing in (guix cpu).
I've included a couple of dumps below and some notes regarding future
implementation:
// My machine
(ins)efraim@3900XT ~$ cat /sys/devices/system/cpu/modalias
cpu:type:x86,ven0002fam0017mod0071:feature:,0000,0001,0002,0003,0004,0005,0006,0007,0008,0009,000B,000C,000D,000E,000F,0010,0011,0013,0017,0018,0019,001A,001C,0020,0021,0022,0023,0024,0025,0026,0027,0028,0029,002B,002C,002D,002E,002F,0030,0031,0034,0036,0037,0038,0039,003A,003B,003D,0064,0068,006E,0070,0074,0075,0076,0078,0079,007A,007C,007D,0080,0081,0083,0089,008C,008D,0093,0094,0095,0096,0097,0099,009A,009B,009C,009D,009E,00C0,00C1,00C3,00C4,00C5,00C6,00C7,00C8,00C9,00CA,00CC,00CD,00D1,00D6,00D7,00D8,00DA,00DC,00DD,00DE,00E2,00E4,00E6,00E8,00EA,00ED,00F0,00F1,00F2,00F3,00F5,00FA,00FB,00FC,010F,0120,0123,0125,0127,0128,012C,012F,0132,0133,0134,0137,0138,013D,0140,0141,0142,0160,0161,0162,0163,0165,016C,016E,016F,0170,0178,017C,01A0,01A1,01A2,01A4,01A6,01A9,01AA,01AC,01AD,01AF,01B2,01B3,01B8,01C2,01E0,01E1,01E2,01E3,01E4,01E5,01E6,01E7,01EA,01EB,01EC,01ED,01EF,01F0,01F1,01F4,0202,0216,0220,0221,0223,0224,0261,0262,0263,0270,0282,029C
// Berlin, aka ci.guix.gnu.org
(ins)efraim@berlin ~$ cat /sys/devices/system/cpu/modalias
cpu:type:x86,ven0002fam0017mod0001:feature:,0000,0001,0002,0003,0004,0005,0006,0007,0008,0009,000B,000C,000D,000E,000F,0010,0011,0013,0017,0018,0019,001A,001C,0020,0021,0022,0023,0024,0025,0026,0027,0028,0029,002B,002C,002D,002E,002F,0030,0031,0034,0036,0037,0038,0039,003A,003B,003D,0064,0068,006E,0070,0074,0075,0078,0079,007A,007B,007C,007D,0080,0081,0083,0089,008C,008D,0093,0094,0096,0097,0099,009A,009B,009C,009D,009E,00C0,00C1,00C2,00C3,00C4,00C5,00C6,00C7,00C8,00C9,00CC,00CD,00D1,00D6,00D7,00D8,00DA,00DC,00DD,00E2,00E8,00EA,00ED,00F1,00F3,00F5,00F8,00FA,00FC,010F,0120,0123,0125,0127,0128,0132,0133,0134,0137,013D,0140,0141,0142,0143,0165,016C,016E,016F,0170,0178,017F,01A0,01A1,01A2,01AC,01C2,01E0,01E1,01E2,01E3,01E4,01E5,01E6,01E7,01EA,01EB,01EC,01ED,01EF,01F0,0220,0221,0223,0224,0261,0262,0263,0282,029C
// pine64, kickstarter addition
(ins)efraim@3900XT ~$ ssh pine64 cat /sys/devices/system/cpu/modalias
cpu:type:aarch64:feature:,0000,0001,0002,0003,0004,0005,0006,0007,000B
// rock64
(ins)efraim@3900XT ~$ ssh rock64 cat /sys/devices/system/cpu/modalias
cpu:type:aarch64:feature:,0000,0001,0002,0003,0004,0005,0006,0007,000B
// raspberry pi 5b
(ins)efraim@3900XT ~$ ssh ubuntu.unicorn-typhon.ts.net cat /sys/devices/system/cpu/modalias
efraim@ubuntu.unicorn-typhon.ts.net: Permission denied (publickey).
(ins)efraim@3900XT ~$ ssh ubuntu@ubuntu.unicorn-typhon.ts.net cat /sys/devices/system/cpu/modalias
cpu:type:aarch64:feature:,0000,0001,0002,0003,0004,0005,0006,0007,0008,0009,000A,000B,000C,000F,0010,0014
// power9 machine from OSU for ci.guix.gnu.org
(ins)efraim@3900XT ~$ ssh guixp9 cat /sys/devices/system/cpu/modalias
cpu:type:power9:feature:,0001,0006,0007,0008,000A,000D,000E,001A,001B,001C,001E,001F,0034,0035,0036,0037,0039,003A,003B,003C,003D,003F
// rpi 1b
(ins)efraim@3900XT ~$ ssh 192.168.68.50 cat /sys/devices/system/cpu/modalias
cpu:type:v6l:feature:,0001,0002,0004,0006,0007,0008,000F
// hifive unmatched, riscv64
(ins)efraim@3900XT ~$ ssh 192.168.68.51 cat /sys/devices/system/cpu/modalias
cat: /sys/devices/system/cpu/modalias: No such file or directory
// macbook 4,1 I think
(ins)efraim@3900XT ~$ ssh israel.unicorn-typhon.ts.net cat /sys/devices/system/cpu/modalias
cpu:type:x86,ven0000fam0006mod0017:feature:,0000,0001,0002,0003,0004,0005,0006,0007,0008,0009,000B,000C,000D,000E,000F,0010,0011,0013,0015,0016,0017,0018,0019,001A,001C,001D,001F,002B,0034,003D,0068,006B,006C,006D,006F,0070,0072,0074,0075,0079,007C,0080,0082,0083,0084,0085,0087,0088,0089,008D,008E,008F,0093,00C0,00EB,00ED,00F3,00FD,00FF,0100,0101,0102,0104,0165,016C,0172,01C0
arch/x86/include/asm/cpufeatures.h
list of CPU features for x86 and x86_64
I haven't been able to find the table for other architectures yet.
¹ https://social.treehouse.systems/@marcan/113548772069263164
--
Efraim Flashner <efraim@flashner.co.il> אפרים פלשנר
GPG key = A28B F40C 3E55 1372 662D 14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#74731: guix/cpu should parse /sys/devices/system/cpu/modalias
2024-12-08 7:25 bug#74731: guix/cpu should parse /sys/devices/system/cpu/modalias Efraim Flashner
@ 2024-12-09 17:37 ` Ludovic Courtès
2024-12-10 8:16 ` Efraim Flashner
0 siblings, 1 reply; 3+ messages in thread
From: Ludovic Courtès @ 2024-12-09 17:37 UTC (permalink / raw)
To: Efraim Flashner; +Cc: 74731
Hello,
Efraim Flashner <efraim@flashner.co.il> skribis:
> I saw a post by Marcan¹ of Asahi Linux the other day about not parsing
> /proc/cpuinfo and remembered that's what we're doing in (guix cpu).
I believe it initially mimicked what GCC does for ‘-march=native’, but
it does seem to be less exhaustive than /sys/devices/cpu/modalias.
I wonder if there are version/portability issues with the latter.
Ludo’.
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#74731: guix/cpu should parse /sys/devices/system/cpu/modalias
2024-12-09 17:37 ` Ludovic Courtès
@ 2024-12-10 8:16 ` Efraim Flashner
0 siblings, 0 replies; 3+ messages in thread
From: Efraim Flashner @ 2024-12-10 8:16 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: 74731
[-- Attachment #1: Type: text/plain, Size: 2161 bytes --]
On Mon, Dec 09, 2024 at 06:37:22PM +0100, Ludovic Courtès wrote:
> Hello,
>
> Efraim Flashner <efraim@flashner.co.il> skribis:
>
> > I saw a post by Marcan¹ of Asahi Linux the other day about not parsing
> > /proc/cpuinfo and remembered that's what we're doing in (guix cpu).
>
> I believe it initially mimicked what GCC does for ‘-march=native’, but
> it does seem to be less exhaustive than /sys/devices/cpu/modalias.
>
> I wonder if there are version/portability issues with the latter.
I've been thinking more about it over the past few days.
I think ultimately we need to match both parts; the kernel interfaces
with the hardware and knows (or at least should know) exactly what the
hardware can support, and gcc (or the other compilers) need to support
optimizing for those hardware bits specifically.
Also, parsing /proc/cpuinfo is already reading what the kernel says it
supports, except in an incomplete manner.
Starting with x86_64 (and i686), I think we keep GCC's definition of
what each sub-architecture is but parse the modalias file instead of
parsing cpuinfo.
I already have some code to parse modalias and some ideas for just
reusing the math bits from the kernel (it looks like ((11*32)+28) for
zen2) to adjust the if-flags to match the numerical equivalent of the
feature.
For x86_64 the kernel does have a policy of reusing flags if they've
been deprecated and unused long enough, but hopefully that won't be a
problem, even with some of our older LTS kernels.
I think for the start it would make most sense to read modalias in
addition to cpuinfo, sort based on the data in modialis, and then
fallback to cpuinfo if it doesn't match. This helps for architectures
without the modalias file (like riscv64), and I don't know what the Hurd
provides, but I'd be surprised if it had the same modalias file for
parsing.
I'll try to work on it a bit over the coming days.
--
Efraim Flashner <efraim@flashner.co.il> אפרים פלשנר
GPG key = A28B F40C 3E55 1372 662D 14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-12-10 8:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-08 7:25 bug#74731: guix/cpu should parse /sys/devices/system/cpu/modalias Efraim Flashner
2024-12-09 17:37 ` Ludovic Courtès
2024-12-10 8:16 ` Efraim Flashner
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.