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

Mitigate size issues with kselftest kernels #1759

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion config/core/build-configs-cip.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,21 @@ cip_variants_kselftest: &cip_variants_kselftest
<<: *cip_architectures
arm:
base_defconfig: 'multi_v7_defconfig'
fragments: [kselftest]
fragments: [kselftest, kselftest-slim]
extra_configs: ['allnoconfig']
arm64:
fragments: [kselftest, arm64-chromebook]
extra_configs:
- 'allnoconfig'
- 'defconfig+arm64-chromebook+kselftest'
- 'defconfig+arm64-chromebook+kselftest-slim'
x86_64:
base_defconfig: 'x86_64_defconfig'
fragments: [kselftest, x86-chromebook]
extra_configs:
- 'allnoconfig'
- 'x86_64_defconfig+x86-chromebook+kselftest'
- 'x86_64_defconfig+x86-chromebook+kselftest-slim'


cip_variants_preempt_rt: &cip_variants_preempt_rt
Expand Down
6 changes: 4 additions & 2 deletions config/core/build-configs-stable.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,20 @@ stable_variants_kselftest: &stable_variants_kselftest
arm:
base_defconfig: 'multi_v7_defconfig'
extra_configs: ['allnoconfig']
fragments: [kselftest]
fragments: [kselftest, kselftest-slim]
arm64:
extra_configs:
- 'allnoconfig'
- 'defconfig+arm64-chromebook+kselftest'
- 'defconfig+arm64-chromebook+kselftest-slim'
fragments: [arm64-chromebook, kselftest]
x86_64:
base_defconfig: 'x86_64_defconfig'
extra_configs:
- 'allnoconfig'
- 'x86_64_defconfig+x86-chromebook+kselftest'
fragments: [x86-chromebook, kselftest]
- 'x86_64_defconfig+x86-chromebook+kselftest-slim'
fragments: [x86-chromebook, kselftest, kselftest-slim]


build_configs:
Expand Down
70 changes: 57 additions & 13 deletions config/core/build-configs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -418,13 +418,17 @@ fragments:
- 'CONFIG_IMA=y'
- 'CONFIG_IMA_READ_POLICY=y'

kselftest:
kselftest: &kselftest-fragment
path: "kernel/configs/kselftest.config"
configs:
- '# CONFIG_DUMMY is not set'
- 'CONFIG_NET_IPGRE=m'
- 'CONFIG_NET_IPGRE_DEMUX=m'

kselftest-slim:
<<: *kselftest-fragment
path: "kernel/configs/kselftest-slim.config"

preempt_rt:
path: "kernel/configs/preempt_rt.config"
configs:
Expand Down Expand Up @@ -716,7 +720,7 @@ build_configs_defaults:

fragments: &default_fragments
- 'debug'
- 'kselftest'
- 'kselftest-slim'
- 'tinyconfig'

architectures: &default_architectures
Expand Down Expand Up @@ -753,7 +757,7 @@ build_configs_defaults:
- 'allnoconfig'
- 'defconfig+CONFIG_CPU_BIG_ENDIAN=y'
- 'defconfig+CONFIG_RANDOMIZE_BASE=y'
- 'defconfig+arm64-chromebook+kselftest'
- 'defconfig+arm64-chromebook+kselftest-slim'
- 'defconfig+arm64-chromebook+videodec'
fragments: [arm64-chromebook, crypto, ima, videodec]

Expand Down Expand Up @@ -782,7 +786,7 @@ build_configs_defaults:
extra_configs:
- 'allmodconfig'
- 'allnoconfig'
- 'x86_64_defconfig+x86-chromebook+kselftest'
- 'x86_64_defconfig+x86-chromebook+kselftest-slim'
- 'x86_64_defconfig+x86-chromebook+amdgpu'
fragments: [amdgpu, crypto, ima, x86_kvm_guest, x86-chromebook]

