Skip to contentSkip to conversation

selftests: resctrl: ignore builds for unsupported architectures

PATCH In review Muhammad Usama Anjum 4 participants 10 messages Aug 9, 2024 – Aug 13, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests: resctrl: ignore builds for unsupported architectures

This test doesn't have support for other architectures. Altough resctrl is supported on x86 and ARM, but arch_supports_noncont_cat() shows that only x86 for AMD and Intel are supported by the test. We get build errors when built for ARM and ARM64.

Hence add support in the Makefile to build this suite only for x86 and x86_64 architectures.

Fixes b733143cc455 ("selftests/resctrl: Make resctrl_tests run using kselftest framework")
---
 tools/testing/selftests/resctrl/Makefile | 2 ++
 1 file changed, 2 insertions(+)
tools/testing/selftests/resctrl/Makefile +2 -0
index f408bd6bfc3d4..d5cf96315ef9b 100644
@@ -3,7 +3,9 @@
 CFLAGS = -g -Wall -O2 -D_FORTIFY_SOURCE=2
 CFLAGS += $(KHDR_INCLUDES)
 
+ifeq ($(ARCH),$(filter $(ARCH),x86 x86_64))
 TEST_GEN_PROGS := resctrl_tests
+endif
 
 LOCAL_HDRS += $(wildcard *.h)
 
Signature · 1 line
2.39.2
#1 lore raw
Quoted 3 lines · Muhammad Usama Anjum

This test doesn't have support for other architectures. Altough resctrl is supported on x86 and ARM, but arch_supports_noncont_cat() shows that only x86 for AMD and Intel are supported by the test.

One does not follow from the other. arch_supports_noncont_cat() is only small part of the tests so saying "This test" based on a small subset of all tests is bogus. Also, I don't see any reason why ARCH_ARM could not be added and arch_supports_noncont_cat() adapted accordingly.

Quoted 2 lines

We get build
errors when built for ARM and ARM64.

As this seems the real reason, please quote any errors when you use them as justification so it can be reviewed if the reasoning is sound or not.

Signature · 1 line
 i.
Quoted 24 lines

Hence add support in the Makefile to build this suite only for x86 and x86_64 architectures.

Fixes b733143cc455 ("selftests/resctrl: Make resctrl_tests run using kselftest framework")
---
 tools/testing/selftests/resctrl/Makefile | 2 ++
 1 file changed, 2 insertions(+)
tools/testing/selftests/resctrl/Makefile +2 -0
index f408bd6bfc3d4..d5cf96315ef9b 100644
@@ -3,7 +3,9 @@
 CFLAGS = -g -Wall -O2 -D_FORTIFY_SOURCE=2
 CFLAGS += $(KHDR_INCLUDES)
 
+ifeq ($(ARCH),$(filter $(ARCH),x86 x86_64))
 TEST_GEN_PROGS := resctrl_tests
+endif
 
 LOCAL_HDRS += $(wildcard *.h)
 
#2 lore raw
Quoted 10 lines · Ilpo Järvinen
Quoted 3 lines · Muhammad Usama Anjum

This test doesn't have support for other architectures. Altough resctrl is supported on x86 and ARM, but arch_supports_noncont_cat() shows that only x86 for AMD and Intel are supported by the test.

One does not follow from the other. arch_supports_noncont_cat() is only small part of the tests so saying "This test" based on a small subset of all tests is bogus. Also, I don't see any reason why ARCH_ARM could not be added and arch_supports_noncont_cat() adapted accordingly.

I'm not familiar with resctrl and the architectural part of it. Feel free to fix it and ignore this patch.

If more things are missing than just adjusting arch_supports_noncont_cat(), the test should be turned off until proper support is added to the test.

Quoted 6 lines
Quoted 3 lines

We get build
errors when built for ARM and ARM64.

As this seems the real reason, please quote any errors when you use them as justification so it can be reviewed if the reasoning is sound or not.

