From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-176.mta1.migadu.com (out-176.mta1.migadu.com [95.215.58.176]) (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 997D83A63E3 for ; Mon, 9 Mar 2026 11:46:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773056806; cv=none; b=SSnIE8r5FUxHBqGFprK46Mg9lGa53r6+Z4GsLhXaVJUV4ww/qhMK29pmLOSupfj2cnFtV1nEiOI7AJhartRne1xaIjmGTWTkh2Ky8Jt88D6SmWM+uAARQLFPqBGi4QY7r4J8MmECH2JjW7XKB9L2rdqLHV7XJ6vGlPHLNpUEsZY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773056806; c=relaxed/simple; bh=hGRjyFTUo/tFc/SDo2BBMZn6Ono/3kQOwUruOONApUM=; h=MIME-Version:Date:Content-Type:From:Message-ID:Subject:To:Cc: In-Reply-To:References; b=YHG9acRF9Knbfq5wMErK2469cpA2+niYmV77UlUV1bOFSFcdj5iLcGYiG/ruD0p0LM0L2NPhUR4N3dcTDQS3tRo+B9S/M2ALZMOFm9qVDx3zgrP2plSgQ8a6BRlr0fpWSWilyAlpIVKOCINY1IGetde+RIzqMDjn7QhRAi+h4Vs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=Zozr370E; arc=none smtp.client-ip=95.215.58.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="Zozr370E" Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1773056802; 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=sHJak2AClGtNfYUwsfEt8bzDUEvGEbjk0Vje8pMFORU=; b=Zozr370E00QI+opnsz7umCy2sLqphlDFAnAaYdwI+HUEi6SrR2VIYDHrIKuE+jKmLTtujF 4LTbS/Q/309GjXUIK2JmKM93Kb+CbOpAomIw5Bh0IER0xLmwpRGjViuemJli3UJ5Y6oP5R 7VNCJdz3T1PDj81jo1JBg5u+glZudis= Date: Mon, 09 Mar 2026 11:46:40 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: "Jiayuan Chen" Message-ID: TLS-Required: No Subject: Re: [PATCH v4 bpf-next] selftests/bpf: livepatch_trampoline: skip when prerequisites are missing To: "Sun Jian" , bpf@vger.kernel.org Cc: "Andrii Nakryiko" , "Eduard Zingerman" , "Alexei Starovoitov" , "Daniel Borkmann" , "Martin KaFai Lau" , "Song Liu" , "Yonghong Song" , "John Fastabend" , "KP Singh" , "Stanislav Fomichev" , "Hao Luo" , "Jiri Olsa" , "Shuah Khan" , "Steven Rostedt" , linux-kselftest@vger.kernel.org, "Sun Jian" In-Reply-To: <20260309104448.817401-1-sun.jian.kdev@gmail.com> References: <20260309104448.817401-1-sun.jian.kdev@gmail.com> X-Migadu-Flow: FLOW_OUT March 9, 2026 at 18:44, "Sun Jian" wrote: >=20 >=20livepatch_trampoline relies on livepatch sysfs and livepatch-sample.k= o. > When CONFIG_LIVEPATCH is disabled or the samples module isn't built, th= e > test fails with ENOENT and causes false failures in minimal CI configs. >=20 >=20Skip the test when livepatch sysfs or the sample module is unavailabl= e. > Also avoid writing to livepatch sysfs when it's not present. >=20 >=20Signed-off-by: Sun Jian > --- > v4: > - Drop redundant and includes; both are already i= ncluded by test_progs.h (per Jiayuan Chen) > - Tested: ./test_progs -t livepatch_trampoline -vv (SKIP when livepatc= h-sample.ko missing) >=20 >=20v3: > - Skip on -ENOENT from load_livepatch() instead of duplicating module = path logic (suggested by Jiri Olsa) > - Tested: ./test_progs -t livepatch_trampoline (SKIP when livepatch-sa= mple.ko missing) >=20 >=20v2: > - Skip when /sys/kernel/livepatch is missing > - Guard sysfs write in unload_livepatch() when enabled knob is absent >=20 >=20v3: https://lore.kernel.org/bpf/20260309033712.728133-1-sun.jian.kdev= @gmail.com/ > v2: https://patchwork.kernel.org/project/netdevbpf/patch/20260305030258= .5273-1-sun.jian.kdev@gmail.com/ > v1: https://patchew.org/linux/20260227042354.20926-1-sun.jian.kdev@gmai= l.com/ >=20 >=20 .../bpf/prog_tests/livepatch_trampoline.c | 20 +++++++++++++++++-- > 1 file changed, 18 insertions(+), 2 deletions(-) >=20 >=20diff --git a/tools/testing/selftests/bpf/prog_tests/livepatch_trampol= ine.c b/tools/testing/selftests/bpf/prog_tests/livepatch_trampoline.c > index 72aa5376c30e..0a12af924a99 100644 > --- a/tools/testing/selftests/bpf/prog_tests/livepatch_trampoline.c > +++ b/tools/testing/selftests/bpf/prog_tests/livepatch_trampoline.c > @@ -5,6 +5,8 @@ > #include "testing_helpers.h" > #include "livepatch_trampoline.skel.h" >=20=20 >=20+#define LIVEPATCH_ENABLED_PATH "/sys/kernel/livepatch/livepatch_samp= le/enabled" > + > static int load_livepatch(void) > { > char path[4096]; > @@ -19,7 +21,8 @@ static int load_livepatch(void) > static void unload_livepatch(void) > { > /* Disable the livepatch before unloading the module */ > - system("echo 0 > /sys/kernel/livepatch/livepatch_sample/enabled"); > + if (!access(LIVEPATCH_ENABLED_PATH, F_OK)) > + system("echo 0 > " LIVEPATCH_ENABLED_PATH); >=20=20 >=20 unload_module("livepatch_sample", env_verbosity > VERBOSE_NONE); > } > @@ -81,9 +84,22 @@ static void __test_livepatch_trampoline(bool fexit_f= irst) > void test_livepatch_trampoline(void) > { > int retry_cnt =3D 0; > + int err; > + > + /* Skip if kernel was built without CONFIG_LIVEPATCH */ > + if (access("/sys/kernel/livepatch", F_OK)) { > + test__skip(); > + return; > + } >=20=20 I=20think Jiri's suggestion in v2 means that you should drop the path che= ck=20 here=20and in unload_livepatch() and just keep checking -ENOENT. -ENOENT returned by load_livepatch() means the ko doesn't exist, which happens when either CONFIG_LIVEPATCH is disabled or livepatch_sampl= e=20 is=20not compiled. > retry: > - if (load_livepatch()) { > + err =3D load_livepatch(); > + if (err) { > + if (err =3D=3D -ENOENT) { > + test__skip(); > + return; > + } > + > if (retry_cnt) { > ASSERT_OK(1, "load_livepatch"); > goto out; >=20 >=20base-commit: 1f318b96cc84d7c2ab792fcc0bfd42a7ca890681 > --=20 >=202.43.0 >