Expand Down Expand Up @@ -1052,15 +1056,19 @@ build_configs:
arm64: &arm64-kselftest
<<: *arm64_defconfig
fragments: [arm64-chromebook]
extra_configs: ['defconfig+kselftest+arm64-chromebook']
extra_configs: [
'defconfig+kselftest+arm64-chromebook',
'defconfig+kselftest-slim+arm64-chromebook']
filters: *kselftest-only
i386:
<<: *i386_defconfig
filters: *kselftest-only
x86_64: &x86_64-kselftest
<<: *x86_64_defconfig
fragments: [x86-chromebook]
extra_configs: ['x86_64+defconfig+kselftest+x86-chromebook']
extra_configs: [
'x86_64+defconfig+kselftest+x86-chromebook',
'x86_64+defconfig+kselftest-slim+x86-chromebook']
filters: *kselftest-only
clang-16:
build_environment: clang-16
Expand Down Expand Up @@ -1102,18 +1110,49 @@ build_configs:
tree: mainline
branch: 'master'
variants:
gcc-10: *default_gcc-10
gcc-10:
<<: *default_gcc-10
fragments: &fragments-kselftest
- 'debug'
- 'kselftest'
- 'kselftest-slim'
- 'tinyconfig'

architectures:
<<: *default_architectures
arm64: &arm64_arch-kselftest
<<: *arm64_arch
extra_configs:
- 'allmodconfig'
- 'allnoconfig'
- 'defconfig+CONFIG_CPU_BIG_ENDIAN=y'
- 'defconfig+CONFIG_RANDOMIZE_BASE=y'
- 'defconfig+arm64-chromebook+kselftest'
- 'defconfig+arm64-chromebook+kselftest-slim'
- 'defconfig+arm64-chromebook+videodec'

x86_64: &x86_64_arch-kselftest
<<: *x86_64_arch
extra_configs:
- 'allmodconfig'
- 'allnoconfig'
- 'x86_64_defconfig+x86-chromebook+kselftest'
- 'x86_64_defconfig+x86-chromebook+kselftest-slim'
- 'x86_64_defconfig+x86-chromebook+amdgpu'

# Minimum version
clang-11:
build_environment: clang-11
architectures: *arch_clang_configs

# Latest stable release
clang-16:
build_environment: clang-16
architectures: *arch_clang_configs

rustc-1.62:
build_environment: rustc-1.62
fragments: [rust, rust-samples, kselftest]
fragments: [rust, rust-samples, kselftest, kselftest-slim]
architectures:
x86_64:
base_defconfig: 'x86_64_defconfig'
Expand Down Expand Up @@ -1155,14 +1194,14 @@ build_configs:
variants:
gcc-10:
build_environment: gcc-10
fragments: *default_fragments
fragments: *fragments-kselftest
architectures:
i386: *i386_arch
x86_64: *x86_64_arch
x86_64: *x86_64_arch-kselftest
mips: *mips_arch
riscv: *riscv_arch
sparc: *sparc_arch
arc: *arc_arch
arc:: *arc_arch
arm64:
<<: *arm64_arch
extra_configs:
Expand All @@ -1173,6 +1212,9 @@ build_configs:
- 'defconfig+CONFIG_CPU_BIG_ENDIAN=y'
- 'defconfig+CONFIG_RANDOMIZE_BASE=y'
- 'defconfig+arm64-chromebook+kselftest'
- 'defconfig+arm64-chromebook+kselftest-slim'
- 'kselftest'
- 'kselftest-slim'
arm:
base_defconfig: 'multi_v7_defconfig'
extra_configs:
Expand All @@ -1182,6 +1224,8 @@ build_configs:
- 'multi_v7_defconfig+CONFIG_THUMB2_KERNEL=y'
- 'allnoconfig'
- 'allmodconfig'
- 'kselftest'
- 'kselftest-slim'

# Current development clang release
clang-17:
Expand Down Expand Up @@ -1341,7 +1385,7 @@ build_configs:
variants:
rustc-1.66:
build_environment: rustc-1.66
fragments: [rust, rust-for-linux-samples, kselftest]
fragments: [rust, rust-for-linux-samples, kselftest, kselftest-slim]
architectures:
x86_64:
base_defconfig: 'x86_64_defconfig'
Expand All @@ -1352,7 +1396,7 @@ build_configs:
variants:
rustc-1.68:
build_environment: rustc-1.68
fragments: [rust, rust-samples, kselftest]
fragments: [rust, rust-samples, kselftest, kselftest-slim]
architectures:
x86_64:
base_defconfig: 'x86_64_defconfig'
Expand Down
10 changes: 7 additions & 3 deletions config/core/test-configs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ default_filters:
- ['x86_64', 'x86_64_defconfig+x86-chromebook']

