Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add AMD64 micro architecture level support #7

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

laozc
Copy link

@laozc laozc commented Mar 18, 2024

This commit adds the support for AMD64 micro architecture levels on Linux.

containerd/containerd#9506

@laozc laozc force-pushed the amd64-micro-arch branch 4 times, most recently from 598e890 to 4d9e82b Compare March 18, 2024 04:26
cpuinfo_linux.go Outdated Show resolved Hide resolved
cpuinfo_linux.go Outdated
flagSet[flag] = true
}

// https://unix.stackexchange.com/questions/631217/how-do-i-check-if-my-cpu-supports-x86-64-v2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be better to reference https://tip.golang.org/wiki/MinimumRequirements#amd64 instead

cpuinfo_linux.go Outdated Show resolved Hide resolved
cpuinfo_linux.go Outdated Show resolved Hide resolved
}
} else if isAmd64Arch(runtime.GOARCH) {
var err error
cpuVariantValue, err = getAmd64MicroArchLevel()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not change the value of DefaultSpec(). Default variant for amd64 is still v1 and v8 for arm64 even if chip is v9 compatible. Eg. image created on amd64 system will always be linux/amd64/v1 (normalized to linux/amd64) if user didn't specify that they want to create specific variant (or multiple images with different variants). This does not change depending on whether the building system happens to have AVX support or not.

I'd recommend creating a new function like MaximumSpec similar to https://github.com/moby/moby/blob/v26.1.4/distribution/pull_v2.go#L1089-L1096 that can be used in the cases where comparison to the maximum compatible version is needed (eg. when pulling multi-arch image manifest).

cpuinfo_linux.go Outdated
@@ -158,3 +159,39 @@ func getCPUVariant() (string, error) {

return variant, nil
}

func getAmd64MicroArchLevel() (string, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/tonistiigi/go-archvariant is an alternative here that does not depend on proc or Linux.

@AkihiroSuda
Copy link
Member

@laozc Please check the comments from Tonis

This commit adds the support for AMD64 micro architecture levels
on Linux.

Signed-off-by: Zhongcheng Lao <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants