From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D9B0642378D for ; Mon, 6 Jul 2026 12:07:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783339652; cv=none; b=MSwx7HnnxF/E/lkg/jXk9PhxzFIOR16Bx6OH+bN3fuo0wBwauLY33QWW3AXW0mJePhsbhN+WUUFFR0IQql7eMJyFNpA14RzjSNuFuNgurukMF8zJhtEfUU1qQ+oUJ23UQw5TkBxyddE1LlqwBWbCYhBtQB8/qoPxYFm7nQS+zmE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783339652; c=relaxed/simple; bh=eavUpsZxei5UtAZevT1ijzwKnp6hdPdATdDPDVBgwss=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Kj3vk4/6dsHqgQ+SNk7DA5031R0ptX0HIQBnhoO6wAiEiq7gqllu6nV+HV+gI0kOHBXiWu5KSpVLChC44ujjyt3aVsKWrBp3R3UShrrATXMSqQxqKRz5MnxHQzzOo7rPNf3oBWIT3ft8f/uu3kMwkj5tvfFiFx3RMK7WsCijkoU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Cr2OF1YO; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Cr2OF1YO" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1783339649; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xYc4YxXkMADptX22VOsP9bchD2b9RbGYp9Ru3MzZ4oY=; b=Cr2OF1YOJOJHWixRaPAtpGSPD+Pn4hdPY0dI/NUxtepeRkfF7RTwvw8xde27rQw4/tFNJG 8mXKSnx3CRxBTUQr9ATZfAUEkwlcMf2T+TV9oFplw8oVvUMF8rT68OjPTtR2lJAi7XnrLY 3VMqRr9SqA3V73GO6yMTLnxr6HyL+9A= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-171-XCFaqTxaOBuOoyEENnVGTA-1; Mon, 06 Jul 2026 08:07:26 -0400 X-MC-Unique: XCFaqTxaOBuOoyEENnVGTA-1 X-Mimecast-MFC-AGG-ID: XCFaqTxaOBuOoyEENnVGTA_1783339644 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 570EB180AC4F; Mon, 6 Jul 2026 12:07:07 +0000 (UTC) Received: from [192.168.1.153] (headnet05.pony-001.prod.iad2.dc.redhat.com [10.2.32.117]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id EA75418005B5; Mon, 6 Jul 2026 12:07:04 +0000 (UTC) From: Albert Esteve Date: Mon, 06 Jul 2026 14:06:43 +0200 Subject: [PATCH v5 4/4] selftests: cgroup: handle vmtest-dmem -b to test locally built kernel Precedence: bulk X-Mailing-List: cgroups@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260706-kunit_cgroups-v5-4-6c42c8753468@redhat.com> References: <20260706-kunit_cgroups-v5-0-6c42c8753468@redhat.com> In-Reply-To: <20260706-kunit_cgroups-v5-0-6c42c8753468@redhat.com> To: Tejun Heo , Johannes Weiner , =?utf-8?q?Michal_Koutn=C3=BD?= , Shuah Khan Cc: linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-kselftest@vger.kernel.org, Albert Esteve , Eric Chanudet X-Developer-Signature: v=1; a=ed25519-sha256; t=1783339614; l=3899; i=aesteve@redhat.com; s=20260303; h=from:subject:message-id; bh=eavUpsZxei5UtAZevT1ijzwKnp6hdPdATdDPDVBgwss=; b=AbCyhwt+t21HQ5QLdnZrJSOifdRH4CW6kSPFNO1vmqGvbeFe5p02I69VqqDxq1FGC15h7T6dY UlIWl+1NetYBL9VLgLdI2uAIHZvej77n4Q8tH4rcTO5hhfLx3rJTxo7 X-Developer-Key: i=aesteve@redhat.com; a=ed25519; pk=YSFz6sOHd2L45+Fr8DIvHTi6lSIjhLZ5T+rkxspJt1s= X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Currently vmtest-dmem.sh relies on the host's running kernel or a pre-built one when booting the virtme-ng VM, with no option to configure and build a local kernel tree directly. This adds friction to the development cycle: the user must manually run vng --kconfig with the correct config fragment, build the kernel, and pass the result to the script. Add a -b flag that automates this workflow. When set, handle_build() configures the kernel using vng --kconfig with the selftest config fragment, builds it with make -j$(nproc), and run_vm() passes the local tree to vng --run so the VM boots the freshly built kernel. Signed-off-by: Eric Chanudet Signed-off-by: Albert Esteve --- tools/testing/selftests/cgroup/vmtest-dmem.sh | 47 ++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/cgroup/vmtest-dmem.sh b/tools/testing/selftests/cgroup/vmtest-dmem.sh index 0bb6529112b54..4d0e2c0511e5b 100755 --- a/tools/testing/selftests/cgroup/vmtest-dmem.sh +++ b/tools/testing/selftests/cgroup/vmtest-dmem.sh @@ -15,6 +15,7 @@ readonly KERNEL_CHECKOUT="$(realpath "${SCRIPT_DIR}"/../../../../)" source "${SCRIPT_DIR}"/../kselftest/ktap_helpers.sh +BUILD=0 QEMU="qemu-system-$(uname -m)" VERBOSE=0 SHELL_MODE=0 @@ -26,10 +27,22 @@ function usage() { cat < $0 -b + +or + + KBUILD_OUTPUT= $0 -b + +O= takes precedence over KBUILD_OUTPUT= if both are set. EOF } @@ -60,17 +73,41 @@ function check_deps() { done } +function handle_build() { + [[ "${BUILD}" -eq 1 ]] || return 0 + + [[ -f "${KERNEL_CHECKOUT}/kernel/cgroup/dmem_selftest.c" ]] || \ + fail "-b requires vmtest-dmem.sh called from the kernel source tree" + + # Figure out where the kernel is being built. + # O takes precedence over KBUILD_OUTPUT. + local out_args=() + if [[ -n "${O:-}" ]]; then + out_args=(O="${O}") + elif [[ -n "${KBUILD_OUTPUT:-}" ]]; then + out_args=(KBUILD_OUTPUT="${KBUILD_OUTPUT}") + fi + + pushd "${KERNEL_CHECKOUT}" &>/dev/null + vng --kconfig --config "${SCRIPT_DIR}"/config "${out_args[@]}" || \ + fail "failed to generate .config for kernel source tree (${KERNEL_CHECKOUT})" + make "${out_args[@]}" -j"$(nproc 2>/dev/null || echo 1)" || \ + fail "failed to build kernel from source tree (${KERNEL_CHECKOUT})" + popd &>/dev/null +} + # Run vng with common flags. Extra arguments are appended by the caller: # --exec