From nobody Sat Feb 7 20:57:58 2026 Received: from out-172.mta1.migadu.com (out-172.mta1.migadu.com [95.215.58.172]) (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 50C6032825F for ; Mon, 19 Jan 2026 13:36:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768829784; cv=none; b=sV3oHdD0+E8jl8+EBBHnxLdakm+z+eSiBjG77vIzFDyQrervBRbTul9wYHxEI4AXlUsukiG9nww73OgUDDi4gfeb0wjNHI2KXXTTlDbHnMiXO/Eg/r5LcQvhvPQexPViKnIZpVIfy7F/zrwQu5OqMiHL7ILCMuv3QdL5JowQebg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768829784; c=relaxed/simple; bh=14Vd7Eb+vbfdhXwTURvxrRMSxlumxUeohOFOyp/oUBA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=qEcVu9cDOfdQD0EFI2MuXPleHb/danttcBEP/2j0JSYuxQ8Fwmq4Puf+adjLu4IBlfc9UEroGgmxUck5MhKrqhIC5InHwvSawqsZfQ0tyf0OG5cgvMbcSrUCHcaZCISypoCt4mWmdiu39TJV1y+4F0u09OLmKdbaSfbdFi3Zbso= 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=NB/qkgIJ; arc=none smtp.client-ip=95.215.58.172 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="NB/qkgIJ" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1768829771; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=XpANsYYHLT0HCyr9qsBCOggQneOZulxMASqjwlqQmbA=; b=NB/qkgIJhf7S2uwiiMbpx3aFojvsWGBoHUVw+qxhLp13fyY4lAtB9fKAyWYcVphrkg8ofF kRdr33RWcPAvycPggbj8ck8KELeCErx+bue8N8t9KkI/aho6wns6Q1dVr3XfzN4Kotjrpj 78pX8BK2OCUyBYoFBJ+wlYJht5V6asA= From: Leon Hwang To: bpf@vger.kernel.org Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan , Leon Hwang , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-patches-bot@fb.com Subject: [PATCH bpf-next] selftests/bpf: Harden cpu flags test for lru_percpu_hash map Date: Mon, 19 Jan 2026 21:34:17 +0800 Message-ID: <20260119133417.19739-1-leon.hwang@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" CI occasionally reports failures in the percpu_alloc/cpu_flag_lru_percpu_hash selftest, for example: First test_progs failure (test_progs_no_alu32-x86_64-llvm-21): #264/15 percpu_alloc/cpu_flag_lru_percpu_hash ... test_percpu_map_op_cpu_flag:FAIL:bpf_map_lookup_batch value on specified c= pu unexpected bpf_map_lookup_batch value on specified cpu: actual 0 !=3D ex= pected 3735929054 The unexpected value indicates that an element was removed from the map. However, the test never calls delete_elem(), so the only possible cause is LRU eviction. This can happen when the current task migrates to another CPU: an update_elem() triggers eviction because there is no available LRU node on local freelist and global freelist. Harden the test against this behavior by provisioning sufficient spare elements. Set max_entries to 'nr_cpus * 2' and restrict the test to using the first nr_cpus entries, ensuring that updates do not spuriously trigger LRU eviction. Signed-off-by: Leon Hwang --- .../testing/selftests/bpf/prog_tests/percpu_alloc.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/percpu_alloc.c b/tools/= testing/selftests/bpf/prog_tests/percpu_alloc.c index c1d0949f093f..a72ae0b29f6e 100644 --- a/tools/testing/selftests/bpf/prog_tests/percpu_alloc.c +++ b/tools/testing/selftests/bpf/prog_tests/percpu_alloc.c @@ -236,6 +236,8 @@ static void test_percpu_map_op_cpu_flag(struct bpf_map = *map, void *keys, size_t err =3D bpf_map_update_batch(map_fd, keys, values, &count, &batch_opts); if (!ASSERT_OK(err, "bpf_map_update_batch all_cpus")) goto out; + if (!ASSERT_EQ(count, entries, "bpf_map_update_batch count")) + goto out; =20 /* update values on specified CPU */ for (i =3D 0; i < entries; i++) @@ -246,6 +248,8 @@ static void test_percpu_map_op_cpu_flag(struct bpf_map = *map, void *keys, size_t err =3D bpf_map_update_batch(map_fd, keys, values, &count, &batch_opts); if (!ASSERT_OK(err, "bpf_map_update_batch specified cpu")) goto out; + if (!ASSERT_EQ(count, entries, "bpf_map_update_batch count")) + goto out; =20 /* lookup values on specified CPU */ batch =3D 0; @@ -254,6 +258,8 @@ static void test_percpu_map_op_cpu_flag(struct bpf_map = *map, void *keys, size_t err =3D bpf_map_lookup_batch(map_fd, NULL, &batch, keys, values, &count,= &batch_opts); if (!ASSERT_TRUE(!err || err =3D=3D -ENOENT, "bpf_map_lookup_batch speci= fied cpu")) goto out; + if (!ASSERT_EQ(count, entries, "bpf_map_lookup_batch count")) + goto out; =20 for (i =3D 0; i < entries; i++) if (!ASSERT_EQ(values[i], value, @@ -269,6 +275,8 @@ static void test_percpu_map_op_cpu_flag(struct bpf_map = *map, void *keys, size_t &batch_opts); if (!ASSERT_TRUE(!err || err =3D=3D -ENOENT, "bpf_map_lookup_batch all_c= pus")) goto out; + if (!ASSERT_EQ(count, entries, "bpf_map_lookup_batch count")) + goto out; =20 for (i =3D 0; i < entries; i++) { values_row =3D (void *) values_percpu + @@ -287,7 +295,6 @@ static void test_percpu_map_op_cpu_flag(struct bpf_map = *map, void *keys, size_t free(values); } =20 - static void test_percpu_map_cpu_flag(enum bpf_map_type map_type) { struct percpu_alloc_array *skel; @@ -300,7 +307,7 @@ static void test_percpu_map_cpu_flag(enum bpf_map_type = map_type) if (!ASSERT_GT(nr_cpus, 0, "libbpf_num_possible_cpus")) return; =20 - max_entries =3D nr_cpus + 1; + max_entries =3D nr_cpus * 2; keys =3D calloc(max_entries, key_sz); if (!ASSERT_OK_PTR(keys, "calloc keys")) return; @@ -322,7 +329,7 @@ static void test_percpu_map_cpu_flag(enum bpf_map_type = map_type) if (!ASSERT_OK(err, "test_percpu_alloc__load")) goto out; =20 - test_percpu_map_op_cpu_flag(map, keys, key_sz, max_entries - 1, nr_cpus, = true); + test_percpu_map_op_cpu_flag(map, keys, key_sz, nr_cpus, nr_cpus, true); out: percpu_alloc_array__destroy(skel); free(keys); --=20 2.52.0