CC resctrl_tests
In file included from resctrl.h:24,

                 from cat_test.c:11:

In function 'arch_supports_noncont_cat',
inlined from 'noncont_cat_run_test' at cat_test.c:323:6:
../kselftest.h:74:9: error: impossible constraint in 'asm'
74 | __asm__ __volatile__ ("cpuid\n\t"

       \
      |         ^~~~~~~
cat_test.c:301:17: note: in expansion of macro '__cpuid_count'
  301 |                 __cpuid_count(0x10, 1, eax, ebx, ecx, edx);
      |                 ^~~~~~~~~~~~~
../kselftest.h:74:9: error: impossible constraint in 'asm'
   74 |         __asm__ __volatile__ ("cpuid\n\t"
       \
      |         ^~~~~~~
cat_test.c:303:17: note: in expansion of macro '__cpuid_count'
  303 |                 __cpuid_count(0x10, 2, eax, ebx, ecx, edx);
      |                 ^~~~~~~~~~~~~
Signature · 2 lines
BR,
Muhammad Usama Anjum
#3 lore raw

Adding Maciej.

Quoted 31 lines · Muhammad Usama Anjum
Quoted 10 lines · Ilpo Järvinen
Quoted 3 lines · Muhammad Usama Anjum

This test doesn't have support for other architectures. Altough resctrl is supported on x86 and ARM, but arch_supports_noncont_cat() shows that only x86 for AMD and Intel are supported by the test.

One does not follow from the other. arch_supports_noncont_cat() is only small part of the tests so saying "This test" based on a small subset of all tests is bogus. Also, I don't see any reason why ARCH_ARM could not be added and arch_supports_noncont_cat() adapted accordingly.

I'm not familiar with resctrl and the architectural part of it. Feel free to fix it and ignore this patch.

If more things are missing than just adjusting arch_supports_noncont_cat(), the test should be turned off until proper support is added to the test.

Quoted 5 lines
Quoted 2 lines

We get build
errors when built for ARM and ARM64.

As this seems the real reason, please quote any errors when you use them as justification so it can be reviewed if the reasoning is sound or not.

CC resctrl_tests
In file included from resctrl.h:24,

                 from cat_test.c:11:

In function 'arch_supports_noncont_cat',
inlined from 'noncont_cat_run_test' at cat_test.c:323:6:
../kselftest.h:74:9: error: impossible constraint in 'asm'
74 | __asm__ __volatile__ ("cpuid\n\t"

Quoted 12 lines
       \
      |         ^~~~~~~
cat_test.c:301:17: note: in expansion of macro '__cpuid_count'
  301 |                 __cpuid_count(0x10, 1, eax, ebx, ecx, edx);
      |                 ^~~~~~~~~~~~~
../kselftest.h:74:9: error: impossible constraint in 'asm'
   74 |         __asm__ __volatile__ ("cpuid\n\t"
       \
      |         ^~~~~~~
cat_test.c:303:17: note: in expansion of macro '__cpuid_count'
  303 |                 __cpuid_count(0x10, 2, eax, ebx, ecx, edx);
      |                 ^~~~~~~~~~~~~

Okay, so it's specific to lack of CPUID. This seems a kselftest common level problem to me, since __cpuid_count() is provided in kselftest.h.

Shuah (or others), what is the intended mechanism for selftests to know if it can be used or not since as is, it's always defined?

I see some Makefiles use compile testing a trivial program to decide whether they build some x86_64 tests or not. Is that what should be done here too, test if __cpuid_count() compiles or not (and then build some #ifdeffery based on the result of that compile testing)?

Signature · 1 line
 i.
maintainer
#4 lore raw
Quoted 50 lines · Ilpo Järvinen

Adding Maciej.

Quoted 35 lines · Muhammad Usama Anjum
Quoted 10 lines · Ilpo Järvinen
Quoted 3 lines · Muhammad Usama Anjum

This test doesn't have support for other architectures. Altough resctrl is supported on x86 and ARM, but arch_supports_noncont_cat() shows that only x86 for AMD and Intel are supported by the test.

One does not follow from the other. arch_supports_noncont_cat() is only small part of the tests so saying "This test" based on a small subset of all tests is bogus. Also, I don't see any reason why ARCH_ARM could not be added and arch_supports_noncont_cat() adapted accordingly.

I'm not familiar with resctrl and the architectural part of it. Feel free to fix it and ignore this patch.

If more things are missing than just adjusting arch_supports_noncont_cat(), the test should be turned off until proper support is added to the test.

Quoted 5 lines
Quoted 2 lines

We get build
errors when built for ARM and ARM64.

As this seems the real reason, please quote any errors when you use them as justification so it can be reviewed if the reasoning is sound or not.

CC resctrl_tests
In file included from resctrl.h:24,

                  from cat_test.c:11:
In function 'arch_supports_noncont_cat',
     inlined from 'noncont_cat_run_test' at cat_test.c:323:6:
../kselftest.h:74:9: error: impossible constraint in 'asm'
    74 |         __asm__ __volatile__ ("cpuid\n\t"
        \
       |         ^~~~~~~
cat_test.c:301:17: note: in expansion of macro '__cpuid_count'
   301 |                 __cpuid_count(0x10, 1, eax, ebx, ecx, edx);
Quoted 8 lines
       |                 ^~~~~~~~~~~~~
../kselftest.h:74:9: error: impossible constraint in 'asm'
    74 |         __asm__ __volatile__ ("cpuid\n\t"
        \
       |         ^~~~~~~
cat_test.c:303:17: note: in expansion of macro '__cpuid_count'
   303 |                 __cpuid_count(0x10, 2, eax, ebx, ecx, edx);
       |                 ^~~~~~~~~~~~~

Okay, so it's specific to lack of CPUID. This seems a kselftest common level problem to me, since __cpuid_count() is provided in kselftest.h.

Quoted 8 lines

Shuah (or others), what is the intended mechanism for selftests to know if it can be used or not since as is, it's always defined?

I see some Makefiles use compile testing a trivial program to decide whether they build some x86_64 tests or not. Is that what should be done here too, test if __cpuid_count() compiles or not (and then build some #ifdeffery based on the result of that compile testing)?

It is not obvious to me that resctrl needs those "trivial program" compile tests. For testing the target architecture ARCH seems appropriate. I do not think it is guaranteed that ARCH will always be set though so the Makefile may need an additional snippet to set ARCH to "uname -m" if it is not provided by environment, similar to what is done in other Makefiles.

Reinette

maintainer
#5 lore raw
In reply to Ilpo Järvinen
Quoted 47 lines · Ilpo Järvinen

Adding Maciej.

Quoted 35 lines · Muhammad Usama Anjum
Quoted 10 lines · Ilpo Järvinen
Quoted 3 lines · Muhammad Usama Anjum

This test doesn't have support for other architectures. Altough resctrl is supported on x86 and ARM, but arch_supports_noncont_cat() shows that only x86 for AMD and Intel are supported by the test.

One does not follow from the other. arch_supports_noncont_cat() is only small part of the tests so saying "This test" based on a small subset of all tests is bogus. Also, I don't see any reason why ARCH_ARM could not be added and arch_supports_noncont_cat() adapted accordingly.

I'm not familiar with resctrl and the architectural part of it. Feel free to fix it and ignore this patch.

If more things are missing than just adjusting arch_supports_noncont_cat(), the test should be turned off until proper support is added to the test.

Quoted 5 lines
Quoted 2 lines

We get build
errors when built for ARM and ARM64.

As this seems the real reason, please quote any errors when you use them as justification so it can be reviewed if the reasoning is sound or not.

CC resctrl_tests
In file included from resctrl.h:24,

                  from cat_test.c:11:
In function 'arch_supports_noncont_cat',
     inlined from 'noncont_cat_run_test' at cat_test.c:323:6:
../kselftest.h:74:9: error: impossible constraint in 'asm'
    74 |         __asm__ __volatile__ ("cpuid\n\t"
        \
       |         ^~~~~~~
cat_test.c:301:17: note: in expansion of macro '__cpuid_count'
   301 |                 __cpuid_count(0x10, 1, eax, ebx, ecx, edx);
Quoted 8 lines
       |                 ^~~~~~~~~~~~~
../kselftest.h:74:9: error: impossible constraint in 'asm'
    74 |         __asm__ __volatile__ ("cpuid\n\t"
        \
       |         ^~~~~~~
cat_test.c:303:17: note: in expansion of macro '__cpuid_count'
   303 |                 __cpuid_count(0x10, 2, eax, ebx, ecx, edx);
       |                 ^~~~~~~~~~~~~
Quoted 5 lines

Okay, so it's specific to lack of CPUID. This seems a kselftest common level problem to me, since __cpuid_count() is provided in kselftest.h.

Shuah (or others), what is the intended mechanism for selftests to know if it can be used or not since as is, it's always defined?

_cpuid_count() gets defined in ksefltest.h if it can't find it.

As the comment says both gcc and cland probide __cpuid_count()

gcc cpuid.h provides __cpuid_count() since v4.4. Clang/LLVM cpuid.h provides __cpuid_count() since v3.4.0.

Quoted 6 lines

I see some Makefiles use compile testing a trivial program to decide whether they build some x86_64 tests or not. Is that what should be done here too, test if __cpuid_count() compiles or not (and then build some #ifdeffery based on the result of that compile testing)?

These build errors need to be fixed instead of restricting the build.

In some cases when the test can't be supported on an architecture then it is okay to suppress build. This is not a general solution to suppress build warnings

I would recommend against adding suppress build code when it can be fixed.

Let's investigate this problem to fix it properly. I don't see any arm and arm64 maintainers and developers on this thread. It would be good to investigate to see if this can be fixed.

thanks,
-- Shuah

maintainer
#6 lore raw

Hi Shuah,

Quoted 61 lines · Shuah Khan
Quoted 47 lines · Ilpo Järvinen

Adding Maciej.

Quoted 35 lines · Muhammad Usama Anjum
Quoted 10 lines · Ilpo Järvinen
Quoted 3 lines · Muhammad Usama Anjum

This test doesn't have support for other architectures. Altough resctrl is supported on x86 and ARM, but arch_supports_noncont_cat() shows that only x86 for AMD and Intel are supported by the test.

One does not follow from the other. arch_supports_noncont_cat() is only small part of the tests so saying "This test" based on a small subset of all tests is bogus. Also, I don't see any reason why ARCH_ARM could not be added and arch_supports_noncont_cat() adapted accordingly.

I'm not familiar with resctrl and the architectural part of it. Feel free to fix it and ignore this patch.

If more things are missing than just adjusting arch_supports_noncont_cat(), the test should be turned off until proper support is added to the test.

Quoted 5 lines
Quoted 2 lines

We get build
errors when built for ARM and ARM64.

As this seems the real reason, please quote any errors when you use them as justification so it can be reviewed if the reasoning is sound or not.

   CC       resctrl_tests
In file included from resctrl.h:24,
                  from cat_test.c:11:
In function 'arch_supports_noncont_cat',
     inlined from 'noncont_cat_run_test' at cat_test.c:323:6:
../kselftest.h:74:9: error: impossible constraint in 'asm' 74 |         __asm__ __volatile__ ("cpuid\n\t"
        \
       |         ^~~~~~~
cat_test.c:301:17: note: in expansion of macro '__cpuid_count' 301 |                 __cpuid_count(0x10, 1, eax, ebx, ecx, edx);

Quoted 8 lines

       |                 ^~~~~~~~~~~~~ ../kselftest.h:74:9: error: impossible constraint in 'asm' 74 |         __asm__ __volatile__ ("cpuid\n\t"
        \
       |         ^~~~~~~
cat_test.c:303:17: note: in expansion of macro '__cpuid_count' 303 |                 __cpuid_count(0x10, 2, eax, ebx, ecx, edx); |                 ^~~~~~~~~~~~~

Quoted 5 lines

Okay, so it's specific to lack of CPUID. This seems a kselftest common level problem to me, since __cpuid_count() is provided in kselftest.h.

Shuah (or others), what is the intended mechanism for selftests to know if it can be used or not since as is, it's always defined?

_cpuid_count() gets defined in ksefltest.h if it can't find it.

As the comment says both gcc and cland probide __cpuid_count()

  gcc cpuid.h provides __cpuid_count() since v4.4. Clang/LLVM cpuid.h provides  __cpuid_count() since v3.4.0.

Quoted 1 line
Quoted 8 lines
Quoted 5 lines

I see some Makefiles use compile testing a trivial program to decide whether they build some x86_64 tests or not. Is that what should be done here too, test if __cpuid_count() compiles or not (and then build some #ifdeffery based on the result of that compile testing)?

These build errors need to be fixed instead of restricting the build> In some cases when the test can't be supported on an architecture then it is okay to suppress build. This is not a general solution to suppress build warnings

While there is an effort to support Arm in resctrl [1], this is not currently the case and the resctrl selftests as a consequence only support x86 with built-in assumptions that a test runs on either AMD or Intel. After the kernel gains support for Arm more changes will be needed for the resctrl tests to support another architecture so I do think the most appropriate change to address this build failure is to restrict resctrl tests to x86.

Quoted 2 lines

I would recommend against adding suppress build code when it can be fixed.

I expect after resctrl fs obtains support for Arm the resctrl selftests can be updated to support it with more fine grained architectural checks than a global enable/disable needed at this time.

Quoted 4 lines

Let's investigate this problem to fix it properly. I don't see any arm and arm64 maintainers and developers on this thread. It would be good to investigate to see if this can be fixed.

Reinette

[1] https://lore.kernel.org/lkml/[email protected]/

#7 lore raw
Quoted 81 lines · Reinette Chatre
Quoted 75 lines · Shuah Khan
Quoted 54 lines · Ilpo Järvinen

Adding Maciej.

Quoted 42 lines · Muhammad Usama Anjum
Quoted 8 lines · Ilpo Järvinen
Quoted 5 lines · Muhammad Usama Anjum

This test doesn't have support for other architectures. Altough resctrl
is supported on x86 and ARM, but arch_supports_noncont_cat() shows that
only x86 for AMD and Intel are supported by the test.

Quoted 7 lines

One does not follow from the other. arch_supports_noncont_cat() is only
small part of the tests so saying "This test" based on a small subset of
all tests is bogus. Also, I don't see any reason why ARCH_ARM could not be
added and arch_supports_noncont_cat() adapted accordingly.

I'm not familiar with resctrl and the architectural part of it. Feel free to fix it and ignore this patch.

If more things are missing than just adjusting arch_supports_noncont_cat(), the test should be turned off until proper support is added to the test.

Quoted 7 lines
Quoted 2 lines

We get build
errors when built for ARM and ARM64.

As this seems the real reason, please quote any errors when you use them
as justification so it can be reviewed if the reasoning is sound or not.

   CC       resctrl_tests
In file included from resctrl.h:24,
                  from cat_test.c:11:
In function 'arch_supports_noncont_cat',
     inlined from 'noncont_cat_run_test' at cat_test.c:323:6:
../kselftest.h:74:9: error: impossible constraint in 'asm' 74 |         __asm__ __volatile__ ("cpuid\n\t"
        \
       |         ^~~~~~~
cat_test.c:301:17: note: in expansion of macro '__cpuid_count' 301 |                 __cpuid_count(0x10, 1, eax, ebx, ecx, edx);

Quoted 8 lines

       |                 ^~~~~~~~~~~~~ ../kselftest.h:74:9: error: impossible constraint in 'asm' 74 |         __asm__ __volatile__ ("cpuid\n\t"
        \
       |         ^~~~~~~
cat_test.c:303:17: note: in expansion of macro '__cpuid_count' 303 |                 __cpuid_count(0x10, 2, eax, ebx, ecx, edx); |                 ^~~~~~~~~~~~~

Quoted 5 lines

Okay, so it's specific to lack of CPUID. This seems a kselftest common level problem to me, since __cpuid_count() is provided in kselftest.h.

Shuah (or others), what is the intended mechanism for selftests to know if it can be used or not since as is, it's always defined?

_cpuid_count() gets defined in ksefltest.h if it can't find it.

As the comment says both gcc and cland probide __cpuid_count()

  gcc cpuid.h provides __cpuid_count() since v4.4. Clang/LLVM cpuid.h provides  __cpuid_count() since v3.4.0.

Quoted 7 lines

I see some Makefiles use compile testing a trivial program to decide whether
they build some x86_64 tests or not. Is that what should be done here too, test if __cpuid_count() compiles or not (and then build some #ifdeffery based on the result of that compile testing)?

Quoted 4 lines

These build errors need to be fixed instead of restricting the build> In some cases when the test can't be supported on an architecture then it is okay
to suppress build. This is not a general solution to suppress build warnings

Quoted 9 lines

While there is an effort to support Arm in resctrl [1], this is not currently the case and the resctrl selftests as a consequence only support x86 with built-in assumptions that a test runs on either AMD or Intel. After the kernel gains support
for Arm more changes will be needed for the resctrl tests to support another architecture
so I do think the most appropriate change to address this build failure is to restrict
resctrl tests to x86.

While ARM lacks resctrl support at the moment (the patch BTW claims otherwise), this problem is general-level problem in selftests. When somebody includes kselftest.h, the header provided __cpuid_count() which seems to not be compilable on ARMs (even if the test itself would never call it on other than when running on Intel). Some #ifdeffery is necessary either in kselftest.h or in the test code.

Quoted 6 lines
Quoted 1 line

I would recommend against adding suppress build code when it can be fixed.

I expect after resctrl fs obtains support for Arm the resctrl selftests can be updated to support it with more fine grained architectural checks than a global
enable/disable needed at this time.

That won't help to a build failure. The build would fail on ARM even if there's some resctrl specific test for arch done by the test itself.

Quoted 5 lines
Quoted 5 lines

Let's investigate this problem to fix it properly. I don't see any arm and arm64
maintainers and developers on this thread. It would be good to investigate to
see if this can be fixed.

Yes, I was hoping there would be a general level solution which would provide e.g. HAS_CPUID_COUNT or an empty stub for __cpuid_count() or something along those lines.

Signature · 1 line
 i.
Quoted 1 line

[1] https://lore.kernel.org/lkml/[email protected]/

maintainer
#8 lore raw
Quoted 101 lines · Ilpo Järvinen
Quoted 81 lines · Reinette Chatre
Quoted 75 lines · Shuah Khan
Quoted 54 lines · Ilpo Järvinen

Adding Maciej.

Quoted 42 lines · Muhammad Usama Anjum
Quoted 8 lines · Ilpo Järvinen
Quoted 5 lines · Muhammad Usama Anjum

This test doesn't have support for other architectures. Altough resctrl
is supported on x86 and ARM, but arch_supports_noncont_cat() shows that
only x86 for AMD and Intel are supported by the test.

Quoted 7 lines

One does not follow from the other. arch_supports_noncont_cat() is only
small part of the tests so saying "This test" based on a small subset of
all tests is bogus. Also, I don't see any reason why ARCH_ARM could not be
added and arch_supports_noncont_cat() adapted accordingly.

I'm not familiar with resctrl and the architectural part of it. Feel free to fix it and ignore this patch.

If more things are missing than just adjusting arch_supports_noncont_cat(), the test should be turned off until proper support is added to the test.

Quoted 7 lines
Quoted 2 lines

We get build
errors when built for ARM and ARM64.

As this seems the real reason, please quote any errors when you use them
as justification so it can be reviewed if the reasoning is sound or not.

   CC       resctrl_tests
In file included from resctrl.h:24,
                  from cat_test.c:11:
In function 'arch_supports_noncont_cat',
     inlined from 'noncont_cat_run_test' at cat_test.c:323:6:
../kselftest.h:74:9: error: impossible constraint in 'asm'
    74 |         __asm__ __volatile__ ("cpuid\n\t"
        \
       |         ^~~~~~~
cat_test.c:301:17: note: in expansion of macro '__cpuid_count'
   301 |                 __cpuid_count(0x10, 1, eax, ebx, ecx, edx);

Quoted 8 lines

       |                 ^~~~~~~~~~~~~
../kselftest.h:74:9: error: impossible constraint in 'asm'
    74 |         __asm__ __volatile__ ("cpuid\n\t"
        \
       |         ^~~~~~~
cat_test.c:303:17: note: in expansion of macro '__cpuid_count'
   303 |                 __cpuid_count(0x10, 2, eax, ebx, ecx, edx); |                 ^~~~~~~~~~~~~

Quoted 5 lines

Okay, so it's specific to lack of CPUID. This seems a kselftest common level problem to me, since __cpuid_count() is provided in kselftest.h.

Shuah (or others), what is the intended mechanism for selftests to know if it can be used or not since as is, it's always defined?

_cpuid_count() gets defined in ksefltest.h if it can't find it.

As the comment says both gcc and cland probide __cpuid_count()

  gcc cpuid.h provides __cpuid_count() since v4.4. Clang/LLVM cpuid.h provides  __cpuid_count() since v3.4.0.

Quoted 7 lines

I see some Makefiles use compile testing a trivial program to decide whether
they build some x86_64 tests or not. Is that what should be done here too, test if __cpuid_count() compiles or not (and then build some #ifdeffery based on the result of that compile testing)?

Quoted 4 lines

These build errors need to be fixed instead of restricting the build> In some cases when the test can't be supported on an architecture then it is okay
to suppress build. This is not a general solution to suppress build warnings

Quoted 9 lines

While there is an effort to support Arm in resctrl [1], this is not currently the case and the resctrl selftests as a consequence only support x86 with built-in assumptions that a test runs on either AMD or Intel. After the kernel gains support
for Arm more changes will be needed for the resctrl tests to support another architecture
so I do think the most appropriate change to address this build failure is to restrict
resctrl tests to x86.

While ARM lacks resctrl support at the moment (the patch BTW claims otherwise), this problem is general-level problem in selftests. When somebody includes kselftest.h, the header provided __cpuid_count() which seems to not be compilable on ARMs (even if the test itself would never call it on other than when running on Intel). Some #ifdeffery is necessary either in kselftest.h or in the test code.

Quoted 2 lines
Quoted 1 line

I would recommend against adding suppress build code when it can be fixed.

Quoted 7 lines
Quoted 4 lines

I expect after resctrl fs obtains support for Arm the resctrl selftests can be updated to support it with more fine grained architectural checks than a global
enable/disable needed at this time.

That won't help to a build failure. The build would fail on ARM even if there's some resctrl specific test for arch done by the test itself.

I see.

Quoted 10 lines
Quoted 6 lines
Quoted 6 lines

Let's investigate this problem to fix it properly. I don't see any arm and arm64
maintainers and developers on this thread. It would be good to investigate to
see if this can be fixed.

Yes, I was hoping there would be a general level solution which would provide e.g. HAS_CPUID_COUNT or an empty stub for __cpuid_count() or something along those lines.

Can we try to make this change?

thanks,
-- Shuah

maintainer
#9 lore raw
In reply to Reinette Chatre
Quoted 73 lines · Reinette Chatre

Hi Shuah,

Quoted 61 lines · Shuah Khan
Quoted 47 lines · Ilpo Järvinen

Adding Maciej.

Quoted 35 lines · Muhammad Usama Anjum
Quoted 10 lines · Ilpo Järvinen
Quoted 3 lines · Muhammad Usama Anjum

This test doesn't have support for other architectures. Altough resctrl is supported on x86 and ARM, but arch_supports_noncont_cat() shows that only x86 for AMD and Intel are supported by the test.

One does not follow from the other. arch_supports_noncont_cat() is only small part of the tests so saying "This test" based on a small subset of all tests is bogus. Also, I don't see any reason why ARCH_ARM could not be added and arch_supports_noncont_cat() adapted accordingly.

I'm not familiar with resctrl and the architectural part of it. Feel free to fix it and ignore this patch.

If more things are missing than just adjusting arch_supports_noncont_cat(), the test should be turned off until proper support is added to the test.

Quoted 5 lines
Quoted 2 lines

We get build
errors when built for ARM and ARM64.

As this seems the real reason, please quote any errors when you use them as justification so it can be reviewed if the reasoning is sound or not.

   CC       resctrl_tests
In file included from resctrl.h:24,
                  from cat_test.c:11:
In function 'arch_supports_noncont_cat',
     inlined from 'noncont_cat_run_test' at cat_test.c:323:6:
../kselftest.h:74:9: error: impossible constraint in 'asm' 74 |         __asm__ __volatile__ ("cpuid\n\t"
        \
       |         ^~~~~~~
cat_test.c:301:17: note: in expansion of macro '__cpuid_count' 301 |                 __cpuid_count(0x10, 1, eax, ebx, ecx, edx);

Quoted 8 lines

       |                 ^~~~~~~~~~~~~ ../kselftest.h:74:9: error: impossible constraint in 'asm' 74 |         __asm__ __volatile__ ("cpuid\n\t"
        \
       |         ^~~~~~~
cat_test.c:303:17: note: in expansion of macro '__cpuid_count' 303 |                 __cpuid_count(0x10, 2, eax, ebx, ecx, edx); |                 ^~~~~~~~~~~~~

Quoted 5 lines

Okay, so it's specific to lack of CPUID. This seems a kselftest common level problem to me, since __cpuid_count() is provided in kselftest.h.

Shuah (or others), what is the intended mechanism for selftests to know if it can be used or not since as is, it's always defined?

_cpuid_count() gets defined in ksefltest.h if it can't find it.

As the comment says both gcc and cland probide __cpuid_count()

   gcc cpuid.h provides __cpuid_count() since v4.4. Clang/LLVM cpuid.h provides  __cpuid_count() since v3.4.0.

Quoted 1 line
Quoted 8 lines
Quoted 5 lines

I see some Makefiles use compile testing a trivial program to decide whether they build some x86_64 tests or not. Is that what should be done here too, test if __cpuid_count() compiles or not (and then build some #ifdeffery based on the result of that compile testing)?

These build errors need to be fixed instead of restricting the build> In some cases when the test can't be supported on an architecture then it is okay to suppress build. This is not a general solution to suppress build warnings

Quoted 7 lines

While there is an effort to support Arm in resctrl [1], this is not currently the case and the resctrl selftests as a consequence only support x86 with built-in assumptions that a test runs on either AMD or Intel. After the kernel gains support for Arm more changes will be needed for the resctrl tests to support another architecture so I do think the most appropriate change to address this build failure is to restrict resctrl tests to x86.

Sounds good to me. This would be good case for suppressing test build.

Quoted 11 lines
Quoted 2 lines

I would recommend against adding suppress build code when it can be fixed.

I expect after resctrl fs obtains support for Arm the resctrl selftests can be updated to support it with more fine grained architectural checks than a global enable/disable needed at this time.

Quoted 4 lines

Let's investigate this problem to fix it properly. I don't see any arm and arm64 maintainers and developers on this thread. It would be good to investigate to see if this can be fixed.

thanks,
-- Shuah