GNU bug report logs - #74731
guix/cpu should parse /sys/devices/system/cpu/modalias

Previous Next

Package: guix;

Reported by: Efraim Flashner <efraim <at> flashner.co.il>

Date: Sun, 8 Dec 2024 07:27:02 UTC

Severity: normal

To reply to this bug, email your comments to 74731 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guix <at> gnu.org:
bug#74731; Package guix. (Sun, 08 Dec 2024 07:27:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Efraim Flashner <efraim <at> flashner.co.il>:
New bug report received and forwarded. Copy sent to bug-guix <at> gnu.org. (Sun, 08 Dec 2024 07:27:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Efraim Flashner <efraim <at> flashner.co.il>
To: bug-guix <at> gnu.org
Subject: guix/cpu should parse /sys/devices/system/cpu/modalias
Date: Sun, 8 Dec 2024 09:25:59 +0200
[Message part 1 (text/plain, inline)]
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 <at> 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 <at> 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 <at> 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 <at> 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 <at> 3900XT ~$ ssh ubuntu.unicorn-typhon.ts.net cat /sys/devices/system/cpu/modalias
efraim <at> ubuntu.unicorn-typhon.ts.net: Permission denied (publickey).
(ins)efraim <at> 3900XT ~$ ssh ubuntu <at> 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 <at> 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 <at> 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 <at> 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 <at> 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 <at> 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
[signature.asc (application/pgp-signature, inline)]

Information forwarded to bug-guix <at> gnu.org:
bug#74731; Package guix. (Mon, 09 Dec 2024 17:38:01 GMT) Full text and rfc822 format available.

Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Efraim Flashner <efraim <at> flashner.co.il>
Cc: bug-guix <at> gnu.org
Subject: Re: bug#74731: guix/cpu should parse /sys/devices/system/cpu/modalias
Date: Mon, 09 Dec 2024 18:37:22 +0100
Hello,

Efraim Flashner <efraim <at> 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’.




Information forwarded to bug-guix <at> gnu.org:
bug#74731; Package guix. (Tue, 10 Dec 2024 08:18:02 GMT) Full text and rfc822 format available.

Message #11 received at 74731 <at> debbugs.gnu.org (full text, mbox):

From: Efraim Flashner <efraim <at> flashner.co.il>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 74731 <at> debbugs.gnu.org
Subject: Re: bug#74731: guix/cpu should parse /sys/devices/system/cpu/modalias
Date: Tue, 10 Dec 2024 10:16:44 +0200
[Message part 1 (text/plain, inline)]
On Mon, Dec 09, 2024 at 06:37:22PM +0100, Ludovic Courtès wrote:
> Hello,
> 
> Efraim Flashner <efraim <at> 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 <at> 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
[signature.asc (application/pgp-signature, inline)]

This bug report was last modified 184 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.