- blocklist: &kselftest_defconfig_filter
defconfig: ['kselftest']
defconfig: ['kselftest', 'kselftest-slim']

device_types:

Expand Down Expand Up @@ -233,15 +233,15 @@ test_plans:
rootfs: debian_bullseye-kselftest_nfs
pattern: 'kselftest/{category}-{method}-{protocol}-{rootfs}-kselftest-template.jinja2'
filters:
- passlist: {defconfig: ['kselftest']}
- passlist: {defconfig: ['kselftest-slim']}

# Add _a_ into the name so we can keep this before the individual
# definitions
kselftest_a_qemu: &kselftest_qemu
rootfs: debian_bullseye-kselftest_ramdisk
pattern: 'kselftest/{category}-{method}-{rootfs}-kselftest-template.jinja2'
filters:
- passlist: {defconfig: ['kselftest']}
- passlist: {defconfig: ['kselftest-slim']}

kselftest-alsa:
<<: *kselftest
Expand Down Expand Up @@ -292,6 +292,9 @@ test_plans:
params:
job_timeout: '10'
kselftest_collections: "cpufreq"
filters: &kselftest_full_fragment
- passlist: {defconfig: ['kselftest']}
- blocklist: {defconfig: ['kselftest-slim']}

kselftest-exec:
<<: *kselftest
Expand Down Expand Up @@ -351,6 +354,7 @@ test_plans:
params:
job_timeout: '10'
kselftest_collections: "lkdtm"
filters: *kselftest_full_fragment

kselftest-membarrier:
<<: *kselftest
Expand Down
13 changes: 12 additions & 1 deletion kernelci/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,12 @@ def make_tarball(kdir, tarball_name):
os.chdir(cwd)


def generate_kselftest_fragment(frag, kdir):
def generate_kselftest_fragment(frag, kdir, skip=[]):
"""Create a config fragment file for kselftest

*frag* is a Fragment object
*kdir* is the path to a kernel source directory
*skip* is a list of kselftests to skip
"""
shell_cmd(r"""
set -e
Expand All @@ -259,6 +260,8 @@ def generate_kselftest_fragment(frag, kdir):
""".format(kdir=kdir, frag_path=frag.path))
with open(os.path.join(kdir, frag.path), 'a') as f:
for kernel_config in frag.configs:
if kernel_config in enumerate(skip):
continue
f.write(kernel_config + '\n')


Expand All @@ -273,6 +276,12 @@ def generate_config_fragment(frag, kdir):
f.write(kernel_config + '\n')


slim_skip_frags = [
"tools/testing/selftests/lkdtm/config",
"tools/testing/selftests/cpufreq/config"
]


Comment on lines +279 to +284
Copy link
Contributor

Choose a reason for hiding this comment

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

How about defining fragments in YAML which disable some configs and then have e.g. kselftest+no-lkdtm+no-cpufreq? That way we don't need to pile up more logic on this kselftest corner-case fragment. All the other fragments are entirely defined in YAML and I think it would be better if we also tried to remove the kselftest special case.

Note: A more longer-term solution I think would be to use the generic way of making the kselftest config with make kselftest-merge and some way of skipping fragments in the upstream Makefile.

Copy link
Member Author

Choose a reason for hiding this comment

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

That would be nice but it's much more work than I'm likely to be able to do in the medium term - we don't have the infrastructure to negatively apply config fragments like this. Getting something done upstream is probably interesting too, it's not clear that it'd even be recommended to put all the config fragments in one kernel as standard (for the reasons we're seeing here).

def generate_fragments(config, kdir):
"""Generate all the config fragments for a given build configuration

Expand All @@ -288,6 +297,8 @@ def generate_fragments(config, kdir):
print(frag.path)
if frag.name == 'kselftest':
generate_kselftest_fragment(frag, kdir)
elif frag.name == 'kselftest-slim':
generate_kselftest_fragment(frag, kdir, skip=slim_skip_frags)
elif frag.configs:
generate_config_fragment(frag, kdir)

Expand Down