node-feature-discovery icon indicating copy to clipboard operation
node-feature-discovery copied to clipboard

cpu: ignore unknown cpuid flags on non-x86

Open marquiz opened this issue 3 years ago • 12 comments

Avoid trying to create empty "cpu-cpuid." labels for cpuid flags that we don't have a description for.

marquiz avatar Oct 13 '22 11:10 marquiz

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: marquiz

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment Approvers can cancel approval by writing /approve cancel in a comment

k8s-ci-robot avatar Oct 13 '22 11:10 k8s-ci-robot

Deploy Preview for kubernetes-sigs-nfd ready!

Name Link
Latest commit 98fd07b1171e6cf68a629a507422c3a235fb6261
Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-nfd/deploys/634d62321e6c520008fa6b83
Deploy Preview https://deploy-preview-914--kubernetes-sigs-nfd.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

netlify[bot] avatar Oct 13 '22 11:10 netlify[bot]

Not verified /hold

marquiz avatar Oct 13 '22 12:10 marquiz

ping @Chandan-Abhyankar @yselkowitz

marquiz avatar Oct 13 '22 12:10 marquiz

  1. this should be done for all architectures' code with manually curated lists (arm64, ppc64le, and s390x)
  2. let's also update the cpu flags for POWER 9 and 10, z14/15/16, and ARM v8.latest.

yselkowitz avatar Oct 13 '22 17:10 yselkowitz

  1. this should be done for all architectures' code with manually curated lists (arm64, ppc64le, and s390x)

    1. let's also update the cpu flags for POWER 9 and 10, z14/15/16, and ARM v8.latest.

I think the defensive fix proposed by @marquiz 'future' proofs the code against changes. I do like the referenced PR from Yaakov. It's a great catch/help. Chandan and I can try this out on a p10.

prb112 avatar Oct 13 '22 19:10 prb112

/retitle cpu: ignore unknown cpuid flags on non-x86

marquiz avatar Oct 14 '22 07:10 marquiz

  1. this should be done for all architectures' code with manually curated lists (arm64, ppc64le, and s390x)

Ach, good point @yselkowitz. I updated the PR to handle other non-x86 architectures.

PTAL @Chandan-Abhyankar @yselkowitz @prb112

marquiz avatar Oct 14 '22 07:10 marquiz

Thank you @marquiz , i don't have time to test it on s390x right now and i will be away next week. However the changes look good to me. Since they are the same for all arches, i'm fine with it if they work on the other arches.

One question unrelated to this PR: When i reviewed the loop, where does the capacity from the string array come from?

	r := make([]string, 0, 20)
	hwcap := uint64(C.gethwcap())
	for i := uint(0); i < 64; i++ {

I mean we have 23 Flags defined for s390x and we check 64 bits. Is there a reason the array only has a cap of 20?

jschintag avatar Oct 14 '22 11:10 jschintag

Thanks @jschintag, I'll then be happy with an ack from the arm and ppc guys 😊

One question unrelated to this PR: When i reviewed the loop, where does the capacity from the string array come from?

	r := make([]string, 0, 20)
	hwcap := uint64(C.gethwcap())
	for i := uint(0); i < 64; i++ {

I mean we have 23 Flags defined for s390x and we check 64 bits. Is there a reason the array only has a cap of 20?

Good question, I'm not the original author of this code. I think it's just a (harmless) leftover from some eariler development stage. The slice capacity will get increased if more than 20 flags are present. This could be fixed in a separate PR though, I think (e.g. set cap to len(flagNames_s390x) or something more meaningful).

marquiz avatar Oct 14 '22 12:10 marquiz

@marquiz This works on ppc64le. Chandan has tried it out and would resolve https://github.com/kubernetes-sigs/node-feature-discovery/issues/913

prb112 avatar Oct 14 '22 13:10 prb112

Any arm64 confirmation? @zvonkok @ArangoGutierrez ?

marquiz avatar Oct 14 '22 17:10 marquiz

Rebased after #919 was merged /unhold

marquiz avatar Oct 17 '22 14:10 marquiz

Verified that images build and unit tests pass on arm64 and s390x

marquiz avatar Oct 18 '22 12:10 marquiz

/lgtm

yselkowitz avatar Oct 19 '22 13:10 yselkowitz

@yselkowitz: changing LGTM is restricted to collaborators

In response to this:

/lgtm

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

k8s-ci-robot avatar Oct 19 '22 13:10 k8s-ci-robot

/lgtm

ping @fmuyassarov @zvonkok

marquiz avatar Oct 20 '22 07:10 marquiz

/lgtm

zvonkok avatar Oct 20 '22 07:10 zvonkok

/lgtm

fmuyassarov avatar Oct 20 '22 07:10 fmuyassarov